Routing Algorithms Overview
Routing Algorithms Overview
The concept of a shortest path deserves some explanation. One way of measuring path length is
the number of hops. Using this metric, the paths ABC and ABE in below Fig. are equally long.
Another metric is the geographic distance in kilometers, in which case ABC is clearly much longer
than ABE (assuming the figure is drawn to scale).
Several algorithms for computing the shortest path between two nodes of a graph are known.
This one is due to Dijkstra (1959). Each node is labeled (in parentheses) 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.
To illustrate how the labeling algorithm works, look at the weighted, undirected graph of Fig.(a),
where the weights represent, for example, distance. We want to find the shortest path from A to
D. We start out by marking node A as permanent, indicated by a filled-in circle. Then we
examine, in turn, each of the nodes adjacent to A (the working node), relabeling each one with the
distance to A. Whenever a node is relabeled, we also label it with the node from which the probe
was made so that we can reconstruct the final path later. Having examined each of the nodes
adjacent to A, we examine all the tentatively labeled nodes in the whole graph and make the one
with the smallest label permanent, as shown in Fig.(b). This one becomes the new working
node.
We now start at B and examine all nodes adjacent to it. If the sum of the label on B and the
1
distance from B to the node being considered is less than the label on that node, we have a shorter
path, so the node is relabeled. The entire graph is searched for the tentatively-labeled node with the
smallest value. This node is made permanent and becomes the working node for the next round.
Look at Fig.(c). At that point we have just made E permanent. Suppose that there were a shorter
path than ABE, say AXYZE. There are two possibilities: either node Z has already been made
permanent, or it has not been. If it has, then E has already been probed (on the round following the
one when Z was made permanent), so the AXYZE path has not escaped our attention and thus
cannot be a shorter path.
Now consider the case where Z is still tentatively labeled. Either the label at Z is greater than or
equal to that at E, in which case AXYZE cannot be a shorter path than ABE, or it is less than that
of E, in which case Z and not E will become permanent first, allowing E to be probed from Z.
Another static algorithm is flooding, in which every incoming packet is sent out on every
outgoing line except the one it arrived on. 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. Ideally, the hop counter
should be initialized to the length of the path from source to destination. If the sender does not
know how long the path is, it can initialize the counter to the worst case, namely, the full diameter
of the subnet.
2
An alternative technique for damming the flood is to keep track of which packets have been
flooded, to avoid sending them out a second time. Achieve this goal is to have the source router put
a sequence number in each packet it receives from its hosts. Each router then needs a list per
source router telling which sequence numbers originating at that source have already been seen.
Distance vector routing algorithms operate by having each router maintain a table (i.e, a
vector) giving the best known distance to each destination and which line to use to get there.
These tables are updated by exchanging information with the neighbors.
The distance vector routing algorithm is sometimes called by other names, most commonly the
distributed Bellman-Ford routing algorithm and the Ford-Fulkerson algorithm, after the
researchers who developed it (Bellman, 1957; and Ford and Fulkerson, 1962).
It was the original ARPANET routing algorithm and was also used in the Internet under the
name RIP.
(a) A subnet. (b) Input from A, I, H, K, and the new routing table for J.
Part (a) shows a subnet. The first four columns of part (b) show the delay vectors received from
the neighbours of router J.
A claims to have a 12-msec delay to B, a 25-msec delay to C, a 40-msec delay to D, etc.
Suppose that J has measured or estimated its delay to its neighbours, A, I, H, and K as 8, 10, 12,
and 6 msec, respectively.
Each node constructs a one-dimensional array containing the "distances"(costs) to all other
nodes and distributes that vector to its immediate neighbors.
1. The starting assumption for distance-vector routing is that each node knows the cost
of the link to each of its directly connected neighbors.
2. A link that is down is assigned an infinite cost.
3
Example.
Stored at Node A B C D E F G
A 0 1 1 ∞ 1 1 ∞
B 1 0 1 ∞ ∞ ∞ ∞
C 1 1 0 1 ∞ ∞ ∞
D ∞ ∞ 1 0 ∞ ∞ 1
E 1 ∞ ∞ ∞ 0 ∞ ∞
F 1 ∞ ∞ ∞ ∞ 0 1
G ∞ ∞ ∞ 1 ∞ 1 0
We can represent each node's knowledge about the distances to all other nodes as a table like
the one given in Table 1.
Note that each node only knows the information in one row of the table.
1. Every node sends a message to its directly connected neighbors containing its
personal list of distance. ( for example, A sends its information to its neighbors
B,C,E, and F. )
2. If any of the recipients of the information from A find that A is advertising a path
shorter than the one they currently know about, they update their list to give the new
path length and note that they should send packets for that destination through A.
( node B learns from A that node E can be reached at a cost of 1; B also knows it can
reach A at a cost of 1, so it adds these to get the cost of reaching E by means
of A. B records that it can reach E at a cost of 2 by going through A.)
4
3. After every node has exchanged a few updates with its directly connected neighbors,
all nodes will know the least-cost path to all the other nodes.
4. In addition to updating their list of distances when they receive updates, the nodes
need to keep track of which node told them about the path that they used to calculate
the cost, so that they can create their forwarding table. ( for example, B knows that it
was A who said " I can reach E in one hop" and so B puts an entry in its table that
says " To reach E, use the link to A.)
Stored at Node A B C D E F G
A 0 1 1 2 1 1 2
B 1 0 1 2 2 2 3
C 1 1 0 1 2 2 2
D ◻ 2 1 0 3 2 1
E 1 2 2 3 0 2 3
F 1 2 2 2 2 0 1
G ◻ 3 2 1 3 1 0
For example, Table 3 shows the complete routing table maintained at node B for the network
in figure1.
A 1 A
C 1 C
D 2 C
E 2 A
F 2 A
G 3 A
5
THE COUNT-TO-INFINITY PROBLEM
Consider the five-node (linear) subnet of above fig, where the delay metric is the number of
hops. Suppose A is down initially and all the other routers know this. In other words, they have
all recorded the delay to A as infinity.
Now let us consider the situation of Fig (b), in which all the lines and routers are initially up.
Routers B, C, D, and E have distances to A of 1, 2, 3, and 4, respectively. Suddenly A goes
down, or alternatively, the line between A and B is cut, which is effectively the same thing
from B's point of view.
Q(5) Explain the Link State Routing protocol with an example. [7M]
The idea behind link state routing is simple and can be stated as five parts. Each router must
do the following:
1. Discover its neighbors and learn their network addresses.
2. Measure the delay or cost to each of its neighbors.
3. Construct a packet telling all it has just learned.
4. Send this packet to all other routers.
5. Compute the shortest path to every other router
When a router is booted, its first task is to learn who its neighbours are. It accomplishes
this goal by sending a special HELLO packet on each point-to-point line. The router on the
other end is expected to send back a reply telling who it is.
6
(a) Nine routers and a LAN. (b) A graph model of
(a). 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. Of
course, this method implicitly assumes the delays are symmetric, which may not always be the
case.
Figure: A subnet in which the East and West parts are connected by two lines.
Unfortunately, there is also an argument against including the load in the delay calculation.
Consider the subnet of above Fig. which is divided into two parts, East and West, connected by
two lines, CF and EI.
7
(a) A subnet. (b) The link state packets for this subnet.
Once the information needed for the exchange has been collected, the next step is for each
router to build a packet containing all the data.
The packet starts with the identity of the sender, followed by a sequence number and age (to
be described later), and a list of neighbours.
For each neighbour, the delay to that neighbour is given.
An example subnet is given in Fig.(a) with delays shown as labels on the lines. The
corresponding link state packets for all six routers are shown in Fig. (b).
Distributing the Link State Packets
As networks grow in size, the router routing tables grow proportionally. Not only is router
memory consumed by ever-increasing tables, but more CPU time is needed to scan them and more
bandwidth is needed to send status reports about them.
When hierarchical routing is used, the routers are divided into what we will call regions, with
each router knowing all the details about how to route packets to destinations within its own
region, but knowing nothing about the internal structure of other regions.
For huge networks, a two-level hierarchy may be insufficient; it may be necessary to group the
regions into clusters, the clusters into zones, the zones into groups, and so on, until we run out of
names for aggregations.
Below Fig. (a) Gives a quantitative example of routing in a two-level hierarchy with five regions.
The full routing table for router 1A has 17 entries, as shown in Fig. (b). When routing is done
hierarchically, as in Fig. (c), there are entries for all the local routers as before, but all other regions
have been condensed into a single router, so all traffic for region 2 goes via the 1B -2A line, but the
rest of the remote traffic goes via the 1C -3B line. Hierarchical routing has reduced the table from
17 to 7 entries. As the ratio of the number of regions to the number of routers per region grows, the
savings in table space increase.
8
Q(8) what is congestion ? Describe congestion control algorithms in datagrams subnets. [7M]
Congestion in a computer network happens when there is too much data being sent at the same time, causing
the network to slow down. Just like traffic congestion on a busy road, network congestion leads to delays
and sometimes data loss. When the network can’t handle all the incoming data, it gets “clogged,” making it
difficult for information to travel smoothly from one place to another.
Congestion control is a crucial concept in computer networks. It refers to the methods used to prevent
network overload and ensure smooth data flow. When too much data is sent through the network at once, it
can cause delays and data loss. Congestion control techniques help manage the traffic, so all users can enjoy
a stable and efficient network connection. These techniques are essential for maintaining the performance
and reliability of modern networks.
Effects of Congestion control in Computer Network:
Improved Network Stability: Congestion control helps keep the network stable by preventing it from
getting overloaded.
Reduced Latency and Packet Loss: Without congestion control, data transmission can slow down,
causing delays and data loss. Congestion control helps manage traffic better,
Enhanced Throughput: By avoiding congestion, the network can use its resources more effectively.
Fairness in Resource Allocation: Congestion control ensures that network resources are shared fairly
among users. No single user or application can take up all the bandwidth, allowing everyone to have a
fair share.
Better User Experience: When data flows smoothly and quickly, users have a better experience.
Websites, online services, and applications work more reliably and without annoying delays.
Mitigation of Network Congestion Collapse: Without congestion control, a sudden spike in data traffic
can overwhelm the network, causing severe congestion and making it almost unusable.
The leaky bucket algorithm discovers its use in the context of network traffic shaping or rate-limiting.
A leaky bucket execution and a token bucket execution are predominantly used for traffic shaping
algorithms.
This algorithm is used to control the rate at which traffic is sent to the network and shape the burst traffic
to a steady traffic stream.
The disadvantages compared with the leaky-bucket algorithm are the inefficient use of available network
resources.
The large area of network resources such as bandwidth is not being used effectively.
Let us consider an example to understand Imagine a bucket with a small hole in the bottom. No matter at
what rate water enters the bucket, the outflow is at constant rate. When the bucket is full with water
additional water entering spills over the sides and is lost.
Similarly, each network interface contains a leaky bucket and the following steps are involved in leaky
bucket algorithm:
When host wants to send packet, packet is thrown into the bucket.
The bucket leaks at a constant rate, meaning the network interface transmits packets at a constant rate.
Bursty traffic is converted to a uniform traffic by the leaky bucket.
In practice the bucket is a finite queue that outputs at a finite rate.
The leaky bucket algorithm has a rigid output design at an average rate independent of the bursty traffic.
In some applications, when large bursts arrive, the output is allowed to speed up. This calls for a more
flexible algorithm, preferably one that never loses information. Therefore, a token bucket algorithm finds
its uses in network traffic shaping or rate-limiting.
It is a control algorithm that indicates when traffic should be sent. This order comes based on the display
of tokens in the bucket.
The bucket contains tokens. Each of the tokens defines a packet of predetermined size. Tokens in the
bucket are deleted for the ability to share a packet.
When tokens are shown, a flow to transmit traffic appears in the display of tokens.
10
No token means no flow sends its packets. Hence, a flow transfers traffic up to its peak burst rate in
good tokens in the bucket.
11
5. Admission Policy :
In admission policy a mechanism should be used to prevent congestion. Switches in a flow should first
check the resource requirement of a network flow before transmitting it further. If there is a chance of a
6. congestion or there is a congestion in the network, router should deny establishing a virtual network
connection to prevent further congestion.
All the above policies are adopted to prevent congestion before it happens in the network.
The presence of congestion means the load is greater than the resources available over a network to handle.
Generally we will get an idea to reduce the congestion by trying to increase the resources or decrease the load,
but it is not that much of a good idea.
There are some approaches for congestion control over a network which are usually applied on different time
scales to either prevent congestion or react to it once it has occurred.
Step 1 − The basic way to avoid congestion is to build a network that is well matched to the traffic that it
carries. If more traffic is directed but a low-bandwidth link is available, definitely congestion occurs.
Step 2 − Sometimes resources can be added dynamically like routers and links when there is serious
congestion. This is called provisioning, and which happens on a timescale of months, driven by long-term
trends.
Step 3 − To utilise most existing network capacity, routers can be tailored to traffic patterns making them
active during daytime when network users are using more and sleep in different time zones.
12
Step 4 − Some of local radio stations have helicopters flying around their cities to report on road congestion to
make it possible for their mobile listeners to route their packets (cars) around hotspots. This is called traffic
aware routing.
Step 5 − Sometimes it is not possible to increase capacity. The only way to reduce the congestion is to
decrease the load. In a virtual circuit network, new connections can be refused if they would cause the network
to become congested. This is called admission control.
Step 6 − Routers can monitor the average load, queueing delay, or packet loss. In all these cases, the rising
number indicates growing congestion. The network is forced to discard packets that it cannot deliver. The
general name for this is Load shedding. The better technique for choosing which packets to discard can help to
prevention congestion collapse.
Characteristics of IPv4
IPv4 could be a 32-bit IP Address.
IPv4 could be a numeric address, and its bits are separated by a dot.
The number of header fields is twelve and the length of the header field is twenty.
It has Unicast, broadcast, and multicast-style addresses.
IPv4 supports VLSM (Virtual Length Subnet Mask ).
IPv4 uses the Post Address Resolution Protocol to map to the MAC address.
RIP may be a routing protocol supported by the routed daemon.
Networks ought to be designed either manually or with DHCP.
Packet fragmentation permits from routers and causes host.
13
Advantages of IPv4
IPv4 security permits encryption to keep up privacy and security.
IPV4 network allocation is significant and presently has quite 85000 practical routers.
It becomes easy to attach multiple devices across an outsized network while not NAT.
This is a model of communication so provides quality service also as economical knowledge transfer.
Q(13) Draw the IPV4 Header format and explain the fields. [7M]
IP stands for Internet Protocol and v4 stands for Version Four (IPv4). IPv4 was the primary version brought
into action for production within the ARPANET in 1983. IP version four addresses are 32-bit integers which
will be expressed in decimal notation. In this article, we will discuss about IPv4 datagram header.
IPv4 Datagram Header:
14
IPv4 Datagram Header
Due to the presence of options, the size of the datagram header can be of variable length (20 bytes to 60
bytes).
Q(13) What are the motivation factors for IPV6? Explain about the IPV6 address structure.?
The Version field is always 6 for IPv6 (and 4 for IPv4). During the transition period from
IPv4, which has already taken more than a decade, routers will be able to examine this field to
tell what kind of acket they have.
The Differentiated services field (originally called Traffic class) is used to distinguish the
class of service for packets with different real-time delivery requirements. It is used with the
differentiated service architecture for quality of service in the same manner as the field of the
same name in the IPv4 packet.
The Flow label field provides a way for a source and destination to mark groups of packets
that have the same requirements and should be treated in the same way by the network,
forming a pseudo connection. The flow can be set up in advance and given an identifier.
The Payload length field tells how many bytes follow the 40-byte header of Fig. 5-56. The
name was changed from the IPv4 Total length field because the meaning was changed
slightly: the 40 header bytes are no longer counted as part of the length (as they used to be).
This change means the payload can now be 65,535 bytes instead of a mere 65,515 bytes.
The Next header field lets the cat out of the bag. The reason the header could be simplified is
that there can be additional (optional) extension headers. This field tells which of the
(currently) six extension headers, if any, follow this one.
The Hop limit field is used to keep packets from living forever. It is, in practice, the same as
the Time to live field in IPv4, namely, a field that is decremented on each hop.
Next the Source address and Destination address fields which contains 1228 bit address.
A new notation has been devised for writing 16-byte addresses. They are written as eight
groups of four hexadecimal digits with colons between the groups, like this:
8000:0000:0000:0000:0123:4567:89AB:CDEF
15
Since many addresses will have many zeros inside them, three optimizations have been
authorized. First, leading zeros within a group can be omitted, so 0123 can be written as 123.
Second, one or more groups of 16 zero bits can be replaced by a pair of colons. Thus, the
above address now becomes
16
Q(14) Explain the TCP segment header format in detail. [7M]
Every TCP segment consists of a 20 byte fixed format header. Header options may follow the fixed header.
With a header so that it can tag up to 65535 data bytes.
Source Port
Destination Port
Sequence Number
The sequence number of the first data byte in this segment. During the SYN Control bit is set, and the
sequence number is n, and the first data byte is n + 1.
Acknowledgement Number
If the ACK control bit is set, this field contains the next number that the receiver expects to receive.
Data Offset
17
The several 32-bit words in the TCP header shows from where the user data begins.
Reserved (6 bit)
URG
ACK
PUSH
The PUSH flag is set or reset according to a data type that is sent immediately or not.
RST
It Resets the connection.
SYN
FIN
Window
It is used in Acknowledgement segment. It specifies the number of data bytes, beginning with the one
indicated in the acknowledgement number field that the receiver is ready to accept.
Checksum
Options
The IP datagram options provide additional punctuality. It can use several optional parameters between a TCP
sender and receiver. It depends on the options used. The length of the field may vary in size, but it can't be
larger than 40 bytes due to the header field's size, which is 4 bit.
The most typical option is the maximum segment size MASS option. A TCP receiver communicates to the
TCP sender the total length of the segment it can accept with this option. The other various options are used
for flow control and congestion control, each explained in the table shown in the table.
18
Q(15) Explain the following protocols:
i) ARP ii) DHCP.
Address Resolution Protocol (ARP) is a protocol or procedure that connects an ever-changing Internet Protocol (IP)
address to a fixed physical machine address, also known as a media access control (MAC) address, in a local-area
network (LAN).
This mapping procedure is important because the lengths of the IP and MAC addresses differ, and a
translation is needed so that the systems can recognize one another. The most used IP today is IP version 4
(IPv4). An IP address is 32 bits long. However, MAC addresses are 48 bits long. ARP translates the 32-bit
address to 48 and vice versa.
There is a networking model known as the Open Systems Interconnection (OSI) model. First developed in the
late 1970s, the OSI model uses layers to give IT teams a visualization of what is going on with a particular
networking system. This can be helpful in determining which layer affects which application, device, or
software installed on the network, and further, which IT or engineering professional is responsible for
managing that layer.
The MAC address is also known as the data link layer, which establishes and terminates a connection
between two physically connected devices so that data transfer can take place. The IP address is also
referred to as the network layer or the layer responsible for forwarding packets of data through different
routers. ARP works between these layers.
ii)
19
(ii) DHCP.
Dynamic Host Configuration Protocol is a network protocol used to automate the process of assigning IP
addresses and other network configuration parameters to devices (such as computers, smartphones, and
printers) on a network. Instead of manually configuring each device with an IP address, DHCP allows devices
to connect to a network and receive all necessary network information, like IP address, subnet mask, default
gateway, and DNS server addresses, automatically from a DHCP server.
This makes it easier to manage and maintain large networks, ensuring devices can communicate effectively
without conflicts in their network settings. DHCP plays a crucial role in modern networks by simplifying the
process of connecting devices and managing network resources efficiently.
Components of DHCP
DHCP Server: DHCP Server is a server that holds IP Addresses and other information related to
configuration.
DHCP Client: It is a device that receives configuration information from the server. It can be a
mobile, laptop, computer, or any other electronic device that requires a connection.
DHCP Relay: DHCP relays basically work as a communication channel between DHCP Client and
Server.
IP Address Pool: It is the pool or container of IP Addresses possessed by the DHCP Server. It has a
range of addresses that can be allocated to devices.
Subnets: Subnets are smaller portions of the IP network partitioned to keep networks under control.
Lease: It is simply the time that how long the information received from the server is valid, in case of
expiration of the lease, the tenant must have to re-assign the lease.
DNS Servers: DHCP servers can also provide DNS (Domain Name System) server information to
DHCP clients, allowing them to resolve domain names to IP addresses.
Default Gateway: DHCP servers can also provide information about the default gateway, which is the
device that packets are sent to when the destination is outside the local network.
Options: DHCP servers can provide additional configuration options to clients, such as the subnet
mask, domain name, and time server information.
Renewal: DHCP clients can request to renew their lease before it expires to ensure that they continue
to have a valid IP address and configuration information.
20
Failover: DHCP servers can be configured for failover, where two servers work together to provide
redundancy and ensure that clients can always obtain an IP address and configuration information,
even if one server goes down.
Dynamic Updates: DHCP servers can also be configured to dynamically update DNS records with the
IP address of DHCP clients, allowing for easier management of network resources.
Hardware Length: This is an 8-bit field defining the length of the physical address in bytes. e.g
for Ethernet the value is 6.
21
Hop count: This is an 8-bit field defining the maximum number of hops the packet can travel.
Transaction ID: This is a 4-byte field carrying an integer. The transcation identification is set by the
client and is used to match a reply with the request. The server returns the same value in its reply.
Number of Seconds: This is a 16-bit field that indicates the number of seconds elapsed since the time
the client started to boot.
Flag: This is a 16-bit field in which only the leftmost bit is used and the rest of the bit should be set to
os. A leftmost bit specifies a forced broadcast reply from the server. If the reply were to be unicast to the
client, the destination. IP address of the IP packet is the address assigned to the client.
Client IP Address: This is a 4-byte field that contains the client IP address . If the client does not have
this information this field has a value of 0.
Your IP Address: This is a 4-byte field that contains the client IP address. It is filled by the server at the
request of the client.
Server IP Address: This is a 4-byte field containing the server IP address. It is filled by the server in a
reply message.
Gateway IP Address: This is a 4-byte field containing the IP address of a routers. IT is filled by the
server in a reply message.
Client Hardware Address: This is the physical address of the client .Although the server can retrieve
this address from the frame sent by the client it is more efficient if the address is supplied explicity by
the client in the request message.
Server Name: This is a 64-byte field that is optionally filled by the server in a reply packet. It contains a
null-terminated string consisting of the domain name of the server. If the server does not want to fill this
filed with data, the server must fill it with all 0s.
Boot Filename: This is a 128-byte field that can be optionally filled by the server in a reply packet. It
contains a null- terminated string consisting of the full pathname of the boot file. The client can use this
path to retrieve other booting information. If the server does not want to fill this field with data, the
server must fill it with all 0s.
Options: This is a 64-byte field with a dual purpose. IT can carry either additional information or some
specific vendor information. The field is used only in a reply message. The server uses a number, called
a magic cookie, in the format of an IP address with the value of [Link]. When the client finishes
reading the message, it looks for this magic cookie. If present the next 60 bytes are options.
22
23
24
25
26
27
28