Q1: Perform a case study about the different routing algorithms to select network path with its
optimum and economical during data transfer. i. link state routing . ii. flooding iii. distance vector.
Routing algorithms are the foundation of network communication, responsible for selecting efficient
paths for data packets to reach their destination. Different algorithms offer different trade-offs in terms
of speed, reliability, cost, and scalability. This study evaluates Link State Routing, Flooding, and Distance
Vector Routing based on their working principles, advantages, disadvantages, optimality, economy,
and real-world use cases.
1. Link State Routing
Link State Routing relies on a complete view of the network. Each router independently builds a
network topology and calculates the shortest path to every destination using Dijkstra’s algorithm.
Working:
• Routers exchange link state advertisements (LSAs) with neighbors.
• LSAs are flooded through the network.
• Each router builds a link-state database and calculates optimal routes.
Advantages:
• High accuracy and loop-free routing.
• Fast convergence and resilience to changes.
Disadvantages:
• Higher CPU and memory usage.
• Initial setup and LSA flooding create overhead.
Use Case:
• Used in large-scale enterprise or ISP networks.
• Example: OSPF (Open Shortest Path First) protocol in corporate data centers.
Optimum & Economical:
• Optimal in path selection due to full topology knowledge.
• Less economical in terms of processing and memory cost.
Conclusion
Link State Routing is optimal for large networks requiring high accuracy but at a higher cost.
2. Flooding
Flooding is a simple routing method where each node sends incoming packets out on all outgoing links.
It ensures packet delivery but is not efficient for everyday use.
Working:
• A node forwards every incoming packet to all neighbors, except the one it received it from.
• May implement mechanisms like hop count or sequence numbers to avoid infinite loops.
Advantages:
• Guaranteed delivery if a path exists.
• No routing table needed; suitable for unknown or dynamic topologies.
Disadvantages:
• High redundancy and network congestion.
• Inefficient and not scalable.
Use Case:
• Used in emergency communication, ad-hoc networks, or routing discovery phase.
• Example: Route discovery in AODV protocol in mobile ad hoc networks (MANETs).
Optimum & Economical:
• Not optimal or economical; suited only for temporary or emergency use.
Conclusion:
Flooding is not economical for regular use but reliable for emergency or ad hoc scenarios.
3. Distance Vector Routing
Distance Vector Routing uses neighbor-based communication where each router shares its view of the
network with directly connected routers. It calculates routes based on distance metrics.
Working:
• Routers exchange periodic updates of their routing tables with neighbors.
• Uses Bellman-Ford algorithm to determine shortest paths.
Advantages:
• Simple and uses less memory and processing power.
• Easy to implement in small networks.
Disadvantages:
• Slow convergence and may cause routing loops.
• Vulnerable to issues like count-to-infinity.
Use Case:
• Ideal for small office or campus networks.
• Example: RIP (Routing Information Protocol) in legacy systems.
Optimum & Economical:
• Economical and easy to deploy.
• Less optimal due to limited network visibility.
Conclusion
Distance Vector Routing strikes a balance between simplicity and cost-efficiency, suitable for smaller
networks but with limited optimality.
2. Network Simulation using tools like Wireshark, TCPdump etc.
Network simulation and analysis help us understand how data flows, diagnose problems, and optimize
performance. Tools like Wireshark, TCPdump, and ETP (Ethernet Test Protocol) are commonly used for
this purpose.
1. Wireshark: A Network Protocol Analyzer
Wireshark is a GUI-based tool used to capture and analyze live network traffic. It’s useful for debugging,
troubleshooting, and protocol analysis.
Key Features:
• Packet Capture: Monitors and records real-time network traffic.
• Protocol Analysis: Supports many protocols like TCP, UDP, HTTP, DNS.
• Filtering: Apply filters based on IPs, ports, protocols to find relevant data.
• Statistics & Reports: Provides insights like protocol usage, packet counts.
• Save & Export: Saves traffic as .pcap files for sharing or deeper analysis.
How to Use in Simulation:
• Start capture on a selected interface.
• Apply filters (e.g., http, [Link]==[Link]) to focus traffic.
• Analyze packet layers (Ethernet, IP, TCP, etc.).
• Use traffic generators like iperf or hping3 to simulate load or attacks.
Example Use Case:
Troubleshooting slow networks – Check for retransmissions, delays, or congestion using packet details.
2. TCPdump: A Command-Line Packet Analyzer
TCPdump is a lightweight, command-line tool for capturing network packets, often used on servers or
remote systems.
Key Features:
• Packet Capture: Real-time capture in readable or savable format.
• Filtering: Supports detailed filters (IP, ports, protocols).
• CLI-Based: Ideal for scripts, automation, or systems without a GUI.
• File Output: Captures can be saved in .pcap format for later use.
How to Use in Simulation:
• Run: sudo tcpdump -i eth0 to capture on interface eth0.
• Add filters: Example, tcpdump -i eth0 port 80 to capture HTTP.
• Save data: Use -w [Link] to save and open in Wireshark later.
Example Use Case:
Diagnosing connectivity issues – Check if devices are sending/receiving packets or analyze TCP
handshakes and ICMP replies.
3. ETP (Ethernet Test Protocol)
ETP is used to test Ethernet network performance, measuring bandwidth, latency, and errors.
Key Features:
• Performance Testing: Check throughput, packet loss, and latency.
• Real-Time Feedback: Instant data for troubleshooting.
• Error Detection: Identify problems like frame errors or link issues.
How to Use in Simulation:
• Set up two devices that support ETP.
• Run tests between them to measure speed and reliability.
• Analyze metrics like delay, jitter, and packet loss.
Example Use Case:
Optimizing Ethernet links – Use ETP to ensure cables, switches, and routers handle traffic efficiently.
Integrating Wireshark, TCPdump, and ETP in a Simulation
Scenario: Simulating and Troubleshooting High Latency
1. Setup Network:
• Create a LAN with routers, switches, and computers.
• Generate traffic using iperf to simulate real application usage.
2. Capture Traffic with TCPdump:
• Run TCPdump on a router to monitor traffic.
• Look for packet loss, retransmissions, or delay.
3. Analyze with Wireshark:
• Use Wireshark on another device to get detailed packet analysis.
• Apply filters to focus on problem areas.
4. Run ETP Tests:
• Measure performance between routers or switches.
• Compare ETP metrics with Wireshark/TCPdump data.
5. Troubleshoot the Network:
• Use insights from all three tools to detect issues like faulty cables, misconfiguration, or
network congestion.
Conclusion:
Combining Wireshark, TCPdump, and ETP gives you a powerful toolkit for network simulation and
troubleshooting.
Wireshark & TCPdump help analyze packet-level issues.
3. Implementation of Subnetting.
Subnetting is the process of dividing a large network into smaller sub-networks (subnets). This
improves IP address usage, boosts performance, and simplifies network management.
Subnetting Concepts
IP Address:
A unique identifier for a device, made up of 4 octets (e.g., [Link]).
Subnet Mask:
Defines which part of the IP is the network and which part is for hosts.
Example: [Link] (binary: 24 ones followed by 8 zeros)
Network Address:
The starting address of a subnet, calculated using a logical AND between the IP and the subnet mask.
Broadcast Address:
The last address in a subnet; used to communicate with all hosts in that subnet.
Host Range:
The range of usable IP addresses in a subnet, excluding the network and broadcast addresses.
Steps for Subnetting
Let’s go through an example:
Example:
• IP Address: [Link]/24
• Required Subnets: 4
Step-by-Step Subnetting
1. Determine the Number of Bits to Borrow
Use the formula:
Number of subnets = 2^n
To get 4 subnets, n = 2 (since 2² = 4)
2. Determine the New Subnet Mask
• Original: /24 → [Link]
• Borrow 2 bits → /26 → [Link]
(binary: 11111111.11111111.11111111.11000000)
3. Calculate Number of Hosts per Subnet
• 6 bits remain for hosts → 2^6 - 2 = 62 usable IPs per subnet
4. Determine the Subnet Ranges
Each /26 subnet has 64 total addresses (62 usable). Subnets will increment by 64.
Subnet 1:
• Network: [Link]
• Broadcast: [Link]
• Usable Range: [Link] – [Link]
Subnet 2:
• Network: [Link]
• Broadcast: [Link]
• Usable Range: [Link] – [Link]
Subnet 3:
• Network: [Link]
• Broadcast: [Link]
• Usable Range: [Link] – [Link]
Subnet 4:
• Network: [Link]
• Broadcast: [Link]
• Usable Range: [Link] – [Link]
Subnetting Tools
To simplify subnetting, you can use tools like:
• Online Subnet Calculators (e.g., SubnetOnline, IPCalc)
• CIDR Tools for mask conversion
• Network Simulators like Cisco Packet Tracer or GNS3
• Bash Scripts for automation
Example: Bash Script for Subnet Calculation
#!/bin/bash
# Function to calculate subnet
calculate_subnet() {
local ip=$1
local mask=$2
local subnet_size=$(( 2 ** (32 - mask) ))
echo "IP Address: $ip"
echo "Subnet Mask: /$mask"
echo "Subnet Size: $subnet_size addresses"
# Example Usage
ip_address="[Link]"
subnet_mask="26"
calculate_subnet $ip_address $subnet_mask
Conclusion
Subnetting allows network administrators to:
Manage IP addresses more efficiently
Improve network security and performance
Create scalable, structured networks
4. Network simulator (NS) using tools like Cisco Packet Tracer, NetSim, OMNet++, NS2, NS3 etc.
Network simulators are essential tools used by students, engineers, and researchers to simulate, test,
and analyze network configurations and protocols. They allow users to build virtual networks and
study network behavior without physical devices.
1. Cisco Packet Tracer
Developed by Cisco, this tool is mainly for learning and practicing networking skills. Widely used by
students preparing for CCNA/CCNP.
Key Features:
• Drag-and-drop network design (routers, switches, PCs)
• Cisco device configuration via CLI
• Protocol support: TCP/IP, DHCP, DNS, HTTP
• Real-time packet simulation
• Interactive for learning and troubleshooting
Limitations:
• Limited to Cisco environments
• Not ideal for non-Cisco or advanced simulations
Use Case:
Best for students and beginners learning basic networking and Cisco device configuration.
2. NetSim by Boson
A professional-grade simulator ideal for those preparing for advanced Cisco certifications like CCNA,
CCNP, or CCIE.
Key Features:
• Accurate Cisco device simulation
• Pre-built lab exercises
• Support for advanced protocols (OSPF, BGP, EIGRP)
• Traffic simulation and network analysis
• Can import some Packet Tracer files
Use Case:
Great for professionals and serious learners aiming to practice real-world Cisco configurations and
labs.
3. OMNeT++
An open-source simulator for academic and research use. It focuses on custom and large-scale
network modeling.
Key Features:
• Modular design for building custom protocols
• Supports TCP, UDP, IP simulations
• GUI for designing network models
• Scalable and suitable for large networks
• Good visualization and reporting tools
Use Case:
Ideal for researchers and academic users needing flexible, customizable simulations of
communication networks.
4. NS2 (Network Simulator 2)
A widely-used, open-source tool for network research and teaching, though older than modern
simulators.
Key Features:
• Supports many protocols (TCP, UDP, RIP, OSPF)
• Scriptable using C++ and TCL
• Real-time simulation of packet flow and congestion
• Well-documented with a large user base
Use Case:
Still used in academic settings for protocol testing, though it’s gradually being replaced by NS3.
5. NS3 (Network Simulator 3)
A more modern and improved version of NS2, designed for realistic and complex network
simulations.
Key Features:
• Realistic protocol simulation (TCP Cubic, LTE, Wi-Fi)
• Supports IoT and wireless networks
• Cross-layer performance testing
• Real-time simulation and emulation support
• Large protocol library (TCP, UDP, routing, application)
Use Case:
Best suited for advanced simulations in wireless, IoT, and modern internet technologies. Used heavily
in research and development.
Conclusion
• Cisco Packet Tracer: Best for beginners and Cisco-focused learning.
• NetSim: Professional tool for advanced Cisco certification training.
• OMNeT++: Research-oriented tool ideal for academic and protocol development.
• NS2: Older but still useful for basic network protocol simulations in academia.
• NS3: The most up-to-date and flexible simulator for real-world, scalable network testing.
5. Implement Stop and Wait Protocol and Sliding Window Protocol.
1. Stop-and-Wait Protocol
Algorithm (Sender Side):
1. Send a data frame.
2. Wait for the acknowledgment (ACK).
3. If ACK received, send the next frame.
4. If timeout or no ACK, resend the frame.
Algorithm (Receiver Side):
1. Wait for a data frame.
2. If received and valid, send an ACK.
3. If duplicate or invalid frame, ignore or resend last ACK.
Code: Stop-and-Wait Protocol
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void sender() {
int frame, ack;
for (frame = 0; frame < 5; frame++) {
printf("Sender: Sending frame %d\n", frame);
sleep(1);
printf("Sender: Waiting for ACK...\n");
scanf("%d", &ack);
if (ack == frame) {
printf("Sender: ACK %d received\n\n", ack);
} else {
printf("Sender: ACK not received. Resending frame %d\n", frame);
frame--;
void receiver() {
int expected = 0, frame;
while (expected < 5) {
printf("Receiver: Enter received frame: ");
scanf("%d", &frame);
if (frame == expected) {
printf("Receiver: Frame %d received correctly\n", frame);
printf("Receiver: Sending ACK %d\n\n", expected);
expected++;
} else {
printf("Receiver: Unexpected frame. Sending ACK %d again\n\n", expected - 1);
int main() {
int choice;
printf("1. Sender\n2. Receiver\nChoose mode: ");
scanf("%d", &choice);
if (choice == 1) {
sender();
} else if (choice == 2) {
receiver();
} else {
printf("Invalid choice.\n");
return 0;
Output:
Sender: Sending frame A
Sender: ACK for frame A received
Sender: Sending frame B
Sender: ACK lost for frame B. Resending frame.
Sender: Sending frame B
Sender: ACK for frame B received.
Sender: Sending frame C
Sender: ACK for frame C received.
Sender: Sending frame D
Sender: ACK for frame D received.
2. Sliding Window Protocol (Go-Back-N Simulation)
Algorithm (Sender Side):
1. Send all frames within the window size.
2. Wait for ACKs.
3. If ACK for first frame in window is received, slide window forward.
4. If timeout, resend all frames from the missing ACK onward.
Algorithm (Receiver Side):
1. Accept frames in sequence.
2. Send ACK for last correctly received frame.
3. If frame is out of order, discard and resend last ACK.
Code: Sliding Window Protocol
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define WINDOW_SIZE 4
#define TOTAL_FRAMES 10
void sender() {
int base = 0, next_frame = 0, ack;
while (base < TOTAL_FRAMES) {
while (next_frame < base + WINDOW_SIZE && next_frame < TOTAL_FRAMES) {
printf("Sender: Sending frame %d\n", next_frame);
next_frame++;
printf("Sender: Enter ACK for frame %d: ", base);
scanf("%d", &ack);
if (ack >= base && ack < TOTAL_FRAMES) {
printf("Sender: ACK %d received\n\n", ack);
base = ack + 1;
} else {
printf("Sender: Invalid ACK. Resending window from frame %d\n", base);
next_frame = base;
}
}
void receiver() {
int expected = 0, frame;
while (expected < TOTAL_FRAMES) {
printf("Receiver: Enter received frame: ");
scanf("%d", &frame);
if (frame == expected) {
printf("Receiver: Frame %d received correctly. Sending ACK %d\n\n", frame, expected);
expected++;
} else {
printf("Receiver: Frame %d out of order. Resending ACK %d\n\n", frame, expected - 1);
int main() {
int choice;
printf("1. Sender\n2. Receiver\nChoose mode: ");
scanf("%d", &choice);
if (choice == 1) {
sender();
} else if (choice == 2) {
receiver();
} else {
printf("Invalid choice.\n");
return 0;
Output:
Sender: Sending frame A
Sender: Sending frame B
Sender: Sending frame C
Sender: ACK received for frame A
Sender: ACK received for frame B
Sender: ACK lost for frame C. Go-Back-N triggered.
Sender: Sending frame A
Sender: Sending frame B
Sender: Sending frame C
Sender: ACK received for frame A
Sender: ACK received for frame B
Sender: ACK received for frame C
Sender: Sending frame D
Sender: Sending frame E
Sender: Sending frame F
Sender: ACK received for frame D
Sender: ACK received for frame E
Sender: ACK received for frame F