}
my $cmd = Test::Command->new(cmd => "fping -4 --icmp-timestamp -c 2 127.0.0.1");
$cmd->exit_is_num(0);
-$cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 20 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\), ICMP timestamp: Originate=\d+ Receive=\d+ Transmit=\d+
-127\.0\.0\.1 : \[1\], 20 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\), ICMP timestamp: Originate=\d+ Receive=\d+ Transmit=\d+
+$cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 20 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\), ICMP timestamp: Originate=\d+ Receive=\d+ Transmit=\d+ Localreceive=\d+
+127\.0\.0\.1 : \[1\], 20 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\), ICMP timestamp: Originate=\d+ Receive=\d+ Transmit=\d+ Localreceive=\d+
});
$cmd->stderr_like(qr{127\.0\.0\.1 : xmt/rcv/%loss = 2/2/0%, min/avg/max = \d\.\d+/\d\.\d+/\d\.\d+
void stats_add(HOST_ENTRY *h, int index, int success, int64_t latency);
void update_current_time();
void print_timestamp_format(int64_t current_time_ns, int timestamp_format);
+static uint32_t ms_since_midnight_utc(int64_t time_val);
/************************************************************
}
if (icmp_request_typ == 13) {
- printf(" (Timestamp Originate=%u Receive=%u Transmit=%u)", ip_header_otime_ms, ip_header_rtime_ms, ip_header_ttime_ms);
+ printf(" (Timestamp Originate=%u Receive=%u Transmit=%u Localreceive=%u)",
+ ip_header_otime_ms, ip_header_rtime_ms, ip_header_ttime_ms,
+ ms_since_midnight_utc(recv_time));
}
if (elapsed_flag)
}
if (icmp_request_typ == 13) {
- printf(", ICMP timestamp: Originate=%u Receive=%u Transmit=%u", ip_header_otime_ms, ip_header_rtime_ms, ip_header_ttime_ms);
+ printf(", ICMP timestamp: Originate=%u Receive=%u Transmit=%u Localreceive=%u",
+ ip_header_otime_ms, ip_header_rtime_ms, ip_header_ttime_ms,
+ ms_since_midnight_utc(recv_time));
}
printf("\n");
}
}
+/************************************************************
+
+ Function: ms_since_midnight_utc
+
+*************************************************************
+
+ Input: int64_t: current UTC time in ns
+
+ Output: uint32_t: current time in ms since midnight UTC
+
+ Description:
+
+ Return ICMP Timestamp value corresponding to the given time value.
+ The given time value must be in UTC.
+
+*************************************************************/
+static uint32_t ms_since_midnight_utc(int64_t time_val)
+{
+ return (uint32_t)((time_val / 1000000) % (24 * 60 * 60 * 1000));
+}
+
/************************************************************
Function: usage