Preemptive Discovery over Raw Sockets
Iâm in a hotel room in Gangnam, Seoul, with a 4G wireless hotspot, a Linux laptop, and a couple of Android phones. The phones and laptop are talking to the hotspot. The ifconfig command says my IP address is 192.168.1.2. Let me try some ping commands. Dynamic Host Control Protocol (DHCP) servers tend to dish out addresses in sequence, so my phones are probably close by, numerically speaking:
$ ping 192.168.1.1 PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data. 64 bytes from 192.168.1.1: icmp_req=1 ttl=64 time=376 ms 64 bytes from 192.168.1.1: icmp_req=2 ttl=64 time=358 ms 64 bytes from 192.168.1.1: icmp_req=4 ttl=64 time=167 ms ^C --- 192.168.1.1 ping statistics --- 3 packets transmitted, 2 received, 33% packet loss, time 2001ms rtt min/avg/max/mdev = 358.077/367.522/376.967/9.445 ms
Found one! 150â300 msec round-trip latency... thatâs a surprisingly high figure, something to keep in mind for later. Now I ping myself, just to try to double-check things:
$ ping 192.168.1.2 PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data. 64 bytes from 192.168.1.2: icmp_req=1 ttl=64 time=0.054 ms 64 bytes from 192.168.1.2: icmp_req=2 ttl=64 time=0.055 ms 64 bytes from 192.168.1.2: icmp_req=3 ttl=64 time=0.061 ms ^C --- 192.168.1.2 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 1998ms rtt min/avg/max/mdev = 0.054/0.056/0.061/0.009 ms
The response time is a bit faster now, which is what weâd expect. Letâs try the next couple ...
Get ZeroMQ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.