UNIT III
ROUTING
Forwarding of IP Packets — Static and Default Routing — Unicast Routing Algorithms: Distance
Vector Routing, Link State Routing, Path Vector Routing — Protocols: RIP V1, RIP V2, OSPF, BGP,
EIGRP — Multicasting Basics — IPV6 Addressing Basics
ROUTING
Routing refers to the process of directing a data packet from one node to
another.
Note: The node here refers to a network device called - 'Router'.
Routing is a crucial mechanism that transmits data from one location to
another across a network
(Network type could be any like LAN, WAN, or MAN).
It involves making various routing decisions
To ensure reliable & efficient delivery of the data packet by finding the
shortest path using various routing metrics.
Routing of a data packet is done by analyzing the destination IP Address of
the packet. Look at the below image:
PACKET FORWARDING
The process of packet forwarding is the process the forwarding of incoming
packets to their intended destination.
Internet is made up of generally two terms- Interconnection and Network.
A packet that is to be forwarded may be associated with the same network
as the source host or may belong to a destination host in a different
network.
The router is responsible for the process of packet forwarding.
It accepts the packet from the origin host or another router in the packet's path
and places it on the route leading to the target host.
The routing table is maintained by the router which is used for deciding the
packet forwarding.
PACKET FORWARDING IN ROUTER:
Routers are used on the network for forwarding a packet from the local network
to the remote network. So, the process of routing involves the packet
forwarding from an entry interface out to an exit interface.
WORKING:
The following steps are included in the packet forwarding in the router-
The router takes the arriving packet from an entry interface and then
forwards that packet to another interface.
The router needs to select the best possible interface for the packet to reach
the intended destination as there exist multiple interfaces in the router.
The forwarding decision is made by the router based on routing table entries.
The entries in the routing table comprise destination networks and exit
interfaces to which the packet is to be forwarded.
The selection of exit interface relies on
Firstly, the interface must lead to the target network to which the
packet is intended to send.
Secondly, it must be the best possible path leading to the destination
network.
PACKET FORWARDING TECHNIQUES:
Following are the packet forwarding techniques based on the destination host:
Next-Hop Method: By only maintaining the details of the next hop or next
router in the packet's path, the next-hop approach reduces the size of the
routing table.
Network-Specific Method: In this method, the entries are not made for all of
the destination hosts in the router's network. Rather, the entry is made of the
destination networks that are connected to the router.
Host-Specific Method: In this method, the routing table has the entries for all
of the destination hosts in the destination network. With the increase in the size
of the routing table, the efficiency of the routing table decreases. It finds its
application in the process of verification of route and security purposes.
Default Method: Let's assume- A host in network N1 is connected to two
routers, one of which (router R1) is connected to network N2 and the other
router R2 to the rest of the internet. As a result, the routing table only has one
default entry for the router R2.
TYPES OF ROUTING ALGORITHM
Routing is typically of 3 types, each serving its purpose and offering
different functionalities.
STATIC ROUTING-(NON-ADAPTIVE ALGORITHMS)
Static routing is also called as "non-adaptive routing". In this, routing
configuration is done manually by the network administrator.
A network administrator has full control over the network, routing the data
packets to their concerned destinations
Routers will route packets to the destination configured manually by the
network administrator.
Although this type of routing gives fine-grained control over the routes, it may
not be suitable for large-scale enterprise networks.
DYNAMIC ROUTING (ADAPTIVE ALGORITHMS)
Dynamic Routing is another type of routing in which routing is an autonomous
procedure without any human intervention. Packets are transmitted over a
network using various shortest-path algorithms and pre-determined metrics. This
type of routing is majorly preferred in modern networks as it offers more
flexibility and versatile functionality.
It is also known as adaptive routing.
In this, the router adds new routes to the routing table based on any changes
made in the topology of the network.
The autonomous procedure of routing helps in automating every routing
operation from adding to removing a route upon updates or any changes made
to the network.
DEFAULT ROUTING (Hybrid Algorithms)
Default Routing is a routing technique in which a router is configured to
transmit packets to a default route that is, a gateway or next-hop device if no
specific path is defined or found. It is commonly used when the network has a
single exit point. The IP Router has the following address as the default route:
[Link]/0.
WORKING PRINCIPLE OF ROUTING
Routing works by finding the shortest path from the source node to the
destination node across a network. Here's the step-by-step working of routing:
STEP 1: COMMUNICATION INITIATION
The first step that typically happens is, one node (client or server) initiates a
communication across a network using HTTP protocols.
STEP 2: DATA PACKETS
The source device now breaks a big chunk of information into small data
packets for reliable and efficient transmission. This process is called de-assembling
and encapsulating the data payload. Then each data packet is labeled with the
destination node's IP address.
STEP 3: ROUTING TABLE
The Routing table is a logical data structure used to store the IP addresses and
relevant information regarding the nearest routers. The source node then looks up
the IP addresses of all the nodes that can transmit the packet to its destination
selects the shortest path using the shortest path algorithm and then routes
accordingly.
The Routing Table is stored in a router, a network device that determines the
shortest path and routes the data packet.
STEP 4: HOPPING PROCEDURE
In the procedure or routing, the data packet will undergo many hops across
various nodes in a network till it reaches its final destination node. Hop count is
defined as the number of nodes required to traverse through to finally reach the
intended destination node.
This hopping procedure has certain criteria defined for every data packet, there's
a limited number of hops a packet can take if the packet exceeds that, then it's
considered to be lost and is retransmitted.
STEP 5: REACHING THE DESTINATION NODE
Once all the data packets reach their intended destination node, they re-assemble
and transform into complete information that was sent by the sender (source node).
The receiver will perform various error-checking mechanisms to verify the
authenticity of the data packets.
Overall, the data packet will be transmitted over the least hop-count path as well
as the path on which there is less traffic to prevent packet loss.
UNICAST ROUTING
Unicast means the transmission from a single sender to a single receiver. It is a
point-to-point communication between the sender and receiver. There are various
unicast protocols such as TCP, HTTP, etc.
TCP (Transmission Control Protocol) is the most commonly used unicast protocol. It is a
connection-oriented protocol that relies on acknowledgment from the receiver side.
HTTP stands for HyperText Transfer Protocol. It is an object-oriented protocol for
communication.
DISTANCE VECTOR ROUTING ALGORITHM
The protocol requires that a router inform its neighbors of topology changes
periodically. Historically known as the old ARPANET routing algorithm (or
known as the Bellman-Ford algorithm).
BELLMAN-FORD BASICS
Each router maintains a Distance Vector table containing the distance between
itself and All possible destination nodes. Distances, based on a chosen metric, are
computed using information from the neighbors' distance vectors.
Information kept by DV router:
Each router has an ID
Associated with each link connected to a router,
there is a link cost (static or dynamic).
Intermediate hops
Distance Vector Table Initialization:
Distance to itself = 0
Distance to ALL other routers = infinity number.
DISTANCE VECTOR ALGORITHM WORKING
A router transmits its distance vector to each of its neighbors in a routing
packet.
Each router receives and saves the most recently received distance vector from
each of its neighbors.
A router recalculates its distance vector when:
o It receives a distance vector from a neighbor containing different
information than before.
o It discovers that a link to a neighbor has gone down.
The DV calculation is based on minimizing the cost to each destination
Dx(y) = Estimate of least cost from x to y
C(x,v) = Node x knows cost to each neighbor v
Dx = [Dx(y): y ? N ] = Node x maintains distance vector
Node x also maintains its neighbors' distance vectors
– For each neighbor v, x maintains Dv = [Dv(y): y ? N ]
Note:
From time-to-time, each node sends its own distance vector estimate to
neighbors.
When a node x receives new DV estimate from any neighbor v, it saves v’s
distance vector and it updates its own DV using B-F equation:
Dx(y) = min { C(x,v) + Dv(y), Dx(y) } for each node y ? N
EXAMPLE:
Consider 3-routers X, Y and Z as shown in figure. Each router has their routing
table. Every routing table will contain distance to the destination nodes.
Consider router X , X will share it routing table to neighbors and neighbors will
share it routing table to it to X and distance from node X to destination will be
calculated using bellmen- ford equation.
Dx(y) = min { C(x,v) + Dv(y)} for each node y ? N
As we can see that distance will be less going from X to Z when Y is
intermediate node (hop) so it will be update in routing table X.
Similarly for Z also -
Finally the routing table for all -
APPLICATIONS OF DISTANCE VECTOR ROUTING ALGORITHM
The Distance Vector Routing Algorithm has several uses:
Computer Networking: It helps route data packets in networks.
Telephone Systems: It's used in some telephone switching systems.
Military Applications: It has been used to route missiles.
ADVANTAGES OF DISTANCE VECTOR ROUTING
Shortest Path : Distance Vector Routing finds the shortest path for data to
travel in a network.
Usage : It is used in local, metropolitan, and wide-area networks.
Easy Implementation : The method is simple to set up and doesn't require
many resources.
DISADVANTAGES OF DISTANCE VECTOR ROUTING ALGORITHM
It is slower to converge than link state.
It is at risk from the count-to-infinity problem.
It creates more traffic than link state since a hop count change must be
propagated to all routers and processed on each router. Hop count updates take
place on a periodic basis, even if there are no changes in the network topology ,
so bandwidth -wasting broadcasts still occur.
For larger networks, distance vector routing results in larger routing tables than
link state since each router must know about all other routers. This can also lead
to congestion on WAN links.
CONCLUSION
In conclusion, Distance Vector Routing (DVR) Protocol is a simple and
efficient method for finding the shortest path for data in various types of
networks. Its ease of implementation and quick adjustment to network changes
make it a valuable tool for ensuring data travels quickly and efficiently. DVR
Protocol helps maintain smooth network operations by constantly updating and
optimizing routes.
DIJKSTRA'S ALGORITHM
Dijkstra’s Algorithm was introduced by Dutch computer scientist Edsger
W. Dijkstra in 1956.
It is one of the most popular algorithms in graph theory, used to find
the shortest path from a single source to all other vertices in a graph with
non-negative edge weights.
The algorithm works by maintaining a set of visited and unvisited vertices.
Starting from the source it repeatedly picks the vertex with the smallest
tentative distance, updates the distances of its neighbours and continues
until all vertices are processed or the destination is reached.
TYPES OF GRAPH
In a directed graph
Undirected graph.
ALGORITHM STEPS
1. Mark the source node with a current distance of 0 and the rest with
infinity.
2. Set the non-visited node with the smallest current distance as the
current node.
3. For each neighbor, N of the current node adds the current distance of
the adjacent node with the weight of the edge connecting 0->1. If it is
smaller than the current distance of Node, set it as the new current
distance of N.
4. Mark the current node 1 as visited.
5. Go to step 2 if there are any nodes are unvisited.
DIJKSTRA'S ALGORITHM WORKING
Dijkstra's Algorithm working with an example :
Dijkstra's Algorithm will generate the shortest path from Node 0 to all
other Nodes in the graph.
Consider the below graph:
The algorithm will generate the shortest path from node 0 to all the other
nodes in the graph.
For this graph, we will assume that the weight of the edges represents the
distance between two nodes.
Initially we have:
The Distance from the source node to itself is 0. In this example the source
node is 0.
The distance from the source node to all other node is unknown so we mark
all of them as infinity.
Example: 0 -> 0, 1-> ∞,2-> ∞,3-> ∞,4-> ∞,5-> ∞,6-> ∞.
We will also have an array of unvisited elements that will keep track of
unvisited or unmarked Nodes.
Algorithm will complete when all the nodes marked as visited and the distance
between them added to the path. Unvisited Nodes:- 0 1 2 3 4 5 6.
STEP 1: Start from Node 0 and mark Node as visited as you can check in
below image visited Node is marked red.
STEP 2: Check for adjacent Nodes, Now we have to choices (Either choose
Node1 with distance 2 or either choose Node 2 with distance 6 ) and choose
Node with minimum distance. In this step Node 1 is Minimum distance adjacent
Node, so marked it as visited and add up the distance.
Distance: Node 0 -> Node 1 = 2
STEP 3: Then Move Forward and check for adjacent Node which is Node 3, so
marked it as visited and add up the distance, Now the distance will be:
Distance: Node 0 -> Node 1 -> Node 3 = 2 + 5 = 7
STEP 4: Again we have two choices for adjacent Nodes (Either we can choose
Node 4 with distance 10 or either we can choose Node 5 with distance 15) so
choose Node with minimum distance. In this step Node 4 is Minimum distance
adjacent Node, so marked it as visited and add up the distance.
Distance: Node 0 -> Node 1 -> Node 3 -> Node 4 = 2 + 5 + 10 = 17
STEP 5: Again, Move Forward and check for adjacent Node which is Node 6, so
marked it as visited and add up the distance, Now the distance will be:
Distance: Node 0 -> Node 1 -> Node 3 -> Node 4 -> Node 6 = 2 + 5 + 10 + 2 =
19
So, the Shortest Distance from the Source Vertex is 19 which is optimal one
CONCLUSION:
Dijkstra's algorithm is a powerful method for finding the shortest path from a
source node to all other nodes in a weighted graph with non-negative edge
weights. It works by iteratively selecting the unvisited node with the smallest
distance, exploring its neighbors, and updating their distances if a shorter path is
found through the selected node. The algorithm is widely used in practical
applications like GPS navigation, network routing, and resource allocation,
proving to be a fundamental and efficient tool for solving real-world shortest path
problems.
PATH VECTOR ROUTING (PVR)
Path-vector routing is an asynchronous and distributed routing algorithm.
The Path-vector routing is not based on least-cost routing.
The best route is determined by the source using the policy it imposes on the
route.
In other words, the source can control the path.
Path-vector routing is not actually used in an internet, and is mostly designed
to route a packet between ISPs.
SPANNING TREES
Example:
The Figure below shows as mall internet with only five nodes.
Each source has created its own spanning tree that meets its policy.
The policy imposed by all sources is to use the minimum number of nodes to
reach a destination.
The spanning tree selected by A and E is such that the communication does not
pass through D as a middle node.
Similarly, the spanning tree selected by B is such that the communication does
not pass through C as a middle node
PATH VECTORS MADE AT BOOTING TIME
The Figure below shows all of these path vectors for the example.
Not all of these tables are created simultaneously.
They are created when each node is booted.
The figure also shows these path vectors are sent to immediate neighbors after they
have been created.
UPDATING PATH VECTORS
The Figure below shows the path vector of node C after two events.
In the first event, node C receives a copy of B’s vector, which improves its
vector: now it knows how to reach node A.
In the second event, node C receives a copy of D’s vector, which does not
change its vector.
The vector for node C after the first event is stabilized and serves as its
forwarding table.
CONCLUSION
A spanning tree is a minimally connected sub-graph of a connected,
undirected graph that includes all vertices with no cycles, containing a fixed
number of edges (N-1 for N vertices). Its key conclusions are to provide a path to
all nodes with the minimum number of edges for a given graph, ensuring
connectivity while preventing loops that disrupt network stability. This
algorithm has widespread applications in network design, telecommunications,
and transportation.