Let server and client fill the flow variables

This commit is contained in:
Thomas De Keulenaer
2017-06-13 16:42:06 +02:00
parent 89f96d1e89
commit 4fa7b9e569
8 changed files with 52 additions and 75 deletions

View File

@@ -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,
MaxReceiveStreamFlowControlWindow: maxReceiveStreamFlowControlWindow,
MaxReceiveConnectionFlowControlWindow: maxReceiveConnectionFlowControlWindow,
}
}

View File

@@ -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,22 +65,8 @@ 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,
@@ -91,11 +74,8 @@ func NewConnectionParamatersManager(
sendConnectionFlowControlWindow: protocol.InitialConnectionFlowControlWindow, // can only be changed by the client
receiveStreamFlowControlWindow: protocol.ReceiveStreamFlowControlWindow,
receiveConnectionFlowControlWindow: protocol.ReceiveConnectionFlowControlWindow,
maxReceiveStreamFlowControlWindowServer: maxReceiveStreamFlowControlWindowServer,
maxReceiveConnectionFlowControlWindowServer: maxReceiveConnectionFlowControlWindowServer,
maxReceiveStreamFlowControlWindowClient: maxReceiveStreamFlowControlWindowClient,
maxReceiveConnectionFlowControlWindowClient: maxReceiveConnectionFlowControlWindowClient,
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

View File

@@ -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))

View File

@@ -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,

View File

@@ -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),

View File

@@ -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

View File

@@ -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,
MaxReceiveStreamFlowControlWindow: maxReceiveStreamFlowControlWindow,
MaxReceiveConnectionFlowControlWindow: maxReceiveConnectionFlowControlWindow,
}
}

View File

@@ -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)