Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve the issue in how we create timestamp_difference_microseconds #86

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions src/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,16 +748,11 @@ impl<const N: usize, P: ConnectionPeer> Connection<N, P> {
let now_micros = crate::time::now_micros();
self.peer_recv_window = packet.window_size();

// Cap the diff. If the clock on the remote machine is ahead of the clock on the local
// machine, then we could end up with large (inaccurate) diffs. Use the max idle timeout as
// an upper bound on the possible diff. If the diff exceeds the bound, then assume the
// remote clock is behind the local clock and use a diff of 1s.
let peer_ts_diff = crate::time::duration_between(packet.ts_micros(), now_micros);
if peer_ts_diff > self.config.max_idle_timeout {
self.peer_ts_diff = Duration::from_secs(1);
self.peer_ts_diff = if packet.ts_micros() == 0 {
Duration::from_micros(0)
} else {
self.peer_ts_diff = peer_ts_diff;
}
Duration::from_micros(now_micros.wrapping_sub(packet.ts_micros()).into())
};

match packet.packet_type() {
PacketType::Syn => self.on_syn(packet.seq_num()),
Expand Down