IP in depth - Dleifnesor/NET-215 GitHub Wiki

IPv6 vs. IPv4


Internet Protocol (IP) is the fundamental protocol for network communication. IPv4 has been the dominant standard but is now being replaced by IPv6 due to address exhaustion.

IPv4 vs. IPv6 Comparison

Feature IPv4 IPv6
Address Size 32-bit (e.g., 192.168.1.1) 128-bit (e.g., 2001:db8::1)
Address Count ~4.3 billion addresses Virtually unlimited (2^128 addresses)
Header Size 20 bytes (without options) 40 bytes
Header Fields 12 fields 8 fields (simplified)
Fragmentation Routers and hosts Only hosts
Broadcast Supported Replaced by multicast and anycast
NAT Required? Yes (due to address shortage) No (ample address space)
Security Optional (IPSec not required) IPSec is built-in
Autoconfiguration Uses DHCP Supports SLAAC (Stateless Address Autoconfiguration)
Checksum Field Present Removed (handled by upper layers)

IPv4 Header Format

image

Breakdown of an IPv6 Address

A typical IPv6 address is divided into three main parts:

  • Routing Prefix (Network ID): 48 bits
  • Subnet ID: 16 bits
  • Interface ID (Host ID): 64 bits

IPv6 Address Structure

| 48 bits (Routing Prefix) | 16 bits (Subnet ID) | 64 bits (Interface ID) |

markdown Copy Edit

Example Breakdown:

For an IPv6 address like 2001:0db8:85a3:0000:0000:8a2e:0370:7334, the breakdown is:

  • Routing Prefix: 2001:0db8:85a3 (48 bits)
  • Subnet ID: 0000 (16 bits)
  • Interface ID: 8a2e:0370:7334 (64 bits)

Explanation of Each Part:

  1. Routing Prefix (48 bits): Identifies the network portion of the address.
  2. Subnet ID (16 bits): Used to subdivide the network into smaller subnets.
  3. Interface ID (64 bits): Identifies the specific device or host on the local network segment (usually derived from the MAC address).

This structure allows IPv6 to provide vast address space for routing and addressing large-scale networks and devices.

Important IPv4 Header Fields

  • Version: Always 4 for IPv4.
  • Time to Live (TTL): Prevents packets from looping forever (decremented at each hop).
  • Header Checksum: Error-checking for the IPv4 header.
  • Source/Destination IP Address: 32-bit addresses of sender and receiver.

IPv6 Header Format

image

Important IPv6 Header Fields

  • Version: Always 6 for IPv6.
  • Hop Limit: Replaces IPv4's TTL field.
  • Next Header: Indicates the type of next header (e.g., TCP, UDP, or Extension Header).
  • Flow Label: Helps with Quality of Service (QoS) optimizations.

IPv6 Address Types

Type Address Range Example Description
Unicast 2001:db8::1 Single sender to single receiver
Multicast ff02::1 One sender to multiple receivers
Anycast Assigned dynamically One sender to closest receiver
Link-local fe80::1 Only valid within a local network
Loopback ::1 Equivalent to 127.0.0.1 in IPv4

Key Differences Between IPv4 and IPv6

1. Addressing

IPv6 has a much larger address space (128-bit vs. 32-bit), eliminating the need for NAT.

2. Header Efficiency

IPv6 has fewer fields, making packet processing faster and more efficient.

3. Security

IPv6 requires IPSec, while in IPv4, it is optional.

4. Auto-Configuration

IPv6 supports SLAAC (Stateless Address Autoconfiguration), reducing dependence on DHCP.


Link-Local Addresses vs. NAT/PAT

What are Link-Local Addresses?

In IPv6, Link-Local addresses are special addresses that are used for communication within the same network segment (or link). These addresses are not routable beyond the local network, meaning that devices can only communicate with each other within the same local network or subnet.

Key Characteristics of Link-Local Addresses:

  • Prefix: Always start with fe80::/10, which means the address range starts from fe80:: to febf::.
  • Automatically Assigned: Devices automatically generate a Link-Local address using the network interface's MAC address, although it can also be manually configured.
  • Scope: Limited to the local network and cannot be routed across different networks.
  • Usage: Primarily used for network discovery and initial communication between devices on the same link (e.g., Neighbor Discovery Protocol (NDP) in IPv6).

Example of a Link-Local Address:

fe80::1


How Link-Local Addresses Compare to NAT and PAT

Network Address Translation (NAT)

  • NAT allows multiple devices on a private network (with private IP addresses) to share a single public IP address when communicating with the internet. This is commonly used in IPv4 to conserve the limited number of available public IP addresses.
  • Link-Local addresses, on the other hand, are not routed at all. They are meant solely for local communication within a single network segment, not for communication across the internet.
  • NAT requires that devices use a public IP address to communicate with the internet, while Link-Local addresses are used for local-only communication.

Port Address Translation (PAT)

  • PAT, also known as overloaded NAT, allows multiple devices on a private network to share a single public IP address, but with different port numbers. This enables many internal devices to be identified by a single public IP address, with each having a different port number.
  • Like NAT, PAT is used for devices to communicate outside the local network (on the internet). In contrast, Link-Local addresses are not used for internet communication at all.
  • Link-Local addresses operate entirely within the local network, whereas PAT operates to map private IPs to a public IP for external communication.

Comparison of Link-Local Addresses, NAT, and PAT

Feature Link-Local Addresses (IPv6) NAT (IPv4) PAT (IPv4)
Scope Local network only (not routable) Private network to public internet Private network to public internet
Usage Local communication (e.g., device discovery) Share a public IP across devices Share a public IP across devices, with different ports
Address Space fe80::/10 range Private IP ranges (10.x.x.x, 192.168.x.x) Private IP ranges with port numbers
Routing Not routable beyond the local link Routable to the internet Routable to the internet
Address Assignment Automatically generated based on MAC or manually assigned Manually configured (DHCP or static IP) Manually configured (via NAT router)
Security Considerations Secure within local network, not exposed Devices behind NAT are somewhat hidden from the internet Devices behind PAT are hidden, but port mapping can be a security concern

  • Link-Local addresses are used for local communication within the same network segment and cannot be routed or used for internet communication.
  • NAT and PAT, on the other hand, are techniques used in IPv4 to allow multiple devices in a private network to communicate with external networks (like the internet) using a single public IP address.
  • Link-Local addresses are typically used for tasks like device discovery and network configuration, whereas NAT/PAT are essential for overcoming IPv4 address shortages and facilitating communication between private and public networks.