-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
# Conflicts: # connection.go # connection_test.go # http3/conn.go
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package congestion | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/quic-go/quic-go/internal/protocol" | ||
) | ||
|
||
type ( | ||
ByteCount protocol.ByteCount | ||
PacketNumber protocol.PacketNumber | ||
) | ||
|
||
// Expose some constants from protocol that congestion control algorithms may need. | ||
const ( | ||
InitialPacketSizeIPv4 = protocol.InitialPacketSizeIPv4 | ||
Check failure on line 16 in congestion/interface.go GitHub Actions / Cross Compilation (Go 1.22.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / Cross Compilation (Go 1.21.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / Unit tests (ubuntu, Go 1.21.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / Unit tests (macos, Go 1.22.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / Unit tests (ubuntu, Go 1.22.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / Unit tests (macos, Go 1.21.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / Unit tests (windows, Go 1.22.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / Unit tests (windows, Go 1.21.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.21.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.21.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.21.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.21.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.21.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.21.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.21.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.21.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.21.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.21.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.21.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.21.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.21.x)
Check failure on line 16 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.21.x)
|
||
InitialPacketSizeIPv6 = protocol.InitialPacketSizeIPv6 | ||
Check failure on line 17 in congestion/interface.go GitHub Actions / Cross Compilation (Go 1.22.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / Cross Compilation (Go 1.21.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / Unit tests (ubuntu, Go 1.21.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / Unit tests (macos, Go 1.22.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / Unit tests (ubuntu, Go 1.22.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / Unit tests (macos, Go 1.21.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / Unit tests (windows, Go 1.22.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.22.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / Unit tests (windows, Go 1.21.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.21.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.21.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.21.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.21.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.21.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.21.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.21.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.21.x)
Check failure on line 17 in congestion/interface.go GitHub Actions / golangci-lint (Go 1.21.x)
|
||
MinPacingDelay = protocol.MinPacingDelay | ||
MaxPacketBufferSize = protocol.MaxPacketBufferSize | ||
MinInitialPacketSize = protocol.MinInitialPacketSize | ||
MaxCongestionWindowPackets = protocol.MaxCongestionWindowPackets | ||
PacketsPerConnectionID = protocol.PacketsPerConnectionID | ||
) | ||
|
||
type AckedPacketInfo struct { | ||
PacketNumber PacketNumber | ||
BytesAcked ByteCount | ||
ReceivedTime time.Time | ||
} | ||
|
||
type LostPacketInfo struct { | ||
PacketNumber PacketNumber | ||
BytesLost ByteCount | ||
} | ||
|
||
type CongestionControl interface { | ||
SetRTTStatsProvider(provider RTTStatsProvider) | ||
TimeUntilSend(bytesInFlight ByteCount) time.Time | ||
HasPacingBudget(now time.Time) bool | ||
OnPacketSent(sentTime time.Time, bytesInFlight ByteCount, packetNumber PacketNumber, bytes ByteCount, isRetransmittable bool) | ||
CanSend(bytesInFlight ByteCount) bool | ||
MaybeExitSlowStart() | ||
OnPacketAcked(number PacketNumber, ackedBytes ByteCount, priorInFlight ByteCount, eventTime time.Time) | ||
OnCongestionEvent(number PacketNumber, lostBytes ByteCount, priorInFlight ByteCount) | ||
OnCongestionEventEx(priorInFlight ByteCount, eventTime time.Time, ackedPackets []AckedPacketInfo, lostPackets []LostPacketInfo) | ||
OnRetransmissionTimeout(packetsRetransmitted bool) | ||
SetMaxDatagramSize(size ByteCount) | ||
InSlowStart() bool | ||
InRecovery() bool | ||
GetCongestionWindow() ByteCount | ||
} | ||
|
||
type RTTStatsProvider interface { | ||
MinRTT() time.Duration | ||
LatestRTT() time.Duration | ||
SmoothedRTT() time.Duration | ||
MeanDeviation() time.Duration | ||
MaxAckDelay() time.Duration | ||
PTO(includeMaxAckDelay bool) time.Duration | ||
UpdateRTT(sendDelta, ackDelay time.Duration, now time.Time) | ||
SetMaxAckDelay(mad time.Duration) | ||
SetInitialRTT(t time.Duration) | ||
OnConnectionMigration() | ||
ExpireSmoothedMetrics() | ||
} |