Skip to content

IPv4 Example

This chapter describes a simplified example of how communication occurs over an IPv4 network when a user tries to access a website. This involves several key protocols and processes.

  • MAC Address (Media Access Control Address): A 48-bit hardware address burned into the Network Interface Card (NIC). Used for communication between devices on the same local network segment (Layer 2).
  • IP Address (Internet Protocol Address): A 32-bit logical address used to identify devices on a network and route packets across different networks (Layer 3).
  • ARP (Address Resolution Protocol): Used within a local network to resolve a known IP address to its corresponding MAC address. Essential for devices to send data frames to each other on the same physical segment.
  • DHCP (Dynamic Host Configuration Protocol): Automates the assignment of IP addresses, subnet masks, default gateway addresses, and DNS server addresses to client devices. This simplifies network administration.
  • DNS (Domain Name System): Translates human-readable domain names (e.g., www.example.com) into numerical IP addresses that computers use to connect to each other.
  • Default Gateway (Router): A device (typically a router) that connects a local network to other networks (like the internet). Hosts send packets destined for remote networks to their default gateway.
  • NAT (Network Address Translation): A technology, often implemented in routers, that allows multiple devices in a private network (using private IP addresses) to share a single public IP address when accessing the internet. It translates private source IPs to the public IP on outgoing packets and vice-versa for incoming packets.

Let’s assume a user on a home network wants to visit www.example.com.

Step 1: Acquiring Network Configuration (DHCP)

Section titled “Step 1: Acquiring Network Configuration (DHCP)”

When the user’s computer (PC) starts up and connects to the network:

  1. The PC broadcasts a DHCPDISCOVER message on the local network to find a DHCP server.
  2. A DHCP server (often integrated into the home router) responds with a DHCPOFFER message, offering an available IP address, subnet mask, default gateway IP, DNS server IP(s), and lease duration.
  3. The PC accepts the offer by sending a DHCPREQUEST message back to the server.
  4. The DHCP server confirms the lease with a DHCPACK (Acknowledgement) message. The PC is now configured for network communication.
  5. (Alternatively, network settings can be configured manually/statically, but DHCP is more common for end-user devices.)

Step 2: Resolving the Domain Name (DNS Query)

Section titled “Step 2: Resolving the Domain Name (DNS Query)”

The user types www.example.com into their web browser:

  1. The PC needs the IP address of www.example.com. It first checks its local DNS cache.
  2. If not found in the cache, the PC sends a DNS query for www.example.com to the DNS server address it received via DHCP.
  3. The DNS server (or a chain of DNS servers) resolves the domain name and returns the corresponding public IP address (e.g., 93.184.216.34) to the PC.

Step 3: Preparing to Send the Packet (ARP for Gateway)

Section titled “Step 3: Preparing to Send the Packet (ARP for Gateway)”

The PC now has the destination IP address for www.example.com.

  1. The PC compares the destination IP (e.g., 93.184.216.34) with its own IP address and subnet mask to determine if the destination is on the local network or a remote network. In this case, it’s remote.
  2. To send the packet to a remote network, the PC must send it to its default gateway (e.g., the home router). The PC knows the gateway’s IP address from DHCP.
  3. The PC needs the MAC address of the gateway to create the Ethernet frame for local delivery. It checks its ARP cache for an entry mapping the gateway’s IP to a MAC address.
  4. If not in the cache, the PC broadcasts an ARP request on the local network: “Who has gateway_IP_address? Tell my_IP_address.”
  5. The gateway (router) responds with an ARP reply containing its MAC address.
  6. The PC stores this IP-to-MAC mapping in its ARP cache.
  1. The PC creates an IP packet with:
    - Source IP: PC’s private IP (e.g., 192.168.1.100)
    - Destination IP: www.example.com’s public IP (e.g., 93.184.216.34).
  2. This IP packet is encapsulated in an Ethernet frame with:
    - Source MAC: PC’s MAC address
    - Destination MAC: Gateway’s (router’s) MAC address.
  3. The frame is sent to the gateway router.
  4. The router de-encapsulates the IP packet. Because the packet is destined for the internet and the source IP is private, the router performs NAT:
    - It replaces the source IP (PC’s private IP) with its own public IP address.
    - It records this translation in its NAT table (typically including port numbers to handle multiple internal devices and return traffic).
  5. The router then determines the next hop towards www.example.com based on its routing table and forwards the (now NAT-ed) packet to the next router in the path.
  6. This process of MAC address changing at each Layer 2 hop, while (usually) the source and destination IP addresses remain constant (except for NAT on the source side), continues across the internet until the packet reaches the server hosting www.example.com.

Return traffic from www.example.com will be addressed to the router’s public IP. The router uses its NAT table to translate the destination IP back to the PC’s private IP and forwards the packet to the PC on the local network.

This example highlights how IP addresses are used for end-to-end routing, while MAC addresses are used for hop-by-hop delivery on local segments, and how protocols like DHCP, DNS, and ARP work together to enable communication.