Continue where you left off ×
Build it: ping, and the parcel that dies on purpose (ICMP and traceroute)
The Parcel's Journey · Open board
A parcel passes depot after depot, and each depot only knows the next one. This lesson builds the two tools that make that journey visible: one that asks “are you there, and how far?”, and one that makes every depot on the way give its name.
Before you start. You need How a parcel finds any house on earth , which did traceroute by hand: depots, hops, and the hop limit that stops a parcel circling forever. Inside one postal company (distance-vector, link-state, and ICMP) met ICMP, the notes routers send back, and showed ping and traceroute output without building either. Here you write both, in Python, with no root access.
The idea in 30 seconds
ICMP is the network’s own mail: echo request and reply (types 8 and 0), Time Exceeded (11), Destination Unreachable (3). It rides directly in an IP packet, with no ports.
Ping sends an echo request with a number, waits for a reply with the same number, and reports the time. The reply TTL is the hop limit left on arrival.
Every router subtracts one from the hop limit, and the one that reaches zero discards the packet and sends a Time Exceeded note naming itself, with the start of your packet quoted so you can match it.
Traceroute sends probes with limits 1, 2, 3 and so on and collects whoever answers. A hop that stays silent is normal and the path usually continues beyond it.
The internet checksum adds the 16-bit words, folds the carry and flips the bits, so a packet that includes its checksum adds to zero.
Read the story
Lesson 43 of 44 in Networking
The rest of this lesson is part of a plan.
A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year .
See plans Already a member? Sign in
Or start free : a free account opens lessons 2 and 3 of every track.
In this lesson December 1983: a thousand-line hack, written in an evening The message that rides inside IP Ping: send, wait for the matching number, time it The hop limit, and the router that tells on itself Traceroute: three probes, one hop limit at a time Why one hop can show two routers Why this runs without root Terms it explains: Echo request, Echo reply, Time exceeded, Destination unreachable.
Review Networking
Mark as read Saved in this browser, and to your account when you sign in.