Unit 03
Unit 03
In computer networks, the shortest path algorithms aim to find the optimal paths
between the network nodes so that routing cost is minimized. They are direct
applications of the shortest path algorithms proposed in graph theory.
Dijkstra’s Algorithm
Input − A graph representing the network; and a source node, s
Dijkstra Algorithm-
Dijkstra Algorithm is a very famous greedy algorithm.
It is used for solving the single source shortest path problem.
It computes the shortest path from one particular source node to all other remaining
nodes of the graph.
It is important to note the following points regarding Dijkstra Algorithm-
Dijkstra algorithm works only for connected graphs.
Dijkstra algorithm works only for those graphs that do not contain any negative
weight edge.
It only provides the value or cost of the shortest paths.
By making minor modifications in the actual algorithm, the shortest paths can be
easily obtained.
Dijkstra algorithm works for directed as well as undirected graphs.
Algorithm-
Input Data-Cost Adjacency Matrix for Graph G, say cost Source vertex, say s
Output Data-Spanning tree having shortest path from s to all other vertices in G
Steps:
1. Initialize all nodes with a tentative distance of infinity, except the source
node, which is set to 0.
2. Mark all nodes as unvisited.
3. For the current node, update the distances to its neighbors.
4. Select the unvisited node with the smallest tentative distance as the next
node.
5. Repeat until all nodes are visited.
Complexity: O(V²) with a simple implementation, but with a priority queue, it
can be improved to O(E + V log V), where V is the number of vertices and E is
the number of edges.
Example: If we have a graph representing cities and roads, Dijkstra’s
algorithm will find the shortest path from one city to all others.
Hierarchical Routing
In hierarchical routing, routers are classified in groups known as regions. Each router has
only the information about the routers in its own region and has no information about
routers in other regions. So routers just save one record in their table for every other
region.
Hierarchical Structure
The network is divided into multiple levels. At each level, there is a hierarchy of routers that handle routing
within that level or between different levels.
2. Routing within Regions (Intra-domain Routing)
Within each region or subnet, routing is done by routers using local information, such as the IP addresses and
network topology within that region.
3. Routing between Regions (Inter-domain Routing)
When data needs to travel between different regions or subnets, routers at higher levels (often called border
routers or gateway routers) are responsible for forwarding the data.
These routers maintain routing information to other regions or networks and handle the communication
between different areas.
4. Reduced Routing Table Size
In hierarchical routing, instead of every router needing to know the complete network topology, routers only
need to know about the local region or domain and the routes to other regions.
5. Scalability
Hierarchical routing is particularly useful for large networks because it simplifies the routing process and
scales efficiently as the network grows.
broadcast routing
Broadcast Routing refers to the process of efficiently transmitting a message
from a single source node to all other nodes in a network. Unlike unicast routing
(which is one-to-one communication) and multicast routing (one-to-many
communication), broadcast routing ensures that a message or data packet is
delivered to every node in the network.
Broadcast routing is particularly important in network environments where there
is a need for a single message to be disseminated to all participants or devices,
such as in the case of network discovery protocols, or certain types of routing
updates and network maintenance tasks.
Types of Broadcast Routing
1. Flooding
•Flooding is the most basic form of broadcast routing.
When a node receives a broadcast message, it forwards it to all of its neighbors, except
the one from which it just received the message. This process continues until all nodes
in the network have received the message.
•Advantages: Very simple to implement, guarantees that every node receives the
broadcast.
•Disadvantages: Flooding leads to redundant messages, which causes network
congestion and inefficiency.
Spanning Tree-Based Broadcast
• In this approach, a spanning tree is created for the broadcast process, ensuring
that the message is sent along a tree structure where each edge is only used once,
eliminating redundancy.
• The network creates a broadcast tree, and the message is forwarded through the
tree, ensuring that it reaches all nodes without causing loops or multiple
transmissions over the same link.
Controlled Flooding
• Controlled Flooding is a more sophisticated version of flooding that aims to limit
the redundancy of broadcasts.
• The flooding process is controlled by using a combination of time-to-live (TTL)
values, hop count, or neighboring node information to restrict how far a
message can propagate. This reduces redundant messages by ensuring that a
broadcast message doesn’t travel too far.
Multicast Routing
Multicast Routing is a method used in computer networks to efficiently send
data from a single source to multiple destination nodes (but not all nodes) in a
network. Unlike unicast (one-to-one communication) and broadcast (one-to-all
communication), multicast allows one-to-many communication where data is
sent to a specific group of receivers, reducing unnecessary traffic and improving
network efficiency.
• Closed loop congestion control mechanisms try to remove the congestion after it happens.
• The various methods used for closed loop congestion control are:
Backpressure
• Back pressure is a node-to-node congestion control that starts with a node and propagates, in
the opposite direction of data flow. The backpressure technique can be applied only to virtual
circuit networks.
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.
• Here, congested node does not inform its upstream node about the congestion as in
backpressure method.
• In choke packet method, congested node sends a warning directly to the source station i.e. the
intermediate nodes through which the packet has traveled are not warned.
implicit Signaling
• In implicit signaling, there is no communication between the congested node or nodes and the
source.
Congestion control algorithms
Leaky Bucket Algorithm
• The leaky bucket algorithm allows only an average (constant) rate of data flow. Its
major problem is that it cannot deal with bursty data.
• A leaky bucket algorithm does not consider the idle time of the host. For example, if
the host was idle for 10 seconds and now it is willing to sent data at a very high speed
for another 10 seconds, the total data transmission will be divided into 20 seconds and
average data rate will be maintained. The host is having no advantage of sitting idle
for 10 seconds.
• To overcome this problem, a token bucket algorithm is used. A token bucket
algorithm allows bursty data transfers.
A token bucket algorithm is a modification of leaky bucket in which leaky bucket
contains tokens.
• In this algorithm, a token(s) are generated at every clock tick. For a packet to be
transmitted, system must remove token(s) from the bucket.
• Thus, a token bucket algorithm allows idle hosts to accumulate credit for the future in
form of tokens.
IP Addressing:
Like IP, UDP is connectionless and unreliable protocol. It doesn’t require making a
connection with the host to exchange data. Since UDP is unreliable protocol, there
is no mechanism for ensuring that data sent is received.
UDP transmits the data in form of a datagram. The UDP datagram consists of five
parts as shown in the following diagram:
Transmission Control Protocol (TCP)
TCP is a connection oriented protocol and offers end-to-end packet delivery. It acts
as back bone for connection. It exhibits the following key features:
Transmission Control Protocol (TCP) corresponds to the Transport Layer of OSI
Model.
TCP is a reliable and connection oriented protocol.
TCP offers:
Stream Data Transfer.
Reliability.
Efficient Flow Control
Full-duplex operation.
Multiplexing.
TCP offers connection oriented end-to-end packet delivery.
TCP Services
Stream Deliver Service
TCP protocol is stream oriented because it allows the sending process to send data as
stream of bytes and the receiving process to obtain data as stream of bytes.
Sending and Receiving Buffers
It may not be possible for sending and receiving process to produce and obtain data
at same speed, therefore, TCP needs buffers for storage at sending and receiving
ends.
Bytes and Segments
The Transmission Control Protocol (TCP), at transport layer groups the bytes into a
packet. This packet is called segment. Before transmission of these packets, these
segments are encapsulated into an IP datagram.
Connection Oriented Service
TCP offers connection oriented service in the following manner:
TCP of process-1 informs TCP of process – 2 and gets its approval.
TCP of process – 1 and TCP of process – 2 and exchange data in both the two
directions.
After completing the data exchange, when buffers on both sides are empty, the two
TCP’s destroy their buffers.
Trivial File Transfer Protocol (TFTP)
Trivial File Transfer Protocol is also used to transfer the files but it transfers
the files without authentication. Unlike FTP, TFTP does not separate control and
data information. Since there is no authentication exists, TFTP lacks in security
features therefore it is not recommended to use TFTP.
Key points
TFTP makes use of UDP for data transport. Each TFTP message is carried in
separate UDP datagram.
The first two bytes of a TFTP message specify the type of message.
The TFTP session is initiated when a TFTP client sends a request to upload or
download a file.
S.N. Parameter FTP TFTP
2 Authenticatio Yes No
n
Fields IPv4 is a numeric address that consists of 4 fields IPv6 is an alphanumeric address that consists of 8
which are separated by dot (.). fields, which are separated by colon.
Classes IPv4 has 5 different classes of IP address that IPv6 does not contain classes of IP addresses.
includes Class A, Class B, Class C, Class D, and
Class E.
Number of IP address IPv4 has a limited number of IP addresses. IPv6 has a large number of IP addresses.
VLSM It supports VLSM (Virtual Length Subnet Mask). It does not support VLSM.
Here, VLSM means that Ipv4 converts IP
addresses into a subnet of different sizes.
Address configuration It supports manual and DHCP configuration. It supports manual, DHCP, auto-configuration, and
renumbering.
Address space It generates 4 billion unique addresses It generates 340 undecillion unique addresses.
End-to-end connection integrity In IPv4, end-to-end connection integrity is In the case of IPv6, end-to-end connection integrity
unachievable. is achievable.
Security features In IPv4, security depends on the application. This In IPv6, IPSEC is developed for security purposes.
IP address is not developed in keeping the security
feature in mind.