Skip to content

Commit

Permalink
Log correct delay when performing TCP retransmit.
Browse files Browse the repository at this point in the history
Before, the delay was erroneously multiplied by 2 and also did not
take processing delay into account.
  • Loading branch information
whitequark committed Jul 23, 2017
1 parent d5610e7 commit c0629f7
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/socket/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,17 +201,18 @@ impl Retransmit {
}
}

fn commit(&mut self, timestamp: u64) -> bool {
fn commit(&mut self, timestamp: u64) -> Option<u64> {
if self.delay == 0 {
self.delay = 100; // ms
self.resend_at = timestamp + self.delay;
false
None
} else if timestamp >= self.resend_at {
let actual_delay = (timestamp - self.resend_at) + self.delay;
self.resend_at = timestamp + self.delay;
self.delay *= 2;
true
Some(actual_delay)
} else {
false
None
}
}
}
Expand Down Expand Up @@ -1109,10 +1110,10 @@ impl<'a> TcpSocket<'a> {
}

if should_send {
if self.retransmit.commit(timestamp) {
net_trace!("[{}]{}:{}: retransmit after {}ms",
if let Some(actual_delay) = self.retransmit.commit(timestamp) {
net_trace!("[{}]{}:{}: retransmitting at t+{}ms ",
self.debug_id, self.local_endpoint, self.remote_endpoint,
self.retransmit.delay);
actual_delay);
}

if self.state != State::SynSent {
Expand Down

0 comments on commit c0629f7

Please sign in to comment.