Switched LANs and ARP

A switched local area network (LAN) allows devices to communicate using layer-2 switches.

Example of a local network with 4 switches connecting:

Switches operate at the link layer:

Instead, switches use link-layer (MAC) addresses to identify interfaces on the local network.

To understand how switches forward frames, we first need to understand MAC addresses.

A host or router with multiple network interfaces (such as Ethernet and Wi-Fi) has:

Both kinds of addresses are needed because they serve different purposes.

MAC addresses (Media Access Control)

Every network interface has a unique MAC address:

A MAC address is 48 bits (6 bytes) long (248 possible addresses) expressed in hexadecimal notation:

MAC addresses

MAC address vs. IP address:

MAC address IP address

Flat structure

Hierarchical structure (network part + host part)

Stays the same regardless of where the device is connected

Changes when the device joins a different network

Analogous to a person's social security number:

  • unique
  • permanent
  • does not depend on location

Analogous to a person's postal address:

  • depends on where they live
  • changes when they move

When an adapter wants to send a frame:

  1. it places the destination MAC address in the frame header
  2. it sends it onto the local network (LAN)

Sometimes a switch forwards a frame to every interface (broadcast), so devices may receive frames that are not meant for them.

When an interface receives a frame:

ARP (IPv4 Address Resolution Protocol)

When a device wants to send data over the LAN, it needs the destination's MAC address, not just its IP address.

ARP (Address Resolution Protocol, RFC 826), maps an IPv4 address to its corresponding MAC address.

Suppose host 222.222.222.220 wants to send an IP datagram to host 222.222.222.222 on the same subnet:

ARP

This is similar to DNS, but with a different purpose:

How ARP works?

Each host and router maintains an ARP table, which stores recently learned IP-to-MAC mappings:

IP                  Address MAC Address     TTL
222.222.222.221     88-B2-2F-54-1A-0F       13:45:00
222.222.222.223     5C-66-AB-90-75-B1       13:52:00

If the destination's MAC address is not in the ARP table:

Step Description

1

The sender broadcasts an ARP request asking:

Who has IP address 222.222.222.222?

2

Every device on the subnet receives the broadcast.

3

Each device checks whether the requested IP address matches its own.

4

The matching device sends an ARP reply directly to the sender with its MAC address.

5

The sender:

  • stores the mapping in its ARP table
  • sends the IP datagram

Key points:

Is ARP a link-layer or network-layer protocol?

So, ARP is generally considered a protocol that operates between the link layer and the network layer.

Communication outside the local subnet

When a host sends an IP datagram to a different subnet, it must first send it to a router, which then forwards it toward the destination.

Communication outside the local subnet

The example network has two subnets connected by a router:

Suppose host 111.111.111.111 wants to send an IP datagram to host 222.222.222.222:

Step Description

1

The sending host already knows the destination IP (from the application or DNS).

2

The host determines that the destination IP is off-subnet using its subnet mask, so it forwards the datagram to its configured default gateway (the next-hop router on the local network).

3

Using ARP, the host resolves the MAC address of the router's interface on the local subnet (111.111.111.110 → E6-E9-00-17-BB-4B).

4

The host sends a frame with:

  • destination MAC: the router (E6-E9-00-17-BB-4B)
  • destination IP: the final destination (222.222.222.222)

5

The router receives the frame, recognizes its own MAC address, decapsulates the IP datagram, and passes it to the network layer, where it consults its forwarding table and decrements the TTL.

6

The router determines the outgoing interface, and if needed, uses ARP on that interface to resolve the MAC address of the final destination (or the next hop if it is not directly connected). It then re-encapsulates the IP datagram into a new frame for forwarding.

7

The new frame is sent onto subnet 2, where it is delivered to host 222.222.222.222.

IP destination stays the same end-to-end, but MAC addresses change at every hop.

Previous Multiple access links and protocols All ⏎ Next Ethernet

A Kemar Joint