Skip to content

Commit 5311a29

Browse files
tomDev5Dirbaio
authored andcommitted
tcp: add retransmission exponential backoff test.
1 parent 1f0e936 commit 5311a29

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/socket/tcp.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6413,6 +6413,38 @@ mod test {
64136413
recv_nothing!(s);
64146414
}
64156415

6416+
#[test]
6417+
fn test_retransmit_exponential_backoff() {
6418+
let mut s = socket_established();
6419+
s.send_slice(b"abcdef").unwrap();
6420+
recv!(s, time 0, Ok(TcpRepr {
6421+
seq_number: LOCAL_SEQ + 1,
6422+
ack_number: Some(REMOTE_SEQ + 1),
6423+
payload: &b"abcdef"[..],
6424+
..RECV_TEMPL
6425+
}));
6426+
6427+
let expected_retransmission_instant = s.rtte.retransmission_timeout().total_millis() as i64;
6428+
recv_nothing!(s, time expected_retransmission_instant - 1);
6429+
recv!(s, time expected_retransmission_instant, Ok(TcpRepr {
6430+
seq_number: LOCAL_SEQ + 1,
6431+
ack_number: Some(REMOTE_SEQ + 1),
6432+
payload: &b"abcdef"[..],
6433+
..RECV_TEMPL
6434+
}));
6435+
6436+
// "current time" is expected_retransmission_instant, and we want to wait 2 * retransmission timeout
6437+
let expected_retransmission_instant = 3 * expected_retransmission_instant;
6438+
6439+
recv_nothing!(s, time expected_retransmission_instant - 1);
6440+
recv!(s, time expected_retransmission_instant, Ok(TcpRepr {
6441+
seq_number: LOCAL_SEQ + 1,
6442+
ack_number: Some(REMOTE_SEQ + 1),
6443+
payload: &b"abcdef"[..],
6444+
..RECV_TEMPL
6445+
}));
6446+
}
6447+
64166448
// =========================================================================================//
64176449
// Tests for window management.
64186450
// =========================================================================================//

0 commit comments

Comments
 (0)