Address Resolution Protocol (ARP) and Routing Examples
Address Resolution Protocol (ARP)
- ARP is used to find the MAC address for a given IP address.
- It operates between Layer 2 (Data Link) and Layer 3 (Network).
- When a device wants to send a packet to an IP address on the same local network but doesn't know the MAC address, it uses ARP.
- Consider a scenario where a laptop wants to send game data to another laptop with IP address 133.330.30.1.
- The source laptop needs the destination's MAC address to create a frame.
ARP Process Explained
- The sending laptop broadcasts an ARP request on Layer 2 (MAC address is all Fs).
- The request asks: "Who has IP address 133.330.30.1?".
- The destination laptop, which also runs ARP, recognizes its IP address in the broadcast.
- It responds with an ARP reply containing its MAC address (e.g., ending in 5BColon78).
- The sending laptop now has the MAC address and can build a frame containing the IP packet.
- The frame is sent to the destination laptop.
- The destination laptop's Layer 2 strips the frame and passes the packet to Layer 3.
- Layer 3 verifies the destination IP and delivers the data to the application (the game).
- Even when devices communicate using Layer 3, Layer 2 is used for local communication. Remote communications might involve multiple Layer 2 frames.
Routing Example
Scenario Setup
- Three networks: Orange, Green, and Pink.
- Routers: R1 connects Orange and Green, R2 connects Green and Pink.
- Routers operate at Layers 1, 2, and 3.
- Devices: Two laptops (D1, D2) in the Orange network, one laptop (D3) in the Pink network.
Local Network Communication (D1 to D2)
- D1 determines D2 is on the same local network using its subnet mask and D2's IP address.
- Router R1 is not needed.
- Packet P1 is created with D2's IP address as the destination.
- ARP is used to get D2's MAC address.
- P1 is encapsulated in a frame with D2's MAC address as the destination.
- The frame is sent to D2, which strips the frame and packet, delivering the data.
Remote Network Communication (D2 to D3)
- D2 determines D3 is on a different network.
- Packet P2 is created with D3's IP address as the destination.
- Frame F2 is created, but since D3 is remote, the destination MAC address is the local router (R1).
- ARP is used to get R1's MAC address.
- The frame F2 is sent to R1.
- R1 strips F2, leaving packet P2.
- R1 consults its routing table and determines the next hop for the Pink network is R2.
- R1 encapsulates P2 in a new frame F3, addressed to R2's MAC address (obtained via ARP).
- F3 is sent to R2.
- R2 strips F3, leaving packet P2.
- R2 consults its routing table and determines D3 is on the same local network.
- R2 uses ARP to get D3's MAC address.
- R2 encapsulates P2 in a new frame F4, addressed to D3's MAC address.
- F4 is sent to D3.
- D3 strips F4 and P2, delivering the data to the application.
Router's Role
- Routers move packets between networks by reviewing packets and checking route tables for the next hop.
- Packets can be re-encapsulated in different Layer 2 frames multiple times during their journey.
- The packet itself usually remains unchanged from source to destination.
- Routers understand Physical, Data Link, and IP networking.
Summary of Layer 3
- Layer 2: Device-to-device communication within the same network using MAC addresses.
- Layer 3 Addition:
- IP addresses (v4, v6) for cross-network addressing.
- ARP to find MAC addresses for given IP addresses.
- Routes: Define where to forward packets.
- Route Tables: Contain multiple routes.
- Routers: Move packets between networks, encapsulating them in Layer 2 frames.
- Device-to-device communication over the internet.
Limitations of Layer 3
- No method of individual communication channels between two devices. Only supports single stream of communication.
- Packets can potentially be delivered out of order due to varying network conditions.
Further Topics (Dedicated Videos)
- Network Address Translation (NAT).
- IP address space.
- IP version 6.