add new timeout consts

ref #320
This commit is contained in:
Lucas Clemente
2016-09-08 13:28:44 +02:00
parent a0fb14381e
commit 634a0eb78c
4 changed files with 18 additions and 14 deletions

View File

@@ -41,7 +41,7 @@ var (
func NewConnectionParamatersManager() *ConnectionParametersManager {
return &ConnectionParametersManager{
params: make(map[Tag][]byte),
idleConnectionStateLifetime: protocol.InitialIdleConnectionStateLifetime,
idleConnectionStateLifetime: protocol.DefaultIdleTimeout,
sendStreamFlowControlWindow: protocol.InitialStreamFlowControlWindow, // can only be changed by the client
sendConnectionFlowControlWindow: protocol.InitialConnectionFlowControlWindow, // can only be changed by the client
receiveStreamFlowControlWindow: protocol.ReceiveStreamFlowControlWindow,
@@ -106,8 +106,7 @@ func (h *ConnectionParametersManager) negotiateMaxStreamsPerConnection(clientVal
}
func (h *ConnectionParametersManager) negotiateIdleConnectionStateLifetime(clientValue time.Duration) time.Duration {
// TODO: what happens if the clients sets 0 seconds?
return utils.MinDuration(clientValue, protocol.MaxIdleConnectionStateLifetime)
return utils.MinDuration(clientValue, protocol.MaxIdleTimeout)
}
// getRawValue gets the byte-slice for a tag

View File

@@ -162,15 +162,15 @@ var _ = Describe("ConnectionsParameterManager", func() {
Context("idle connection state lifetime", func() {
It("has initial idle connection state lifetime", func() {
Expect(cpm.GetIdleConnectionStateLifetime()).To(Equal(protocol.InitialIdleConnectionStateLifetime))
Expect(cpm.GetIdleConnectionStateLifetime()).To(Equal(protocol.DefaultIdleTimeout))
})
It("negotiates correctly when the client wants a longer lifetime", func() {
Expect(cpm.negotiateIdleConnectionStateLifetime(protocol.MaxIdleConnectionStateLifetime + 10*time.Second)).To(Equal(protocol.MaxIdleConnectionStateLifetime))
Expect(cpm.negotiateIdleConnectionStateLifetime(protocol.MaxIdleTimeout + 10*time.Second)).To(Equal(protocol.MaxIdleTimeout))
})
It("negotiates correctly when the client wants a shorter lifetime", func() {
Expect(cpm.negotiateIdleConnectionStateLifetime(protocol.MaxIdleConnectionStateLifetime - 1*time.Second)).To(Equal(protocol.MaxIdleConnectionStateLifetime - 1*time.Second))
Expect(cpm.negotiateIdleConnectionStateLifetime(protocol.MaxIdleTimeout - 1*time.Second)).To(Equal(protocol.MaxIdleTimeout - 1*time.Second))
})
It("sets the negotiated lifetime", func() {
@@ -189,7 +189,7 @@ var _ = Describe("ConnectionsParameterManager", func() {
}
err := cpm.SetFromMap(values)
Expect(err).To(MatchError(ErrMalformedTag))
Expect(cpm.GetIdleConnectionStateLifetime()).To(Equal(protocol.InitialIdleConnectionStateLifetime))
Expect(cpm.GetIdleConnectionStateLifetime()).To(Equal(protocol.DefaultIdleTimeout))
})
It("gets idle connection state lifetime", func() {

View File

@@ -53,9 +53,6 @@ const InitialStreamFlowControlWindow ByteCount = (1 << 14) // 16 kB
// InitialConnectionFlowControlWindow is the initial connection-level flow control window for sending
const InitialConnectionFlowControlWindow ByteCount = (1 << 14) // 16 kB
// InitialIdleConnectionStateLifetime is the initial idle connection state lifetime
const InitialIdleConnectionStateLifetime = 30 * time.Second
// DefaultRetransmissionTime is the RTO time on new connections
const DefaultRetransmissionTime = 500 * time.Millisecond

View File

@@ -39,10 +39,6 @@ const MaxStreamsMinimumIncrement = 10
// note that the number of streams is half this value, since the client can only open streams with open StreamID
const MaxNewStreamIDDelta = 4 * MaxStreamsPerConnection
// MaxIdleConnectionStateLifetime is the maximum value accepted for the idle connection state lifetime
// TODO: set a reasonable value here
const MaxIdleConnectionStateLifetime = 60 * time.Second
// MaxSessionUnprocessedPackets is the max number of packets stored in each session that are not yet processed.
const MaxSessionUnprocessedPackets = DefaultMaxCongestionWindow
@@ -77,3 +73,15 @@ const CryptoParameterMaxLength = 2000
// EphermalKeyLifetime is the lifetime of the ephermal key during the handshake, see handshake.getEphermalKEX.
const EphermalKeyLifetime = time.Minute
// InitialIdleTimeout is the timeout before the handshake succeeds.
const InitialIdleTimeout = 5 * time.Second
// DefaultIdleTimeout is the default idle timeout.
const DefaultIdleTimeout = 30 * time.Second
// MaxIdleTimeout is the maximum idle timeout that can be negotiated.
const MaxIdleTimeout = 1 * time.Minute
// MaxTimeForCryptoHandshake is the default timeout for a connection until the crypto handshake succeeds.
const MaxTimeForCryptoHandshake = 10 * time.Second