IP

Work in Progress

Summary

Subnet mask to decimal

BinaryNumber of 1sDecimal
0000 000000
1000 00001128
1100 00002192
1110 00003224
1111 00004240
1111 10005248
1111 11006252
1111 11107254
1111 11118255

Special IP addresses

Address / RangeNamePurpose / Meaning
0.0.0.0/8Unspecified addressMeans “no specific address”; used by a host before it gets an IP or to mean “this host”
255.255.255.255/32Limited broadcastBroadcast to all devices on the local network (not forwarded by routers)
127.0.0.0/8 (e.g. 127.0.0.1)LoopbackRefers to the local machine (localhost)
10.0.0.0/8Private rangeInternal networks (not routable on internet)
172.16.0.0/12Private rangeInternal networks
192.168.0.0/16Private rangeInternal networks (home networks)
Network address (e.g. 192.168.1.0/24)Network IDIdentifies the subnet itself; used in routing
Broadcast address (e.g. 192.168.1.255/24)Directed broadcastSends 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
subnetpre¯xhostidnbits32¡nbits
  • 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