Sender :
x=$(date +%s%N) && ping google.com -p 4142434445464748494A4B4C4D4E4F50 -s 24 -c 1000 -i 0.000 > /dev/null && echo $((($(date +%s%N)-$x)/1000000))ms
Receiver :
import socket
import struct
import sys
def receive_icmp_packets():
sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.getprotobyname(“icmp”))
while True:
packet, addr = sock.recvfrom(1024)
icmp_header = packet[20:28]
payload = packet[28:]
type, code, checksum, packet_id, sequence = struct.unpack(“bbHHh”, icmp_header)
if type == 8: # ICMP Echo Request
sys.stdout.write(payload[-8:] + payload[-16:-8])
if __name__ == “__main__”:
sys.stderr.write(“Starting ICMP listener…\n”)
receive_icmp_packets()