1

I am not sure about the ARP protocol.

An example network is shown below:

example network

I want to send a message from A to B, the ARP protocol will work:

  • First A will sent the MAC address of R1 and the B IP
  • Then R1 will communicate with R3, and R1 sends the R3 MAC address but also send B's IP.
  • After this R3 communicate with R4, R3 sends R4 MAC address but B's IP
  • In the end the package arrives in B.

  • Is my logic correct?
  • Is this how it works when I have to change more than 2 nodes?
  • Also if this works like this, how does the previous node know the MAC address of the next node?

3 Answers 3

0

You're confusing two things - ARP and Routing.

ARP

ARP (Address Resolution Protocol) is used to identify the hardware address of a host on the local network (i.e: the same subnet).

If A (IP 10.0.1.2/24) wanted to communicate with another host (C) with IP address 10.0.1.5, then the following happens if this host in not in the cache:

  1. A broadcasts an "ARP Request"
    • Using the broadcast MAC Address (ff:ff:ff:ff:ff:ff)
    • Asking for any host with the IP Address 10.0.1.5 to respond
  2. If the remote host (C) receives this packet, then it responds with it's correct MAC Address.

ARP can also occur pro-actively, with hosts "announcing" themselves in an attempt to reduce the latency incurred by the lookup, though this can easily lead to spoofing and poisoning.

Routing

Routing allows a host to access other hosts that are outside the "local" network. For example host B has an IP address of 10.0.5.2, which is outside host A's 10.0.1.0/24 subnet.

In order to get packets to host B, host A must send them via a router (aka "gateway"). If no default route is given (or no matching specific route is configured), then the host is unreachable.

If a route does exist, then A will:

  1. Use ARP to locate the router's (R1) MAC address
  2. Send a packet addressed to B's IP (10.0.5.2), but using router R1's MAC address
  3. Router R1 will perform the same lookup, sending a packet to the MAC address of R3 (or R2), but with the IP address of B.
  4. This continues until the packet reaches B, or until a router declares that it is unable to route to the given host.

If this works like this, how does the previous node know the MAC address of the next node?

ARP is used at each step to get the MAC address of the next host. R1 wants to forward a packet via R3, so it uses ARP to get R3's MAC address.

3

The ARP protocol is only used to discover the MAC address associated with the IPv4 address of a host on the local link.

In you example, when host A wants to send a message to host B, it sends it to the appropriate router for delivery. Which router is chosen depends on the routing table on host A. The router is on the same link as host A, and to send the message to the router host A needs the MAC address of router R1. If host A can't find the MAC address of router R1 in its ARP cache, it uses the ARP protocol to find out the MAC address of router R1. Once the MAC address is known, the packet can be sent.

Once router R1 has received the message, it repeats what host A did: it consults its routing table, selects the next hop router (say R3). If R1 does not know the MAC address R3, it uses the ARP protocol to find out. Once it has the MAC address of R3, it uses it to send the message to R3.

This repeats until the message reaches the destination host B (or some error occurs).

0

Basically, some node X will send an ARP request whenever it has an IP address for some node Y, but doesn't know the MAC address of Y. In that case, the node Y with this IP address will respond with its own MAC address.

These assignments are cached on each host, and new messages are only sent if the information can't be found in the cache.

So there's no fixed order of messages when A wants to communicate with B; it will depend on what communication has happened before.

Also note that since you have different LAN segments between nodes, each node will ask for the IP address of the next node ("next hop"), and not of the IP address of B. So you need proper routing tables for all this to work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .