Unit 3
Unit 3
( KCS-603 )
Routing
Routin
Routing is a process of selecting g
path along which the data can be transferred from
source to the destination. Routing is performed by a special device known as a router.
Router is a networking device that forwards the packet based on the information
available in the packet header and forwarding table. A Router works at the network
layer in the OSI model and internet layer in TCP/IP model.
Routing Algorithms are used for routing the packets. Routing algorithm initializes and
maintains the routing table for the process of path determination.
Routing Algorithms use the metric to determine the best path for the packet delivery.
The metric is the standard of measurement such as hop count, bandwidth, delay,
current load on the path etc. used by the routing algorithm to determine the optimal
path to the destination.
Desirable properties of a Routing
Algorithm
Correctness: The routing should be done properly and correctly so that the packets may reach their proper
destination.
Simplicity: The routing should be done in a simple manner so that the overhead is as low as possible. With
increasing complexity of the routing algorithms the overhead also increases.
Robustness: Once a major network becomes operative, it may be expected to run continuously for years
without any failures. The algorithms designed for routing should be robust enough to handle hardware and
software failures.
Stability: The routing algorithms should be stable under all possible circumstances.
Fairness: Every node connected to the network should get a fair chance of transmitting their packets. This is
generally done on a first come first serve basis.
Optimality: The routing algorithms should be optimal in terms of throughput and minimizing mean packet
delays.
Design Parameters of a Routing
Algorithm
Performance Criteria: Number of hops, Cost, Delay, Throughput, etc.
Decision Time: Per packet basis (Datagram) or per session (Virtual-circuit) basis
Decision Place: Each node (distributed), Central node (centralized), Originated node (source)
Network Information Source: None, Local, Adjacent node, Nodes along route, All nodes
Network Information Update Timing: Continuous, Periodic, Major load change, Topology
change
Classification of a Routing
Algorithm
Multi-path routing algorithms learn routes and can select more than one path to a destination. These
protocols are better for performing load balancing.
Flat vs Hierarchical
Routing
Flat routing algorithm propagates all routing information throughout the network.
Hierarchical routing algorithm divides large networks into smaller areas for routing.
Inter-domain (between domains) is any routing protocols that you have setup between two
different networks. These are usually called Autonomous Systems (AS). The main inter-domain
protocol is BGP. Most of the time when talking about inter-domain is routing on the internet.
Autonomous
Systems
Interdomain
Intradomain routing
routing
An autonomous system (AS) is a group of networks and routers under the authority of a single
administration.
An internet or a bigger collection of networks can be so large, one routing protocol cannot
handle the task of updating routing tables of all routers. So, internet or a bigger collection of
networks is divided into autonomous systems.
Unicast
Routing
Most of the traffic on the network known as unicast data or unicast traffic is
sent with specified destination. Routing unicast data over the internet is called
unicast routing. It is the simplest form of routing because the destination is
already known.
Hence the router just has to look up the routing table and forward the packet
to
next hop.
Shortest Path
Routing
Flooding
Flow Based Routing
Shortest Path
Routing
Algorithm of Dijkstra: shortest path in graph
Several algorithms ( like Dijkstra Shortest Path Algorithm ) are available for computing the shortest path
between two nodes of a graph.
In Dijkstra Shortest Path Algorithm, each node is labeled with its distance from the source node along
the best known path. Initially, no paths are known, so all nodes are labeled with infinity. As the algorithm
proceeds and paths are found, the labels may change, reflecting better paths. A label may be either
tentative or permanent. Initially, all labels are tentative. When it is discovered that a label represents the
shortest possible path from the source to that node, it is made permanent and never changed
thereafter.
Graph Metric
• Node = router • Number of hops
• Edge = communication line • Geographic distance
• Mean queueing
• Transmission delay
Shortest Path Routing
(contd.)
Initial node
Elements of algorithm:
• Mark all nodes as free:
• Mark initial node as selected: ⚫
• repeat till destination is selected:
• Label all free nodes reachable from selected nodes with shortest
distance to a selected node
• Select free node with shortest distance to a selected node and
mark it as selected
Shortest Path Routing
(contd.)
Flooding obviously generates vast numbers of duplicate packets, in fact, an infinite number unless
some
measures are taken to damp the process.
One such measure is to have a hop counter contained in the header of each packet, which is
decremented at each hop, with the packet being discarded when the counter reaches zero.
Another technique is to keep the track of the packed that have been flooded, to avoid sending them a
second time. For this, the source router put a sequence number in each packet it receives from its
hosts.
A variation of flooding that is slightly more practical is selective flooding. In this algorithm the routers
do not send every incoming packet out on every line, only on those lines that are going
approximately in the right direction.
Flow Based
Routing
This is a static algorithm which uses topology and load condition
(traffic) for deciding a route.
To use this algorithm, following information should be known in advance -
o Subnet Topology
o Traffic Matrix
o Line Capacity Matrix
For example, If there is always a huge amount of traffic from A to B in figure above, then it
may be better to route traffic from A to C via AGEFC, even though this path is much longer
than ABC.
Dynamic /
Adaptive Routing
Algorithms
Distance Vector
Routing
Distance Vector Algorithm (based on Bellman-Ford algorithm)
is a Adaptive / Dynamic algorithm.
Key features:
o In Distance Vector Routing Algorithm, each node shares its
routes in the network only to the neighbors and does not
broadcast it. (not to all)
o Whenever any node receives the Routing Information it updates
its own routing table and inform to its neighbors.
Distance Vector Routing
(contd.)
Algorithm
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.
The DV ( Distance Vector ) calculation is based on minimizing the cost to each destination
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.
Distance Vector Routing
(contd.)
Routing Table for
AT cost via
o
A 0 -
B 12 B
C 25 B
D 40 B
E 14 E
F 23 E
G 18 B
H 17 J
I 21 E
J 9 J
K 24 J
L 29 J
Distance Vector Routing
(contd.)
Drawback of Distance Vector Algorithm
Count to Infinity Problem
The main issue with Distance Vector Routing (DVR) protocols is Routing Loops, since
Bellman-Ford Algorithm cannot prevent loops. This routing loop in Distance Vector
routing network causes Count to Infinity Problem. Routing loops usually occur when
any interface goes down or two-routers send updates at the same time.
How fast are changes propagated?
• Good news?
• Bad news?
Distance Vector Routing
(contd.) Count to Infinity Problem
How fast are changes propagated?
From the previous figure, it should be clear why bad news travels slowly: no router ever has a value more than one higher
than the minimum of all its neighbors. Gradually, all routers work their way up to infinity, but the number of exchanges
required depends on the numerical value used for infinity. For this reason, it is wise to set infinity to the longest path
plus 1.
If the metric is time delay, there is no well-defined upper bound, so a high value is needed to prevent a path with a long
delay from being treated as down. Not entirely surprisingly, this problem is known as the count-to-infinity problem.
Link State
Routing
Key Features:
The routers share the knowledge only about their neighbors compared to all
the routers in the autonomous system.
Sharing of information takes place only with all the routers in the network, by
sending small updates using flooding compared to sending larger updates to
their neighbors
Sharing of information takes place only when there is a change, which leads to
lesser internet traffic compared to distance vector routing.
Link State Routing
(contd.)
Overview of algorithm:
4
Link State Routing
(contd.)
2) Measuring Line Cost
The link state routing algorithm requires each router to know, or at
least have a reasonable estimate of, the delay to each of its
neighbors. The most direct way to determine this delay is to send
over the line a special ECHO packet that the other side is required
to send back immediately. By measuring the round-trip time and
dividing it by two, the sending router can get a reasonable
estimate of the delay. For even better results, the test can be
conducted several times, and the average used.
5
Link State Routing
(contd.)
3) Building link state packets
o When to build?
o Packet containing:
• periodically
• Identity of sender
• when significant events occur
• Sequence number + age
• For each neighbour: name +
distance
Link State Routing
4)
(contd.)
Distributing link state packets
o Trickiest part of algorithm
• Arrival time for packets different
• How to keep consistent routing tables
o Basic algorithm
• Flooding + Sequence number (in each packet) to limit
duplicates
o Manageable problems
• Wrap around of sequence numbers:
• Wrong sequence number used:
– lost in case of crash
– Corruption
o Refinements
• Link state packets are not forwarded immediately
• During holding time:
– duplicates are discarded
– Old packets are thrown out
Packet buffer for router B
Link State Routing o ACK flag: ACK to send
o Send flag: packet to forward
(contd.)
a. Retransmission Policy
b. Window Policy
The type of window at the sender may also affect congestion. The Selective
Repeat window is better than the Go-Back-N window for congestion control.
c. Acknowledgment Policy
The acknowledgment policy imposed by the receiver may also affect congestion.
If the receiver does not acknowledge every packet it receives, it may slow down
the sender and help prevent congestion.
d. Discarding Policy
A good discarding policy by the routers may prevent congestion and at the same
time may not harm the integrity of the transmission. For example, in audio
transmission, if the policy is to discard less sensitive packets when congestion is
likely to happen, the quality of sound is still preserved and congestion is prevented
or alleviated.
e. Admission Policy
FIFO queue
Priority
queuing
Weighted fair queuing
Traffic Shaping
Leaky bucket
Leaky bucket implementation
Note
Solution
We replace each group of 8 bits with its equivalent decimal number
and add dots for separation.
Change the following
GraphicalIPv4 addresses from
dotted- decimal notation to binary notation.
Illustration
Solution
We replace each decimal number with its binary equivalent.
• Find the error, if any, in the following IPv4
addresses.
Solution
a. There must be no leading zero (045).
b. There can be no more than four numbers.
c. Each number needs to be less than or equal to 255.
d. A mixture of binary and dotted-decimal
notation notation is not allowed.
In classful addressing, the address space is divided into five
classes: A, B, C, D, and E.
Finding the classes in binary and dotted-decimal
notation
Find the class of each
address.
a. 00000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111
c. 14.23.120.8
d. 252.5.15.111
Solution
a. The first bit is 0. This is a class A address.
b. The first 2 bits are 1; the third bit is 0. This is a class
C address.
c. The first byte is 14; the class is A.
d. The first byte is 252; the class is E.
• Every IP address also has two parts-
• The first part identifies the network (Network ID) where the
system is connected
• the second part identifies the system (Host ID)
Within the address range of each IPv4 network, we have
three types of addresses:
• Network address - The address by which we refer to
the network
• Broadcast address - A special address used to send data to all
hosts in the network
• Host addresses - The addresses assigned to the end devices
in the network
Class A :
No of Network: 27 (The first bit of a Class A address is always 0.)
No. of Usable Host address per Network: 224-2
(Minus 2 because 2 addresses are reserved for network and
broadcast address)
Class B :
No of Network: 214 (The first two bits of the first octet of a Class B
address are always 10.)
No. of Usable Host address per Network: 216-2
Class C :
No of Network: 221 (A Class C address begins with binary 110. )
No. of Usable Host address per Network: 28-2
• Class D: The Class D address class was created to enable multicasting in
an IP address. A multicast address is a unique network address that
directs packets with that destination address to predefined groups of IP
addresses. Therefore, a single station can simultaneously transmit a single
stream of data to multiple recipients. The Class D address space, much
like the other address spaces, is mathematically constrained. The first
four bits of a Class D address must be 1110.
The addresses in color are the default masks for classes A, B, and
C.
Thus, classful addressing is a special case of classless addressing
The last address in the block can be
found by setting the rightmost
32 − n bits to 1s.
Solution
The value of n is 28, which means that number
of addresses is 2 32−28 or 16.
N= 2
H= 6
Total subnets ( 2N ) :- 22 = 4
Block size (256 - subnet mask) :- 256 - 192 = 64
Valid subnets ( Count blocks from 0) :-
0,64,128,192 Total hosts (2H) :- 26 = 64
Valid hosts per subnet ( Total host - 2 ) :- 64 - 2 =
62
Subnets Subnet 1 Subnet 2 Subnet 3 Subnet 4
Network ID 0 64 128 192
First host 1 65 129 193
Last host 62 126 190 254
Broadcast ID 63 127 191 255
What is the maximum number of hosts which a network
on internet having a subnet mask of 255.255.240.0 can
handle? Answer:
Convert the subnet mask to binary:
11111111.11111111.11110000.00000000
Solution
The prefix length is 27, which means that we must keep the first 27
bits as is and change the remaining bits (5) to 0s. The 5 bits affect
only the last byte. The last byte is 01010010. Changing the last 5
bits to 0s, we get 01000000 or 64. The network address is
167.199.170.64/27.
Questio
n
An organization is granted the block 130.34.12.64/26.
The organization needs to have four subnets. What are the
subnet addresses and the range of addresses for each
subnet?
Solution
Answer: 255.255.240.0
2^3-2 = 6 subnets
2^4-2 = 14
subnets
(2^16 - 2^4) -2 =
2^12 - 2 = 4094
hosts possible per
subnet
Because 3 bits of subnetting will only yield 6 usable subnets (7 if ip subnet-zero is enabled), you will need
to borrow another bit. To meet your minimum requirement of 8 subnets, and the maximum number of
hosts per subnet, this Subnet mask will be correct: 255.255.240.0
Questio
n
If a class B network on the Internet has a subnet mask of
255.255.248.0, what is the maximum number of hosts per subnet?
Solution: The binary representation of subnet mask is
11111111.11111111.11111000.00000000. There are 21 bits set in subnet.
So 11 (32-21) bits are left for host ids.
Total possible values of host ids is 2^11 = 2048.
Out of these 2048 values, 2 addresses are reserved = 2046.
The address with all bits as 1 is reserved as broadcast address and
address with all host id bits as 0 is used as network address of subnet.
In general, the number of addresses usable for addressing specific hosts
in each network is always 2^N – 2 where N is the number of bits for
host id.
Questio
n
Consider-
• We have a big single network having IP Address 200.1.2.0. We
want to do subnetting and divide this network into 2 subnets.
Solution:
• Clearly, the given network belongs to class C.
• For creating two subnets and to represent their subnet IDs,
we require 1 bit. So,
• We borrow one bit from the Host ID part.
• After borrowing one bit, Host ID part remains with only 7
bits.
• If borrowed bit = 0, then it represents the first subnet.
• If borrowed bit = 1, then it represents the second
subnet.
• IP Address of the two subnets are-
• 200.1.2.00000000 = 200.1.2.0
• 200.1.2.10000000 = 200.1.2.128
• For 1st Subnet-