A Packet's Journey (Pt. 1: NAT)

Sid Shanker - 06/07/2018


Impress upon you that:

  • Networks are cool and worth learning about
  • Networks are very inelegant (but still worth learning about)!

Information gets from your computer to the internet...somehow

Sid's Macbook

Google Server

RC Router

The internet

Google Router

Lots of different protocols in play here!

  • Uses Ethernet to get data to the router
  • Uses IP to move packets across the internet
  • Uses TCP to implement that actual web application  

IP Addresses

  • You've seen 'em:
  • Used to designated different devices on a computer network
  • Two protocols, ipv4 and ipv6, we're running out of ipv4 addresses!
  • There are both private IPs and public IPs

An IP Header

Source and destination address are both IP Addresses

TCP Very Quickly 

  • Higher Level network protocol that ensures reliability of packet delivery
  • TCP data is inside the IP packets
  • IP can be used to transmit other protocols too

A typical TCP packet

Private Network

Public Internet

Google Router

RC Router

Private Network

has public ip









My question: if all Google knows is the public IP address of my router, how do packets make it back to me?

Introducing: the NAT

Answer: A Disappointing Hack


Original IP Packet:

private ip:

original port: 65419


Modified IP Packet:

source ip:

new "port": 72192


NAT Table:

out-ip:out-port             | local-ip:local-port |


Exercise for the reader: How could this work with a transport-protocol that doesn't use ports?

Moral of the story: sometimes you have to make compromises for things to work in the real world.

A Packet's Journey Pt. 1

By Sid Shanker

A Packet's Journey Pt. 1

  • 624
Loading comments...

More from Sid Shanker