Skip to content

IPv4 and IPv6

IPv4

  • 32-bit address → 2³² = ~4.3 billion addresses.
  • Written in dotted decimal: 192.168.1.1
  • 4 octets, each 0–255.
  • Header size: 20–60 bytes.

IPv4 Header Key Fields

  • Version (4 bits) — value = 4
  • TTL — prevents infinite loops, decremented at each hop
  • Protocol — TCP=6, UDP=17, ICMP=1
  • Source/Destination IP
  • Checksum — error checking

Address Classes (Classful — mostly obsolete)

ClassRangeUse
A1.0.0.0 – 126.x.x.xLarge networks
B128.0.0.0 – 191.255.x.xMedium networks
C192.0.0.0 – 223.255.255.xSmall networks
D224.0.0.0 – 239.x.x.xMulticast
E240.0.0.0 – 255.x.x.xReserved

Private IP Ranges (RFC 1918)

RangeCIDR
10.0.0.0 – 10.255.255.25510.0.0.0/8
172.16.0.0 – 172.31.255.255172.16.0.0/12
192.168.0.0 – 192.168.255.255192.168.0.0/16

Special Addresses

  • 127.0.0.1 → Loopback
  • 0.0.0.0 → Default route / unspecified
  • 255.255.255.255 → Limited broadcast

IPv4 Notation Explained

192       . 168      . 1        . 1
11000000    10101000   00000001   00000001

Each octet = 8 bits (decimal 0–255). Total = 32 bits.

IPv6

  • 128-bit address → 2¹²⁸ = ~340 undecillion addresses.
  • Written in colon-hex: 2001:0db8:85a3:0000:0000:8a2e:0370:7334

IPv6 Compression Rules

  • Leading zeros dropped: 0db8db8
  • Consecutive all-zero groups → :: (only once)
  • Example: 2001:db8::8a2e:370:7334

IPv6 Header (Fixed 40 bytes — simpler than IPv4)

  • Version (4 bits) — value = 6
  • Traffic Class — like DSCP/ToS in IPv4
  • Flow Label — identifies packet flows for QoS
  • Hop Limit — like TTL
  • No checksum — offloaded to transport layer

IPv6 Address Types

TypeDescriptionExample
UnicastOne-to-one2001:db8::1
MulticastOne-to-manyFF02::1
AnycastOne-to-nearestSame as unicast format
No BroadcastReplaced by multicast

Special IPv6 Addresses

  • ::1 → Loopback (equivalent to 127.0.0.1)
  • FE80::/10 → Link-local (auto-configured, not routable)
  • :: → Unspecified

Key Improvements of IPv6 over IPv4

  • No NAT needed — every device gets a global address
  • No ARP — replaced by NDP (Neighbor Discovery Protocol)
  • Auto-configuration — SLAAC (Stateless Address Autoconfiguration)
  • Built-in IPSec support
  • Simpler header — faster routing
  • No broadcast — reduces unnecessary traffic

IPv6 Notation Explained

2001 : 0db8 : 85a3 : 0000 : 0000 : 8a2e : 0370 : 7334
16b    16b    16b    16b    16b    16b    16b    16b   = 128 bits total

IPv4 vs IPv6 — Side by Side

FeatureIPv4IPv6
Address size32-bit128-bit
Address count~4.3 billion~340 undecillion
Header size20–60 bytes (variable)40 bytes (fixed)
ChecksumYesNo
BroadcastYesNo (multicast instead)
ARPYesNo (NDP instead)
NAT requiredYes (usually)No
ConfigurationManual / DHCPSLAAC / DHCPv6
SecurityOptional IPSecBuilt-in IPSec
NotationDotted decimalColon hexadecimal
Groups4 octets (8 bits)8 groups (16 bits)
Display formatDecimalHexadecimal