Stats of NACKs acked and number of repeated NACKs. (#664)
* Stats of NACKs acked and number of repeated NACKs. Also making a change in delta stat to drop negative packet loss counts to 0. Because of windowing it is a legitimate case. The receiver could have seen a loss in window we are measuring and in the subsequent window, the receiver could have gotten a retransmission and reduced the packet loss count resulting in a negative delta. When we report negative delta, it could get dropped by analytics validator. That will be lost data. Avoid that. * Remove unused code * Pick up latest protocol
This commit is contained in:
@@ -12,7 +12,7 @@ require (
|
||||
github.com/google/wire v0.5.0
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
github.com/hashicorp/golang-lru v0.5.4
|
||||
github.com/livekit/protocol v0.13.2-0.20220502043729-cef16c8ef304
|
||||
github.com/livekit/protocol v0.13.2-0.20220502170852-688e4f627bcf
|
||||
github.com/mackerelio/go-osstat v0.2.1
|
||||
github.com/magefile/mage v1.11.0
|
||||
github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0
|
||||
|
||||
@@ -129,8 +129,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/lithammer/shortuuid/v3 v3.0.6 h1:pr15YQyvhiSX/qPxncFtqk+v4xLEpOZObbsY/mKrcvA=
|
||||
github.com/lithammer/shortuuid/v3 v3.0.6/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts=
|
||||
github.com/livekit/protocol v0.13.2-0.20220502043729-cef16c8ef304 h1:89IfWGgaolVwwifutyhqqWdIGQQTdXjWxLb1jKxGB5s=
|
||||
github.com/livekit/protocol v0.13.2-0.20220502043729-cef16c8ef304/go.mod h1:BLtSeVmn2rLP37xjzw7gHgaAmkWl3L/L9bPvgSbaOfo=
|
||||
github.com/livekit/protocol v0.13.2-0.20220502170852-688e4f627bcf h1:x7l15X3hAFnGAd1hd9rfHkliAbtaRRcx0agB/Tb7rWQ=
|
||||
github.com/livekit/protocol v0.13.2-0.20220502170852-688e4f627bcf/go.mod h1:BLtSeVmn2rLP37xjzw7gHgaAmkWl3L/L9bPvgSbaOfo=
|
||||
github.com/mackerelio/go-osstat v0.2.1 h1:5AeAcBEutEErAOlDz6WCkEvm6AKYgHTUQrfwm5RbeQc=
|
||||
github.com/mackerelio/go-osstat v0.2.1/go.mod h1:UzRL8dMCCTqG5WdRtsxbuljMpZt9PCAGXqxPst5QtaY=
|
||||
github.com/magefile/mage v1.11.0 h1:C/55Ywp9BpgVVclD3lRnSYCwXTYxmSppIgLeDYlNuls=
|
||||
|
||||
+25
-24
@@ -123,8 +123,10 @@ type RTPStats struct {
|
||||
|
||||
gapHistogram [GapHistogramNumBins]uint32
|
||||
|
||||
nacks uint32
|
||||
nackMisses uint32
|
||||
nacks uint32
|
||||
nackAcks uint32
|
||||
nackMisses uint32
|
||||
nackRepeated uint32
|
||||
|
||||
plis uint32
|
||||
lastPli time.Time
|
||||
@@ -364,18 +366,6 @@ func (r *RTPStats) UpdateFromReceiverReport(extHighestSN uint32, packetsLost uin
|
||||
}
|
||||
}
|
||||
|
||||
func (r *RTPStats) UpdateNackAndMiss(nackCount uint32, nackMissCount uint32) {
|
||||
r.lock.Lock()
|
||||
defer r.lock.Unlock()
|
||||
|
||||
if !r.endTime.IsZero() {
|
||||
return
|
||||
}
|
||||
|
||||
r.updateNackLocked(nackCount)
|
||||
r.updateNackMissLocked(nackMissCount)
|
||||
}
|
||||
|
||||
func (r *RTPStats) UpdateNack(nackCount uint32) {
|
||||
r.lock.Lock()
|
||||
defer r.lock.Unlock()
|
||||
@@ -384,14 +374,10 @@ func (r *RTPStats) UpdateNack(nackCount uint32) {
|
||||
return
|
||||
}
|
||||
|
||||
r.updateNackLocked(nackCount)
|
||||
}
|
||||
|
||||
func (r *RTPStats) updateNackLocked(nackCount uint32) {
|
||||
r.nacks += nackCount
|
||||
}
|
||||
|
||||
func (r *RTPStats) UpdateNackMiss(nackMissCount uint32) {
|
||||
func (r *RTPStats) UpdateNackProcessed(nackAckCount uint32, nackMissCount uint32, nackRepeatedCount uint32) {
|
||||
r.lock.Lock()
|
||||
defer r.lock.Unlock()
|
||||
|
||||
@@ -399,11 +385,9 @@ func (r *RTPStats) UpdateNackMiss(nackMissCount uint32) {
|
||||
return
|
||||
}
|
||||
|
||||
r.updateNackMissLocked(nackMissCount)
|
||||
}
|
||||
|
||||
func (r *RTPStats) updateNackMissLocked(nackMissCount uint32) {
|
||||
r.nackAcks += nackAckCount
|
||||
r.nackMisses += nackMissCount
|
||||
r.nackRepeated += nackRepeatedCount
|
||||
}
|
||||
|
||||
func (r *RTPStats) UpdatePliAndTime(pliCount uint32) {
|
||||
@@ -593,6 +577,9 @@ func (r *RTPStats) SnapshotRtcpReceptionReport(ssrc uint32, proxyFracLost uint8,
|
||||
if r.params.IsReceiverReportDriven {
|
||||
// should not be set for streams that need to generate reception report
|
||||
packetsLost = now.packetsLostOverridden - then.packetsLostOverridden
|
||||
if int32(packetsLost) < 0 {
|
||||
packetsLost = 0
|
||||
}
|
||||
} else {
|
||||
_, _, _, _, packetsLost, _ = r.getIntervalStats(uint16(then.extStartSN), uint16(now.extStartSN))
|
||||
}
|
||||
@@ -653,6 +640,9 @@ func (r *RTPStats) SnapshotInfo(snapshotId uint32) *RTPSnapshotInfo {
|
||||
packetsLost := uint32(0)
|
||||
if r.params.IsReceiverReportDriven {
|
||||
packetsLost = now.packetsLostOverridden - then.packetsLostOverridden
|
||||
if int32(packetsLost) < 0 {
|
||||
packetsLost = 0
|
||||
}
|
||||
} else {
|
||||
_, _, _, _, packetsLost, _ = r.getIntervalStats(uint16(then.extStartSN), uint16(now.extStartSN))
|
||||
}
|
||||
@@ -698,6 +688,9 @@ func (r *RTPStats) DeltaInfo(snapshotId uint32) *RTPDeltaInfo {
|
||||
_, bytes, packetsPadding, bytesPadding, packetsLost, frames := r.getIntervalStats(uint16(then.extStartSN), uint16(now.extStartSN))
|
||||
if r.params.IsReceiverReportDriven {
|
||||
packetsLost = now.packetsLostOverridden - then.packetsLostOverridden
|
||||
if int32(packetsLost) < 0 {
|
||||
packetsLost = 0
|
||||
}
|
||||
}
|
||||
|
||||
maxJitter := then.maxJitter
|
||||
@@ -775,7 +768,7 @@ func (r *RTPStats) ToString() string {
|
||||
}
|
||||
|
||||
str += ", n:"
|
||||
str += fmt.Sprintf("%d|%d", p.Nacks, p.NackMisses)
|
||||
str += fmt.Sprintf("%d|%d|%d|%d", p.Nacks, p.NackAcks, p.NackMisses, p.NackRepeated)
|
||||
|
||||
str += ", pli:"
|
||||
str += fmt.Sprintf("%d|%+v / %d|%+v",
|
||||
@@ -862,7 +855,9 @@ func (r *RTPStats) ToProto() *livekit.RTPStats {
|
||||
JitterCurrent: jitterTime,
|
||||
JitterMax: maxJitterTime,
|
||||
Nacks: r.nacks,
|
||||
NackAcks: r.nackAcks,
|
||||
NackMisses: r.nackMisses,
|
||||
NackRepeated: r.nackRepeated,
|
||||
Plis: r.plis,
|
||||
LastPli: timestamppb.New(r.lastPli),
|
||||
LayerLockPlis: r.layerLockPlis,
|
||||
@@ -1111,7 +1106,9 @@ func AggregateRTPStats(statsList []*livekit.RTPStats) *livekit.RTPStats {
|
||||
maxJitter := float64(0)
|
||||
gapHistogram := make(map[int32]uint32, GapHistogramNumBins)
|
||||
nacks := uint32(0)
|
||||
nackAcks := uint32(0)
|
||||
nackMisses := uint32(0)
|
||||
nackRepeated := uint32(0)
|
||||
plis := uint32(0)
|
||||
lastPli := time.Time{}
|
||||
layerLockPlis := uint32(0)
|
||||
@@ -1160,7 +1157,9 @@ func AggregateRTPStats(statsList []*livekit.RTPStats) *livekit.RTPStats {
|
||||
}
|
||||
|
||||
nacks += stats.Nacks
|
||||
nackAcks += stats.NackAcks
|
||||
nackMisses += stats.NackMisses
|
||||
nackRepeated += stats.NackRepeated
|
||||
|
||||
plis += stats.Plis
|
||||
if lastPli.IsZero() || lastPli.Before(stats.LastPli.AsTime()) {
|
||||
@@ -1229,7 +1228,9 @@ func AggregateRTPStats(statsList []*livekit.RTPStats) *livekit.RTPStats {
|
||||
JitterMax: maxJitter,
|
||||
GapHistogram: gapHistogram,
|
||||
Nacks: nacks,
|
||||
NackAcks: nackAcks,
|
||||
NackMisses: nackMisses,
|
||||
NackRepeated: nackRepeated,
|
||||
Plis: plis,
|
||||
LastPli: timestamppb.New(lastPli),
|
||||
LayerLockPlis: layerLockPlis,
|
||||
|
||||
@@ -1036,8 +1036,9 @@ func (d *DownTrack) retransmitPackets(nacks []uint16) {
|
||||
src := PacketFactory.Get().(*[]byte)
|
||||
defer PacketFactory.Put(src)
|
||||
|
||||
numRepeatedNACKs := uint32(0)
|
||||
nackAcks := uint32(0)
|
||||
nackMisses := uint32(0)
|
||||
numRepeatedNACKs := uint32(0)
|
||||
for _, meta := range d.sequencer.getPacketsMeta(filtered) {
|
||||
if meta.layer == int8(InvalidLayerSpatial) {
|
||||
// padding packet, no RTX for those
|
||||
@@ -1048,6 +1049,8 @@ func (d *DownTrack) retransmitPackets(nacks []uint16) {
|
||||
continue
|
||||
}
|
||||
|
||||
nackAcks++
|
||||
|
||||
if pool != nil {
|
||||
PacketFactory.Put(pool)
|
||||
pool = nil
|
||||
@@ -1119,7 +1122,7 @@ func (d *DownTrack) retransmitPackets(nacks []uint16) {
|
||||
d.totalRepeatedNACKs += numRepeatedNACKs
|
||||
d.statsLock.Unlock()
|
||||
|
||||
d.rtpStats.UpdateNackMiss(nackMisses)
|
||||
d.rtpStats.UpdateNackProcessed(nackAcks, nackMisses, numRepeatedNACKs)
|
||||
}
|
||||
|
||||
// writes RTP header extensions of track
|
||||
|
||||
Reference in New Issue
Block a user