Do not take padding packets into account in max pps calculation (#2990)

This commit is contained in:
Raja Subramanian
2024-09-09 11:08:50 +05:30
committed by GitHub
parent b63192a376
commit d53f732ada
2 changed files with 14 additions and 10 deletions
+2 -1
View File
@@ -208,7 +208,8 @@ func (cs *ConnectionStats) updateScoreWithAggregate(agg *buffer.RTPDeltaInfo, la
if agg != nil { if agg != nil {
stat.startedAt = agg.StartTime stat.startedAt = agg.StartTime
stat.duration = agg.EndTime.Sub(agg.StartTime) stat.duration = agg.EndTime.Sub(agg.StartTime)
stat.packetsExpected = agg.Packets + agg.PacketsPadding stat.packets = agg.Packets
stat.packetsPadding = agg.PacketsPadding
stat.packetsLost = agg.PacketsLost stat.packetsLost = agg.PacketsLost
stat.packetsMissing = agg.PacketsMissing stat.packetsMissing = agg.PacketsMissing
stat.packetsOutOfOrder = agg.PacketsOutOfOrder stat.packetsOutOfOrder = agg.PacketsOutOfOrder
+12 -9
View File
@@ -54,7 +54,8 @@ var (
type windowStat struct { type windowStat struct {
startedAt time.Time startedAt time.Time
duration time.Duration duration time.Duration
packetsExpected uint32 packets uint32
packetsPadding uint32
packetsLost uint32 packetsLost uint32
packetsMissing uint32 packetsMissing uint32
packetsOutOfOrder uint32 packetsOutOfOrder uint32
@@ -111,8 +112,8 @@ func (w *windowStat) calculatePacketScore(plw float64, includeRTT bool, includeJ
} }
var lossEffect float64 var lossEffect float64
if w.packetsExpected > 0 { if w.packets+w.packetsPadding > 0 {
lossEffect = float64(actualLost) * 100.0 / float64(w.packetsExpected) lossEffect = float64(actualLost) * 100.0 / float64(w.packets+w.packetsPadding)
} }
lossEffect *= plw lossEffect *= plw
@@ -148,10 +149,11 @@ func (w *windowStat) calculateBitrateScore(expectedBits int64, isEnabled bool) f
} }
func (w *windowStat) String() string { func (w *windowStat) String() string {
return fmt.Sprintf("start: %+v, dur: %+v, pe: %d, pl: %d, pm: %d, pooo: %d, b: %d, rtt: %d, jitter: %0.2f, lastRTCP: %+v", return fmt.Sprintf("start: %+v, dur: %+v, p: %d, pp: %d, pl: %d, pm: %d, pooo: %d, b: %d, rtt: %d, jitter: %0.2f, lastRTCP: %+v",
w.startedAt, w.startedAt,
w.duration, w.duration,
w.packetsExpected, w.packets,
w.packetsPadding,
w.packetsLost, w.packetsLost,
w.packetsMissing, w.packetsMissing,
w.packetsOutOfOrder, w.packetsOutOfOrder,
@@ -169,7 +171,8 @@ func (w *windowStat) MarshalLogObject(e zapcore.ObjectEncoder) error {
e.AddTime("startedAt", w.startedAt) e.AddTime("startedAt", w.startedAt)
e.AddString("duration", w.duration.String()) e.AddString("duration", w.duration.String())
e.AddUint32("packetsExpected", w.packetsExpected) e.AddUint32("packets", w.packets)
e.AddUint32("packetsPadding", w.packetsPadding)
e.AddUint32("packetsLost", w.packetsLost) e.AddUint32("packetsLost", w.packetsLost)
e.AddUint32("packetsMissing", w.packetsMissing) e.AddUint32("packetsMissing", w.packetsMissing)
e.AddUint32("packetsOutOfOrder", w.packetsOutOfOrder) e.AddUint32("packetsOutOfOrder", w.packetsOutOfOrder)
@@ -395,7 +398,7 @@ func (q *qualityScorer) updateAtLocked(stat *windowStat, at time.Time) {
plw := q.getPacketLossWeight(stat) plw := q.getPacketLossWeight(stat)
reason := "none" reason := "none"
var score float64 var score float64
if stat.packetsExpected == 0 { if stat.packets+stat.packetsPadding == 0 {
if !stat.lastRTCPAt.IsZero() && at.Sub(stat.lastRTCPAt) > stat.duration { if !stat.lastRTCPAt.IsZero() && at.Sub(stat.lastRTCPAt) > stat.duration {
reason = "dry" reason = "dry"
score = qualityTransitionScore[livekit.ConnectionQuality_LOST] score = qualityTransitionScore[livekit.ConnectionQuality_LOST]
@@ -522,10 +525,10 @@ func (q *qualityScorer) getPacketLossWeight(stat *windowStat) float64 {
// and the effect of loss is not pronounced in those scenarios (audio silence, statis screen share). // and the effect of loss is not pronounced in those scenarios (audio silence, statis screen share).
// for example, DTX typically uses only 5% of packets of full packet rate. at that rate, // for example, DTX typically uses only 5% of packets of full packet rate. at that rate,
// packet loss weight is reduced to ~22% of configured weight (i. e. sqrt(0.05) * configured weight) // packet loss weight is reduced to ~22% of configured weight (i. e. sqrt(0.05) * configured weight)
pps := float64(stat.packetsExpected) / stat.duration.Seconds() pps := float64(stat.packets) / stat.duration.Seconds()
if pps > q.maxPPS { if pps > q.maxPPS {
q.maxPPS = pps q.maxPPS = pps
q.params.Logger.Debugw("updating maxPPS", "expected", stat.packetsExpected, "duration", stat.duration.Seconds(), "pps", pps) q.params.Logger.Debugw("updating maxPPS", "expected", stat.packets, "duration", stat.duration.Seconds(), "pps", pps)
} }
if q.maxPPS == 0 { if q.maxPPS == 0 {