Address Resolution Protocol (ARP) and Ethernet switching
There are three main functions of an Ethernet switch. Here, we’ll focus on the first two functions, both of which relate to forwarding Ethernet frames.
To see where the switch fits when two endpoints communicate, let’s walk through the scenario below.
(Image 033) Image Title - PC A and PC B connected to Switch-1
PC A would like to send pings to PC B. PC A is connected to Switch-1’s GigabitEthernet0/2 port and PC B is connected to Switch-1’s GigabitEthernet0/3.
PC A pings PC B
Assume you’ve opened a command prompt on PC A and verified that it has a valid IP address for the LAN. Assume PC B also has a valid IP address on the same LAN. You can now ping PC B by entering: “ping 192.168.1.3”
(This example assumes PC A and PC B have never communicated before this ping, and PC B has not sent any frames into the network yet.)
(Image 036) Image Title - Pinging PC B
Step 1: After you enter the “ping 192.168.1.3” command on PC A, PC A first determines whether the destination IP address (PC B) is on the same network. The operating system on PC A performs a Boolean operation called a “Logical AND.” It uses PC A’s own IP address and subnet mask, compares the result to PC B’s IP address, and decides whether they’re on the same network.
We’ll cover how to determine the range of IPs in a network when we discuss IPv4 addressing. For now, assume PC A and PC B are in the same IP network (LAN).
Step 2: Since PC A and PC B are on the same network, PC A must decide whether it needs to use its default gateway.
Does PC A need to use its default gateway in this case? Yes or no?
No. Devices on a network only need to use their Default Gateway whenever they are sending packets to devices with destination IP Addresses outside of their own network.
Step 3: PC A now builds an Ethernet frame that will carry the ICMP (Ping) Echo Request, and it starts filling in the required Ethernet frame fields.
- Devices on a LAN communicate using IP addresses and their associated MAC addresses. Every IP Address should have a MAC Address associated with it (and vice versa). A MAC address is the physical address “burned-in” to the NIC of an endpoint (or to a router interface on a router).
- Ethernet switches forward Ethernet frames from switchport to switchport using the destination MAC address in the frame. This is the core of Layer 2 forwarding. Endpoints use both:
- the Layer 3 IP address (to identify the destination logically), and
- the Layer 2 MAC address (to deliver the frame on the local network).
- Switches, however, only care about MAC addresses.
(Ethernet Frame Diagram - Ping Echo Request) (Description of an Ethernet Frame)
Step 4: In the diagram above, the Destination MAC Address field for the Ping Echo Request frame is empty. Since PC A has never communicated with PC B before (and PC B hasn’t sent any frames into the switch yet), PC A doesn’t know the MAC address associated with PC B’s IP address.
- PC A tries to look up PC B’s MAC address in its Address Resolution Protocol (ARP) cache. The ARP cache is a database on hosts (which is another name for endpoints and routers on a network) that stores mappings of IP addresses to MAC addresses for other hosts on the LAN. Since PC A hasn’t talked to PC B before, PC A won’t have an entry for PC B yet.
(PC A’s ARP Table)
Step 5: PC A now realizes it can’t complete the Ethernet frame because it’s missing the destination MAC address. To send an Ethernet frame, a host must fill in all required fields. So PC A must DROP the incomplete Ethernet frame containing the Ping Echo Request.
- To learn the MAC address for 192.168.1.3, PC A must send an Address Resolution Protocol (ARP) Request.
- ARP is the protocol that lets hosts discover the MAC address associated with a known IP address. When the sender knows the destination IP address but not the destination MAC address associated with it, ARP resolves the missing MAC address so the sender can build a valid Ethernet frame.
- Conceptually, the sender is asking: “I know your IP address - what MAC address should I use to reach you on this LAN?” The destination host responds with an ARP Reply that includes its MAC address.
(Image 037) Image title - Sender Host sending ARP Request to Destination Host
Step 6: At this point, PC A builds an Ethernet frame containing an ARP Request.
(Ethernet Frame containing PC A’s ARP Request)
Notice that all required fields in this frame are filled in, so PC A can transmit it. PC A sends it out its NIC to the switch, and the switch receives it.