diff --git a/pkg/sfu/streamallocator/channelobserver.go b/pkg/sfu/streamallocator/channelobserver.go index f19bbb69..dcef36f3 100644 --- a/pkg/sfu/streamallocator/channelobserver.go +++ b/pkg/sfu/streamallocator/channelobserver.go @@ -148,29 +148,17 @@ func (c *ChannelObserver) GetNackRatio() (uint32, uint32, float64) { func (c *ChannelObserver) GetTrend() (ChannelTrend, ChannelCongestionReason) { estimateDirection := c.estimateTrend.GetDirection() - packets, repeatedNacks, nackRatio := c.GetNackRatio() + _, _, nackRatio := c.GetNackRatio() switch { case estimateDirection == TrendDirectionDownward: - c.logger.Debugw( - "stream allocator: channel observer: estimate is trending downward", - "name", c.params.Name, - "estimate", c.estimateTrend.ToString(), - "packets", packets, - "repeatedNacks", repeatedNacks, - "ratio", nackRatio, - ) + c.logger.Debugw( "stream allocator: channel observer: estimate is trending downward", "channel", c.ToString()) return ChannelTrendCongesting, ChannelCongestionReasonEstimate + case c.params.NackWindowMinDuration != 0 && !c.nackWindowStartTime.IsZero() && time.Since(c.nackWindowStartTime) > c.params.NackWindowMinDuration && nackRatio > c.params.NackRatioThreshold: - c.logger.Debugw( - "stream allocator: channel observer: high rate of repeated NACKs", - "name", c.params.Name, - "estimate", c.estimateTrend.ToString(), - "packets", packets, - "repeatedNacks", repeatedNacks, - "ratio", nackRatio, - ) + c.logger.Debugw( "stream allocator: channel observer: high rate of repeated NACKs", "channel", c.ToString()) return ChannelTrendCongesting, ChannelCongestionReasonLoss + case estimateDirection == TrendDirectionUpward: return ChannelTrendClearing, ChannelCongestionReasonNone } @@ -178,4 +166,9 @@ func (c *ChannelObserver) GetTrend() (ChannelTrend, ChannelCongestionReason) { return ChannelTrendNeutral, ChannelCongestionReasonNone } +func (c *ChannelObserver) ToString() string { + packets, repeatedNacks, nackRatio := c.GetNackRatio() + return fmt.Sprintf("name: %s, estimate: %s, packets: %d, repeatedNacks: %d, nackRatio: %f", c.params.Name, c.estimateTrend.ToString(), packets, repeatedNacks, nackRatio) +} + // ------------------------------------------------ diff --git a/pkg/sfu/streamallocator/streamallocator.go b/pkg/sfu/streamallocator/streamallocator.go index a65834ed..fdf6c335 100644 --- a/pkg/sfu/streamallocator/streamallocator.go +++ b/pkg/sfu/streamallocator/streamallocator.go @@ -785,6 +785,9 @@ func (s *StreamAllocator) handleNewEstimateInNonProbe() { switch reason { case ChannelCongestionReasonLoss: estimateToCommit = int64(float64(expectedBandwidthUsage) * (1.0 - NackRatioAttenuator*nackRatio)) + if estimateToCommit > s.lastReceivedEstimate { + estimateToCommit = s.lastReceivedEstimate + } default: estimateToCommit = s.lastReceivedEstimate } @@ -1156,6 +1159,10 @@ func (s *StreamAllocator) initProbe(probeRateBps int64) { s.probeEndTime = time.Time{} + channelState := "" + if s.channelObserver != nil { + channelState = s.channelObserver.ToString() + } s.channelObserver = s.newChannelObserverProbe() s.channelObserver.SeedEstimate(s.lastReceivedEstimate) @@ -1172,6 +1179,7 @@ func (s *StreamAllocator) initProbe(probeRateBps int64) { "current usage", expectedBandwidthUsage, "committed", s.committedChannelCapacity, "lastReceived", s.lastReceivedEstimate, + "channel", channelState, "probeRateBps", probeRateBps, "goalBps", s.probeGoalBps, )