github.com/MerlinKodo/quic-go@v0.39.2/internal/ackhandler/cc_adapter_ex.go (about) 1 package ackhandler 2 3 import ( 4 "time" 5 6 "github.com/MerlinKodo/quic-go/congestion" 7 cgInternal "github.com/MerlinKodo/quic-go/internal/congestion" 8 "github.com/MerlinKodo/quic-go/internal/protocol" 9 ) 10 11 var ( 12 _ cgInternal.SendAlgorithmEx = &ccAdapterEx{} 13 _ cgInternal.SendAlgorithmWithDebugInfos = &ccAdapterEx{} 14 ) 15 16 type ccAdapterEx struct { 17 CC congestion.CongestionControlEx 18 } 19 20 func (a *ccAdapterEx) TimeUntilSend(bytesInFlight protocol.ByteCount) time.Time { 21 return a.CC.TimeUntilSend(congestion.ByteCount(bytesInFlight)) 22 } 23 24 func (a *ccAdapterEx) HasPacingBudget(now time.Time) bool { 25 return a.CC.HasPacingBudget(now) 26 } 27 28 func (a *ccAdapterEx) OnPacketSent(sentTime time.Time, bytesInFlight protocol.ByteCount, packetNumber protocol.PacketNumber, bytes protocol.ByteCount, isRetransmittable bool) { 29 a.CC.OnPacketSent(sentTime, congestion.ByteCount(bytesInFlight), congestion.PacketNumber(packetNumber), congestion.ByteCount(bytes), isRetransmittable) 30 } 31 32 func (a *ccAdapterEx) CanSend(bytesInFlight protocol.ByteCount) bool { 33 return a.CC.CanSend(congestion.ByteCount(bytesInFlight)) 34 } 35 36 func (a *ccAdapterEx) MaybeExitSlowStart() { 37 a.CC.MaybeExitSlowStart() 38 } 39 40 func (a *ccAdapterEx) OnPacketAcked(number protocol.PacketNumber, ackedBytes protocol.ByteCount, priorInFlight protocol.ByteCount, eventTime time.Time) { 41 a.CC.OnPacketAcked(congestion.PacketNumber(number), congestion.ByteCount(ackedBytes), congestion.ByteCount(priorInFlight), eventTime) 42 } 43 44 func (a *ccAdapterEx) OnCongestionEvent(number protocol.PacketNumber, lostBytes protocol.ByteCount, priorInFlight protocol.ByteCount) { 45 a.CC.OnCongestionEvent(congestion.PacketNumber(number), congestion.ByteCount(lostBytes), congestion.ByteCount(priorInFlight)) 46 } 47 48 func (a *ccAdapterEx) OnCongestionEventEx(priorInFlight protocol.ByteCount, eventTime time.Time, ackedPackets []congestion.AckedPacketInfo, lostPackets []congestion.LostPacketInfo) { 49 a.CC.OnCongestionEventEx(congestion.ByteCount(priorInFlight), eventTime, ackedPackets, lostPackets) 50 } 51 52 func (a *ccAdapterEx) OnRetransmissionTimeout(packetsRetransmitted bool) { 53 a.CC.OnRetransmissionTimeout(packetsRetransmitted) 54 } 55 56 func (a *ccAdapterEx) SetMaxDatagramSize(size protocol.ByteCount) { 57 a.CC.SetMaxDatagramSize(congestion.ByteCount(size)) 58 } 59 60 func (a *ccAdapterEx) InSlowStart() bool { 61 return a.CC.InSlowStart() 62 } 63 64 func (a *ccAdapterEx) InRecovery() bool { 65 return a.CC.InRecovery() 66 } 67 68 func (a *ccAdapterEx) GetCongestionWindow() protocol.ByteCount { 69 return protocol.ByteCount(a.CC.GetCongestionWindow()) 70 }