Skip to content

Commit 8b21c76

Browse files
mailbox: use dynamic resend timeouts for conns
With this commit, the resend timeout will now be set dynamically for the connections of the gbn package.
1 parent 5c2d3f3 commit 8b21c76

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

mailbox/client_conn.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ const (
4646
// to receive ACKS from the peer before resending the queue.
4747
gbnTimeout = 1000 * time.Millisecond
4848

49+
// gbnResendMultiplier is the multiplier that we want the gbn
50+
// connection to use when dynamically setting the resend timeout.
51+
gbnResendMultiplier = 5
52+
53+
// gbnTimeoutUpdateFrequency is the frequency representing the number of
54+
// packages + responses we want, before we update the resend timeout.
55+
gbnTimeoutUpdateFrequency = 200
56+
4957
// gbnN is the queue size, N, that the gbn server will use. The gbn
5058
// server will send up to N packets before requiring an ACK for the
5159
// first packet in the queue.
@@ -167,7 +175,10 @@ func NewClientConn(ctx context.Context, sid [64]byte, serverHost string,
167175

168176
c.gbnOptions = []gbn.Option{
169177
gbn.WithTimeoutOptions(
170-
gbn.WithStaticResendTimeout(gbnTimeout),
178+
gbn.WithResendMultiplier(gbnResendMultiplier),
179+
gbn.WithTimeoutUpdateFrequency(
180+
gbnTimeoutUpdateFrequency,
181+
),
171182
gbn.WithHandshakeTimeout(gbnHandshakeTimeout),
172183
gbn.WithKeepalivePing(
173184
gbnClientPingTimeout, gbnPongTimeout,

mailbox/server_conn.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ func NewServerConn(ctx context.Context, serverHost string,
8181
quit: make(chan struct{}),
8282
gbnOptions: []gbn.Option{
8383
gbn.WithTimeoutOptions(
84-
gbn.WithStaticResendTimeout(gbnTimeout),
84+
gbn.WithResendMultiplier(gbnResendMultiplier),
85+
gbn.WithTimeoutUpdateFrequency(
86+
gbnTimeoutUpdateFrequency,
87+
),
8588
gbn.WithHandshakeTimeout(gbnHandshakeTimeout),
8689
gbn.WithKeepalivePing(
8790
gbnServerPingTimeout, gbnPongTimeout,

0 commit comments

Comments
 (0)