Working of ARP and IP Forwarding in LAN and across a router

Understand working of ARP, and IP Forwarding within a LAN and across a router

Theory#

In a network architecture different layers have their own addressing scheme. This helps the different layers in being largely independent. Application layer uses host names, network layer uses IP addresses, and the link layer uses MAC addresses. Whenever a source node wants to send an IP datagram to a destination node, it needs to know the address of the destination. Since there are both IP addresses and MAC addresses, there needs to be a translation between them. This translation is handled by the Address Resolution Protocol (ARP). In IP network, IP routing involves the determination of suitable path for a network packet from a source to its destination. If the destination address is not on the local network, routers forward the packets to the next adjacent network.

(Reference: A good reference for this topic is Section 5.4.1: Link Layer Addressing and ARP, of the book, Computer Networking, A Top-Down Approach, 6^th^ Edition by Kurose and Ross)

ARP protocol Description#

  1. ARP module in the sending host takes any IP address as input and returns the corresponding MAC address.

  2. First the sender constructs a special packet called an ARP packet, which contains several fields including the sending and receiving IP and MAC addresses.

  3. Both ARP request and response packets have the same format.

  4. The purpose of the ARP request packet is to query all the other hosts and routers on the subnet to determine the MAC address corresponding to the IP address that is being resolved.

  5. The sender broadcasts the ARP request packet, which is received by all the hosts in the subnet.

  6. Each node checks if its IP address matches the destination IP address in the ARP packet.

  7. The one with the match sends back to the querying host a response ARP packet with the desired mapping.

  8. Each host and router have an ARP table in its memory, which contains mapping of IP addresses to MAC addresses.

  9. The ARP table also contains a Time-to-live (TTL) value, which indicates when each mapping will be deleted from the table.

ARP Frame Format#


Hardware Type Protocol Type


Hardware Address Protocol Opcode Length address length

Sender Hardware
Address

Sender Protocol Sender Protocol Address (3-4) Address (1-2)

Target hardware
Address

Target Protocol
Address


Figure 5‑1: ARP Frame Format

The ARP message format is designed to accommodate layer two and layer three addresses of various sizes. This diagram shows the most common implementation, which uses 32 bits for the layer three ("Protocol") addresses, and 48 bits for the layer two hardware addresses.

IP Forwarding Description#

  1. Every router has a forwarding table that maps the destination addresses (or portions of the destination addresses) to that router's outbound links.

  2. A router forwards a packet by examining the value of a field in the arriving packet's header, and then using this header value to index into the router's forwarding table.

  3. The value stored in the forwarding table entry for that header indicates the router's outgoing link interface to which that packet is to be forwarded.

  4. Depending on the network-layer protocol, the header value could be the destination address of the packet or an indication of the connection to which the packet belongs.

  5. ARP operates when a host wants to send a datagram to another host on the same subnet.

  6. When sending a Datagram off the subnet, the datagram must first be sent to the first-hop router on the path to the final destination. The MAC address of the router interface is acquired using ARP.

  7. The router determines the interface on which the datagram is to be forwarded by consulting its forwarding table.

  8. Router obtains the MAC address of the destination node using ARP.

  9. The router sends the packet into the respective subnet from the interface that was identified using the forwarding table.

Network Set up#

Open NetSim and click on Experiments> Internetworks> Routing and Switching > Working of ARP and IP Forwarding within a LAN and across a router then click on the tile in the middle panel to load the example see Figure 5‑2.

Graphical user interface, application Description automatically
generated{width="6.260416666666667in" height="3.352777777777778in"}

Figure 5‑2: List of scenarios for the example of Working of ARP and IP Forwarding within a LAN and across a router

NetSim UI displays the configuration file corresponding to this experiment as shown below Figure 5‑3.

{width="3.971803368328959in" height="2.387217847769029in"}

Figure 5‑3: Network set up for studying the ARP across a LAN

Procedure#

ARP across a LAN

The following set of procedures were done to generate this sample:

Step 1: A network scenario is designed in NetSim GUI comprising of 3 Wired Nodes, 2 L2 Switches, and 1 Router in the "Internetworks" Network Library.

Step 2: Right click on the Application Flow App1 CBR and select Properties or click on the Application icon present in the top ribbon/toolbar.

A CBR Application is generated from Wired Node 1 i.e., Source to Wired Node 2 i.e., Destination with Packet Size remaining 1460Bytes and Inter Arrival Time remaining 20000µs.

Transport Protocol is set to UDP instead of TCP. If set to TCP, the ARP table will get updated due to the transmission of TCP control packets thereby eliminating the need for ARP to resolve addresses.

Step 3: Packet Trace is enabled in the NetSim GUI, and hence we can view the ARP Request and ARP Reply packets exchanged initially, before transmission of the data packets.

Step 4: Enable the plots and click on Run simulation. The simulation time is set to 10 seconds. In the "Static ARP Configuration" tab, Static ARP is set to disable see Figure 5‑4.

{width="3.730765529308836in" height="2.73545384951881in"}

Figure 5‑4: Static ARP Configuration Window

Click on Accept and then click on OK.

If Static ARP is enabled, then NetSim will automatically create an ARP table for each node. To see the working of the ARP protocol users should disable Static ARP.

By doing so, ARP request would be sent to the destination to find out the destinations MAC Address.

Output -- ARP across a LAN#

Once the simulation is complete, to view the packet trace file, click on "Open Packet Trace" option present in the left-hand-side of the Results Dashboard.

{width="6.268055555555556in" height="0.8in"}

Figure 5‑5: Open Packet Trace

