Skip to content

Commit

Permalink
tcp: add retransmission exponential backoff test.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomDev5 authored and Dirbaio committed Dec 27, 2024
1 parent 05f580d commit f8aa18c
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/socket/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6411,6 +6411,38 @@ mod test {
recv_nothing!(s);
}

#[test]
fn test_retransmit_exponential_backoff() {
let mut s = socket_established();
s.send_slice(b"abcdef").unwrap();
recv!(s, time 0, Ok(TcpRepr {
seq_number: LOCAL_SEQ + 1,
ack_number: Some(REMOTE_SEQ + 1),
payload: &b"abcdef"[..],
..RECV_TEMPL
}));

let expected_retransmission_instant = s.rtte.retransmission_timeout().total_millis() as i64;
recv_nothing!(s, time expected_retransmission_instant - 1);
recv!(s, time expected_retransmission_instant, Ok(TcpRepr {
seq_number: LOCAL_SEQ + 1,
ack_number: Some(REMOTE_SEQ + 1),
payload: &b"abcdef"[..],
..RECV_TEMPL
}));

// "current time" is expected_retransmission_instant, and we want to wait 2 * retransmission timeout
let expected_retransmission_instant = 3 * expected_retransmission_instant;

recv_nothing!(s, time expected_retransmission_instant - 1);
recv!(s, time expected_retransmission_instant, Ok(TcpRepr {
seq_number: LOCAL_SEQ + 1,
ack_number: Some(REMOTE_SEQ + 1),
payload: &b"abcdef"[..],
..RECV_TEMPL
}));
}

// =========================================================================================//
// Tests for window management.
// =========================================================================================//
Expand Down

0 comments on commit f8aa18c

Please sign in to comment.