44 "fmt"
55
66 "github.com/sagernet/quic-go/congestion"
7- "github.com/sagernet/quic-go/logging"
87 "github.com/sagernet/quic-go/monotime"
8+ "github.com/sagernet/quic-go/qlog"
99)
1010
1111const (
@@ -57,8 +57,7 @@ type cubicSender struct {
5757
5858 maxDatagramSize congestion.ByteCount
5959
60- lastState logging.CongestionState
61- tracer * logging.ConnectionTracer
60+ lastState qlog.CongestionState
6261}
6362
6463var _ congestion.CongestionControl = & cubicSender {}
@@ -68,15 +67,13 @@ func NewCubicSender(
6867 clock Clock ,
6968 initialMaxDatagramSize congestion.ByteCount ,
7069 reno bool ,
71- tracer * logging.ConnectionTracer ,
7270) * cubicSender {
7371 return newCubicSender (
7472 clock ,
7573 reno ,
7674 initialMaxDatagramSize ,
7775 initialCongestionWindow * initialMaxDatagramSize ,
7876 MaxCongestionWindowPackets * initialMaxDatagramSize ,
79- tracer ,
8077 )
8178}
8279
@@ -86,7 +83,6 @@ func newCubicSender(
8683 initialMaxDatagramSize ,
8784 initialCongestionWindow ,
8885 initialMaxCongestionWindow congestion.ByteCount ,
89- tracer * logging.ConnectionTracer ,
9086) * cubicSender {
9187 c := & cubicSender {
9288 largestSentPacketNumber : InvalidPacketNumber ,
@@ -99,14 +95,9 @@ func newCubicSender(
9995 cubic : NewCubic (clock ),
10096 clock : clock ,
10197 reno : reno ,
102- tracer : tracer ,
10398 maxDatagramSize : initialMaxDatagramSize ,
10499 }
105100 c .pacer = newPacer (c .BandwidthEstimate )
106- if c .tracer != nil {
107- c .lastState = logging .CongestionStateSlowStart
108- c .tracer .UpdatedCongestionState (logging .CongestionStateSlowStart )
109- }
110101 return c
111102}
112103
@@ -167,7 +158,6 @@ func (c *cubicSender) MaybeExitSlowStart() {
167158 c .hybridSlowStart .ShouldExitSlowStart (c .rttStats .LatestRTT (), c .rttStats .MinRTT (), c .GetCongestionWindow ()/ c .maxDatagramSize ) {
168159 // exit slow start
169160 c .slowStartThreshold = c .congestionWindow
170- c .maybeTraceStateChange (logging .CongestionStateCongestionAvoidance )
171161 }
172162}
173163
@@ -194,7 +184,6 @@ func (c *cubicSender) OnCongestionEvent(packetNumber congestion.PacketNumber, lo
194184 return
195185 }
196186 c .lastCutbackExitedSlowstart = c .InSlowStart ()
197- c .maybeTraceStateChange (logging .CongestionStateRecovery )
198187
199188 if c .reno {
200189 c .congestionWindow = congestion .ByteCount (float64 (c .congestionWindow ) * renoBeta )
@@ -223,7 +212,6 @@ func (c *cubicSender) maybeIncreaseCwnd(
223212 // the current window.
224213 if ! c .isCwndLimited (priorInFlight ) {
225214 c .cubic .OnApplicationLimited ()
226- c .maybeTraceStateChange (logging .CongestionStateApplicationLimited )
227215 return
228216 }
229217 if c .congestionWindow >= c .maxCongestionWindow () {
@@ -232,11 +220,9 @@ func (c *cubicSender) maybeIncreaseCwnd(
232220 if c .InSlowStart () {
233221 // TCP slow start, exponential growth, increase by one for each ACK.
234222 c .congestionWindow += c .maxDatagramSize
235- c .maybeTraceStateChange (logging .CongestionStateSlowStart )
236223 return
237224 }
238225 // Congestion avoidance
239- c .maybeTraceStateChange (logging .CongestionStateCongestionAvoidance )
240226 if c .reno {
241227 // Classic Reno congestion avoidance.
242228 c .numAckedPackets ++
@@ -297,14 +283,6 @@ func (c *cubicSender) OnConnectionMigration() {
297283 c .slowStartThreshold = c .initialMaxCongestionWindow
298284}
299285
300- func (c * cubicSender ) maybeTraceStateChange (new logging.CongestionState ) {
301- if c .tracer == nil || new == c .lastState {
302- return
303- }
304- c .tracer .UpdatedCongestionState (new )
305- c .lastState = new
306- }
307-
308286func (c * cubicSender ) SetMaxDatagramSize (s congestion.ByteCount ) {
309287 if s < c .maxDatagramSize {
310288 panic (fmt .Sprintf ("congestion BUG: decreased max datagram size from %d to %d" , c .maxDatagramSize , s ))
0 commit comments