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

pcap timestamp bugfix #513

Merged
merged 1 commit into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/phy/pcap_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub trait PcapSink {
assert!(length <= 65535);

self.write_u32(timestamp.secs() as u32); // timestamp seconds
self.write_u32(timestamp.millis() as u32); // timestamp microseconds
self.write_u32(timestamp.micros() as u32); // timestamp microseconds
self.write_u32(length as u32); // captured length
self.write_u32(length as u32); // original length
}
Expand Down
6 changes: 6 additions & 0 deletions src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ impl Instant {
self.millis % 1000
}

/// The fractional number of microseconds that have passed
/// since the beginning of time.
pub const fn micros(&self) -> i64 {
self.millis % 1000 * 1000
}

/// The number of whole seconds that have passed since the
/// beginning of time.
pub const fn secs(&self) -> i64 {
Expand Down