CN Unit 4
CN Unit 4
CN Unit 4
Routing Algorithms- Shortest-Path Routing, Flooding, Hierarchical routing, Broadcast, Multicast and
Distance Vector Routing. Congestion Control Algorithms, Approaches to Congestion Control-Traffic Aware
Routing-Admission Control-Traffic Throttling-Load Shedding, IP Addressing, Classless and Class full
Addressing, Sub-netting.
What is a Router?
• A router receives and sends data on computer networks.
• Routers can combine the functions of hubs, modems, or network switches, and connect with these
devices, to improve Internet access or help create business networks.
• They are responsible for receiving, analysing, and forwarding data packets among the connected
computer networks.
• When a data packet arrives, the router inspects the destination address, consults its routing tables to
decide the optimal route and then transfers the packet along this route.
Features of Routers
• A router is a layer 3 or network layer device.
• It connects different networks together and sends data packets from one network to another.
• A router can be used both in LANs (Local Area Networks) and WANs (Wide Area Networks).
• It transfers data in the form of IP packets. In order to transmit data, it uses IP address mentioned in the
destination field of the IP packet.
• Routers have a routing table in it that is refreshed periodically according to the changes in the network.
1
• In order to transmit data packets, it consults the table and uses a routing protocol.
• In order to prepare or refresh the routing table, routers share information among each other.
• Routers provide protection against broadcast storms.
• Routers are more expensive than other networking devices like hubs, bridges, and switches.
• Routers are manufactured by some popular companies like −
o Cisco
o D-Link
o HP
o 3Com
o Juniper
o Nortel
Routing Table
• The functioning of a router depends largely upon the routing table stored in it.
• The routing table stores the available routes for all destinations.
• The router consults the routing table to determine the optimal route through which the data packets can
be sent.
• A routing table typically contains the following entities −
o IP addresses and subnet mask of the nodes in the network
o IP addresses of the routers in the network
o Interface information among the network devices and channels
Two types:
1. Static Routing Table
− Here, the routes are fed manually and are not refreshed automatically.
− It is suitable for small networks containing 2-3 routers.
2. Dynamic Routing Table
− Here, the router communicates with other routers using routing protocols to determine the
available routes.
− It is suited for larger networks having large number of routers.
Types of Routers
• A variety of routers are available depending upon their usages.
• The main types of routers are −
1. Wireless Router − They provide WiFi connection WiFi devices like laptops, smartphones etc.
They can also provide standard Ethernet routing. For indoor connections, the range is 150 feet
while its 300 feet for outdoor connections.
2
2. Broadband Routers − They are used to connect to the Internet through telephone and to use voice
over Internet Protocol (VoIP) technology for providing high-speed Internet access. They are
configured and provided by the Internet Service Provider (ISP).
3. Core Routers − They can route data packets within a given network, but cannot route the packets
between the networks. They helps to link all devices within a network thus forming the backbone
of network. It is used by ISP and communication interfaces.
4. Edge Routers − They are low-capacity routers placed at the periphery of the networks. They
connect the internal network to the external networks, and are suitable for transferring data packets
across networks. They use Border Gateway Protocol (BGP) for connectivity. There are two types
of edge routers, subscriber edge routers and label edge routers.
5. Brouters − Brouters are specialised routers that can provide the functionalities of bridges as well.
Like a bridge, brouters help to transfer data between networks. And like a router, they route the
data within the devices of a network.
6. Virtual router − Virtual routers are pieces of software that allow some router functions to be
virtualized in the cloud and delivered as a service. These routers are ideal for large businesses with
complex network needs. They offer flexibility, easy scalability, and a lower entry cost. Another
benefit of virtual routers is reduced management of local network hardware.
Routing:
• A Router is a process of selecting path along which the data can be transferred from source to the
destination.
• Routing is performed by a special device known as a router.
• Routing is a process that is performed by layer 3 (or network layer) devices in order to deliver the
packet by choosing an optimal path from one network to another.
• A router is a networking device that forwards the packet based on the information available in the
packet header and forwarding table.
• The routing algorithms are used for routing the packets. The routing algorithm is nothing but a software
responsible for deciding the optimal path through which packet can be transmitted.
• The routing protocols 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.
• The routing algorithm initializes and maintains the routing table for the process of path determination.
3
Routing Metrics:
• Metrics are the network variables used to determine the best route to the destination.
• For some protocols use the static metrics means that their value cannot be changed and for some other
routing protocols use the dynamic metrics means that their value can be assigned by the system
administrator.
• The most common metric values are given below:
o Hop count: Hop count is defined as a metric that specifies the number of passes through
internetworking devices such as a router, a packet must travel in a route to move from source
to the destination. If the routing protocol considers the hop as a primary metric value, then the
path with the least hop count will be considered as the best path to move from source to the
destination.
o Delay: It is a time taken by the router to process, queue and transmit a datagram to an interface.
The protocols use this metric to determine the delay values for all the links along the path end-
to-end. The path having the lowest delay value will be considered as the best path.
o Bandwidth: The capacity of the link is known as a bandwidth of the link. The bandwidth is
measured in terms of bits per second. The link that has a higher transfer rate like gigabit is
preferred over the link that has the lower capacity like 56 kb. The protocol will determine the
bandwidth capacity for all the links along the path, and the overall higher bandwidth will be
considered as the best route.
o Load: Load refers to the degree to which the network resource such as a router or network link
is busy. A Load can be calculated in a variety of ways such as CPU utilization, packets
processed per second. If the traffic increases, then the load value will also be increased. The
load value changes with respect to the change in the traffic.
o Reliability: Reliability is a metric factor may be composed of a fixed value. It depends on the
network links, and its value is measured dynamically. Some networks go down more often than
others. After network failure, some network links repaired more easily than other network links.
Any reliability factor can be considered for the assignment of reliability ratings, which are
generally numeric values assigned by the system administrator.
Types of Routing:
• There are 3 types of routing:
4
1. Static Routing:
• Static Routing is also known as non-adaptive routing which doesn’t change the routing table unless
the network administrator changes or modifies them manually.
• Static routing does not use complex routing algorithms.
• It provides high or more security than dynamic routing.
Advantages
• No routing overhead for the router CPU which means a cheaper router can be used to do routing.
• It adds security because an only administrator can allow routing to particular networks only.
• No bandwidth usage between routers.
Disadvantage
• For a large network, it is a hectic task for administrators to manually add each route for the network in
the routing table on each router.
• The administrator should have good knowledge of the topology. If a new administrator comes, then he
has to manually add each route so he should have very good knowledge of the routes of the topology.
Default Routing
• Default Routing is a technique in which a router is configured to send all the packets to the same hop
device, and it doesn't matter whether it belongs to a particular network or not.
• A Packet is transmitted to the device for which it is configured in default routing.
• Default Routing is used when networks deal with the single exit point.
• It is also useful when the bulk of transmission networks have to transmit the data to the same hp device.
• When a specific route is mentioned in the routing table, the router will choose the specific route rather
than the default route. The default route is chosen only when a specific route is not mentioned in the
routing table.
Dynamic Routing
• Dynamic routing is also known as adaptive routing which changes the routing table according to the
change in topology.
5
• Dynamic routing uses complex routing algorithms and it does not provide high security like static
routing.
• When the network change(topology) occurs, it sends the message to the router to ensure that changes
then the routes are recalculated for sending updated routing information.
In static routing, additional resources are In dynamic routing, additional resources are
6.
not required. required.
6
S.NO Static Routing Dynamic Routing
In static routing, failure of the link In dynamic routing, failure of the link does not
7.
disrupts the rerouting. interrupt the rerouting.
Another name for static routing is non- Another name for dynamic routing is adaptive
10.
adaptive routing. routing.
7
Single-Pair Shortest Path Problem-
• It is a shortest path problem where the shortest path between a given pair of vertices is computed.
• A* Search Algorithm is a famous algorithm used for solving single-pair shortest path problem.
Single-Source Shortest Path Problem-
• It is a shortest path problem where the shortest path from a given source vertex to all other remaining
vertices is computed.
• Dijkstra’s Algorithm and Bellman Ford Algorithm are the famous algorithms used for solving
single-source shortest path problem.
Single-Destination Shortest Path Problem-
• It is a shortest path problem where the shortest path from all the vertices to a single destination vertex
is computed.
• By reversing the direction of each edge in the graph, this problem reduces to single-source shortest
path problem.
• Dijkstra’s Algorithm is a famous algorithm adapted for solving single-destination shortest path
problem.
All Pairs Shortest Path Problem-
• It is a shortest path problem where the shortest path between every pair of vertices is computed.
• Floyd-Warshall Algorithm and Johnson’s Algorithm are the famous algorithms used for solving All
pairs shortest path problem.
A* Search Algorithm:
• A* Search algorithm is one of the best and popular technique used in path-finding and graph traversals.
• It is also worth mentioning that many games and web-based maps use this algorithm to find the shortest
path very efficiently (approximation).
• A* is a version of the best-first algorithm that is based on the use of heuristic techniques to attain
optimality and completeness.
• Each time A* enters a state, it computes the cost of travel, f(n) (n being the adjacent node), and then
enters the node with the lowest value of f(n).
• The following formula is used to compute these values:
• g(n) is the value of the shortest route between the start and end nodes, and h(n) is a heuristic estimate
of the value of the node.
• To rebuild any route, we must associate each node with the relative with the optimum f(n) value.
8
• A*' algorithm efficiency is largely reliant on the heuristic value h(n), and depending on the kind of
issue, a different heuristic function may be required to discover the optimum solution.
• Admissibility and consistency are the two basic characteristics that a heuristic function may have.
Admissibility and Consistency
• A heuristic function h(n) is acceptable if it never exceeds the true distance between n and the target
node.
• As a result, the following formula holds true for any node n:
• The actual distance between n and the target node is denoted by h*(n). However, if the function
overestimates the actual distance but never by more than d, we may confidently conclude that the
solution produced by the function is accurate to d (i.e. it does not overstate the shortest route between
points A and B by more than d).
• A given heuristic function h(n) is consistent if the estimated distance between the target n and any
given neighbour is always less than or equal to the expected cost of reaching that neighbour:
• The distance between nodes n and m is denoted by c(n,m). Furthermore, if h(n) is constant, we know
the optimum route to every node that has been examined before. This indicates that this function
performs optimally.
Example:
• The number
o written with Blue is the distance between the nodes and
o written with Red is the heuristics value.
9
• A* uses f(n) = g(n) + h(n) to find the shortest
path.
• Let us start with A
o A have 2 nodes B and F.
o Let’s calculate F(B) and F(F)
o F(B) = 6 + 8 = 14
o F(F) = 3 + 6 = 9
• F(F) < F(B), so we will choose F as our new
start node.
• Path: A - F
• Now F is our new start node
• F have 2 nodes G and H
• Lets calculate F(G) and F(H)
o F(G) = 4 + 5 (3 +1 = 4)
o F(H) = 10 + 3 = 13 (3 + 7 = 10)
• F(G) < F(H)
• So we will choose G as our new start node
• Path : A – F – G
10
Disadvantage:
• But it does not produce the shortest path always because it heavily depends on heuristics.
Dijkstra’s algorithm:
Definition
• Dijkstra’s algorithm is a popular algorithm for solving many single-source shortest path problems
having non-negative edge weight in the graphs i.e., it is to find the shortest distance between two
vertices on a graph.
• It was conceived by Dutch computer scientist Edsger W. Dijkstra in 1956.
• The algorithm maintains a set of visited vertices and a set of unvisited vertices.
• It starts at the source vertex and iteratively selects the unvisited vertex with the smallest tentative
distance from the source.
• It then visits the neighbours of this vertex and updates their tentative distances if a shorter path is found.
• This process continues until the destination vertex is reached, or all reachable vertices have been
visited.
Basics requirements
1. Graph:
Dijkstra’s Algorithm can be implemented on any graph but it works best with a weighted
Directed Graph with non-negative edge weights and the graph should be represented as a set of vertices
and edges.
2. Source Vertex:
Dijkstra’s Algorithm requires a source node which is starting point for the search.
3. Destination vertex:
Dijkstra’s algorithm may be modified to terminate the search once a specific destination vertex
is reached.
4. Non-Negative Edges:
Dijkstra’s algorithm works only on graphs that have positive weights this is because during the
process the weights of the edge have to be added to find the shortest path. If there is a negative weight
in the graph then the algorithm will not work correctly. Once a node has been marked as visited the
current path to that node is marked as the shortest path to reach that node.
Introduction to Graphs
Introduction:
• A Graph is a non-linear data structure consisting of vertices and edges.
• The vertices are sometimes also referred to as nodes and the edges are lines or arcs that connect
any two nodes in the graph.
11
Components of a Graph
• Vertices:
Vertices are the fundamental units of the graph.
Sometimes, vertices are also known as vertex or nodes.
Every node/vertex can be labeled or unlabelled.
• Edges:
Edges are drawn or used to connect two nodes of the graph.
It can be ordered pair of nodes in a directed graph.
Edges can connect any two nodes in any possible way.
There are no rules. Sometimes, edges are also known as arcs. Every edge can be
labelled/unlabelled.
Types Of Graph:
1. Undirected Graph
A graph in which edges do not have any direction. That is the nodes are unordered pairs in the definition
of every edge.
2. Directed Graph
A graph in which edge has direction. That is the nodes are ordered pairs in the definition of every edge.
12
• Graph algorithms are often very efficient and can be used to solve complex problems quickly and
effectively.
• Graphs can be used to represent complex data structures in a simple and intuitive way, making them
easier to understand and analyze.
Disadvantages:
• Graphs can be complex and difficult to understand, especially for people who are not familiar with
graph theory or related algorithms.
• Creating and manipulating graphs can be computationally expensive, especially for very large or
complex graphs.
• Graph algorithms can be difficult to design and implement correctly, and can be prone to bugs and
errors.
• Graphs can be difficult to visualize and analyze, especially for very large or complex graphs, which
can make it challenging to extract meaningful insights from the data.
Dijkstra’s Algorithm
• Input − A graph representing the network; and a source node, s
• Output − A shortest path tree, spt [], with s as the root node.
Algorithm for Dijkstra’s Algorithm:
• Mark the source node with a current distance of 0 and the rest with infinity.
• Set the non-visited node with the smallest current distance as the current node.
• For each neighbour, 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.
• Mark the current node 1 as visited.
• Go to step 2 if there are any nodes are unvisited.
Example:
Dijkstra’s Algorithm will generate the shortest path from Node 0 to all other Nodes in the graph.
Consider the below graph:
13
• 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 a set of resources given below:
• 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.
o Example: 0 -> 0, 1-> ∞,2-> ∞,3-> ∞,4-> ∞,5-> ∞,6-> ∞.
• 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:
o Distance: Node 0 -> Node 1 -> Node 3 = 2 + 5 = 7
14
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.
15
Pseudo Code for Dijkstra’s Algorithm
function Dijkstra(Graph, source):
// Initialize distances to all nodes as infinity, except for the source node.
distances = map infinity to all nodes
distances = 0
// Initialize an empty set of visited nodes and a priority queue to keep track of the nodes to visit.
visited = empty set
queue = new PriorityQueue()
queue.enqueue(source, 0)
// Loop until all nodes have been visited.
while queue is not empty:
// Dequeue the node with the smallest distance from the priority queue.
current = queue.dequeue()
// If the node has already been visited, skip it.
if current in visited:
continue
// Mark the node as visited.
visited.add(current)
// Check all neighboring nodes to see if their distances need to be updated.
for neighbor in Graph.neighbors(current):
// Calculate the tentative distance to the neighbor through the current node.
tentative_distance = distances[current] + Graph.distance(current, neighbor)
// If the tentative distance is smaller than the current distance to the neighbor, update the distance.
if tentative_distance < distances[neighbor]:
distances[neighbor] = tentative_distance
// Enqueue the neighbor with its new distance to be considered for visitation in the future.
queue.enqueue(neighbor, distances[neighbor])
// Return the calculated distances from the source to all other nodes in the graph.
return distances
16
1. Adaptive Routing algorithm:
• Adaptive routing algorithm is also called a dynamic routing algorithm. In this algorithm, the routing
decisions are made based on network traffic and topology. The parameters which are used in adaptive
routing algorithms are distance, hop, estimated transit time and count.
• The adaptive routing algorithm is of three types –
1. Centralized algorithm
2. Isolation algorithm
3. Distributed algorithm
2. Non-Adaptive Routing algorithm:
• Non-adaptive routing algorithm is also called a static routing algorithm. In a non-adaptive routing
algorithm, the routing decisions are not made based on network traffic and topology. This algorithm is
used by static routing. Non-adaptive routing algorithms are simple as compared to Adaptive routing
algorithms in terms of complexity.
• The non-adaptive routing algorithm is of two types –
1. Flooding
2. Random walks
Flooding:
• Flooding is a non-adaptive routing technique following this simple method: when a data packet arrives
at a router, it is sent to all the outgoing links except the one it has arrived on.
• For example, let us consider the network in the figure, having six routers that are connected through
transmission lines.
Using flooding technique −
• An incoming packet to A, will be sent to B,
C and D.
• B will send the packet to C and E.
• C will send the packet to B, D and F.
• D will send the packet to C and F.
• E will send the packet to F.
• F will send the packet to C and E.
Types of Flooding
• Flooding may be of three types −
1. Uncontrolled flooding − Here, each router unconditionally transmits the incoming data
packets to all its neighbours.
17
2. Controlled flooding − They use some methods to control the transmission of packets to the
neighbouring nodes. The two popular algorithms for controlled flooding are Sequence Number
Controlled Flooding (SNCF) and Reverse Path Forwarding (RPF).
3. Selective flooding − Here, the routers don't transmit the incoming packets only along those
paths which are heading towards approximately in the right direction, instead of every available
paths.
Characteristics –
• All possible routes between Source and Destination are tried. A packet will always get through if the
path exists
• As all routes are tried, there will be at least one route which is the shortest
• All nodes directly or indirectly connected are visited
Advantages:
• It is very simple to setup and implement, since a router may know only its neighbours.
• It is extremely robust. Even in case of malfunctioning of a large number routers, the packets find a way
to reach the destination.
• All nodes which are directly or indirectly connected are visited. So, there are no chances for any node
to be left out. This is a main criterion in case of broadcast messages.
• The shortest path is always chosen by flooding.
Limitations
• Flooding tends to create an infinite number of duplicate data packets, unless some measures are
adopted to damp packet generation.
• It is wasteful if a single destination needs the packet, since it delivers the data packet to all nodes
irrespective of the destination.
• The network may be clogged with unwanted and duplicate data packets. This may hamper delivery of
other data packets.
Hierarchical routing
• In hierarchical routing, the routers are divided into regions.
• Each router has complete details about how to route packets to destinations within its own region.
• But it does not have any idea about the internal structure of other regions.
• In hierarchical routing, routers are classified in groups called regions.
• Each router has information about the routers in its own region and it has no information about routers
in other regions.
• So, routers save one record in their table for every other region.
18
Example
• Consider an example of two-level hierarchy with five regions as shown in figure
Let see the full routing table for router 1A which has 17 entries, as shown below –
19
• For example, the best route from 1A to 5C is via region 2, but with hierarchical routing all traffic to
region 5 goes via region 3, because that is better for most destinations in region 5.
• For example, consider a subnet with 720 routers. If there is no hierarchy, each router needs 720 routing
table entries.
• If the subnet is partitioned into 24 regions of 30 routers each, each router needs 30 local entries plus
23 remote entries for a total of 53 entries. If a three-level hierarchy is chosen, with eight clusters, each
containing 9 regions of 10 routers, each router needs 10 entries for local routers, 8 entries for routing
to other regions within its own cluster, and 7 entries for distant clusters, for a total of 25 entries.
Kamoun and Kleinrock (1979) discovered that the optimal number of levels for an N router subnet is
ln N, requiring a total of e ln N entries per router.
• They have also shown that the increase in effective mean path length caused by hierarchical routing is
sufficiently small that it is usually acceptable.
20
• They can then forward packets only onto those networks containing devices with the connected MAC
addresses.
• Unicast gradually becomes less efficient as more receivers need to see identical data.
Example:
• Host A sends the data to the Host B.
21
Limited Broadcast
• In Limited Broadcast, the data is transmitted from a single source host to all the other hosts residing in
the same network.
22
• It is necessary to keep track of the topology and inform neighbouring devices if any changes occur in
the topology.
• This algorithm is used to find the shortest route from one node to another node in the network.
• The routing protocol is used to calculate the best route from source to destination based on the distance
or hops as its primary metric to define an optimal path. The distance vector refers to the distance to the
neighbour nodes, where routing defines the routes to the established node.
• The Distance Vector routing algorithm (DVR) shares the information of the routing table with the other
routers in the network and keeps the information up-to-date to select an optimal path from source to
destination.
key points:
• Network Information:
o Every node in the network should have information about its neighbouring node.
o Each node in the network is designed to share information with all the nodes in the network.
• Routing Pattern:
o In DVR the data shared by the nodes are transmitted only to that node that is linked directly to
one or more nodes in the network.
• Data sharing:
o The nodes share the information with the neighbouring node from time to time as there is a
change in network topology.
The Bellman-Ford algorithm is defined as:
where,
dx(y)= The least distance from x to y
c(x,v)= Node x's cost from each of its neighbour v
dv(y)= Distance to each node from initial node
minv= selecting shortest distance
Working Principle:
• Each router maintains a routing table
1. It Gives the best-known distance from source to destination and which route is used to get there.
• These tables are updated by exchanging the information with the neighbor having a direct link.
• Tables contain one entry for each route, this entry contains two-part,
1. The preferred outgoing line use to reach the destination or an estimate of the time or distance
to that destination.
2. The metric used can be the number of hops required to reach from source to destination.
23
• The router exchanges the network topology information periodically with its neighboring node and
updates the information in the routing table.
• The cost of reaching the destination is estimated based on the metric, and an optimal path is obtained
to send data packets from source to destination.
Example:
Consider-
• There is a network consisting of 4 routers.
• The weights are mentioned on the edges.
• Weights could be distances or costs or delays.
Step - 1:
• The routers in the network start sharing their information with the neighbouring router in the network.
Routing table of A:
Routing table of B:
24
Routing table of C:
Routing table of D:
Step-02:
• Each router exchanges its distance vector with its neighbors and prepares a new routing table.
• At Router A-
• Router A receives distance vectors from its neighbors B and D and prepares a new routing table
as-
25
Old Routing Table New Routing Table
At Router B-
• Router B receives distance vectors from its neighbors A, C and D.
• Router B prepares a new routing table as-
• Cost of reaching destination A from router B = min {2+0, 3+∞, 7+1} = 2 via A.
• Cost of reaching destination C from router B = min {2+∞, 3+0, 7+11} = 3 via C.
• Cost of reaching destination D from router B = min {2+1, 3+11, 7+0} = 3 via A.
• Thus, the new routing table at router B is-
• Old Routing Table New Routing Table
At Router C-
Router C receives distance vectors from its neighbors B and D.
Router C prepares a new routing table as-
26
• Cost of reaching destination A from router C = min { 3+2 , 11+1 } = 5 via B.
• Cost of reaching destination B from router C = min { 3+0 , 11+7 } = 3 via B.
• Cost of reaching destination D from router C = min { 3+7 , 11+0 } = 10 via B.
• Thus, the new routing table at router C is-
• Old Routing Table New Routing Table
At Router D-
• Router D receives distance vectors from its neighbors A, B and C.
• Router D prepares a new routing table as-
• Cost of reaching destination A from router D = min { 1+0 , 7+2 , 11+∞ } = 1 via A.
• Cost of reaching destination B from router D = min { 1+2 , 7+0 , 11+3 } = 3 via A.
• Cost of reaching destination C from router D = min { 1+∞ , 7+3 , 11+0 } = 10 via B.
Thus, the new routing table at router D is-
Old Routing Table New Routing Table
27
Congestion Control Algorithms:
What is congestion?
• It is a situation in Communication Networks in which too many packets are present
• A state occurring in network layer when the message traffic is so heavy that it slows down network
response time.
• Congestion may occur when the load on the network is greater than the capacity of the network.
Effects of Congestion
• As delay increases, performance decreases.
• If delay increases, retransmission occurs, making situation worse.
28
These two categories are:
1. Open loop
2. Closed loop
Open Loop Congestion Control
• In this method, policies are used to prevent the congestion before it happens.
• Congestion control is handled either by the source or by the destination.
1. Retransmission Policy
• When sender retransmits a packet, may increase the congestion in the network.
• To implement good retransmission policy and the retransmission timers need to prevent the congestion.
2. Window Policy
• To implement window policy, selective reject window method is used for congestion control.
• Selective reject method sends only the specific lost or damaged packets.
3. Acknowledgement Policy:
• Acknowledgments also add to the traffic load on the network. Thus, by sending fewer
acknowledgements we can reduce load on the network.
• To implement it, several approaches can be used:
1. A receiver may send an acknowledgement only if it has a packet to be sent.
2. A receiver may send an acknowledgement when a timer expires.
3. A receiver may also decide to acknowledge only N packets at a time.
4. Discarding Policy
• A router may discard less sensitive packets when congestion is likely to happen.
• Such a discarding policy may prevent congestion and at the same time may not harm the integrity of
the transmission.
5. Admission Policy
• An admission policy, which is a quality-of-service mechanism, can also prevent congestion in virtual
circuit networks.
• A router can deny establishing a virtual circuit connection if there is congestion in the “network or if
there is a possibility of future congestion.
Closed Loop Congestion Control
• Closed loop congestion control mechanisms try to remove the congestion after it happens.
• The various methods used for closed loop congestion control are:
1. Backpressure
• Back pressure is a node-to-node congestion control that starts with a node and propagates, in the
opposite direction of data flow.
• In this method of congestion control, the congested node stops receiving data from the immediate
upstream node or nodes.
29
• Node 3 is congested and it stops receiving packets and informs its upstream node 2 to slow down. Node
2 in turns may be congested and informs node 1 to slow down. Now node 1 may create congestion and
informs the source node to slow down.
2. Choke Packet
• In this method of congestion control, congested router or node sends a special type of packet called
choke packet to the source to inform it about the congestion.
• In choke packet method, congested node sends a warning directly to the source station.
3. Implicit Signaling
• In implicit signaling, there is no communication between the congested node or nodes and the source.
• The source guesses that there is congestion somewhere in the network when it does not receive any
acknowledgment.
• On sensing this congestion, the source slows down.
• This type of congestion control policy is used by TCP.
4. Explicit Signaling
• In this method, the congested nodes explicitly send a signal to the source or destination to inform about
the congestion.
• Explicit signaling is different from the choke packet method.
30
• In choke packed method, a separate packet is used for this purpose whereas in explicit signaling
method, the signal is included in the packets that carry data .
• Explicit signaling can occur in either
• the forward direction or
• the backward direction
1. The forward direction
• In backward signaling, a bit is set in a packet moving in the direction opposite to the congestion.
• This bit warns the source about the congestion and informs the source to slow down.
2. The backward direction
• In forward signaling, a bit is set in a packet moving in the direction of congestion.
• This bit warns the destination about the congestion.
Congestion Control Algorithms:
• There are two types of Congestion control algorithms, which are as follows −
1. Leaky Bucket Algorithm
2. Token Bucket Algorithm
1. Leaky Bucket Algorithm:
• Leaky Bucket Algorithm mainly controls the total amount and the rate of the traffic sent to the network.
Step 1
• Imagine a bucket with a small hole at the bottom
• Water is poured into the bucket is not constant and can vary but it leaks from the bucket at a constant
rate.
Step 2
• The rate at which the water leaks does not depend on the rate at which the water is input to the
bucket.
Step 3
• If the bucket is full, additional water that spills over the sides and is lost.
Step 4
• The same concept applied to packets in the network.
• Consider that data is coming from the source at variable speeds.
31
• Suppose that a source sends data at 10 Mbps for 4 seconds. Then there is no data for 3 seconds. The
source again transmits data at a rate of 8 Mbps for 2 seconds. Thus, in a time span of 8 seconds, 68 Mb
data has been transmitted.
• Leaky bucket algorithm is used, the data flow would be 8 Mbps for 9 seconds.
• Thus, the constant flow is maintained.
Formula:
M*s=C+ρ*s
where
S – is time taken
M – Maximum output rate
ρ – Token arrival rate
C – Capacity of the token bucket in byte
32
Traffic Aware Routing:
• It is one of the approaches for congestion control over the network.
• The main goal of traffic aware routing is to
o identify the best routes by considering the load,
o set the link weight to be a function of fixed link bandwidth and propagation delay and
o the variable measured load or average queuing delay.
• The main objective is to choose the optimum routes by taking the load into account.
Example
• Consider a network that is separated into two regions, North and South
Explanation
Step 1
• Consider a network which is divided into two parts, East and West both are connected by links CF and
EI.
Step 2
• Suppose most of the traffic in between East and West is using link CF, and as a result CF link is heavily
loaded with long delays. Including queueing delay in the weight which is used for shortest path
calculation will make EI more attractive.
Step 3
• After installing the new routing tables, most of East-West traffic will now go over the EI link. As a
result in the next update CF link will appear to be the shortest path.
Step 4
• As a result the routing tables may oscillate widely, leading to erratic routing and many potential
problems.
Step 5
• If we consider only bandwidth and propagation delay by ignoring the load, this problem does not occur.
Attempts to include load but change the weights within routing scheme to shift traffic across routes
arrow range only to slow down routing oscillations.
33
Step 6
• Two techniques can contribute for successful solution, which are as follows −
1. Multipath routing
2. The routing scheme to shift traffic across routes.
Admission Control:
• It is widely used in virtual-circuit networks.
• Idea:
• Do not set up a new virtual circuit unless the network can carry the added traffic without
becoming congested.
• Admission control combined with traffic aware routing by considering routes around traffic
hotspots as part of the setup procedure.
• Take two networks (a) A congestion network and (b) The portion of the network that is not
congested.
• A virtual circuit A to B is also shown below −
Explanation:
• Step 1 − Router A wants to set up a connection to router B. Normally this connection passes through
one of the congested routers.
• Step 2 − To avoid this situation, we can redraw the network as shown in figure (b), removing the
congested routers and all of their lines.
• Step 3 − The dashed line indicates a possible route for the virtual circuit that avoids the congested
routers.
Traffic Throttling
• Traffic Throttling is an approach used to avoid congestion.
• It can be used in virtual circuit networks and datagram networks.
• Various approaches are used for throttling traffic.
• Each used approach must solve two problems.
34
Problem1
• The router must identify the congestion before it has arrived.
• Each router can continuously monitor the resources it is using.
• There are three possibilities, which are as follows −
1. Utilization of output links.
2. Buffering of queued packets inside the router.
3. Numbers of packets are lost due to insufficient buffering.
Problem2
• The router must send the feedback on time to the senders that are creating congestion.
• To deliver this feedback, the router must identify the senders properly.
• The router needs to send them warning efficiently without sending more packets in an already
congested network.
• Different feedback mechanisms are used for solving this problem.
Feedback Mechanisms:
1. Choke packets
2. Explicit Congestion Notification
3. Hop-by-Hop Backpressure
Load Shedding
• Load shedding is one of the techniques used for congestion control.
• A network router consists of a buffer. This buffer is used to store the packets and then route them to
their destination.
• It is an approach of discarding the packets when the buffer is full according to the strategy implemented
in the data link layer.
• The selection of packets to discard is an important task.
• Many times packets with less importance and old packets are discarded.
Selection of Packets to be Discarded
1. Random Selection of packets
2. Selection of packets based on applications
3. Selection of packets based on priority
4. Random early detection
1. Random Selection of packets
• When the router is filled with more packets, the packets are selected randomly for discarding.
• Discarding the packets it can include old, new, important, priority-based, or less important packets.
• Random selection of packets can lead to various disadvantages and problems.
35
2. Selection of packets based on applications
• According to the application, the new packets will be discarded or old packets can be discarded by the
router.
• When the application is regarding file transfer new packets are discarded and
• When the application is regarding multimedia the old packets are discarded.
3. Selection of packets based on priority
• The source of packets can mark the priority stating how much important the packet is.
• Depending upon the priority provided by the sender the packet can either be selected or discarded.
• The priority can be given according to price, algorithm, and methods used, the functions that it will
perform, and its effect on another task upon selecting and discarding the packets.
4. Random early detection
• Randomly early detection is an approach in which packets are discarded before the buffer space
becomes full.
• Therefore the situation of congestion is controlled earlier.
• In this approach, the router initially maintains a specific queue length for the outgoing lines.
• When this average set line is exceeded it warns for congestion and discards the packets.
IP ADDRESSING:
IP: Introduction
• IP stands for internet protocol.
• It is a protocol defined in the TCP/IP model.
• It used for sending the packets from source to destination.
• The main task of IP is
• to deliver the packets based on the IP addresses available in the packet headers.
• An IP protocol provides the connectionless service, which is accompanied by two transport
protocols, i.e., TCP/IP and UDP/IP.
• The first version of IP (Internet Protocol) was IPv4, later IPv6 came into the market.
• To provide addressing to the hosts, encapsulating the data into a packet structure, and routing
the data from source to the destination across one or more IP networks.
• In order to achieve these functionalities, internet protocol provides two major things:
• Format of IP packet
• IP Addressing system
Components of IP packet:
• Two major components are added in an IP packet before sent over the network,
1. header and
2. Payload - Payload is the data that is to be transported.
36
IP packet: Header
• An IP header contains lots of information about the IP packet which includes:
1. Source IP address: The source is the one who is sending the data.
2. Destination IP address: The destination is a host that receives the data from the sender.
3. Header length
4. Packet length
5. TTL (Time to Live): The number of hops occurs before the packet gets discarded.
6. Transport protocol: The transport protocol used by the internet protocol, either it can be TCP
or UDP.
• There is a total of 14 fields exist in the IP header, and one of them is optional.
• A unique address
o distinguishes any device on the internet or any network from another.
• It defines the set of commands
o directing the data transferred through the internet or any other local network.
o It is the identifier that enables your device to send or receive data packets across the internet.
o It holds information related to your location.
IP Address: Introduction
o IP addresses are essentially numerical.
o An IP address is represented by a series of numbers segregated by periods(.).
o They are expressed in the form of four pairs.
o Example: 255.255.255.255
o wherein each set can range from 0 to 255.
IP Address: Types
• Each IP packet contains two addresses
1. The IP address of the device, which is sending the packet, and
2. The IP address of the device which is receiving the packet.
IP Address: Types
1. IPv4:
• Internet Protocol version 4.
• It consists of 4 numbers separated by the dots.
• Each number can be from 0-255 in decimal numbers.
• But computers do not understand decimal numbers, they instead change them to binary numbers which
are only 0 and 1.
• Therefore, in binary, this (0-255) range can be written as (00000000 – 11111111).
• Since each number N can be represented by a group of 8-digit binary digits.
• So, a whole IPv4 binary address can be represented by 32-bits of binary digits.
37
• In IPv4, a unique sequence of bits is assigned to a computer, so a total of (2 32) devices approximately
= 4,294,967,296 can be assigned with IPv4.
• IPv4 can be written as: 189.123.123.90
• For easier management and assignment IP addresses are organized in numeric order and divided into
the following 5 classes:
• Types:
• IPv4 addresses are divided into two categories:
• Public address
• Private address
IPV4: Types
1. Public address
• Also known as an external address as they are grouped under the WAN addresses.
• Using this address, we can communicate outside the network.
• This address is used to access the internet.
• This address is generally assigned by the ISP (Internet Service Provider).
2. Private address
• A private address is also known as an internal address, as it is grouped under the LAN
addresses.
• It is used to communicate within the network.
• The private addresses are assigned to mainly those computers, printers, smartphones, which
are kept inside the home or the computers that are kept within the organization.
• To access the computer directly, NAT (Network Address Translator) is to be used.
2. IPv6:
• With IPv4, we can connect only the above number of 4 billion devices uniquely, and apparently, there
are much more devices in the world to be connected to the internet.
• IPv6 Address which is a 128-bit IP address.
• In human-friendly form, IPv6 is written as a group of 8 hexadecimal numbers separated with colons(:).
38
• But in the computer-friendly form, it can be written as 128 bits of 0s and 1s.
• Since, a unique sequence of binary digits is given to computers, smartphones, and other devices to be
connected to the internet.
• So, via IPv6 a total of (2128) devices can be assigned with unique addresses which are actually more
than enough for upcoming future generations.
• IPv6 can be written as:
2011:0bd9:75c5:0000:0000:6b3e: 0170:8394
IP Address: Classful Addressing
• An ip address is divided into two parts:
• Network ID: It represents the number of networks.
• Host ID: It represents the number of hosts.
• An IP address is 32-bit long.
• An IP address is divided into sub-classes:
• Class A
• Class B
• Class C
• Class D
• Class E
Class A
• In Class A, an IP address is assigned to those networks that contain a large number of hosts.
• The network ID is 8 bits long.
• The host ID is 24 bits long.
• In Class A, the first bit in higher order bits of the first octet is always set to 0 and the remaining 7 bits
determine the network ID.
• Total number of networks in Class A = 27 = 128 network address.
• Total number of hosts in Class A = 224-2 = 16,777,214 host address.
39
Class B
• In Class B, an IP address is assigned to those networks that range from small-sized to large-sized
networks.
• The Network ID is 16 bits long.
• The Host ID is 16 bits long.
• In Class B, the higher order bits of the first octet is always set to 10, and the remaining14 bits determine
the network ID. The other 16 bits determine the Host ID.
• Total number of networks in Class B = 214 = 16384 network address
• Total number of hosts in Class B = 216 - 2 = 65534 host address
Class C
• In Class C, an IP address is assigned to only small-sized networks.
• The Network ID is 24 bits long.
• The host ID is 8 bits long.
• In Class C, the higher order bits of the first octet is always set to 110, and the remaining 21 bits
determine the network ID.
• The 8 bits of the host ID determine the host in a network.
• The total number of networks = 221 = 2097152 network address
• The total number of hosts = 28 - 2 = 254 host address
Class D
• In Class D, an IP address is reserved for multicast addresses.
• It does not possess subnetting.
• The higher order bits of the first octet is always set to 1110, and the remaining bits determines the host
ID in any network.
Class E
• In Class E, an IP address is used for the future use or for the research and development purposes.
• It does not possess any subnetting.
• The higher order bits of the first octet is always set to 1111, and the remaining bits determines the host
ID in any network.
40
Rules for assigning Host ID:
• The Host ID is used to determine the host within any network.
Rules:
• The Host ID must be unique within any network.
• The Host ID in which all the bits are set to 0 cannot be assigned as it is used to represent the network
ID of the IP address.
• The Host ID in which all the bits are set to 1 cannot be assigned as it is reserved for the multicast
address.
Rules for assigning Network ID:
• If the hosts are located within the same local network, then they are assigned with the same network
ID.
Rules:
• The network ID cannot start with 127 as 127 is used by Class A.
• The Network ID in which all the bits are set to 0 cannot be assigned as it is used to specify a particular
host on the local network.
• The Network ID in which all the bits are set to 1 cannot be assigned as it is reserved for the multicast
address.
Classless Addressing-
• Classless Addressing is an improved IP Addressing system.
• It is also known as Classless Inter Domain Routing (CIDR).
• Classless addressing is the temporary fix.
• The entire address space is partitioned into blocks of varying lengths with classless addressing.
41
Prefix Length - Slash Notation
o In classless addressing, the address is inserted, followed by a slash, and the prefix length, n.
o Slash notation is the colloquial name for the notation, while classless interdomain routing, or CIDR
(pronounced cider) method, is the official name.
o An address in classless addressing can thus be expressed as
• The classless addressing also divides the IPv4 address into two parts referred to as ‘prefix‘ and
‘suffix‘.
• Prefix defines the network id whereas suffix defines the host address in the corresponding
network.
42