<aside> 🤔 Have you ever asked yourself what is the journey a packet follows in order to reach its destination?

</aside>

In this article, we’ll briefly cover how packets are transmitted between two clients (locally and remotely), and how the traceroute command allow us to trace a packet’s journey to its destination.

Packet delivery 101

The way a packet reaches its destination varies depending on the location of the sender and receiver.

Delivery of packets between a local network

Photo by Lucidchart

Photo by Lucidchart

In the case that both sender and receiver reside in the same local network, the sender has to find out the Media Access Control (MAC) address of the destination machine.

The MAC addresses are used to uniquely identify each node in a network. They’re commonly used in the lower layers of the Ethernet protocol, where all IP addresses are translated to MAC addresses.

In order for the sender to find out the destination machine’s MAC address, the Address Resolution Protocol (ARP) is used.

When the sender machine’s makes an ARP request, all nodes in the network will examine this request, but only the machine which matches the defined IP address in the ARP request will reply with its MAC address.

Once the sender receives the MAC address of the destination machine, it formats the package and sends it with the received MAC address.

Delivery of packets between remote clients

Photo by Tech Terms

Photo by Tech Terms

Now that we know how packets are transmitted between peers of a local network, what happens when the clients are in different networks?

As in the previous case, the first requirement is to know the destination’s machine IP address.

Once we know the IP address of the destination machine, the sender checks if the machine associated to that IP address is within reach in its local network.

If it’s not, then the sender will forward that packet to its network gateway (e.g., a router).