remove the receive flow control window from the params negotiator

The receive windows are not negotiated, they are just announced to the
peer.
This commit is contained in:
Marten Seemann
2017-10-15 13:50:19 +07:00
parent f5acb690d3
commit 480db80da1
10 changed files with 45 additions and 96 deletions

View File

@@ -79,9 +79,9 @@ func (h *paramsNegotiator) SetFromTransportParameters(params []transportParamete
func (h *paramsNegotiator) GetTransportParameters() []transportParameter {
initialMaxStreamData := make([]byte, 4)
binary.BigEndian.PutUint32(initialMaxStreamData, uint32(h.GetReceiveStreamFlowControlWindow()))
binary.BigEndian.PutUint32(initialMaxStreamData, uint32(protocol.ReceiveStreamFlowControlWindow))
initialMaxData := make([]byte, 4)
binary.BigEndian.PutUint32(initialMaxData, uint32(h.GetReceiveConnectionFlowControlWindow()))
binary.BigEndian.PutUint32(initialMaxData, uint32(protocol.ReceiveConnectionFlowControlWindow))
initialMaxStreamID := make([]byte, 4)
// TODO: use a reasonable value here
binary.BigEndian.PutUint32(initialMaxStreamID, math.MaxUint32)

View File

@@ -13,8 +13,6 @@ import (
type ParamsNegotiator interface {
GetSendStreamFlowControlWindow() protocol.ByteCount
GetSendConnectionFlowControlWindow() protocol.ByteCount
GetReceiveStreamFlowControlWindow() protocol.ByteCount
GetReceiveConnectionFlowControlWindow() protocol.ByteCount
GetMaxOutgoingStreams() uint32
// get the idle timeout that was sent by the peer
GetRemoteIdleTimeout() time.Duration
@@ -39,20 +37,16 @@ type paramsNegotiatorBase struct {
omitConnectionID bool
requestConnectionIDOmission bool
maxOutgoingStreams uint32
idleTimeout time.Duration
remoteIdleTimeout time.Duration
sendStreamFlowControlWindow protocol.ByteCount
sendConnectionFlowControlWindow protocol.ByteCount
receiveStreamFlowControlWindow protocol.ByteCount
receiveConnectionFlowControlWindow protocol.ByteCount
maxOutgoingStreams uint32
idleTimeout time.Duration
remoteIdleTimeout time.Duration
sendStreamFlowControlWindow protocol.ByteCount
sendConnectionFlowControlWindow protocol.ByteCount
}
func (h *paramsNegotiatorBase) init(params *TransportParameters) {
h.sendStreamFlowControlWindow = protocol.InitialStreamFlowControlWindow // can only be changed by the client
h.sendConnectionFlowControlWindow = protocol.InitialConnectionFlowControlWindow // can only be changed by the client
h.receiveStreamFlowControlWindow = protocol.ReceiveStreamFlowControlWindow
h.receiveConnectionFlowControlWindow = protocol.ReceiveConnectionFlowControlWindow
h.requestConnectionIDOmission = params.RequestConnectionIDOmission
h.idleTimeout = params.IdleTimeout
@@ -74,19 +68,6 @@ func (h *paramsNegotiatorBase) GetSendConnectionFlowControlWindow() protocol.Byt
return h.sendConnectionFlowControlWindow
}
func (h *paramsNegotiatorBase) GetReceiveStreamFlowControlWindow() protocol.ByteCount {
h.mutex.RLock()
defer h.mutex.RUnlock()
return h.receiveStreamFlowControlWindow
}
// GetReceiveConnectionFlowControlWindow gets the size of the stream-level flow control window for receiving data
func (h *paramsNegotiatorBase) GetReceiveConnectionFlowControlWindow() protocol.ByteCount {
h.mutex.RLock()
defer h.mutex.RUnlock()
return h.receiveConnectionFlowControlWindow
}
func (h *paramsNegotiatorBase) GetMaxOutgoingStreams() uint32 {
h.mutex.RLock()
defer h.mutex.RUnlock()

View File

@@ -89,9 +89,9 @@ func (h *paramsNegotiatorGQUIC) SetFromMap(params map[Tag][]byte) error {
// GetHelloMap gets all parameters needed for the Hello message.
func (h *paramsNegotiatorGQUIC) GetHelloMap() (map[Tag][]byte, error) {
sfcw := bytes.NewBuffer([]byte{})
utils.LittleEndian.WriteUint32(sfcw, uint32(h.GetReceiveStreamFlowControlWindow()))
utils.LittleEndian.WriteUint32(sfcw, uint32(protocol.ReceiveStreamFlowControlWindow))
cfcw := bytes.NewBuffer([]byte{})
utils.LittleEndian.WriteUint32(cfcw, uint32(h.GetReceiveConnectionFlowControlWindow()))
utils.LittleEndian.WriteUint32(cfcw, uint32(protocol.ReceiveConnectionFlowControlWindow))
mids := bytes.NewBuffer([]byte{})
utils.LittleEndian.WriteUint32(mids, protocol.MaxIncomingStreams)
icsl := bytes.NewBuffer([]byte{})

View File

@@ -44,19 +44,19 @@ var _ = Describe("Params Negotiator (for gQUIC)", func() {
})
It("sets the stream-level flow control windows in SHLO", func() {
pn.receiveStreamFlowControlWindow = 0xDEADBEEF
entryMap, err := pn.GetHelloMap()
Expect(err).ToNot(HaveOccurred())
Expect(entryMap).To(HaveKey(TagSFCW))
Expect(entryMap[TagSFCW]).To(Equal([]byte{0xEF, 0xBE, 0xAD, 0xDE}))
expected := make([]byte, 4)
binary.LittleEndian.PutUint32(expected, uint32(protocol.ReceiveStreamFlowControlWindow))
Expect(entryMap).To(HaveKeyWithValue(TagSFCW, expected))
})
It("sets the connection-level flow control windows in SHLO", func() {
pn.receiveConnectionFlowControlWindow = 0xDECAFBAD
entryMap, err := pn.GetHelloMap()
Expect(err).ToNot(HaveOccurred())
Expect(entryMap).To(HaveKey(TagCFCW))
Expect(entryMap[TagCFCW]).To(Equal([]byte{0xAD, 0xFB, 0xCA, 0xDE}))
expected := make([]byte, 4)
binary.LittleEndian.PutUint32(expected, uint32(protocol.ReceiveConnectionFlowControlWindow))
Expect(entryMap).To(HaveKeyWithValue(TagCFCW, expected))
})
It("sets the connection-level flow control windows in SHLO", func() {
@@ -128,13 +128,6 @@ var _ = Describe("Params Negotiator (for gQUIC)", func() {
Expect(pnClient.GetSendConnectionFlowControlWindow()).To(Equal(protocol.InitialConnectionFlowControlWindow))
})
It("has the correct default flow control windows for receiving", func() {
Expect(pn.GetReceiveStreamFlowControlWindow()).To(BeEquivalentTo(protocol.ReceiveStreamFlowControlWindow))
Expect(pn.GetReceiveConnectionFlowControlWindow()).To(BeEquivalentTo(protocol.ReceiveConnectionFlowControlWindow))
Expect(pnClient.GetReceiveStreamFlowControlWindow()).To(BeEquivalentTo(protocol.ReceiveStreamFlowControlWindow))
Expect(pnClient.GetReceiveConnectionFlowControlWindow()).To(BeEquivalentTo(protocol.ReceiveConnectionFlowControlWindow))
})
It("sets a new stream-level flow control window for sending", func() {
values := map[Tag][]byte{TagSFCW: {0xDE, 0xAD, 0xBE, 0xEF}}
err := pn.SetFromMap(values)