questions about the IP protocol

Hello! Here are some questions & answers. The goal isn't to get all the questions "right". Instead, the goal is to learn something! If you find a topic you're interested in learning more about, I'd encourage you to look it up and learn more.

how many bits is an IPv4 address?

32 bits!

For example,

  127         0    
01111111 00000000 
    0         1
00000000 00000001

Which IP addresses does represent? to! means "all the IP addresses that have the same 24 bits as". There are 2^(32 - 24) IP addresses like that, or 256 -- everything from to

this is called "CIDR notation"

does every TCP packet have an IP address?

yes! it has two!

Here's how a TCP packet is structured:

|  Ethernet header  |
|  IP header        |
|  TCP header       |
|   packet contents |       

the IP header contains a source and destination IP address, a TTL, a length field, and a few more things.

Does every UDP packet have an IP address?


It's structured the same way as a TCP packet, except with a UDP header instead of a TCP header.

does every IP packet have a port?


the IP header contains an IP address, but no port. For example, ICMP packets (the kind of packet ping sends) have an IP address but no port. TCP and UDP packets have a port.

is a computer's public IP address allowed to be


These 3 IP ranges are reserved for private networks:

  • –
  • –
  • – is also reserved for connections inside the same computer.

if your computer's IP address on the local network is and it sends a packet to, is the source IP address on the packet when it gets to

nope! is a local IP address, so Google would have no way of knowing how to contact your computer. Instead, your router rewrites the packet to have your computer's public IP on it instead. This is called "network address translation" or "NAT".

is it possible to send a 2 megabyte IPv4 packet?


the length field on an IPv4 packet is 16 bits, so the maximum length is 65535.

in practice network packets often have to be even smaller than that -- a common limit is 1500 bytes (google "MTU" to learn more)

which part of a packet do your ISP's routers use to get your packet to the right server?

the destination IP address!

They don't generally use any other information from the packet.

how does Netflix know what country you're in?

your source IP address!

A lot of services use your source IP address to decide what country you're in. This is why a lot of people use VPNs -- they proxy their browsing through the VPN so that the source IP address on their packets is in a different country.

what does it mean if the TTL field in the IP header is set to 64?

it's allowed to make 63 hops!

it means after it's made about 63 hops (to 63 servers or routers), it won't be sent further!

The TTL ("time to live") IP field exists so that packets don't get stuck going in a loop on the internet forever.

more reading