Created
November 27, 2024 09:32
-
-
Save dutchLuck/29317aa327ae6afdb002295e28665cce to your computer and use it in GitHub Desktop.
Shell script to check on the short-comings of the MacOS ping utility and its associated man-page that have been reported to Apple through Feedback Assistant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# | |
# This shell script allows a quick check on whether Apple have done | |
# anything about the feedback on the short-comings of MacOS ping. | |
# | |
# Needs to have a target that responds to ICMP requests (i.e. ping request). | |
# In my case my local router (192.168.1.1) responds to ICMP requests apart from | |
# MASK_REQ. Edit "LOCAL_IP_ROUTER" value to suit a different network setup. | |
# | |
LOCAL_IP4_ROUTER=192.168.1.1 | |
# | |
# | |
# Use bold to high-light parameters | |
function printItem { | |
echo "(\033[1;30m$1\033[0m) --------- \033[1;30m$2\033[0m ---------" | |
} | |
# | |
# | |
function printLineItem { | |
echo "" | |
printItem $1 "$2" | |
} | |
# | |
# Use Green between == == separators to high-light title | |
function printSeparator { | |
echo "" | |
echo "==============\033[1;32m $1 \033[0m==============" | |
} | |
# | |
printSeparator "Status of Record Route option (Closed Apple F/B FB13620964)" | |
printItem 1a "man page segment does say deprecated" | |
man ping | grep -A2 " route\." | |
printLineItem 1b "ping with record route (-R) option" | |
ping -c 1 -R $LOCAL_IP4_ROUTER | grep -A2 "RR:" | |
# | |
printSeparator "Minimum size payload that shows Round-Trip Time (Apple F/B FB13453152)" | |
printItem 2a "man page segment says eight bytes is limit" | |
man ping | grep -A3 "at least eight byte" | |
printLineItem 2b "ping with 8 byte data payload (-s 8) shows no RTT" | |
ping -c 1 -s 8 $LOCAL_IP4_ROUTER | |
printLineItem 2c "ping with 16 byte data payload (-s 16) option" | |
ping -c 1 -s 16 $LOCAL_IP4_ROUTER | |
# | |
printSeparator "Round-Trip-Time stddev calculated for single pings (Apple F/B FB13453235)" | |
printItem 3a "man page segment just assumes showing stddev is meaningful" | |
man ping | grep -A4 "When the specified number" | |
printLineItem 3b "single ping (-c 1 option) shows stddev" | |
ping -c 1 -s 16 $LOCAL_IP4_ROUTER | |
# | |
printSeparator "-M options fail if used without companion -s 0 option (Apple F/B FB13523626)" | |
printItem 4a "man page segment says nothing about -s 0 requirement" | |
man ping | grep -B1 -A4 ICMP_TSTAMP | |
printLineItem 4b "ping time (-M time) fails without -s 0 option" | |
ping -c 1 -M time $LOCAL_IP4_ROUTER | |
printLineItem 4c "ping time (-M time) succeeds with -s 0 option" | |
ping -c 1 -M time -s 0 $LOCAL_IP4_ROUTER | |
# | |
printSeparator "mSec since midnight time output truncated to seconds (Apple F/B FB13523685)" | |
printItem 5a "man page segment says nothing about truncated time output" | |
man ping | grep -A1 origination | |
printLineItem 5b "ping with time (-M time) option output only shows hh:mm:ss no mSecs" | |
ping -c 1 -M time -s 0 $LOCAL_IP4_ROUTER | sed -E -n 's/^([0-9]+) bytes from ([0-9.]+): icmp_seq=([0-9]+) ttl=([0-9]+) tso=([0-9\:\.]+) tsr=([0-9\:\.]+) tst=([0-9\:\.]+)$/\5 \6 \7/p' | |
# | |
echo "" | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output of script (MacOS Sequoia) is; -
% ./checkReportedMacOS_ping_short-comings.sh
============== Status of Record Route option (Closed Apple F/B FB13620964) ==============
(1a) --------- man page segment does say deprecated ---------
-R Record route. Includes the RECORD_ROUTE option in the
ECHO_REQUEST packet and displays the route buffer on returned
packets. This option is deprecated and is now a no-op.
(1b) --------- ping with record route (-R) option ---------
============== Minimum size payload that shows Round-Trip Time (Apple F/B FB13453152) ==============
(2a) --------- man page segment says eight bytes is limit ---------
If the data space is at least eight bytes large, ping uses the first
eight bytes of this space to include a timestamp which it uses in the
computation of round trip times. If less than eight bytes of pad are
specified, no round trip times are given.
(2b) --------- ping with 8 byte data payload (-s 8) shows no RTT ---------
PING 192.168.1.1 (192.168.1.1): 8 data bytes
16 bytes from 192.168.1.1: icmp_seq=0 ttl=64
--- 192.168.1.1 ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
(2c) --------- ping with 16 byte data payload (-s 16) option ---------
PING 192.168.1.1 (192.168.1.1): 16 data bytes
24 bytes from 192.168.1.1: icmp_seq=0 ttl=64 time=2.414 ms
--- 192.168.1.1 ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 2.414/2.414/2.414/0.000 ms
============== Round-Trip-Time stddev calculated for single pings (Apple F/B FB13453235) ==============
(3a) --------- man page segment just assumes showing stddev is meaningful ---------
calculating the round-trip time statistics. When the specified number of
packets have been sent (and received) or if the program is terminated
with a SIGINT, a brief summary is displayed, showing the number of
packets sent and received, and the minimum, mean, maximum, and standard
deviation of the round-trip times.
(3b) --------- single ping (-c 1 option) shows stddev ---------
PING 192.168.1.1 (192.168.1.1): 16 data bytes
24 bytes from 192.168.1.1: icmp_seq=0 ttl=64 time=2.938 ms
--- 192.168.1.1 ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 2.938/2.938/2.938/nan ms
============== -M options fail if used without companion -s 0 option (Apple F/B FB13523626) ==============
(4a) --------- man page segment says nothing about -s 0 requirement ---------
-M mask | time
Use ICMP_MASKREQ or ICMP_TSTAMP instead of ICMP_ECHO. For mask,
print the netmask of the remote machine. Set the
net.inet.icmp.maskrepl MIB variable to enable ICMP_MASKREPLY.
For time, print the origination, reception and transmission
timestamps.
(4b) --------- ping time (-M time) fails without -s 0 option ---------
ICMP_TSTAMP
PING 192.168.1.1 (192.168.1.1): 56 data bytes
ping: sendto: Invalid argument
--- 192.168.1.1 ping statistics ---
1 packets transmitted, 0 packets received, 100.0% packet loss
(4c) --------- ping time (-M time) succeeds with -s 0 option ---------
ICMP_TSTAMP
PING 192.168.1.1 (192.168.1.1): 0 data bytes
20 bytes from 192.168.1.1: icmp_seq=0 ttl=64 tso=09:34:15 tsr=09:34:14 tst=09:34:14
--- 192.168.1.1 ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
============== mSec since midnight time output truncated to seconds (Apple F/B FB13523685) ==============
(5a) --------- man page segment says nothing about truncated time output ---------
For time, print the origination, reception and transmission
timestamps.
(5b) --------- ping with time (-M time) option output only shows hh:mm:ss no mSecs ---------
09:34:15 09:34:15 09:34:15
%