NODE 1 will send ARP_REQUEST to SWITCH-4, SWITCH-4 sends this to ROUTER-6, and SWITCH-4 also sends this to NODE-2. ARP-REPLY is sent by the NODE-2 to SWITCH -4, and in-turn SWITCH-4 sends it to NODE-1.

Discussion -- ARP across a LAN#

[Intra-LAN-IP-forwarding]{.underline}

ARP PROTOCOL- WORKING:

{width="6.315025153105862in" height="1.1477099737532808in"}

Figure 5‑6: Intra LAN IP Forwarding

NODE-1 broadcasts ARP_Request, which is then broadcasted by SWITCH-4. NODE-2 sends the ARP_Reply to NODE-1 via SWITCH-4. After this step, datagrams are transmitted from NODE-1 to NODE-2. Notice the DESTINATION_ID column for ARP_Request type packets, which indicates Broadcast-0.

ARP across a WAN

NetSim UI displays the configuration file corresponding to this experiment as shown below Figure 5‑7.

{width="3.633403324584427in" height="2.1862423447069115in"}

Figure 5‑7: Network set up for studying the ARP across a WAN Procedure

The following set of procedures were done to generate this sample.

Step 1: A network scenario is designed in the NetSim GUI comprising of 3 Wired Nodes, 2 L2 Switches, and 1 Router.

Step 2: Right click on the Application tool bar and select Properties or click on the Application icon present in the top ribbon/toolbar.

APP 1 CBR is created from Wired Node 1 to Wired Node 3, Packet size set as 1460 bytes and Inter arrival time as 20000 Micro sec and Transport layer protocol to UDP.

APP 2 CBR is created from Wired Node 2 to Wired Node 3, Packet size set as 1460 bytes and Inter arrival time as 20000 Micro sec and Transport layer protocol to UDP. Additionally, the start time is set to 1 second and end time to 3 second.

Transport Protocol is set to UDP instead of TCP. If set to TCP, the ARP table will get updated during transmission of TCP control packets thereby eliminating the need for ARP to resolve addresses.

Step 3: Packet Trace is enabled in the NetSim GUI, and hence we can view the ARP Request and ARP Reply packets exchanged initially, before transmission of the data packets.

Step 4: Click on Run simulation. The simulation time is set to 10 seconds. In the "Static ARP Configuration" tab, Static ARP is set to disable.

Output I -- ARP across a WAN#

Once the simulation is complete, to view the packet trace file, click on "Open Packet Trace" option present in the left-hand-side of the Results Dashboard.

In packet trace, filter the CONTROL PACKET TYPE/ APP NAME filed to view APP 1CBR, ARP_REQUEST, ARP_REPLY.

{width="6.268055555555556in" height="2.8944444444444444in"}

Figure 5‑8: Open Packet Trace

NODE 1 will send ARP_REQUEST to SWITCH-4, SWITCH-4 sends this to ROUTER-6, and SWITCH-4 also sends this to NODE-2. ARP-REPLY is sent by the ROUTER-6 to SWITCH -4, and in-turn SWITCH-4 sends it to NODE-1. Again ROUTER-6 will send ARP_REQUEST to SWITCH-5, SWITCH-5 sends this to NODE-3. ARP_REPLY is sent by NODE-3 to SWITCH-5 and in-turn SWITCH-5 sends it to ROUTER-6.

The IP forwarding table formed in the router can be accessed from the IP_Forwarding_Table list present in the Simulation Results window as shown below Figure 5‑9.

Graphical user interface, table Description automatically
generated{width="6.3005982064741906in" height="1.9251826334208224in"}

Figure 5‑9: IP Forwarding Table

Click on Detailed View checkbox to view the additional fields as indicated above.

Router forwards packets intended to the subnet 11.2.0.0 to the interface with the IP 11.2.1.1 based on the first entry in its routing table.

Discussion I -- ARP across a WAN#

  • From the above case we can understand that, since Router_6 did not know the destination address, the Application packets reach only till Router_6, and ARP mechanism continues with Router_6 re-broadcasting the ARP_REQUEST, finding the destination address and the datagram is getting transferred to Wired node 3 (destination).

Output II -- ARP across a WAN#

In same packet trace, filter the CONTROL PACKET TYPE/ APP NAME column to view APP 2 CBR, ARP_REQUEST, ARP_REPLY only.

In the below figure you can observer that ARP_REQUEST is broadcasted from Wired Node 2, the ARP Reply is sent from the Router 6, upon receiving the ARP_REPLY. Router 6 directly starts sending the data packet to the Wired Node 3 unlike the previous sample.

{width="6.268055555555556in" height="2.936111111111111in"}

Figure 5‑10: Open Packet Trace

Discussion II -- ARP across a WAN#

[Across-Router-IP-forwarding]{.underline}

ARP PROTOCOL- WORKING

{width="3.7016951006124232in" height="2.9705752405949255in"}

Figure 5‑11: Across Router IP Forwarding

NODE-2 transmits ARP_Request which is further broadcasted by SWITCH-4. ROUTER-6 sends ARP_Reply to NODE-2 which goes through SWITCH-4. Then NODE-2 starts sending datagrams to NODE-3. If router has the MAC address of NODE-3 in its ARP table, then ARP ends here, and router starts forwarding the datagrams to NODE-3 by consulting its forwarding table. Router 6, has this information updated during transmission of APP1 packets and hence ARP request for identifying the MAC address of NODE-3, need not be sent again. In the other case (Output -I), Router sends ARP_Request to appropriate subnet and after getting the MAC address of NODE-3, it then forwards the datagrams to NODE-3 using its forwarding table.