Direct routing can also be thought of as packet delivery; it is the process of passing a packet from one device to another within a subnetwork. Direct routing occurs when the source and destination of a packet share a common subnetwork. Every packet must eventually be directly routed because some device (perhaps a router) is eventually going to recognize that the destination is on a directly attached network and deliver the packet.
The visual shows an example of two hosts between which packets can be directly routed. Assuming a subnet mask of 255.255.0.0, the subnetwork depicted has the network address 184.108.40.206. If Host A generates a packet for Host B, it can be delivered immediately by transmitting it across the subnetwork. Host A determines that this packet can be directly routed by extracting the network address from the destination IP address, comparing it to its own, and finding a match.
However, in order for Host A to deliver the packet to Host B, the packet must be encapsulated within an appropriate Layer 2 frame. If the underlying Layer 2 protocol is Ethernet, then Host A must place the packet within an Ethernet frame addressed to Host B’s network interface card. This implies that Host A must know (or learn) Host B’s Media Access Control (MAC) address.
Direct Routing and ARP
Direct routing always involves transmission across the underlying network. However, this raises a problem. The TCP/IP software in the network identifies a host or router in the internetwork by its IP (or Network Layer) address. However, communication actually occurs by placing the packet in a frame (Data Link Layer) and transmitting it across the physical network (e.g., a LAN, a point-to-point link, or a WAN). Consider the case of a packet moving between two hosts attached to the same Ethernet. The source host knows the IP address of the destination host, but the packet must actually travel in an Ethernet frame. How does the source host know the Media Access Control (MAC) address of the destination host?
A packet traveling across several networks is encapsulated in a different frame for each network it crosses. If the source network is an Ethernet, the source host must place the packet in an Ethernet frame addressed to a router. If the router determines that the packet is to cross a token ring next, it must place the packet in a token ring frame addressed to the next router on the path (or possibly to the end system if the packet has arrived at its destination network). IP defines a routing algorithm by which the IP address of the intervening routers can be identified, but that IP address needs to be mapped to the corresponding Data Link Layer address. This is handled by the Address Resolution Protocol (ARP).