From 150bc1ec2999d57247956b5a2cb18c3013d6bda8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Tigerstr=C3=B6m?= Date: Tue, 7 Nov 2023 14:50:11 +0100 Subject: [PATCH] gbn: increase NACK wait time by 2X --- gbn/gbn_conn.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gbn/gbn_conn.go b/gbn/gbn_conn.go index 4a85046..a6377df 100644 --- a/gbn/gbn_conn.go +++ b/gbn/gbn_conn.go @@ -553,9 +553,19 @@ func (g *GoBackNConn) receivePacketsForever() error { // nolint:gocyclo // If we recently sent a NACK for the same // sequence number then back off. - if lastNackSeq == g.recvSeq && - time.Since(lastNackTime) < - g.cfg.resendTimeout { + // We wait 2 times the resendTimeout before + // sending a new nack, as this case is likely + // hit if the sender is currently resending + // the queue, and therefore the threads that + // are resending the queue is likely busy with + // the resend, and therefore won't react to the + // NACK we send here in time. + sinceSent := time.Since(lastNackTime) + recentlySent := sinceSent < + g.cfg.resendTimeout*2 //nolint:gomnd + + if lastNackSeq == g.recvSeq && recentlySent { + g.log.Tracef("Recently sent NACK") continue }