1

I understood that each router maintains an ARP module that stores each client's IP address and associated MAC address. Let's say, there are 512 clients in a router's subnet. When the router gets a datagram from another subnet, it inspects the MAC address in the link layer, and confirms if the datagram's destination lies in it's subnet by checking with the ARP module.

My question is this: How exactly does the packet go to destination host once it reaches the subnet? Is it like this: Router sending that packet to all clients and each client would process that packet only if the MAC address in the packet matches with it's own MAC address?

If this is the case, why should the router maintain an ARP module as in both cases it is broadcasting every packet?

5

You seem to be confused about a couple of things.

Let's say, there are 512 clients in a router's subnet. when the router gets a datagram from other subnet, it inspects the MAC address in the link layer, and confirms if the datagram's destination lies in it's subnet by checking with the ARP module.

That's not how it works. A MAC address is only significant or even seen in the LAN on where the host with that MAC address is. MAC addresses do not cross a router to get to a different LAN. When a router receives a frame with the source and destination MAC addresses, it strips the frame off the packet, losing the original source and destination MAC addresses.

How exactly does the packet go to destination host once it reaches the subnet.

When the router has the packet, stripped of the frame containing the source and destination MAC addresses, it will inspect the destination IP address in the packet header, and it will switch the packet to the interface toward the destination. It will then build a new frame for the packet from scratch for the next hop. The next hop may not be ethernet, or any other protocol which uses MAC addresses. If the next hop uses MAC addresses, it will build the frame with its own MAC address for the next ho as the source MAC address, and the MAC address of the destination device (another router or the end host) of the next hop as the destination MAC address.

Router sending that packet to all clients and each client would process that packet only if the MAC address in the packet matches with it's own MAC address? If this is the case, why should the router maintain an ARP module as in both cases it is broadcasting every packet?

Any host, even a router, sending a broadcast will send to the broadcast address MAC address, not a specific host MAC address.


Any host (a router is just another host on the LAN) sending an IP packet to another host will compare the masked destination IP address to its own masked source IP address.

If both IP addresses are on the same network, the sending host will inspect its ARP cache to see if it already knows the MAC address associated with the IP address. If it has it in its ARP cache, it will build the frame with that MAC address. If it doesn't have it in its ARP cache, it will send an ARP looking for the MAC address of the destination IP address. If the host with that IP address responds, it will add the MAC address to its ARP cache, and it will use that MAC address to build the frame. If the destination host does not respond, the packet will be dropped, and an error generated.

If the destination IP address is on a different network, the sending host will use the MAC address of its configured gateway to build the frame so that the frame containing the packet gets delivered to it configured gateway. It will use its ARP cache or ARP to discover the MAC address of its configured gateway to build the frame.

4

You may be confused on a few points:

when the router gets a datagram from other subnet, it inspects the MAC address in the link layer, and confirms if the datagram's destination lies in it's subnet by checking with the ARP module.

Not quite. A packet received from another interface will have the MAC address of the router, not the MAC address of the end host (note: there are rare exceptions, but you can ignore that for now). When a router receives a datagram from any subnet, the first thing it does is strip away the layer 2 information and throw it away. Then it uses the layer 3 information (i.e., IP address) to determine which interface to use, and if the host is directly connected.

If this is the case, why should the router maintain an ARP module as in both cases it is broadcasting every packet?

The answer is, obviously, that isn't the case. The router acts like any other host: It looks in it's ARP table for the host MAC address, and (in the case of Ethernet) encapsulates the IP packet in an Ethernet frame, with the destination MAC set to the MAC address of the desired host.

  • You just beat me that time. – Ron Maupin Jul 23 '16 at 17:59
  • I've been practicing my typing. :-) – Ron Trunk Jul 23 '16 at 17:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.