ratecontroller: use durations instead of manually handling time

This commit is contained in:
Nils Andreas Svee committed 2022-11-10 13:54:26 +01:00
1 parent bb9d1ed4af
commit 5c0a6c304f
7 files changed
+84 -67

No files matched your search

+2 -2
View File
@@ -6,6 +6,7 @@ use etherparse::TransportSlice::{Icmpv4, Icmpv6};
use etherparse::{Icmpv4Header, Icmpv4Type, SlicedPacket};
use rustix::thread::ClockId;
use std::net::IpAddr;
use std::time::Instant;
pub struct PingerICMPTimestampListener {}
@@ -47,8 +48,7 @@ impl PingListener for PingerICMPTimestampListener {
originate_timestamp: originate_timestamp as i64,
receive_timestamp: receive_timestamp as i64,
transmit_timestamp: transmit_timestamp as i64,
last_receive_time_s: time_now.get_seconds() as f64
+ (time_now.get_nanoseconds() as f64 / 1e9),
last_receive_time_s: Instant::now(),
})
}
type_ => Err(PingError::InvalidType(format!("{:?}", type_))),