mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-06 05:37:36 +03:00
rename {Stream,Connection}FlowControlWindow to InitialMax{Stream}Data
This commit is contained in:
parent
74c5e9a26c
commit
a1acfc3045
8 changed files with 54 additions and 54 deletions
12
client.go
12
client.go
|
@ -397,12 +397,12 @@ func (c *client) handleRetryPacket(hdr *wire.Header) {
|
||||||
|
|
||||||
func (c *client) createNewTLSSession(version protocol.VersionNumber) error {
|
func (c *client) createNewTLSSession(version protocol.VersionNumber) error {
|
||||||
params := &handshake.TransportParameters{
|
params := &handshake.TransportParameters{
|
||||||
StreamFlowControlWindow: protocol.ReceiveStreamFlowControlWindow,
|
InitialMaxStreamData: protocol.InitialMaxStreamData,
|
||||||
ConnectionFlowControlWindow: protocol.ReceiveConnectionFlowControlWindow,
|
InitialMaxData: protocol.InitialMaxData,
|
||||||
IdleTimeout: c.config.IdleTimeout,
|
IdleTimeout: c.config.IdleTimeout,
|
||||||
MaxBidiStreams: uint16(c.config.MaxIncomingStreams),
|
MaxBidiStreams: uint16(c.config.MaxIncomingStreams),
|
||||||
MaxUniStreams: uint16(c.config.MaxIncomingUniStreams),
|
MaxUniStreams: uint16(c.config.MaxIncomingUniStreams),
|
||||||
DisableMigration: true,
|
DisableMigration: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
c.mutex.Lock()
|
c.mutex.Lock()
|
||||||
|
|
|
@ -16,14 +16,14 @@ var _ = Describe("QUIC TLS Extension", func() {
|
||||||
chtp := &clientHelloTransportParameters{
|
chtp := &clientHelloTransportParameters{
|
||||||
InitialVersion: 0x123456,
|
InitialVersion: 0x123456,
|
||||||
Parameters: TransportParameters{
|
Parameters: TransportParameters{
|
||||||
StreamFlowControlWindow: 0x42,
|
InitialMaxStreamData: 0x42,
|
||||||
IdleTimeout: 0x1337 * time.Second,
|
IdleTimeout: 0x1337 * time.Second,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
chtp2 := &clientHelloTransportParameters{}
|
chtp2 := &clientHelloTransportParameters{}
|
||||||
Expect(chtp2.Unmarshal(chtp.Marshal())).To(Succeed())
|
Expect(chtp2.Unmarshal(chtp.Marshal())).To(Succeed())
|
||||||
Expect(chtp2.InitialVersion).To(Equal(chtp.InitialVersion))
|
Expect(chtp2.InitialVersion).To(Equal(chtp.InitialVersion))
|
||||||
Expect(chtp2.Parameters.StreamFlowControlWindow).To(Equal(chtp.Parameters.StreamFlowControlWindow))
|
Expect(chtp2.Parameters.InitialMaxStreamData).To(Equal(chtp.Parameters.InitialMaxStreamData))
|
||||||
Expect(chtp2.Parameters.IdleTimeout).To(Equal(chtp.Parameters.IdleTimeout))
|
Expect(chtp2.Parameters.IdleTimeout).To(Equal(chtp.Parameters.IdleTimeout))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -44,15 +44,15 @@ var _ = Describe("QUIC TLS Extension", func() {
|
||||||
NegotiatedVersion: 0x123456,
|
NegotiatedVersion: 0x123456,
|
||||||
SupportedVersions: []protocol.VersionNumber{0x42, 0x4242},
|
SupportedVersions: []protocol.VersionNumber{0x42, 0x4242},
|
||||||
Parameters: TransportParameters{
|
Parameters: TransportParameters{
|
||||||
StreamFlowControlWindow: 0x42,
|
InitialMaxStreamData: 0x42,
|
||||||
IdleTimeout: 0x1337 * time.Second,
|
IdleTimeout: 0x1337 * time.Second,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
eetp2 := &encryptedExtensionsTransportParameters{}
|
eetp2 := &encryptedExtensionsTransportParameters{}
|
||||||
Expect(eetp2.Unmarshal(eetp.Marshal())).To(Succeed())
|
Expect(eetp2.Unmarshal(eetp.Marshal())).To(Succeed())
|
||||||
Expect(eetp2.NegotiatedVersion).To(Equal(eetp.NegotiatedVersion))
|
Expect(eetp2.NegotiatedVersion).To(Equal(eetp.NegotiatedVersion))
|
||||||
Expect(eetp2.SupportedVersions).To(Equal(eetp.SupportedVersions))
|
Expect(eetp2.SupportedVersions).To(Equal(eetp.SupportedVersions))
|
||||||
Expect(eetp2.Parameters.StreamFlowControlWindow).To(Equal(eetp.Parameters.StreamFlowControlWindow))
|
Expect(eetp2.Parameters.InitialMaxStreamData).To(Equal(eetp.Parameters.InitialMaxStreamData))
|
||||||
Expect(eetp2.Parameters.IdleTimeout).To(Equal(eetp.Parameters.IdleTimeout))
|
Expect(eetp2.Parameters.IdleTimeout).To(Equal(eetp.Parameters.IdleTimeout))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,13 @@ import (
|
||||||
var _ = Describe("Transport Parameters", func() {
|
var _ = Describe("Transport Parameters", func() {
|
||||||
It("has a string representation", func() {
|
It("has a string representation", func() {
|
||||||
p := &TransportParameters{
|
p := &TransportParameters{
|
||||||
StreamFlowControlWindow: 0x1234,
|
InitialMaxStreamData: 0x1234,
|
||||||
ConnectionFlowControlWindow: 0x4321,
|
InitialMaxData: 0x4321,
|
||||||
MaxBidiStreams: 1337,
|
MaxBidiStreams: 1337,
|
||||||
MaxUniStreams: 7331,
|
MaxUniStreams: 7331,
|
||||||
IdleTimeout: 42 * time.Second,
|
IdleTimeout: 42 * time.Second,
|
||||||
}
|
}
|
||||||
Expect(p.String()).To(Equal("&handshake.TransportParameters{StreamFlowControlWindow: 0x1234, ConnectionFlowControlWindow: 0x4321, MaxBidiStreams: 1337, MaxUniStreams: 7331, IdleTimeout: 42s}"))
|
Expect(p.String()).To(Equal("&handshake.TransportParameters{InitialMaxStreamData: 0x1234, InitialMaxData: 0x4321, MaxBidiStreams: 1337, MaxUniStreams: 7331, IdleTimeout: 42s}"))
|
||||||
})
|
})
|
||||||
|
|
||||||
Context("parsing", func() {
|
Context("parsing", func() {
|
||||||
|
@ -57,8 +57,8 @@ var _ = Describe("Transport Parameters", func() {
|
||||||
It("reads parameters", func() {
|
It("reads parameters", func() {
|
||||||
err := params.unmarshal(marshal(parameters))
|
err := params.unmarshal(marshal(parameters))
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(params.StreamFlowControlWindow).To(Equal(protocol.ByteCount(0x11223344)))
|
Expect(params.InitialMaxStreamData).To(Equal(protocol.ByteCount(0x11223344)))
|
||||||
Expect(params.ConnectionFlowControlWindow).To(Equal(protocol.ByteCount(0x22334455)))
|
Expect(params.InitialMaxData).To(Equal(protocol.ByteCount(0x22334455)))
|
||||||
Expect(params.MaxBidiStreams).To(Equal(uint16(0x3344)))
|
Expect(params.MaxBidiStreams).To(Equal(uint16(0x3344)))
|
||||||
Expect(params.MaxUniStreams).To(Equal(uint16(0x4455)))
|
Expect(params.MaxUniStreams).To(Equal(uint16(0x4455)))
|
||||||
Expect(params.IdleTimeout).To(Equal(0x1337 * time.Second))
|
Expect(params.IdleTimeout).To(Equal(0x1337 * time.Second))
|
||||||
|
@ -150,21 +150,21 @@ var _ = Describe("Transport Parameters", func() {
|
||||||
Context("marshalling", func() {
|
Context("marshalling", func() {
|
||||||
It("marshals", func() {
|
It("marshals", func() {
|
||||||
params := &TransportParameters{
|
params := &TransportParameters{
|
||||||
StreamFlowControlWindow: 0xdeadbeef,
|
InitialMaxStreamData: 0xdeadbeef,
|
||||||
ConnectionFlowControlWindow: 0xdecafbad,
|
InitialMaxData: 0xdecafbad,
|
||||||
IdleTimeout: 0xcafe * time.Second,
|
IdleTimeout: 0xcafe * time.Second,
|
||||||
MaxBidiStreams: 0x1234,
|
MaxBidiStreams: 0x1234,
|
||||||
MaxUniStreams: 0x4321,
|
MaxUniStreams: 0x4321,
|
||||||
DisableMigration: true,
|
DisableMigration: true,
|
||||||
StatelessResetToken: bytes.Repeat([]byte{100}, 16),
|
StatelessResetToken: bytes.Repeat([]byte{100}, 16),
|
||||||
}
|
}
|
||||||
b := &bytes.Buffer{}
|
b := &bytes.Buffer{}
|
||||||
params.marshal(b)
|
params.marshal(b)
|
||||||
|
|
||||||
p := &TransportParameters{}
|
p := &TransportParameters{}
|
||||||
Expect(p.unmarshal(b.Bytes())).To(Succeed())
|
Expect(p.unmarshal(b.Bytes())).To(Succeed())
|
||||||
Expect(p.StreamFlowControlWindow).To(Equal(params.StreamFlowControlWindow))
|
Expect(p.InitialMaxStreamData).To(Equal(params.InitialMaxStreamData))
|
||||||
Expect(p.ConnectionFlowControlWindow).To(Equal(params.ConnectionFlowControlWindow))
|
Expect(p.InitialMaxData).To(Equal(params.InitialMaxData))
|
||||||
Expect(p.MaxUniStreams).To(Equal(params.MaxUniStreams))
|
Expect(p.MaxUniStreams).To(Equal(params.MaxUniStreams))
|
||||||
Expect(p.MaxBidiStreams).To(Equal(params.MaxBidiStreams))
|
Expect(p.MaxBidiStreams).To(Equal(params.MaxBidiStreams))
|
||||||
Expect(p.IdleTimeout).To(Equal(params.IdleTimeout))
|
Expect(p.IdleTimeout).To(Equal(params.IdleTimeout))
|
||||||
|
|
|
@ -26,8 +26,8 @@ const (
|
||||||
|
|
||||||
// TransportParameters are parameters sent to the peer during the handshake
|
// TransportParameters are parameters sent to the peer during the handshake
|
||||||
type TransportParameters struct {
|
type TransportParameters struct {
|
||||||
StreamFlowControlWindow protocol.ByteCount
|
InitialMaxStreamData protocol.ByteCount
|
||||||
ConnectionFlowControlWindow protocol.ByteCount
|
InitialMaxData protocol.ByteCount
|
||||||
|
|
||||||
MaxPacketSize protocol.ByteCount
|
MaxPacketSize protocol.ByteCount
|
||||||
|
|
||||||
|
@ -56,12 +56,12 @@ func (p *TransportParameters) unmarshal(data []byte) error {
|
||||||
if paramLen != 4 {
|
if paramLen != 4 {
|
||||||
return fmt.Errorf("wrong length for initial_max_stream_data: %d (expected 4)", paramLen)
|
return fmt.Errorf("wrong length for initial_max_stream_data: %d (expected 4)", paramLen)
|
||||||
}
|
}
|
||||||
p.StreamFlowControlWindow = protocol.ByteCount(binary.BigEndian.Uint32(data[:4]))
|
p.InitialMaxStreamData = protocol.ByteCount(binary.BigEndian.Uint32(data[:4]))
|
||||||
case initialMaxDataParameterID:
|
case initialMaxDataParameterID:
|
||||||
if paramLen != 4 {
|
if paramLen != 4 {
|
||||||
return fmt.Errorf("wrong length for initial_max_data: %d (expected 4)", paramLen)
|
return fmt.Errorf("wrong length for initial_max_data: %d (expected 4)", paramLen)
|
||||||
}
|
}
|
||||||
p.ConnectionFlowControlWindow = protocol.ByteCount(binary.BigEndian.Uint32(data[:4]))
|
p.InitialMaxData = protocol.ByteCount(binary.BigEndian.Uint32(data[:4]))
|
||||||
case initialMaxBidiStreamsParameterID:
|
case initialMaxBidiStreamsParameterID:
|
||||||
if paramLen != 2 {
|
if paramLen != 2 {
|
||||||
return fmt.Errorf("wrong length for initial_max_stream_id_bidi: %d (expected 2)", paramLen)
|
return fmt.Errorf("wrong length for initial_max_stream_id_bidi: %d (expected 2)", paramLen)
|
||||||
|
@ -118,11 +118,11 @@ func (p *TransportParameters) marshal(b *bytes.Buffer) {
|
||||||
// initial_max_stream_data
|
// initial_max_stream_data
|
||||||
utils.BigEndian.WriteUint16(b, uint16(initialMaxStreamDataParameterID))
|
utils.BigEndian.WriteUint16(b, uint16(initialMaxStreamDataParameterID))
|
||||||
utils.BigEndian.WriteUint16(b, 4)
|
utils.BigEndian.WriteUint16(b, 4)
|
||||||
utils.BigEndian.WriteUint32(b, uint32(p.StreamFlowControlWindow))
|
utils.BigEndian.WriteUint32(b, uint32(p.InitialMaxStreamData))
|
||||||
// initial_max_data
|
// initial_max_data
|
||||||
utils.BigEndian.WriteUint16(b, uint16(initialMaxDataParameterID))
|
utils.BigEndian.WriteUint16(b, uint16(initialMaxDataParameterID))
|
||||||
utils.BigEndian.WriteUint16(b, 4)
|
utils.BigEndian.WriteUint16(b, 4)
|
||||||
utils.BigEndian.WriteUint32(b, uint32(p.ConnectionFlowControlWindow))
|
utils.BigEndian.WriteUint32(b, uint32(p.InitialMaxData))
|
||||||
// initial_max_bidi_streams
|
// initial_max_bidi_streams
|
||||||
utils.BigEndian.WriteUint16(b, uint16(initialMaxBidiStreamsParameterID))
|
utils.BigEndian.WriteUint16(b, uint16(initialMaxBidiStreamsParameterID))
|
||||||
utils.BigEndian.WriteUint16(b, 2)
|
utils.BigEndian.WriteUint16(b, 2)
|
||||||
|
@ -153,5 +153,5 @@ func (p *TransportParameters) marshal(b *bytes.Buffer) {
|
||||||
|
|
||||||
// String returns a string representation, intended for logging.
|
// String returns a string representation, intended for logging.
|
||||||
func (p *TransportParameters) String() string {
|
func (p *TransportParameters) String() string {
|
||||||
return fmt.Sprintf("&handshake.TransportParameters{StreamFlowControlWindow: %#x, ConnectionFlowControlWindow: %#x, MaxBidiStreams: %d, MaxUniStreams: %d, IdleTimeout: %s}", p.StreamFlowControlWindow, p.ConnectionFlowControlWindow, p.MaxBidiStreams, p.MaxUniStreams, p.IdleTimeout)
|
return fmt.Sprintf("&handshake.TransportParameters{InitialMaxStreamData: %#x, InitialMaxData: %#x, MaxBidiStreams: %d, MaxUniStreams: %d, IdleTimeout: %s}", p.InitialMaxStreamData, p.InitialMaxData, p.MaxBidiStreams, p.MaxUniStreams, p.IdleTimeout)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,13 +24,13 @@ const InitialCongestionWindow ByteCount = 32 * DefaultTCPMSS
|
||||||
// session queues for later until it sends a public reset.
|
// session queues for later until it sends a public reset.
|
||||||
const MaxUndecryptablePackets = 10
|
const MaxUndecryptablePackets = 10
|
||||||
|
|
||||||
// ReceiveStreamFlowControlWindow is the stream-level flow control window for receiving data
|
// InitialMaxStreamData is the stream-level flow control window for receiving data
|
||||||
// This is the value that Google servers are using
|
// This is the value that Google servers are using
|
||||||
const ReceiveStreamFlowControlWindow = (1 << 10) * 32 // 32 kB
|
const InitialMaxStreamData = (1 << 10) * 32 // 32 kB
|
||||||
|
|
||||||
// ReceiveConnectionFlowControlWindow is the connection-level flow control window for receiving data
|
// InitialMaxData is the connection-level flow control window for receiving data
|
||||||
// This is the value that Google servers are using
|
// This is the value that Google servers are using
|
||||||
const ReceiveConnectionFlowControlWindow = (1 << 10) * 48 // 48 kB
|
const InitialMaxData = (1 << 10) * 48 // 48 kB
|
||||||
|
|
||||||
// DefaultMaxReceiveStreamFlowControlWindowServer is the default maximum stream-level flow control window for receiving data, for the server
|
// DefaultMaxReceiveStreamFlowControlWindowServer is the default maximum stream-level flow control window for receiving data, for the server
|
||||||
// This is the value that Google servers are using
|
// This is the value that Google servers are using
|
||||||
|
|
12
server.go
12
server.go
|
@ -375,12 +375,12 @@ func (s *server) createNewSession(
|
||||||
version protocol.VersionNumber,
|
version protocol.VersionNumber,
|
||||||
) (quicSession, error) {
|
) (quicSession, error) {
|
||||||
params := &handshake.TransportParameters{
|
params := &handshake.TransportParameters{
|
||||||
StreamFlowControlWindow: protocol.ReceiveStreamFlowControlWindow,
|
InitialMaxStreamData: protocol.InitialMaxStreamData,
|
||||||
ConnectionFlowControlWindow: protocol.ReceiveConnectionFlowControlWindow,
|
InitialMaxData: protocol.InitialMaxData,
|
||||||
IdleTimeout: s.config.IdleTimeout,
|
IdleTimeout: s.config.IdleTimeout,
|
||||||
MaxBidiStreams: uint16(s.config.MaxIncomingStreams),
|
MaxBidiStreams: uint16(s.config.MaxIncomingStreams),
|
||||||
MaxUniStreams: uint16(s.config.MaxIncomingUniStreams),
|
MaxUniStreams: uint16(s.config.MaxIncomingUniStreams),
|
||||||
DisableMigration: true,
|
DisableMigration: true,
|
||||||
// TODO(#855): generate a real token
|
// TODO(#855): generate a real token
|
||||||
StatelessResetToken: bytes.Repeat([]byte{42}, 16),
|
StatelessResetToken: bytes.Repeat([]byte{42}, 16),
|
||||||
}
|
}
|
||||||
|
|
|
@ -277,7 +277,7 @@ func (s *session) preSetup() {
|
||||||
s.sentPacketHandler = ackhandler.NewSentPacketHandler(s.rttStats, s.logger, s.version)
|
s.sentPacketHandler = ackhandler.NewSentPacketHandler(s.rttStats, s.logger, s.version)
|
||||||
s.receivedPacketHandler = ackhandler.NewReceivedPacketHandler(s.rttStats, s.logger, s.version)
|
s.receivedPacketHandler = ackhandler.NewReceivedPacketHandler(s.rttStats, s.logger, s.version)
|
||||||
s.connFlowController = flowcontrol.NewConnectionFlowController(
|
s.connFlowController = flowcontrol.NewConnectionFlowController(
|
||||||
protocol.ReceiveConnectionFlowControlWindow,
|
protocol.InitialMaxData,
|
||||||
protocol.ByteCount(s.config.MaxReceiveConnectionFlowControlWindow),
|
protocol.ByteCount(s.config.MaxReceiveConnectionFlowControlWindow),
|
||||||
s.onHasConnectionWindowUpdate,
|
s.onHasConnectionWindowUpdate,
|
||||||
s.rttStats,
|
s.rttStats,
|
||||||
|
@ -746,7 +746,7 @@ func (s *session) processTransportParameters(params *handshake.TransportParamete
|
||||||
s.peerParams = params
|
s.peerParams = params
|
||||||
s.streamsMap.UpdateLimits(params)
|
s.streamsMap.UpdateLimits(params)
|
||||||
s.packer.HandleTransportParameters(params)
|
s.packer.HandleTransportParameters(params)
|
||||||
s.connFlowController.UpdateSendWindow(params.ConnectionFlowControlWindow)
|
s.connFlowController.UpdateSendWindow(params.InitialMaxData)
|
||||||
// the crypto stream is the only open stream at this moment
|
// the crypto stream is the only open stream at this moment
|
||||||
// so we don't need to update stream flow control windows
|
// so we don't need to update stream flow control windows
|
||||||
}
|
}
|
||||||
|
@ -992,12 +992,12 @@ func (s *session) newStream(id protocol.StreamID) streamI {
|
||||||
func (s *session) newFlowController(id protocol.StreamID) flowcontrol.StreamFlowController {
|
func (s *session) newFlowController(id protocol.StreamID) flowcontrol.StreamFlowController {
|
||||||
var initialSendWindow protocol.ByteCount
|
var initialSendWindow protocol.ByteCount
|
||||||
if s.peerParams != nil {
|
if s.peerParams != nil {
|
||||||
initialSendWindow = s.peerParams.StreamFlowControlWindow
|
initialSendWindow = s.peerParams.InitialMaxStreamData
|
||||||
}
|
}
|
||||||
return flowcontrol.NewStreamFlowController(
|
return flowcontrol.NewStreamFlowController(
|
||||||
id,
|
id,
|
||||||
s.connFlowController,
|
s.connFlowController,
|
||||||
protocol.ReceiveStreamFlowControlWindow,
|
protocol.InitialMaxStreamData,
|
||||||
protocol.ByteCount(s.config.MaxReceiveStreamFlowControlWindow),
|
protocol.ByteCount(s.config.MaxReceiveStreamFlowControlWindow),
|
||||||
initialSendWindow,
|
initialSendWindow,
|
||||||
s.onHasStreamWindowUpdate,
|
s.onHasStreamWindowUpdate,
|
||||||
|
|
|
@ -995,10 +995,10 @@ var _ = Describe("Session", func() {
|
||||||
sess.run()
|
sess.run()
|
||||||
}()
|
}()
|
||||||
params := &handshake.TransportParameters{
|
params := &handshake.TransportParameters{
|
||||||
IdleTimeout: 90 * time.Second,
|
IdleTimeout: 90 * time.Second,
|
||||||
StreamFlowControlWindow: 0x5000,
|
InitialMaxStreamData: 0x5000,
|
||||||
ConnectionFlowControlWindow: 0x5000,
|
InitialMaxData: 0x5000,
|
||||||
MaxPacketSize: 0x42,
|
MaxPacketSize: 0x42,
|
||||||
}
|
}
|
||||||
streamManager.EXPECT().UpdateLimits(params)
|
streamManager.EXPECT().UpdateLimits(params)
|
||||||
packer.EXPECT().HandleTransportParameters(params)
|
packer.EXPECT().HandleTransportParameters(params)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue