Computer Networks Essentials / Network Layer

Routing Concepts

๐Ÿค” What is Routing? (Basic Idea)

In a network, data usually does not travel directly from sender to receiver.

๐Ÿ“Œ Instead:

  • Data passes through multiple intermediate devices

  • These devices decide where to send the data next

๐Ÿ‘‰ This entire process is called Routing.


๐Ÿง  Simple Definition

๐Ÿ“Œ Routing is the process of selecting the best path for data packets to travel from source to destination across one or more networks.


๐Ÿง  Real-Life Analogy

๐Ÿš— Google Maps Example

  • You want to go from City A to City B

  • There are many roads

  • Google Maps chooses the best route

๐Ÿ“Œ Routers do the same job for data packets.


๐Ÿ“ Where Does Routing Happen?

  • Routing is performed at the Network Layer

  • Main device involved โ†’ Router

๐Ÿ“Œ Switches work inside a LAN,

๐Ÿ“Œ Routers work between networks.


๐Ÿงญ Why Routing Is Needed

Routing is needed because:

  • ๐ŸŒ Internet has millions of networks

  • ๐Ÿ“ฆ Data must cross multiple networks

  • ๐Ÿ” Multiple paths may exist

  • โšก Best path must be selected

Without routing:

  • Internet will not work โŒ

  • Inter-network communication fails โŒ


๐Ÿ“ฆ Routing vs Forwarding (Very Important Difference)

Routing

Forwarding

Decides the path

Sends packet to next hop

Control plane

Data plane

Happens less often

Happens for every packet

๐Ÿ“Œ Routing decides, forwarding delivers.


๐Ÿง  Key Components of Routing

Routing depends on:

1๏ธโƒฃ IP Address

2๏ธโƒฃ Routing Table

3๏ธโƒฃ Routing Protocols

4๏ธโƒฃ Metrics


๐Ÿ“‘ What is a Routing Table?

A Routing Table is a data structure stored in a router that contains:

  • Destination network

  • Next hop

  • Interface

  • Metric (cost)

๐Ÿ“Œ Router uses this table to forward packets correctly.


๐Ÿง  Simple Example Entry

Destination

Next Hop

Interface

192.168.2.0/24

10.0.0.2

eth0


๐Ÿงฎ What is a Metric?

A metric is a value that helps a router choose the best path.

๐Ÿ“Œ Lower metric = better path.

๐Ÿง  Common Metrics

  • Hop count

  • Bandwidth

  • Delay

  • Cost

  • Reliability


๐Ÿ” Types of Routing

Routing is broadly classified into:

1๏ธโƒฃ Static Routing

2๏ธโƒฃ Dynamic Routing

3๏ธโƒฃ Default Routing


๐Ÿ“Œ 1. Static Routing

๐Ÿ”น What is Static Routing?

Routes are manually configured by the network administrator.

๐Ÿ“Œ Router does not change routes automatically.

  • Simple

  • Secure

  • No overhead

  • Not scalable

  • Manual updates required

  • Not suitable for large networks

๐Ÿ“Œ Used in small or stable networks.


๐Ÿ”„ 2. Dynamic Routing

๐Ÿ”น What is Dynamic Routing?

Routers automatically learn and update routes using routing protocols.

๐Ÿ“Œ Adapts to network changes.

๐Ÿง  Examples of Routing Protocols

  • RIP

  • OSPF

  • BGP

  • Scalable

  • Automatic updates

  • Fault tolerant

  • Complex

  • Uses bandwidth

  • More CPU & memory

๐Ÿ“Œ Used in medium & large networks.


๐Ÿšช 3. Default Routing

๐Ÿ”น What is Default Routing?

Used when:

  • No specific route is found

  • Packet is sent to a default gateway

๐Ÿ“Œ Example:

0.0.0.0/0

๐Ÿง  Real-Life Example

If you donโ€™t know the address โ†’ go to main post office.


๐Ÿง  Routing Protocol Categories

๐Ÿ”น Interior Gateway Protocols (IGP)

  • Used within an organization

  • Examples: RIP, OSPF

๐Ÿ”น Exterior Gateway Protocols (EGP)

  • Used between organizations

  • Example: BGP


๐Ÿงญ Distance Vector vs Link State (Concept Only)

Feature

Distance Vector

Link State

Knowledge

Neighbor info

Full topology

Speed

Slow

Fast

Example

RIP

OSPF

๐Ÿ“Œ Detailed algorithms come next.


๐Ÿ”„ Routing Loop (Common Problem)

A routing loop occurs when:

  • Packet circulates endlessly

  • Never reaches destination

๐Ÿ“Œ Caused by:

  • Incorrect routing tables

  • Slow convergence

๐Ÿ‘‰ Solved using routing algorithms.


๐Ÿง  Routing Process (Step-by-Step)

1๏ธโƒฃ Packet arrives at router

2๏ธโƒฃ Router checks destination IP

3๏ธโƒฃ Looks into routing table

4๏ธโƒฃ Selects best route

5๏ธโƒฃ Forwards packet to next hop


โญ Advantages of Routing

  • Efficient data delivery

  • Supports large networks

  • Fault tolerance

  • Enables Internet communication


โญ One-Line Summary

๐Ÿ”น Routing enables data packets to travel across multiple networks by selecting the best possible path.