Computer Network - Network Layer Routing

Network Layer Routing (Full Explanation)


When a device has several routes to a destination, it always chooses one path, favoring it over the others. This process is known as Routing. Routing can be performed by specialized network devices called routers, or it can be executed through software processes. However, software-based routers have limited capabilities and scope.

A router is typically set up with a default route. This default route indicates where the router should send a packet if no specific route is available for the destination. If multiple paths exist to the same destination, the router can make decisions based on the following criteria:

- Hop Count
- Bandwidth
- Metric
- Prefix-length
- Delay

Routes can either be statically configured or dynamically learned. One route can be designated as preferred over others.

Unicast Routing

Unicast Routing Poster


Most of the traffic on the internet and intranets, referred to as unicast data or unicast traffic, is directed to a specified destination. Routing unicast data over the internet is termed unicast routing. This is the most straightforward form of routing since the destination is already known. Therefore, the router simply needs to consult the routing table and forward the packet to the next hop.

Broadcast Routing

By default, routers do not route or forward broadcast packets on any network. They create broadcast domains. However, it can be configured to forward broadcasts in certain special situations. A broadcast message is intended for all devices on the network.

Broadcast routing can be accomplished in two ways (algorithms):

1. A router generates a data packet and sends it to each host individually. In this scenario, the router creates multiple copies of a single data packet, each with different destination addresses. All packets are sent as unicast, but since they are directed to everyone, it mimics broadcasting.

This method consumes a significant amount of bandwidth, and the router must know the destination address of each node.

2. Secondly, when a router gets a packet intended for broadcasting, it simply sends those packets out through all its interfaces. All routers are set up in the same manner.

This approach is light on the router's CPU but can lead to the issue of duplicate packets being received from neighboring routers.

Reverse path forwarding is a method where the router is aware in advance of its predecessor from which it should expect to receive broadcasts. This technique helps in identifying and eliminating duplicates.

Multicast Routing

Multicast routing is a specific type of broadcast routing that comes with distinct differences and challenges. In broadcast routing, packets are dispatched to all nodes, regardless of whether they want them. In contrast, multicast routing sends data only to those nodes that have expressed a desire to receive the packets.

The router must be aware of the nodes that wish to receive multicast packets (or streams) before it forwards them. Multicast routing employs the spanning tree protocol to prevent looping.

Additionally, multicast routing utilizes the reverse path forwarding technique to identify and eliminate duplicates and loops.

Anycast Routing

Anycast packet forwarding is a method where multiple hosts can share the same logical address. When a packet is directed to this logical address, it is sent to the host that is closest in the routing topology.

Anycast routing is facilitated by a DNS server. When an Anycast packet is received, the DNS is consulted to determine where to send it. The DNS provides the IP address of the nearest configured host.

Unicast Routing Protocols

There are two types of routing protocols available for routing unicast packets:

Distance Vector Routing Protocol

Distance Vector is a straightforward routing protocol that makes routing decisions based on the number of hops between the source and destination. A route with fewer hops is deemed the best route. Each router shares its best routes with other routers, allowing all routers to construct their network topology based on the information received from their peers.

For instance, the Routing Information Protocol (RIP).

Link State Routing Protocol

Link State protocol is a bit more complex than Distance Vector. It considers the states of links from all routers within a network. This method enables routers to construct a unified graph of the entire network. Subsequently, all routers determine their optimal routing paths. Examples include Open Shortest Path First (OSPF) and Intermediate System to Intermediate System (ISIS).

Multicast Routing Protocols

While unicast routing protocols utilize graphs, multicast routing protocols employ trees, specifically spanning trees, to prevent loops. The most efficient tree is referred to as the shortest path spanning tree.

  • DVMRP  - Distance Vector Multicast Routing Protocol
  • MOSPF  - Multicast Open Shortest Path First
  • CBT  - Core Based Tree
  • PIM  - Protocol Independent Multicast

Protocol Independent Multicast is widely used today. It comes in two variations:

- PIM Dense Mode
This mode relies on source-based trees and is suitable for dense environments like LANs.

- PIM Sparse Mode
This mode utilizes shared trees and is appropriate for sparse environments such as WANs.

Routing Algorithms

The routing algorithms include:

Flooding

Flooding is the simplest method for packet forwarding. Upon receiving a packet, routers transmit it to all interfaces except the one it was received on. This can overload the network and result in numerous duplicate packets circulating.

To prevent infinite packet looping, Time to Live (TTL) can be implemented. An alternative method known as Selective Flooding exists to minimize network overhead. In this approach, the router selectively floods only certain interfaces rather than all.

Shortest Path

Routing decisions in networks are primarily based on the cost between the source and destination, with hop count being a significant factor. The shortest path technique employs various algorithms to identify a route with the least number of hops.

Common shortest path algorithms include:

  • Dijkstra's algorithm
  • Bellman Ford algorithm
  • Floyd Warshall algorithm