mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 14:36:16 +01:00
Calculate TCP flight time in current thread
This commit is contained in:
@@ -15,22 +15,13 @@ pub(crate) async fn log_packet(file: &Arc<tokio::sync::Mutex<tokio::fs::File>>,
|
|||||||
debug!("Logging {} byte packet", packet.len());
|
debug!("Logging {} byte packet", packet.len());
|
||||||
let packet = packet.to_vec();
|
let packet = packet.to_vec();
|
||||||
let file = file.to_owned();
|
let file = file.to_owned();
|
||||||
|
let now = SystemTime::now();
|
||||||
tokio::task::spawn(async move {
|
tokio::task::spawn(async move {
|
||||||
let mut file = file.lock().await;
|
let mut file = file.lock().await;
|
||||||
file.write_all(
|
file.write_all(&(now.duration_since(UNIX_EPOCH).unwrap().as_secs() as u32).to_le_bytes())
|
||||||
&(SystemTime::now()
|
.await
|
||||||
.duration_since(UNIX_EPOCH)
|
.unwrap();
|
||||||
.unwrap()
|
let micros = now.duration_since(UNIX_EPOCH).unwrap().as_micros() % 1_000_000_000;
|
||||||
.as_secs() as u32)
|
|
||||||
.to_le_bytes(),
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let micros = SystemTime::now()
|
|
||||||
.duration_since(UNIX_EPOCH)
|
|
||||||
.unwrap()
|
|
||||||
.as_micros()
|
|
||||||
% 1_000_000_000;
|
|
||||||
file.write_all(&(micros as u32).to_le_bytes())
|
file.write_all(&(micros as u32).to_le_bytes())
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|||||||
Reference in New Issue
Block a user