0% found this document useful (0 votes)
8 views14 pages

CN Lab

This document provides a comprehensive case study on various routing algorithms (Link State, Flooding, and Distance Vector) and their applications in network path selection. It also discusses network simulation tools like Wireshark and TCPdump, the implementation of subnetting, and the use of network simulators such as Cisco Packet Tracer and NS3. Additionally, it covers the Stop-and-Wait and Sliding Window protocols for data transmission.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views14 pages

CN Lab

This document provides a comprehensive case study on various routing algorithms (Link State, Flooding, and Distance Vector) and their applications in network path selection. It also discusses network simulation tools like Wireshark and TCPdump, the implementation of subnetting, and the use of network simulators such as Cisco Packet Tracer and NS3. Additionally, it covers the Stop-and-Wait and Sliding Window protocols for data transmission.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Q1: Perform a case study about the different rou ng algorithms to select network path with its

op mum and economical during data transfer. i. link state rou ng . ii. flooding iii. distance vector.

Rou ng algorithms are the founda on of network communica on, responsible for selec ng efficient
paths for data packets to reach their des na on. Different algorithms offer different trade-offs in terms
of speed, reliability, cost, and scalability. This study evaluates Link State Rou ng, Flooding, and Distance
Vector Rou ng based on their working principles, advantages, disadvantages, op mality, economy,
and real-world use cases.

1. Link State Rou ng

Link State Rou ng relies on a complete view of the network. Each router independently builds a
network topology and calculates the shortest path to every des na on using Dijkstra’s algorithm.

Working:

 Routers exchange link state adver sements (LSAs) with neighbors.

 LSAs are flooded through the network.

 Each router builds a link-state database and calculates op mal routes.

Advantages:

 High accuracy and loop-free rou ng.

 Fast convergence and resilience to changes.

Disadvantages:

 Higher CPU and memory usage.

 Ini al 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.

Op mum & Economical:

 Op mal in path selec on due to full topology knowledge.

 Less economical in terms of processing and memory cost.

Conclusion

Link State Rou ng is op mal for large networks requiring high accuracy but at a higher cost.

2. Flooding

Flooding is a simple rou ng 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 rou ng table needed; suitable for unknown or dynamic topologies.

Disadvantages:

 High redundancy and network conges on.

 Inefficient and not scalable.

Use Case:

 Used in emergency communica on, ad-hoc networks, or rou ng discovery phase.

 Example: Route discovery in AODV protocol in mobile ad hoc networks (MANETs).

Op mum & Economical:

 Not op mal 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 Rou ng

Distance Vector Rou ng uses neighbor-based communica on 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 rou ng 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 rou ng loops.

 Vulnerable to issues like count-to-infinity.

Use Case:

 Ideal for small office or campus networks.

 Example: RIP (Rou ng Informa on Protocol) in legacy systems.

Op mum & Economical:

 Economical and easy to deploy.


 Less op mal due to limited network visibility.

Conclusion

Distance Vector Rou ng strikes a balance between simplicity and cost-efficiency, suitable for smaller
networks but with limited op mality.

2. Network Simula on using tools like Wireshark, TCPdump etc.

Network simula on and analysis help us understand how data flows, diagnose problems, and op mize
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,
troubleshoo ng, and protocol analysis.

Key Features:

 Packet Capture: Monitors and records real- me network traffic.

 Protocol Analysis: Supports many protocols like TCP, UDP, HTTP, DNS.

 Filtering: Apply filters based on IPs, ports, protocols to find relevant data.

 Sta s cs & Reports: Provides insights like protocol usage, packet counts.

 Save & Export: Saves traffic as .pcap files for sharing or deeper analysis.

How to Use in Simula on:

 Start capture on a selected interface.

 Apply filters (e.g., h p, [Link]==[Link]) to focus traffic.

 Analyze packet layers (Ethernet, IP, TCP, etc.).

 Use traffic generators like iperf or hping3 to simulate load or a acks.

Example Use Case:

Troubleshoo ng slow networks – Check for retransmissions, delays, or conges on using packet details.

2. TCPdump: A Command-Line Packet Analyzer

TCPdump is a lightweight, command-line tool for capturing network packets, o en used on servers or
remote systems.

Key Features:

 Packet Capture: Real- me capture in readable or savable format.

 Filtering: Supports detailed filters (IP, ports, protocols).

 CLI-Based: Ideal for scripts, automa on, or systems without a GUI.

 File Output: Captures can be saved in .pcap format for later use.

How to Use in Simula on:


 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 fi[Link] to save and open in Wireshark later.

Example Use Case:

Diagnosing connec vity 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 Tes ng: Check throughput, packet loss, and latency.

 Real-Time Feedback: Instant data for troubleshoo ng.

 Error Detec on: Iden fy problems like frame errors or link issues.

How to Use in Simula on:

 Set up two devices that support ETP.

 Run tests between them to measure speed and reliability.

 Analyze metrics like delay, ji er, and packet loss.

Example Use Case:

Op mizing Ethernet links – Use ETP to ensure cables, switches, and routers handle traffic efficiently.

Integra ng Wireshark, TCPdump, and ETP in a Simula on

Scenario: Simula ng and Troubleshoo ng High Latency

