Record probe information in send side BWE module. (#3231)
Still not doing anythingw with it, but just making a small PR to record that information for future use.
This commit is contained in:
+7
-1
@@ -90,7 +90,13 @@ type BWE interface {
|
||||
)
|
||||
|
||||
// TWCC sequence number
|
||||
RecordPacketSendAndGetSequenceNumber(atMicro int64, size int, isRTX bool) uint16
|
||||
RecordPacketSendAndGetSequenceNumber(
|
||||
atMicro int64,
|
||||
size int,
|
||||
isRTX bool,
|
||||
probeClusterId ccutils.ProbeClusterId,
|
||||
isProbe bool,
|
||||
) uint16
|
||||
|
||||
HandleTWCCFeedback(report *rtcp.TransportLayerCC)
|
||||
|
||||
|
||||
@@ -28,7 +28,13 @@ func (n *NullBWE) Reset() {}
|
||||
|
||||
func (n *NullBWE) Stop() {}
|
||||
|
||||
func (n *NullBWE) RecordPacketSendAndGetSequenceNumber(_atMicro int64, _size int, _isRTX bool) uint16 {
|
||||
func (n *NullBWE) RecordPacketSendAndGetSequenceNumber(
|
||||
_atMicro int64,
|
||||
_size int,
|
||||
_isRTX bool,
|
||||
_probeClusterId ccutils.ProbeClusterId,
|
||||
_isProbe bool,
|
||||
) uint16 {
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
@@ -80,35 +80,41 @@ func (s stat) MarshalLogObject(e zapcore.ObjectEncoder) error {
|
||||
type classStat struct {
|
||||
primary stat
|
||||
rtx stat
|
||||
probe stat
|
||||
}
|
||||
|
||||
func (c *classStat) add(size int, isRTX bool) {
|
||||
func (c *classStat) add(size int, isRTX bool, isProbe bool) {
|
||||
if isRTX {
|
||||
c.rtx.add(size)
|
||||
} else if isProbe {
|
||||
c.probe.add(size)
|
||||
} else {
|
||||
c.primary.add(size)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *classStat) remove(size int, isRTX bool) {
|
||||
func (c *classStat) remove(size int, isRTX bool, isProbe bool) {
|
||||
if isRTX {
|
||||
c.rtx.remove(size)
|
||||
} else if isProbe {
|
||||
c.probe.remove(size)
|
||||
} else {
|
||||
c.primary.remove(size)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *classStat) numPackets() int {
|
||||
return c.primary.getNumPackets() + c.rtx.getNumPackets()
|
||||
return c.primary.getNumPackets() + c.rtx.getNumPackets() + c.probe.getNumPackets()
|
||||
}
|
||||
|
||||
func (c *classStat) numBytes() int {
|
||||
return c.primary.getNumBytes() + c.rtx.getNumBytes()
|
||||
return c.primary.getNumBytes() + c.rtx.getNumBytes() + c.probe.getNumBytes()
|
||||
}
|
||||
|
||||
func (c classStat) MarshalLogObject(e zapcore.ObjectEncoder) error {
|
||||
e.AddObject("primary", c.primary)
|
||||
e.AddObject("rtx", c.rtx)
|
||||
e.AddObject("probe", c.probe)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -175,11 +181,11 @@ func (p *packetGroup) Add(pi *packetInfo, sendDelta, recvDelta int64, isLost boo
|
||||
}
|
||||
p.maxRecvTime = max(p.maxRecvTime, pi.recvTime)
|
||||
|
||||
p.acked.add(int(pi.size), pi.isRTX)
|
||||
p.acked.add(int(pi.size), pi.isRTX, pi.isProbe)
|
||||
if p.snBitmap.IsSet(pi.sequenceNumber - p.minSequenceNumber) {
|
||||
// an earlier packet reported as lost has been received
|
||||
p.snBitmap.Clear(pi.sequenceNumber - p.minSequenceNumber)
|
||||
p.lost.remove(int(pi.size), pi.isRTX)
|
||||
p.lost.remove(int(pi.size), pi.isRTX, pi.isProbe)
|
||||
}
|
||||
|
||||
// note that out-of-order deliveries will amplify the queueing delay.
|
||||
@@ -212,7 +218,7 @@ func (p *packetGroup) lostPacket(pi *packetInfo) error {
|
||||
p.maxSequenceNumber = max(p.maxSequenceNumber, pi.sequenceNumber)
|
||||
p.snBitmap.Set(pi.sequenceNumber - p.minSequenceNumber)
|
||||
|
||||
p.lost.add(int(pi.size), pi.isRTX)
|
||||
p.lost.add(int(pi.size), pi.isRTX, pi.isProbe)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package sendsidebwe
|
||||
|
||||
import (
|
||||
"github.com/livekit/livekit-server/pkg/sfu/ccutils"
|
||||
"go.uber.org/zap/zapcore"
|
||||
)
|
||||
|
||||
@@ -22,18 +23,10 @@ type packetInfo struct {
|
||||
sequenceNumber uint64
|
||||
sendTime int64
|
||||
recvTime int64
|
||||
probeClusterId ccutils.ProbeClusterId
|
||||
size uint16
|
||||
isRTX bool
|
||||
// SSBWE-TODO: possibly add the following fields - pertaining to this packet,
|
||||
// idea is to be able to figure out probe start/end and check for bitrate in that window
|
||||
}
|
||||
|
||||
func (pi *packetInfo) Reset(sequenceNumber uint64) {
|
||||
pi.sequenceNumber = sequenceNumber
|
||||
pi.sendTime = 0
|
||||
pi.recvTime = 0
|
||||
pi.size = 0
|
||||
pi.isRTX = false
|
||||
isProbe bool
|
||||
}
|
||||
|
||||
func (pi *packetInfo) MarshalLogObject(e zapcore.ObjectEncoder) error {
|
||||
@@ -44,7 +37,9 @@ func (pi *packetInfo) MarshalLogObject(e zapcore.ObjectEncoder) error {
|
||||
e.AddUint64("sequenceNumber", pi.sequenceNumber)
|
||||
e.AddInt64("sendTime", pi.sendTime)
|
||||
e.AddInt64("recvTime", pi.recvTime)
|
||||
e.AddUint32("probeClusterId", uint32(pi.probeClusterId))
|
||||
e.AddUint16("size", pi.size)
|
||||
e.AddBool("isRTX", pi.isRTX)
|
||||
e.AddBool("isProbe", pi.isProbe)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"math/rand"
|
||||
"sync"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/sfu/ccutils"
|
||||
"github.com/livekit/protocol/logger"
|
||||
"github.com/livekit/protocol/utils/mono"
|
||||
)
|
||||
@@ -49,8 +50,13 @@ func newPacketTracker(params packetTrackerParams) *packetTracker {
|
||||
}
|
||||
}
|
||||
|
||||
// SSBWE-TODO: this potentially needs to take isProbe as argument?
|
||||
func (p *packetTracker) RecordPacketSendAndGetSequenceNumber(atMicro int64, size int, isRTX bool) uint16 {
|
||||
func (p *packetTracker) RecordPacketSendAndGetSequenceNumber(
|
||||
atMicro int64,
|
||||
size int,
|
||||
isRTX bool,
|
||||
probeClusterId ccutils.ProbeClusterId,
|
||||
isProbe bool,
|
||||
) uint16 {
|
||||
p.lock.Lock()
|
||||
defer p.lock.Unlock()
|
||||
|
||||
@@ -59,11 +65,14 @@ func (p *packetTracker) RecordPacketSendAndGetSequenceNumber(atMicro int64, size
|
||||
}
|
||||
|
||||
pi := p.getPacketInfo(uint16(p.sequenceNumber))
|
||||
pi.sequenceNumber = p.sequenceNumber
|
||||
pi.sendTime = atMicro - p.baseSendTime
|
||||
pi.recvTime = 0
|
||||
pi.size = uint16(size)
|
||||
pi.isRTX = isRTX
|
||||
*pi = packetInfo{
|
||||
sequenceNumber: p.sequenceNumber,
|
||||
sendTime: atMicro - p.baseSendTime,
|
||||
size: uint16(size),
|
||||
isRTX: isRTX,
|
||||
probeClusterId: probeClusterId,
|
||||
isProbe: isProbe,
|
||||
}
|
||||
// SSBWE-REMOVE p.params.Logger.Infow("packet sent", "packetInfo", pi) // SSBWE-REMOVE
|
||||
|
||||
p.sequenceNumber++
|
||||
|
||||
@@ -93,6 +93,8 @@ func (b *Base) patchRTPHeaderExtensions(p *Packet) error {
|
||||
sendingAt.UnixMicro(),
|
||||
packetSize,
|
||||
p.IsRTX,
|
||||
p.ProbeClusterId,
|
||||
p.IsProbe,
|
||||
)
|
||||
twccExt := rtp.TransportCCExtension{
|
||||
TransportSequence: twccSN,
|
||||
|
||||
Reference in New Issue
Block a user