add max incoming dynamic streams to connection parameter mgr

ref #281
This commit is contained in:
Lucas Clemente
2016-08-18 16:13:00 +02:00
parent 37469f5c34
commit c3832965d0
4 changed files with 19 additions and 7 deletions

View File

@@ -130,12 +130,15 @@ func (h *ConnectionParametersManager) GetSHLOMap() map[Tag][]byte {
utils.WriteUint32(cfcw, uint32(h.GetReceiveConnectionFlowControlWindow()))
mspc := bytes.NewBuffer([]byte{})
utils.WriteUint32(mspc, h.GetMaxStreamsPerConnection())
mids := bytes.NewBuffer([]byte{})
utils.WriteUint32(mids, protocol.MaxIncomingDynamicStreams)
icsl := bytes.NewBuffer([]byte{})
utils.WriteUint32(icsl, uint32(h.GetIdleConnectionStateLifetime()/time.Second))
return map[Tag][]byte{
TagICSL: icsl.Bytes(),
TagMSPC: mspc.Bytes(),
TagMIDS: mids.Bytes(),
TagCFCW: cfcw.Bytes(),
TagSFCW: sfcw.Bytes(),
}
@@ -145,7 +148,6 @@ func (h *ConnectionParametersManager) GetSHLOMap() map[Tag][]byte {
func (h *ConnectionParametersManager) GetSendStreamFlowControlWindow() protocol.ByteCount {
h.mutex.RLock()
defer h.mutex.RUnlock()
return h.sendStreamFlowControlWindow
}
@@ -153,7 +155,6 @@ func (h *ConnectionParametersManager) GetSendStreamFlowControlWindow() protocol.
func (h *ConnectionParametersManager) GetSendConnectionFlowControlWindow() protocol.ByteCount {
h.mutex.RLock()
defer h.mutex.RUnlock()
return h.sendConnectionFlowControlWindow
}
@@ -161,7 +162,6 @@ func (h *ConnectionParametersManager) GetSendConnectionFlowControlWindow() proto
func (h *ConnectionParametersManager) GetReceiveStreamFlowControlWindow() protocol.ByteCount {
h.mutex.RLock()
defer h.mutex.RUnlock()
return h.receiveStreamFlowControlWindow
}
@@ -169,7 +169,6 @@ func (h *ConnectionParametersManager) GetReceiveStreamFlowControlWindow() protoc
func (h *ConnectionParametersManager) GetReceiveConnectionFlowControlWindow() protocol.ByteCount {
h.mutex.RLock()
defer h.mutex.RUnlock()
return h.receiveConnectionFlowControlWindow
}
@@ -177,7 +176,6 @@ func (h *ConnectionParametersManager) GetReceiveConnectionFlowControlWindow() pr
func (h *ConnectionParametersManager) GetMaxStreamsPerConnection() uint32 {
h.mutex.RLock()
defer h.mutex.RUnlock()
return h.maxStreamsPerConnection
}
@@ -185,7 +183,6 @@ func (h *ConnectionParametersManager) GetMaxStreamsPerConnection() uint32 {
func (h *ConnectionParametersManager) GetIdleConnectionStateLifetime() time.Duration {
h.mutex.RLock()
defer h.mutex.RUnlock()
return h.idleConnectionStateLifetime
}

View File

@@ -37,6 +37,7 @@ var _ = Describe("ConnectionsParameterManager", func() {
entryMap := cpm.GetSHLOMap()
Expect(entryMap).To(HaveKey(TagICSL))
Expect(entryMap).To(HaveKey(TagMSPC))
Expect(entryMap).To(HaveKey(TagMIDS))
})
It("sets the stream-level flow control windows in SHLO", func() {
@@ -66,6 +67,12 @@ var _ = Describe("ConnectionsParameterManager", func() {
Expect(entryMap).To(HaveKey(TagMSPC))
Expect(entryMap[TagMSPC]).To(Equal([]byte{0xEF, 0xBE, 0xAD, 0xDE}))
})
It("sets the maximum incoming dynamic streams per connection in SHLO", func() {
entryMap := cpm.GetSHLOMap()
Expect(entryMap).To(HaveKey(TagMIDS))
Expect(entryMap[TagMIDS]).To(Equal([]byte{100, 0, 0, 0}))
})
})
Context("Truncated connection IDs", func() {

View File

@@ -23,6 +23,8 @@ const (
TagCCRT Tag = 'C' + 'C'<<8 + 'R'<<16 + 'T'<<24
// TagMSPC is max streams per connection
TagMSPC Tag = 'M' + 'S'<<8 + 'P'<<16 + 'C'<<24
// TagMIDS is max incoming dyanamic streams
TagMIDS Tag = 'M' + 'I'<<8 + 'D'<<16 + 'S'<<24
// TagUAID is the user agent ID
TagUAID Tag = 'U' + 'A'<<8 + 'I'<<16 + 'D'<<24
// TagTCID is truncation of the connection ID

View File

@@ -31,9 +31,15 @@ const ReceiveConnectionFlowControlWindow ByteCount = (1 << 20) * 1.5 // 1.5 MB
// MaxStreamsPerConnection is the maximum value accepted for the number of streams per connection
const MaxStreamsPerConnection uint32 = 100
// MaxStreamsMultiplier is the slack the client is allowed for the maximum number of streams per connection, needed e.g. when packets are out of order or dropped.
// MaxIncomingDynamicStreams is the maximum value accepted for the incoming number of dynamic streams per connection
const MaxIncomingDynamicStreams uint32 = 100
// MaxStreamsMultiplier is the slack the client is allowed for the maximum number of streams per connection, needed e.g. when packets are out of order or dropped. The minimum of this procentual increase and the absolute increment specified by MaxStreamsMinimumIncrement is used.
const MaxStreamsMultiplier = 1.1
// MaxStreamsMinimumIncrement is the slack the client is allowed for the maximum number of streams per connection, needed e.g. when packets are out of order or dropped. The minimum of this absolute increment and the procentual increase specified by MaxStreamsMultiplier is used.
const MaxStreamsMinimumIncrement = 10
// MaxIdleConnectionStateLifetime is the maximum value accepted for the idle connection state lifetime
// TODO: set a reasonable value here
const MaxIdleConnectionStateLifetime = 60 * time.Second