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

Sid Shanker - 06/07/2018

Goals

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: 172.16.254.1
  • 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

computer

computer

computer

computer

computer

computer

computer

computer

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

Router

Original IP Packet:

private ip: 10.0.0.1

original port: 65419

 

Modified IP Packet:

source ip: 207.251.103.46

new "port": 72192

 

NAT Table:

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

207.251.103.46:72192 |10.0.0.1:65419

                                   ....

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

  • 28
Loading comments...

More from Sid Shanker