fix(gateway): qualify stepped impairment throughput

This commit is contained in:
sechmachine
2026-07-30 06:59:32 +07:00
parent b7a42dc652
commit 9d627413a0
2 changed files with 28 additions and 14 deletions
+11 -2
View File
@@ -1187,8 +1187,17 @@ func runQualificationImpairment(t *testing.T, profile qualificationImpairmentPro
observation.ObservedLossPercent = float64(observation.Dropped) * 100 / float64(packetCount)
observation.ObservedReorderPercent = float64(observation.ObservedOutOfOrder) * 100 / float64(packetCount)
if packetCount >= qualificationImpairmentPacketCount {
lowerThroughput := float64(media.BitrateKbps) * (1 - profile.LossPercent/100) * 0.90
upperThroughput := float64(media.BitrateKbps) * 1.05
capacityFactor := 1.0
if len(profile.CapacitySteps) > 0 {
inverseRates := 1.0
for _, reduction := range profile.CapacitySteps {
inverseRates += 100 / float64(100-reduction)
}
capacityFactor = float64(len(profile.CapacitySteps)+1) / inverseRates
}
expectedThroughput := float64(media.BitrateKbps) * (1 - profile.LossPercent/100) * capacityFactor
lowerThroughput := expectedThroughput * 0.90
upperThroughput := expectedThroughput * 1.05
if observation.ObservedThroughputKbps < lowerThroughput || observation.ObservedThroughputKbps > upperThroughput {
return qualificationImpairmentObservation{}, fmt.Errorf("observed throughput %.2f outside [%.2f,%.2f]", observation.ObservedThroughputKbps, lowerThroughput, upperThroughput)
}