IP
Summary
Subnet mask to decimal
| Binary | Number of 1s | Decimal |
|---|---|---|
0000 0000 | 0 | 0 |
1000 0000 | 1 | 128 |
1100 0000 | 2 | 192 |
1110 0000 | 3 | 224 |
1111 0000 | 4 | 240 |
1111 1000 | 5 | 248 |
1111 1100 | 6 | 252 |
1111 1110 | 7 | 254 |
1111 1111 | 8 | 255 |
Special IP addresses
| Address / Range | Name | Purpose / Meaning |
|---|---|---|
0.0.0.0/8 | Unspecified address | Means “no specific address”; used by a host before it gets an IP or to mean “this host” |
255.255.255.255/32 | Limited broadcast | Broadcast to all devices on the local network (not forwarded by routers) |
127.0.0.0/8 (e.g. 127.0.0.1) | Loopback | Refers to the local machine (localhost) |
10.0.0.0/8 | Private range | Internal networks (not routable on internet) |
172.16.0.0/12 | Private range | Internal networks |
192.168.0.0/16 | Private range | Internal networks (home networks) |
Network address (e.g. 192.168.1.0/24) | Network ID | Identifies the subnet itself; used in routing |
Broadcast address (e.g. 192.168.1.255/24) | Directed broadcast | Sends to all hosts in a specific subnet |
Concept
IP address
- unique identifier for a host/router
- 32-bit number
Router
- forward packets between 2 hosts/networks
Interface
- connection between host/router and a physical link
- hosts/routers may have multiple interfaces
Address aggregation
- reduces the size of the forwarding table
Subnet
- group of “directly” interconnected host interfaces
- hosts in the same subnet can reach each other without the router
- the router provides a connection to the outside
- network address - all 0s in host id, identifies the subnet from outside
- broadcast address - all 1s in host id, refers to every interface in the subnet
Subnet mask
- bit mask for the subnet prefix
Hierarchical addressing
- ISPs subdivide their subnet for other users
- match the longest prefix in forwarding table
IPv4 datagram
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version| IHL |Type of Service| Total Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Identification |Flags| Fragment Offset |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Time to Live | Protocol | Header Checksum |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Destination Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Data ...
+---------------- ...
unlike UDP or TCP the header’s size of 20 bytes is included in the length field
Time to live
- number of hops the packet can take
- router decrements the value before passing on
- if 0 the packet is dropped
Fragmentation
- different links might have different maximum transfer unit(MTU)
- packets that are too large will be fragmented by the routers
- reassembled only at the destination
- frag flag
- 1 if there is a next fragment
- 0 is this is the last fragment
- frag offset,
offset bytes / 8
Application
Subnet mask
Different subnet
Subnet division
Prefix matching(8-bit addresses)
Fragmentation