diff --git a/client.go b/client.go index 2072ffa40..aeadee75f 100644 --- a/client.go +++ b/client.go @@ -123,15 +123,22 @@ func populateClientConfig(config *Config) *Config { handshakeTimeout = config.HandshakeTimeout } + maxReceiveStreamFlowControlWindow := config.MaxReceiveStreamFlowControlWindow + if maxReceiveStreamFlowControlWindow == 0 { + maxReceiveStreamFlowControlWindow = protocol.DefaultMaxReceiveStreamFlowControlWindowClient + } + maxReceiveConnectionFlowControlWindow := config.MaxReceiveConnectionFlowControlWindow + if maxReceiveConnectionFlowControlWindow == 0 { + maxReceiveConnectionFlowControlWindow = protocol.DefaultMaxReceiveConnectionFlowControlWindowClient + } + return &Config{ - TLSConfig: config.TLSConfig, - Versions: versions, - HandshakeTimeout: handshakeTimeout, - RequestConnectionIDTruncation: config.RequestConnectionIDTruncation, - MaxReceiveStreamFlowControlWindowServer: config.MaxReceiveStreamFlowControlWindowServer, - MaxReceiveConnectionFlowControlWindowServer: config.MaxReceiveConnectionFlowControlWindowServer, - MaxReceiveStreamFlowControlWindowClient: config.MaxReceiveStreamFlowControlWindowClient, - MaxReceiveConnectionFlowControlWindowClient: config.MaxReceiveConnectionFlowControlWindowClient, + TLSConfig: config.TLSConfig, + Versions: versions, + HandshakeTimeout: handshakeTimeout, + RequestConnectionIDTruncation: config.RequestConnectionIDTruncation, + MaxReceiveStreamFlowControlWindow: maxReceiveStreamFlowControlWindow, + MaxReceiveConnectionFlowControlWindow: maxReceiveConnectionFlowControlWindow, } } diff --git a/handshake/connection_parameters_manager.go b/handshake/connection_parameters_manager.go index 799dd4bf1..1ad9a3a41 100644 --- a/handshake/connection_parameters_manager.go +++ b/handshake/connection_parameters_manager.go @@ -50,11 +50,8 @@ type connectionParametersManager struct { sendConnectionFlowControlWindow protocol.ByteCount receiveStreamFlowControlWindow protocol.ByteCount receiveConnectionFlowControlWindow protocol.ByteCount - - maxReceiveStreamFlowControlWindowServer protocol.ByteCount - maxReceiveConnectionFlowControlWindowServer protocol.ByteCount - maxReceiveStreamFlowControlWindowClient protocol.ByteCount - maxReceiveConnectionFlowControlWindowClient protocol.ByteCount + maxReceiveStreamFlowControlWindow protocol.ByteCount + maxReceiveConnectionFlowControlWindow protocol.ByteCount } var _ ConnectionParametersManager = &connectionParametersManager{} @@ -68,34 +65,17 @@ var ( // NewConnectionParamatersManager creates a new connection parameters manager func NewConnectionParamatersManager( pers protocol.Perspective, v protocol.VersionNumber, - maxReceiveStreamFlowControlWindowServer protocol.ByteCount, maxReceiveConnectionFlowControlWindowServer protocol.ByteCount, - maxReceiveStreamFlowControlWindowClient protocol.ByteCount, maxReceiveConnectionFlowControlWindowClient protocol.ByteCount, + maxReceiveStreamFlowControlWindow protocol.ByteCount, maxReceiveConnectionFlowControlWindow protocol.ByteCount, ) ConnectionParametersManager { - if maxReceiveStreamFlowControlWindowServer == 0 { - maxReceiveStreamFlowControlWindowServer = protocol.DefaultMaxReceiveStreamFlowControlWindowServer - } - if maxReceiveConnectionFlowControlWindowServer == 0 { - maxReceiveConnectionFlowControlWindowServer = protocol.DefaultMaxReceiveConnectionFlowControlWindowServer - } - if maxReceiveStreamFlowControlWindowClient == 0 { - maxReceiveStreamFlowControlWindowClient = protocol.DefaultMaxReceiveStreamFlowControlWindowClient - } - if maxReceiveConnectionFlowControlWindowClient == 0 { - maxReceiveConnectionFlowControlWindowClient = protocol.DefaultMaxReceiveConnectionFlowControlWindowClient - } - h := &connectionParametersManager{ - perspective: pers, - version: v, - sendStreamFlowControlWindow: protocol.InitialStreamFlowControlWindow, // can only be changed by the client - sendConnectionFlowControlWindow: protocol.InitialConnectionFlowControlWindow, // can only be changed by the client - receiveStreamFlowControlWindow: protocol.ReceiveStreamFlowControlWindow, - receiveConnectionFlowControlWindow: protocol.ReceiveConnectionFlowControlWindow, - - maxReceiveStreamFlowControlWindowServer: maxReceiveStreamFlowControlWindowServer, - maxReceiveConnectionFlowControlWindowServer: maxReceiveConnectionFlowControlWindowServer, - maxReceiveStreamFlowControlWindowClient: maxReceiveStreamFlowControlWindowClient, - maxReceiveConnectionFlowControlWindowClient: maxReceiveConnectionFlowControlWindowClient, + perspective: pers, + version: v, + sendStreamFlowControlWindow: protocol.InitialStreamFlowControlWindow, // can only be changed by the client + sendConnectionFlowControlWindow: protocol.InitialConnectionFlowControlWindow, // can only be changed by the client + receiveStreamFlowControlWindow: protocol.ReceiveStreamFlowControlWindow, + receiveConnectionFlowControlWindow: protocol.ReceiveConnectionFlowControlWindow, + maxReceiveStreamFlowControlWindow: maxReceiveStreamFlowControlWindow, + maxReceiveConnectionFlowControlWindow: maxReceiveConnectionFlowControlWindow, } if h.perspective == protocol.PerspectiveServer { @@ -234,10 +214,7 @@ func (h *connectionParametersManager) GetReceiveStreamFlowControlWindow() protoc // GetMaxReceiveStreamFlowControlWindow gets the maximum size of the stream-level flow control window for sending data func (h *connectionParametersManager) GetMaxReceiveStreamFlowControlWindow() protocol.ByteCount { - if h.perspective == protocol.PerspectiveServer { - return h.maxReceiveStreamFlowControlWindowServer - } - return h.maxReceiveStreamFlowControlWindowClient + return h.maxReceiveStreamFlowControlWindow } // GetReceiveConnectionFlowControlWindow gets the size of the stream-level flow control window for receiving data @@ -249,10 +226,7 @@ func (h *connectionParametersManager) GetReceiveConnectionFlowControlWindow() pr // GetMaxReceiveConnectionFlowControlWindow gets the maximum size of the stream-level flow control window for sending data func (h *connectionParametersManager) GetMaxReceiveConnectionFlowControlWindow() protocol.ByteCount { - if h.perspective == protocol.PerspectiveServer { - return h.maxReceiveConnectionFlowControlWindowServer - } - return h.maxReceiveConnectionFlowControlWindowClient + return h.maxReceiveConnectionFlowControlWindow } // GetMaxOutgoingStreams gets the maximum number of outgoing streams per connection diff --git a/handshake/connection_parameters_manager_test.go b/handshake/connection_parameters_manager_test.go index ba8f427d8..1901051bb 100644 --- a/handshake/connection_parameters_manager_test.go +++ b/handshake/connection_parameters_manager_test.go @@ -21,10 +21,8 @@ var _ = Describe("ConnectionsParameterManager", func() { BeforeEach(func() { cpm = NewConnectionParamatersManager(protocol.PerspectiveServer, protocol.Version36, maxReceiveStreamFlowControlWindowServer, maxReceiveConnectionFlowControlWindowServer, - maxReceiveStreamFlowControlWindowClient, maxReceiveConnectionFlowControlWindowClient, ).(*connectionParametersManager) cpmClient = NewConnectionParamatersManager(protocol.PerspectiveClient, protocol.Version36, - maxReceiveStreamFlowControlWindowServer, maxReceiveConnectionFlowControlWindowServer, maxReceiveStreamFlowControlWindowClient, maxReceiveConnectionFlowControlWindowClient, ).(*connectionParametersManager) }) @@ -155,8 +153,8 @@ var _ = Describe("ConnectionsParameterManager", func() { }) It("defaults to the correct maximum flow control windows", func() { - cpmDefault := NewConnectionParamatersManager(protocol.PerspectiveServer, protocol.Version36, 0, 0, 0, 0).(*connectionParametersManager) - cpmClientDefault := NewConnectionParamatersManager(protocol.PerspectiveClient, protocol.Version36, 0, 0, 0, 0).(*connectionParametersManager) + cpmDefault := NewConnectionParamatersManager(protocol.PerspectiveServer, protocol.Version36, 0, 0).(*connectionParametersManager) + cpmClientDefault := NewConnectionParamatersManager(protocol.PerspectiveClient, protocol.Version36, 0, 0).(*connectionParametersManager) Expect(cpmDefault.GetMaxReceiveStreamFlowControlWindow()).To(Equal(protocol.DefaultMaxReceiveStreamFlowControlWindowServer)) Expect(cpmDefault.GetMaxReceiveConnectionFlowControlWindow()).To(Equal(protocol.DefaultMaxReceiveConnectionFlowControlWindowServer)) Expect(cpmClientDefault.GetMaxReceiveStreamFlowControlWindow()).To(Equal(protocol.DefaultMaxReceiveStreamFlowControlWindowClient)) diff --git a/handshake/crypto_setup_client_test.go b/handshake/crypto_setup_client_test.go index aeb1f5a20..a47059573 100644 --- a/handshake/crypto_setup_client_test.go +++ b/handshake/crypto_setup_client_test.go @@ -112,7 +112,6 @@ var _ = Describe("Client Crypto Setup", func() { stream, nil, NewConnectionParamatersManager(protocol.PerspectiveClient, version, - protocol.DefaultMaxReceiveStreamFlowControlWindowServer, protocol.DefaultMaxReceiveConnectionFlowControlWindowServer, protocol.DefaultMaxReceiveStreamFlowControlWindowClient, protocol.DefaultMaxReceiveConnectionFlowControlWindowClient, ), aeadChanged, diff --git a/handshake/crypto_setup_server_test.go b/handshake/crypto_setup_server_test.go index 4e681604c..7e2aeb880 100644 --- a/handshake/crypto_setup_server_test.go +++ b/handshake/crypto_setup_server_test.go @@ -186,7 +186,6 @@ var _ = Describe("Server Crypto Setup", func() { supportedVersions = []protocol.VersionNumber{version, 98, 99} cpm = NewConnectionParamatersManager(protocol.PerspectiveServer, protocol.VersionWhatever, protocol.DefaultMaxReceiveStreamFlowControlWindowServer, protocol.DefaultMaxReceiveConnectionFlowControlWindowServer, - protocol.DefaultMaxReceiveStreamFlowControlWindowClient, protocol.DefaultMaxReceiveConnectionFlowControlWindowClient, ) csInt, err := NewCryptoSetup( protocol.ConnectionID(42), diff --git a/interface.go b/interface.go index 9901203fb..9169cccaa 100644 --- a/interface.go +++ b/interface.go @@ -80,18 +80,12 @@ type Config struct { // If not set, it verifies that the address matches, and that the STK was issued within the last 24 hours // This option is only valid for the server. AcceptSTK func(clientAddr net.Addr, stk *STK) bool - // MaxReceiveStreamFlowControlWindowServer is the maximum stream-level flow control window for receiving data, for the server - // If this value is zero, the timeout is set to protocol.DefaultMaxReceiveStreamFlowControlWindowServer - MaxReceiveStreamFlowControlWindowServer protocol.ByteCount - // MaxReceiveConnectionFlowControlWindowServer is the connection-level flow control window for receiving data, for the server - // If this value is zero, the timeout is set to protocol.DefaultMaxReceiveConnectionFlowControlWindowServer - MaxReceiveConnectionFlowControlWindowServer protocol.ByteCount - // MaxReceiveStreamFlowControlWindowClient is the maximum stream-level flow control window for receiving data, for the client - // If this value is zero, the timeout is set to protocol.DefaultMaxReceiveStreamFlowControlWindowClient - MaxReceiveStreamFlowControlWindowClient protocol.ByteCount - // MaxReceiveConnectionFlowControlWindowClient is the connection-level flow control window for receiving data, for the client - // If this value is zero, the timeout is set to protocol.DefaultMaxReceiveConnectionFlowControlWindowClient - MaxReceiveConnectionFlowControlWindowClient protocol.ByteCount + // MaxReceiveStreamFlowControlWindowServer is the maximum stream-level flow control window for receiving data + // If this value is zero, it will default to 1 MB for the server and 6 MB for the client + MaxReceiveStreamFlowControlWindow protocol.ByteCount + // MaxReceiveConnectionFlowControlWindowServer is the connection-level flow control window for receiving data + // If this value is zero, it will default to 1.5 MB for the server and 15 MB for the client + MaxReceiveConnectionFlowControlWindow protocol.ByteCount } // A Listener for incoming QUIC connections diff --git a/server.go b/server.go index a613fe93f..5048df5f3 100644 --- a/server.go +++ b/server.go @@ -117,15 +117,22 @@ func populateServerConfig(config *Config) *Config { handshakeTimeout = config.HandshakeTimeout } + maxReceiveStreamFlowControlWindow := config.MaxReceiveStreamFlowControlWindow + if maxReceiveStreamFlowControlWindow == 0 { + maxReceiveStreamFlowControlWindow = protocol.DefaultMaxReceiveStreamFlowControlWindowServer + } + maxReceiveConnectionFlowControlWindow := config.MaxReceiveConnectionFlowControlWindow + if maxReceiveConnectionFlowControlWindow == 0 { + maxReceiveConnectionFlowControlWindow = protocol.DefaultMaxReceiveConnectionFlowControlWindowServer + } + return &Config{ - TLSConfig: config.TLSConfig, - Versions: versions, - HandshakeTimeout: handshakeTimeout, - AcceptSTK: vsa, - MaxReceiveStreamFlowControlWindowServer: config.MaxReceiveStreamFlowControlWindowServer, - MaxReceiveConnectionFlowControlWindowServer: config.MaxReceiveConnectionFlowControlWindowServer, - MaxReceiveStreamFlowControlWindowClient: config.MaxReceiveStreamFlowControlWindowClient, - MaxReceiveConnectionFlowControlWindowClient: config.MaxReceiveConnectionFlowControlWindowClient, + TLSConfig: config.TLSConfig, + Versions: versions, + HandshakeTimeout: handshakeTimeout, + AcceptSTK: vsa, + MaxReceiveStreamFlowControlWindow: maxReceiveStreamFlowControlWindow, + MaxReceiveConnectionFlowControlWindow: maxReceiveConnectionFlowControlWindow, } } diff --git a/session.go b/session.go index 22bdaca8b..c3859a97c 100644 --- a/session.go +++ b/session.go @@ -173,8 +173,7 @@ func (s *session) setup( s.rttStats = &congestion.RTTStats{} s.connectionParameters = handshake.NewConnectionParamatersManager(s.perspective, s.version, - s.config.MaxReceiveStreamFlowControlWindowServer, s.config.MaxReceiveConnectionFlowControlWindowServer, - s.config.MaxReceiveStreamFlowControlWindowClient, s.config.MaxReceiveConnectionFlowControlWindowClient) + s.config.MaxReceiveStreamFlowControlWindow, s.config.MaxReceiveConnectionFlowControlWindow) s.sentPacketHandler = ackhandler.NewSentPacketHandler(s.rttStats) s.flowControlManager = flowcontrol.NewFlowControlManager(s.connectionParameters, s.rttStats) s.receivedPacketHandler = ackhandler.NewReceivedPacketHandler(s.ackAlarmChanged)