1. Setup Network:

 Create a LAN with routers, switches, and computers.

 Generate traffic using iperf to simulate real applica on 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, misconfigura on, or
network conges on.

Conclusion:

Combining Wireshark, TCPdump, and ETP gives you a powerful toolkit for network simula on and
troubleshoo ng.

Wireshark & TCPdump help analyze packet-level issues.

3. Implementa on of Subne ng.

Subne ng is the process of dividing a large network into smaller sub-networks (subnets). This
improves IP address usage, boosts performance, and simplifies network management.

Subne ng Concepts

IP Address:

A unique iden fier 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 star ng 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 Subne ng

Let’s go through an example:

Example:

 IP Address: [Link]/24

 Required Subnets: 4

Step-by-Step Subne ng

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]

Subne ng Tools

To simplify subne ng, 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 automa on

Example: Bash Script for Subnet Calcula on


#!/bin/bash

# Func on 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

Subne ng 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 essen al tools used by students, engineers, and researchers to simulate, test,
and analyze network configura ons 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 prac cing networking skills. Widely used by
students preparing for CCNA/CCNP.

Key Features:

 Drag-and-drop network design (routers, switches, PCs)

 Cisco device configura on via CLI

 Protocol support: TCP/IP, DHCP, DNS, HTTP

 Real- me packet simula on

 Interac ve for learning and troubleshoo ng


Limita ons:

 Limited to Cisco environments

 Not ideal for non-Cisco or advanced simula ons

Use Case:

Best for students and beginners learning basic networking and Cisco device configura on.

2. NetSim by Boson

A professional-grade simulator ideal for those preparing for advanced Cisco cer fica ons like CCNA,
CCNP, or CCIE.

Key Features:

 Accurate Cisco device simula on

 Pre-built lab exercises

 Support for advanced protocols (OSPF, BGP, EIGRP)

 Traffic simula on and network analysis

 Can import some Packet Tracer files

Use Case:

Great for professionals and serious learners aiming to prac ce real-world Cisco configura ons 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 simula ons

 GUI for designing network models

 Scalable and suitable for large networks

 Good visualiza on and repor ng tools

Use Case:

Ideal for researchers and academic users needing flexible, customizable simula ons of
communica on 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- me simula on of packet flow and conges on

 Well-documented with a large user base

Use Case:

S ll used in academic se ngs for protocol tes ng, though it’s gradually being replaced by NS3.

5. NS3 (Network Simulator 3)

A more modern and improved version of NS2, designed for realis c and complex network
simula ons.

Key Features:

 Realis c protocol simula on (TCP Cubic, LTE, Wi-Fi)

 Supports IoT and wireless networks

 Cross-layer performance tes ng

 Real- me simula on and emula on support

 Large protocol library (TCP, UDP, rou ng, applica on)

Use Case:

Best suited for advanced simula ons 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 cer fica on training.

 OMNeT++: Research-oriented tool ideal for academic and protocol development.

 NS2: Older but s ll useful for basic network protocol simula ons in academia.

 NS3: The most up-to-date and flexible simulator for real-world, scalable network tes ng.

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 meout 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++) {

prin ("Sender: Sending frame %d\n", frame);

sleep(1);

prin ("Sender: Wai ng for ACK...\n");

scanf("%d", &ack);

if (ack == frame) {

prin ("Sender: ACK %d received\n\n", ack);

} else {

prin ("Sender: ACK not received. Resending frame %d\n", frame);

frame--;

void receiver() {

int expected = 0, frame;

while (expected < 5) {

prin ("Receiver: Enter received frame: ");

scanf("%d", &frame);

if (frame == expected) {

prin ("Receiver: Frame %d received correctly\n", frame);

prin ("Receiver: Sending ACK %d\n\n", expected);

expected++;
} else {

prin ("Receiver: Unexpected frame. Sending ACK %d again\n\n", expected - 1);

int main() {

int choice;

prin ("1. Sender\n2. Receiver\nChoose mode: ");

scanf("%d", &choice);

if (choice == 1) {

sender();

} else if (choice == 2) {

receiver();

} else {

prin ("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 Simula on)

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 meout, 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) {

prin ("Sender: Sending frame %d\n", next_frame);

next_frame++;

prin ("Sender: Enter ACK for frame %d: ", base);

scanf("%d", &ack);

if (ack >= base && ack < TOTAL_FRAMES) {

prin ("Sender: ACK %d received\n\n", ack);

base = ack + 1;

} else {

prin ("Sender: Invalid ACK. Resending window from frame %d\n", base);

next_frame = base;

}
}

void receiver() {

int expected = 0, frame;

while (expected < TOTAL_FRAMES) {

prin ("Receiver: Enter received frame: ");

scanf("%d", &frame);

if (frame == expected) {

prin ("Receiver: Frame %d received correctly. Sending ACK %d\n\n", frame, expected);

expected++;

} else {

prin ("Receiver: Frame %d out of order. Resending ACK %d\n\n", frame, expected - 1);

int main() {

int choice;

prin ("1. Sender\n2. Receiver\nChoose mode: ");

scanf("%d", &choice);

if (choice == 1) {

sender();

} else if (choice == 2) {

receiver();

} else {

prin ("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

You might also like