routeprotocol.com

Layer 3 Forwarding

Layer 3 forwarding can be broken down into two types:

  • Forwarding traffic to devices within the same subnet
  • Forwarding traffic to devices on a different subnet

Forwarding to devices within the same subnet

Two devices that wish to communicate on the same subnet can do so locally. As the source device begins to form the network packets to send the data, it needs to fill in the missing headers, one of the important headers that are required for forwarding is a destination MAC address. In order to find out this destination MAC address the host needs to use a protocol called Address Resolution Protocol or ARP.

The ARP table provides a mapping of IP addresses in Layer 3 to MAC addresses in Layer 2 in a device. A sending device can use this ARP table to add the required Layer 2 destination MAC headers to network packets before sending it on the Layer 2 patch for processing and forwarding.

The ARP table will contain entiries for hosts that the source has communicated with recently and are on the same IP subnet. Devices on remote networks are not stored in the ARP table but the default gateway of the local devices subnet is stored within ARP.

In order to fill the ARP table, the local device broadcasts an ARP request to the entire local layer 2 subnet. The source device will request that the device that owns the IP address in the ARP request replies with it’s MAC addresss. Whilst all devices recieve this ARP request, only the device with it’s IP address in the packet should reply.

The response to the ARP request is not a broadcast and sent only to the requesters address.

The ARP table can be viewed with the comamnd show ip arp

Forwarding to devices on a different subnet

Packets will need to be routed via a router when two devices are on seperate networks. As the source device is preparing the network packet to be sent it will detect that its destination network is on a different subnet, this can be dealt with in a few ways:

  • A static route entry on the local device will inform where the packet needs to be sent in order to reach the destination network
  • A default gateway will inform the device where to forward all non local network traffic.
  • Routes for traffic can be dynamically learned via routing protocols.

The local device will need to add the required Layer 2 headers in order to reach the destination IP address, it works a little bit differently when traversing to a seperate subnet. The destination MAC addres will be set to that of the next-hop IP address rather then the destination IP address.

The next-hop device (a router or multi layer switch) will recieve this packet and update the destination MAC address again with ethier the destination IP device if it has access to its network, or it’s next-hop router or multilayer switches MAC address.


by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.