0

enter image description here

Host E would like to send some data to Host B. Further assume that Host E doesn't have Host B's MAC Address. When the router is present between sub net 2 and 3 no ARP query message is send but when this router is replaced by a switch then Host E would send an ARP query message? Why will it send in the presence of the switch? Why can't is send when router is attached? Can I say that only switch is capable of sending ARP to another sub net and router is unable to do so?

2 Answers 2

3

Host E would like to send some data to Host B. Further assume that Host E doesn't have Host B's MAC Address.

Since B and E are on different subnets, their MAC addresses are of no consequence to each other. MAC addresses are used for "direct" L2 communication in a common subnet. Different subnets require L3 communication across a router.

When the router is present between sub net 2 and 3 no ARP query message is send but when this router is replaced by a switch then Host E would send an ARP query message?

E sends all communication for B to the router in between. The router forwards to B. E ARPs the router and the router ARPs B.

Why will it send in the presence of the switch?

A switch is a device transparent for L2 and above. Communication across a switch uses "physical" MAC addressing. Basically, a switch enables you to create a subnet with more than two nodes (in the absence of obsolete repeater hubs or bus-wired physical layers like 10BASE5).

Why can't is send when router is attached? Can I say that only switch is capable of sending ARP to another sub net and router is unable to do so?

ARP uses L2 broadcasting to send the request to all hosts within its broadcast domain (spanned by a switch). L2 broadcasts are not forwarded by routers, so an ARP request can't reach a remote subnet.

1
  • now i understand the concept of ARP. Jun 30, 2019 at 16:43
3

It's not the presence or absence of the router that controls Host E's behaviour, it's the addressing.

A host IP layer on top of ethernet essentially will ARP for any destination IP address in its own subnet, as defined by its own IP address and network mask. If the destination is local, it ARPs for the ethernet address, if necessary, and sends the packet with IP.dst = B.ip in an ethernet frame with Ether.dst = B.ether.

If it's not local, and it's configured with a single default gateway router, it will ARP for the router, if necessary, and then send the packet with IP.dst = B.ip in an ethernet frame with Ether.dst = R.ether. (If there's more than one router configured, it chooses one according to its own rules, usually the "most specific", but this is a question for later.)

In pseudocode, it might be

define send_packet_to(dstip, data)
    if (dstip & netmask) == (myip & netmask) then
       # it's local, send it direct
       send_etherframe_to(etheraddress_of(dstip), ...)
    else
       # it's not local, send to default gateway
       send_etherframe_to(etheraddress_of(mydefaultrouter), ...)
    end
end

define etheraddress_of(ipaddr)
    if has_cached(ipaddr) then
        return(arpcache[ipaddr])
    else
       etheraddr = arp_for_address(ipaddr) # send and receive ARP
       arpcache[ipaddr] = etheraddr
       return(etheraddr)
    end
end

(This description is what a pure IPv4/ether system is supposed to do. You will historically find all kinds of buggy implementations, including "always ARP regardless of address", but I haven't seen one of those for at least a decade.)

3
  • can you please further simplify your explanation? Jun 29, 2019 at 12:00
  • @AhmadQayyum I added some pseudocode, perhaps it helps.
    – jonathanjo
    Jun 29, 2019 at 12:13
  • thethingthat is still bugging me is that why in the presence of router the ARP will not be generated to find the MAC address for Host B but when it is replaced with switch the ARP will be generated and will also reach the Host B? Jun 29, 2019 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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