diff --git a/src/formats/internal/models.rs b/src/formats/internal/models.rs index 9dc0355..5c799a7 100644 --- a/src/formats/internal/models.rs +++ b/src/formats/internal/models.rs @@ -125,8 +125,8 @@ impl FromStr for Protocol { match s { "ICMP" => Ok(Protocol::ICMP), "ICMP6" => Ok(Protocol::ICMP), - "TCP" => Ok(Protocol::ICMP), - "UDP" => Ok(Protocol::ICMP), + "TCP" => Ok(Protocol::TCP), + "UDP" => Ok(Protocol::UDP), _ => Err(format!("Unsupported protocol: {s}")), } } diff --git a/src/formats/iris/to_internal.rs b/src/formats/iris/to_internal.rs index 1ec6a16..55b2349 100644 --- a/src/formats/iris/to_internal.rs +++ b/src/formats/iris/to_internal.rs @@ -2,7 +2,9 @@ use crate::formats::internal::{ MplsEntry, Traceroute, TracerouteFlow, TracerouteHop, TracerouteProbe, TracerouteReply, }; use crate::formats::iris::{IrisFlow, IrisMplsEntry, IrisReply, IrisTraceroute}; +use chrono::Duration; use std::collections::HashMap; +use std::ops::Sub; impl From<&IrisTraceroute> for Traceroute { fn from(traceroute: &IrisTraceroute) -> Traceroute { @@ -47,7 +49,7 @@ impl From<&IrisFlow> for TracerouteFlow { impl From<&IrisReply> for TracerouteProbe { fn from(reply: &IrisReply) -> TracerouteProbe { TracerouteProbe { - timestamp: Default::default(), // TODO + timestamp: reply.0.sub(Duration::microseconds(reply.9 as i64 * 100)), size: 0, reply: Some(TracerouteReply { timestamp: reply.0, diff --git a/src/formats/scamper_trace_warts/to_internal.rs b/src/formats/scamper_trace_warts/to_internal.rs index bbd5793..b759b70 100644 --- a/src/formats/scamper_trace_warts/to_internal.rs +++ b/src/formats/scamper_trace_warts/to_internal.rs @@ -23,10 +23,16 @@ impl From<&ScamperTraceWarts> for Traceroute { measurement_name: "".to_string(), measurement_id: trace.cycle_id.to_string(), agent_id: trace.monitor_name.to_string(), - start_time: Default::default(), // TODO - // start_time: Utc - // .timestamp_opt(traceroute.start_time.map_or(|t| t.seconds, 0) as i64, 0) - // .unwrap(), + start_time: Utc + .timestamp_opt( + trace + .traceroute + .start_time + .as_ref() + .map_or(0, |t| t.seconds) as i64, + 0, + ) + .unwrap(), end_time: Default::default(), // TODO protocol: trace.traceroute.trace_type.as_ref().unwrap().into(), src_addr: trace @@ -66,7 +72,9 @@ impl From<&TraceProbe> for TracerouteProbe { .unwrap() .add(Duration::microseconds(tp.rtt_usec.unwrap_or(0) as i64)); TracerouteProbe { - timestamp: Default::default(), + timestamp: Utc + .timestamp_opt(tx.seconds as i64, tx.microseconds * 1000) + .unwrap(), size: 0, reply: Some(TracerouteReply { timestamp: capture_timestamp,