Skip to content

Commit

Permalink
formats/iris,formats/scamper_trace_warts: minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmouchet committed Mar 5, 2023
1 parent 64d9a53 commit 03f3b73
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/formats/internal/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}")),
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/formats/iris/to_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
18 changes: 13 additions & 5 deletions src/formats/scamper_trace_warts/to_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 03f3b73

Please sign in to comment.