#!/usr/bin/perl -w
-use Test::Command tests => 62;
+use Test::Command tests => 68;
use Test::More;
use Time::HiRes qw(gettimeofday tv_interval);
$cmd->stderr_is_eq("");
}
+# fping -a --icmp-timestamp
+SKIP: {
+if($^O eq 'darwin') {
+ skip 'On macOS, this test is unreliable', 3;
+}
+my $cmd = Test::Command->new(cmd => "fping -a --icmp-timestamp 127.0.0.1");
+$cmd->exit_is_num(0);
+$cmd->stdout_like(qr{127\.0\.0\.1 timestamps: Originate=\d+ Receive=\d+ Transmit=\d+ Localreceive=\d+});
+$cmd->stderr_is_eq("");
+}
+
# fping --print-ttl
{
my $cmd = Test::Command->new(cmd => "fping --print-ttl 127.0.0.1");
}
my $cmd = Test::Command->new(cmd => "fping --icmp-timestamp 127.0.0.1");
$cmd->exit_is_num(0);
-$cmd->stdout_like(qr{127\.0\.0\.1 is alive \(Timestamp Originate=\d+ Receive=\d+ Transmit=\d+ Localreceive=\d+\)});
+$cmd->stdout_like(qr{127\.0\.0\.1 is alive, timestamps: Originate=\d+ Receive=\d+ Transmit=\d+ Localreceive=\d+});
+$cmd->stderr_is_eq("");
+}
+
+# fping --icmp-timestamp --print-tos --print-ttl -e
+SKIP: {
+if($^O eq 'darwin') {
+ skip 'On macOS, this test is unreliable', 3;
+}
+my $cmd = Test::Command->new(cmd => "fping --icmp-timestamp --print-tos --print-ttl -e 127.0.0.1");
+$cmd->exit_is_num(0);
+$cmd->stdout_like(qr{127\.0\.0\.1 is alive, timestamps: Originate=\d+ Receive=\d+ Transmit=\d+ Localreceive=\d+ \(TOS \d+\) \(TTL \d+\) \(\d+(\.\d*)? ms\)});
$cmd->stderr_is_eq("");
}
#!/usr/bin/perl -w
-use Test::Command tests => 84;
+use Test::Command tests => 87;
use Test::More;
# -c n count of pings to send to each target (default 1)
}
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+ 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->stdout_like(qr{127\.0\.0\.1 : \[0\], 20 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\), timestamps: Originate=\d+ Receive=\d+ Transmit=\d+ Localreceive=\d+
+127\.0\.0\.1 : \[1\], 20 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\), timestamps: 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+
+});
+}
+
+# fping --icmp-timestamp --print-tos --print-ttl -c n 127.0.0.1
+SKIP: {
+if($^O eq 'darwin') {
+ skip 'On macOS, this test is unreliable', 3;
+}
+my $cmd = Test::Command->new(cmd => "fping -4 --icmp-timestamp --print-tos --print-ttl -p 100 -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\), timestamps: Originate=\d+ Receive=\d+ Transmit=\d+ Localreceive=\d+ \(TOS \d+\) \(TTL \d+\)
+127\.0\.0\.1 : \[1\], 20 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\), timestamps: Originate=\d+ Receive=\d+ Transmit=\d+ Localreceive=\d+ \(TOS \d+\) \(TTL \d+\)
});
$cmd->stderr_like(qr{127\.0\.0\.1 : xmt/rcv/%loss = 2/2/0%, min/avg/max = \d\.\d+/\d\.\d+/\d\.\d+
=item B<--icmp-timestamp>
Send ICMP timestamp requests (ICMP type 13) instead of ICMP Echo requests.
+Print ICMP timestamps for originate, receive, and transmit, together with
+the local receive time in the same format, in addition to normal output.
Cannot be used together with B<-b> because ICMP timestamp messages have a fixed size.
IPv4 only, requires root privileges or cap_net_raw.
fprintf(stderr, " [<- %s]", buf);
}
- if(print_tos_flag) {
- if(ip_header_tos != -1) {
- printf(" (TOS %d)", ip_header_tos);
- }
- else {
- printf(" (TOS unknown)");
- }
- }
+ if (icmp_request_typ == 13) {
+ printf("%s timestamps: Originate=%u Receive=%u Transmit=%u Localreceive=%u",
+ alive_flag ? "" : ",",
+ ip_header_otime_ms, ip_header_rtime_ms, ip_header_ttime_ms,
+ ms_since_midnight_utc(recv_time));
+ }
- if (print_ttl_flag) {
- if(ip_header_ttl != -1) {
- printf(" (TTL %d)", ip_header_ttl);
- }
- else {
- printf(" (TTL unknown)");
- }
+ if(print_tos_flag) {
+ if(ip_header_tos != -1) {
+ printf(" (TOS %d)", ip_header_tos);
+ }
+ else {
+ printf(" (TOS unknown)");
}
+ }
- if (icmp_request_typ == 13) {
- printf("%simestamp%s Originate=%u Receive=%u Transmit=%u Localreceive=%u%s",
- per_recv_flag ? ", ICMP t" : " (T",
- per_recv_flag ? ":" : "",
- ip_header_otime_ms, ip_header_rtime_ms, ip_header_ttime_ms,
- ms_since_midnight_utc(recv_time),
- per_recv_flag ? "" : ")");
+ if (print_ttl_flag) {
+ if(ip_header_ttl != -1) {
+ printf(" (TTL %d)", ip_header_ttl);
+ }
+ else {
+ printf(" (TTL unknown)");
+ }
}
if (elapsed_flag && !per_recv_flag)