0% found this document useful (0 votes)
17 views36 pages

CN Almost

The document is a lab manual for a Computer Network course at the Oriental Institute of Science & Technology, detailing various experiments related to networking concepts and technologies. It includes aims, theoretical backgrounds, and procedures for experiments on LAN configurations, network topologies, error correction techniques, framing methods, and the use of network simulators. The manual is prepared by a student and submitted to a professor, indicating its academic purpose for the Jan - June 2025 session.

Uploaded by

Muskaan Pandey
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)
17 views36 pages

CN Almost

The document is a lab manual for a Computer Network course at the Oriental Institute of Science & Technology, detailing various experiments related to networking concepts and technologies. It includes aims, theoretical backgrounds, and procedures for experiments on LAN configurations, network topologies, error correction techniques, framing methods, and the use of network simulators. The manual is prepared by a student and submitted to a professor, indicating its academic purpose for the Jan - June 2025 session.

Uploaded by

Muskaan Pandey
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
You are on page 1/ 36

ORIENTAL INSTITUTE OF SCIENCE & TECHNOLOGY, BHOPAL

DEPARTMENT OF ARTIFICIAL INTELLIGENCE & MACHINE


LEARNING

LAB MANUAL

Name: Computer Network


Course Code: AL - 602
Course: B. Tech
Session: Jan - June, 2025

Prepared By : Submitted to :
Roll No - 0105AL221108 Prof. Sandhya Vishwakarma
Name - Krity Kumari CSE-AIML, OIST
LIST OF EXPERIMENTS

Date Date Sign/R


Sr. No. Name of Experiments
emarks

To study of different type of LAN and


1
equipment devices

Study and verification of standard Network


2
topologies i.e. Star, Bus, Ring etc.

3 LAN installations and their Configurations.

To implement various types of error correcting


4
techniques.

To implement various types of framing


5
methods.

6 To study of Tool Command Language (TCL).

Study and Installation of Standard Network


7
Simulator: N.S-2, N.S-3.OpNet,QualNet etc

Study & Installation of ONE (Opportunistic


8 Network Environment) Simulator for High
Mobility Networks

9 Configure 802.11 WLAN

Implement & Simulate various types of


10
routing algorithm.

Study & Simulation of MAC Protocols like


11 Aloha, CSMA, CSMA/CD and CSMA/CA
using Standard Network Simulators

Study of Application layer protocols- DNS,


12
HTTP, HTTPS, FTP and TelNet.
EXPERIMENT NO. 1

AIM: To study various types of connectors.

1. Repeater
2. Hub
3. Switch
4. Bridge
5. Router
6. Gate Way

Apparatus Required
No software or hardware needed

Theory

1. Repeater: Functioning at Physical Layer. A repeater is an electronic device


that receives a signal and retransmits it at a higher level and/or higher power.
Repeaters have two ports, so cannot be used to connect for more than two
devices.

2. Hub: An Ethernet hub, active hub, network hub, repeater hub, hub or
concentrator is a device for connecting multiple twisted pair or fiber optic
Ethernet devices together and making them act as a single network segment.
Hubs work at the physical layer of the OSI model.

3. Switch: A network switch or switching hub is a computer networking device


that connects network segments. The term commonly refers to a network
bridge that processes and routes data at the data link layer of the OSI model.

4. Bridge: A network bridge connects multiple network segments at the data


link layer of the OSI model. Switch of layer 2 switch is often used
interchangeably with bridge. Bridges can analyze incoming data packets to
determine if the bridge is able to send the given packet to another segment of
the network.

5. Router: A router is an electronic device that interconnects two or more


computer networks, and selectively interchanges packets of data between
them. Each data packet contains address information that a router can use to
determine if the source and destination are on the same network.

6. Gate way: A gateway may contain devices such as protocol translators,


impedance matching devices, rate converters, fault isolators as necessary to
provide system interoperability. It also requires the establishment of
mutually acceptable administrative procedures between both networks.
EXPERIMENT NO. 2

AIM: Study and verification of standard Network topologies i.e. Star, Bus,
Ring etc.

Theory

Network topology is the arrangement of the various elements (links, nodes,


etc.) of a computer or biological network. Essentially, it is the topological
structure of a network, and may be depicted physically or logically.

Physical topology refers to the placement of the network's various components,


including device location and cable installation, while logical topology shows
how data flows within a network, regardless of its physical design.

Graphically mapping links results in a geometric shape that can be used to


describe the physical topology of the network. Conversely, mapping the data
flow between the components determines the logical topology of the network.

Types of Topology

There are two basic categories of network topologies:

1. Physical topologies
2. Logical topologies

▪ The shape of the cabling layout used to link devices is called the physical
topology of the network. The physical topology of a network is
determined by the capabilities of the network access devices and media,
the level of control or fault tolerance desired, and the cost associated with
cabling or telecommunications circuits.
▪ The logical topology, in contrast, is the way that the signals act on the
network media, or the way that the data passes through the network from
one device to the next without regard to the physical interconnection of
the devices.
▪ A network's logical topology is not necessarily the same as its physical
topology. Token Ring is a logical ring topology, but is wired a physical
star from the Media Access Unit.
▪ The logical classification of network topologies generally follows the
same classifications as those in the physical classifications of network
topologies but describes the path that the data takes between nodes being
used as opposed to the actual physical connections between nodes.
▪ The logical topologies are generally determined by network protocols as
opposed to being determined by the physical layout of cables, wires, and
network devices or by the flow of the electrical signals, although in many
cases the paths that the electrical signals take between nodes may closely
match the logical flow of data, hence the convention of using the terms
logical topology and signal topology interchangeably.

The study of network topology recognizes eight basic topologies:

• Point-to-point
• Bus
• Star
• Ring or circular
• Mesh
• Tree
• Hybrid
• Daisy chain
EXPERIMENT NO. 3

AIM: LAN installations and their Configurations.

Theory
Performance:
Perform the following steps as directed

Step 1: To make a Direct Cable connection

1. Click Start, click Control Panel, and then double-click Network


Connections.
2. Under Network Tasks, click Create a new connection, and then click next.
3. Click Set up an advanced connection, and then click next.
4. Click Connect directly to another computer, and click next.
5. Choose the role this machine will play in the communication. If this computer
has the information to which you need to gain access, click Host. If this
computer will access information from the other computer, click Guest.

Step 2: To Set Up the Host Computer

1. Click the connection device that you want to use for this connection (a
parallel or serial port, or an infrared port), and then click Next.
2. Grant access to the users who are allowed to connect by selecting the
appropriate check boxes, and then click Next.
3. Click Finish to end the configuration process.

Step 3: To Set up the Guest Computer

1. Type a name to identify this connection, and then click Next.


2. Click the connection device that you want to use for this connection (a
parallel or serial port, or an infrared port), and then click Next.
3. Decide whether this connection will be available for all users (click Anyone's
use), or only for you (click my use only), and then click Next.
4. Click Finish to end the setup process

Step 4: To create Windows Workgroup


1. In Windows XP, right click on My Computer, select System Properties.
2. Select the Computer Name tab, click on Change.
3. Enter the appropriate Computer name and Workgroup.
4. Make sure that every computer on your home network references the same
workgroup.

Step 5: To Configure TCP/IP

To assign IP address, gateway, subnet mask, DNS

Step 6: To create domain

1. Bring all the PC of Lab under a network using workgroup or domain.


2. Create client and server

Result/ Conclusions

Windows workgroup is established and used for sharing and transferring data
between physically connected PCs.
EXPERIMENT NO. 4

AIM: To implement various types of error correcting techniques.

Theory
Error detection and correction are implemented either at the data link layer or
the transport layer of the OSI model.

Types of Errors

Single-bit error

Single bit errors are the least likely type of errors in serial data transmission
because the noise must have a very short duration which is very rare. However
this kind of errors can happen in parallel transmission.

Example:
 If data is sent at 1Mbps then each bit lasts only 1/1,000,000 sec. or 1 μs.
 For a single-bit error to occur, the noise must have a duration of only 1
μs, which is very rare.
Burst error

Burst errors do not necessarily mean that the errors occur in consecutive
bits, the length of burst is measured from the first corrupted bit to last corrupted
bit. The number of bits affected depends on data rate and duration of noise.

Example:
If data is sent at rate = 1Kbps then a noise of 1/100 sec can affect 10
bits.(1/100*1000)

CYCLIC REDUNDANCY CHECK (CRC) LOGIC:

1. Let r be the degree of G(x).Append r zero bits to the low-order end of the
frame. So it now contains m+r bits and corresponds to the polynomial x2 m(x).

2. Divide the bit string corresponding to G(x) into the bit string corresponding
to x2 m(x) using modulo-2 division.

3. Subtract the remainder from the bit string corresponding to x2 m(x) using
modulo-2 sub. The result is the check summed frame to be transmitted. We call
it as a polynomial.
EXPERIMENT NO. 5

AIM : To implement various types of framing methods.

a) CHARACTER COUNT

b) BIT STUFFING AND DE STUFFING

c) CHARACTER STUFFING AND DE STUFFING

Theory:

CHARACTER COUNT

LOGIC: The header in the given frame is by default first frame size including
the first field data bits are counted and considered as the first frame and the next
field contains the next frame size and so on.

PSEUDO CODE:
1. At the sender side the user is asked to enter the number of frames he want to
transmit.
2. Depending upon the input, that much number of frames are taken as input
from the user and stored in a 2 by 2 matrix.
3. The length of each frame is calculated and stored in a new array.
4. While out putting the frame, the length of each frame is added to the each
frame and finally all the frames are appended and sent as a single string.
5. At the receiver side, the first number is treated as the length of the first frame
and the string is extracted and displayed.
6. The next number is treated as the length of the next frame and so on.

At Sender:
INPUT:
Enter the number of frames you want to send: 2
Enter the frame: 1234
Enter the frame: 678
OUTPUT
The transmitted frame is: 512344678
At receiver:
INPUT:
Enter data 512344678
OUTPUT:
Frame sizes are: 5 4
Frames are:
Frame 1: 1234
Frame 2: 678

BIT STUFFING

LOGIC: Stuffing a 0 bit in a data frame in order to differentiate the header,


trailer and data.

PSEUDO CODE:

1. a flag “01111110” is embedded at the starting and the ending of the data.
2. if data bit is 1 increment count else count is zero.
3. If count is five store a zero bit after the five 1‟s in the data array.
4. Repeat step 3 till the end of data. /* De stuffing of data */
5. If the data bit is 1 increment count else count is zero.
6. If the count is five and the next bit is zero then store the next bit after zero in
the data array. /* transmit the data */
7. De stuffed data is transmitted without flags.

At sender:
INPUT:
Enter the string 1111110101
OUTPUT:
Transmitted data is: 01111110111111010101111110
Stuffed data is: 011111101111101010101111110

At Receiver:
INPUT:
Enter the string 1111110101
OUTPUT:
De stuffed data is: 11111110101

CHARACTER STUFFING & DE STUFFING

LOGIC: In a char data frame if a DLE is encountered between data, it is


doubled & transmitted at receiver side, de stuffed & original data is obtained.
PSEUDO CODE:

1. As the DLE characters are non-printable characters. The ASCII values of the
printable characters like *, #, $ are assigned to DLE, STX, ETX.

2. If the ASCII value that is assigned to DLE occurs in the data array another
DLE character is stuffed and stored in the array and transmitted along with
starting and ending flags

3. If the ASCII value of DLE occurs in the data array, the next bit is stored in to
the array and transmitted without the flags.

4. Here whenever the program encounters characters like * the string DLE is
added to the original string.

At Sender:
INPUT:
Enter Data r*gm
OUTPUT:
Stuffed data DLESTXrDLEDLEgmDLEETX

At receiver:
OUTPUT:
The message: r*gm
EXPERIMENT NO. 6

AIM: Study of Tool Command Language (Tcl)

Theory:

Tcl (originally from "Tool Command Language") is a scripting language


created by John Ouster out. Originally "born out of frustration”, according to the
author, with programmers devising their own languages intended to be
embedded into applications.

It is commonly used for rapid prototyping, scripted applications, GUIs and


testing. Tcl is used on embedded systems platforms, both in its full form and in
several other small-footprint versions.

The combination of Tcl and the TkGUI toolkit is referred to as Tcl/Tk.

Features

Tcl's features include:

• All operations are commands, including language structures. They are


written in prefix notation.
• Commands are commonly variadic.
• Everything can be dynamically redefined and overridden.
• All data types can be manipulated as strings, including source code.
• Event-driven interface to sockets and files. Time-based and user-defined
events are also possible.
• All commands defined by Tcl itself generate error messages on incorrect
usage.
• Extensibility, via C, C++, Java, and Tcl.
• Interpreted language using byte code
• Full Unicode (3.1) support, first released 1999.
• Cross-platform: Windows API; UNIX, Linux, Macintosh, etc.
• Close integration with windowing (GUI) interface Tk.

Syntax and fundamental semantics

▪ A Tcl script consists of several command invocations. A command


invocation is a list of words separated by whitespace and terminated by a
newline or semicolon.
word0 word1 word2 ... wordN

▪ The first word is the name of a command, which is not built into the
language, but which is in the library. The following words are arguments.
So we have:

commandName argument1 argument2 ... argumentN

▪ Practical example, using the puts command which outputs a string,


adding a trailing newline, by default to the stdout channel:

puts"Hello, world!"

▪ Variables and the results of other commands can be substituted inside


strings too, such as in this example where we use set and expr to store a
calculation result in a variable, and puts to print the result together with
some explanatory text:

# Good style would put the expression (1+2+3+4+5, in this case) inside {curly
braces}
set sum [expr1+2+3+4+5]
puts"The sum of the numbers 1..5 is $sum."

#expr function will be evaluated faster if curly braces are added on the equation.

set sum [expr{1+2+3+4+5}]


puts"The sum of the numbers 1..5 is $sum."

(subject to syntactic constraints) as other types on demand. However, values are


immutable and operations that appear to change them actually just return a new
value instead.
EXPERIMENT NO. 7

AIM: Study and Installation of Standard Network Simulator

Theory:

▪ Network simulation is a technique where a program models the behavior


of a network either by calculating the interaction between the different
network entities (hosts/routers, data links, packets, etc.) using
mathematical formulas, or actually capturing and playing back
observations from a production network.

▪ The behavior of the network and the various applications and services it
supports can then be observed in a test lab.

▪ When a simulation program is used in conjunction with live applications


and services in order to observe end-to-end performance to the user
desktop, this technique is also referred to as network emulation.

Network simulator

A network simulator is a piece of software or hardware that predicts the


behavior of a network, without an actual network being present. A network
simulator is a software program that imitates the working of a computer
network.

In simulators, the computer network is typically modeled with devices, traffic


etc. and the performance is analyzed. Simulators typically come with support
for the most popular protocols in use today, such as WLAN, Wi-Max, UDP, and
TCP.

Simulations

• Most of the commercial simulators are GUI driven, while some network
simulators require input scripts or commands (network parameters). An
important output of simulations is the trace files. Network simulators can
also provide other tools to facilitate visual analysis of trends and potential
trouble spots.
• Most network simulators use discrete event simulation, in which a list of
pending "events" is stored, and those events are processed in order.
• Markov chain simulation is typically faster but less accurate and flexible
than detailed discrete event simulation. Some simulations are cyclic based
simulations and these are faster as compared to event based simulations.
• Simulation of networks can be a difficult task. For example, if congestion
is high, then estimation of the average occupancy is challenging because
of high variance.

Examples of network simulators

Examples of notable network simulation software are, ordered after how often
they are mentioned in research papers:

1. ns2/ns3
2. OPNET
3. NetSim

Components

• Ns, the simulator itself has Nam, the network animator to visualize ns
(or other) output.
• Pre-processing component for Traffic and topology generators.
• Post-processing for Simple trace analysis, often in Awk, Perl, or Tcl.

Installation of Network Simulator:

1. Install CYGWIN

• Download zip file of ns2.29 (allinone) from:


http://www.isi.edu/nsnam/dist/ns-allinone-2.29.2.tar.gz
• Download cygwin setup.exe from www.cygwin.com
• Click on “cygwin.exe”.

▪ Select “install local directory.


▪ Select browse for “cygwin” file (I selected as default).
▪ Install
“C:\NS2\NS-2.29 Install files\Cygwin
files\ftp%3a%2f%2fftp.mirror.ac.uk%2fsites%2fsources.redhat.com%2fft
p%2fcygwin”

▪ Select to install all


You can select “install”, “default”, “uninstall”, “install”, and “reinstall” behind
the first line “all”. If we select “install”, then all sub items will be automatically
selected. Otherwise you may lose some items.

• Finish in installing
“ftp%3a%2f%2fftp.mirror.ac.uk%2fsites%2fsources.redhat.com%2fftp%
2fcygwin”

• Install “Install
“C:\NS2\NS-2.29 Install files\Cygwin files \
ftp%3a%2f%2fftp.is.co.za%2fmirrors%2fcygwin”.

• Select to install all.


• Finish in stalling “ftp%3a%2f%2fftp.is.co.za%2fmirrors%2fcygwin”
EXPERIMENT NO. 8

AIM: Study & Installation of ONE (Opportunistic Network Environment)


Simulator for High Mobility Networks.

Theory-

▪ The goal of this study is to add more realism to the simulations of Delay
Tolerant Networks. For this purpose, we created a new simulation
environment called Opportunistic Network Environment simulator
(ONE).
▪ Unlike other DTN simulators, which usually focus only on routing
simulation, the ONE combines mobility modeling, DTN routing and
visualization in one package that is easily extensible and provides a rich
set of reporting and analyzing modules.

Background - One hindrance for research on DTNs is the lack of good simulators.
Many simulators exist for MANETs and also for DTN routing but the former lack good
DTN support and the latter concentrate solely on routing simulation

The DTN routing simulators have also seen little evolution since their first public
release and implementations of recent routing protocols don’t exist or are not publicly
available

The second approach is to simulate the movement of the nodes and derive contact
information from that. With this approach the temporal and spatial granularity can be
set as high as what is needed for good simulation.

For these reasons, there appears to be a need for a simulator that has reasonable
mobility modeling capabilities, integrated support for DTN routing, and ways for
visualizing the simulation progress and results in an intuitive way.

Opportunistic Network Environment simulator –

To make complex DTN simulations more feasible and understandable, we created a


new simulation environment that combines movement modeling, routing simulation,
visualization and reporting in one program.
Movement modeling can be done either on-demand using the integrated movement
models or movement data can be imported from an external source. The node position
data that the movement models provide is then used for determining if two nodes can
communicate and exchange messages.

The core of the ONE is an agent-based discrete event simulator. To make it suitable
and efficient enough for simultaneous movement and routing simulation, it uses time
slicing approach [2], so the simulation time is advanced in mixed time steps. The time
slicing can be complemented by scheduling update requests between the mixed time
steps for higher simulation time resolution.

Mobility modeling- Mobility models dictate how the nodes move during the
simulation. Three different types of mobility models were initially implemented for
ONE. For reference purposes, even despite of its shortcomings, ONE includes the basic
Random Waypoint movement model. For more realistic mobility scenarios.

ONE provides variety of map-based movement models which constrain the node
movement to predetermined paths. Finally, ONE also supports importing of mobility
data from external sources.
Map-based movement models accept map data that is described using a subset of the
Well-Known Text (WKT) format. WKT is an ASCII based format that is commonly
used in Geographic Information System (GIS) programs. Also, GIS programs can be
used as powerful map editors for the ONE.

The agent movement data can be exported from TRANSIMS and imported into ONEs
external mobility model and used for DTN simulations.

Installation of ONE simulator for High Mobility Networks:

Step 1: Download the ONE simulator :


• Visit the official ONE simulator website: https://akeranen.github.io/the-
one/
• Download the latest stable release package (ZIP file)

Step 2: Extract the package


• Create a directory where you want to install the ONE simulator
• Extract the downloaded ZIP file to this directory

Step 3: Verify the installation


• Open a terminal/command prompt
• Navigate to the ONE simulator directory
• Run: java -version to confirm Java is installed correctly

Step 4: Compile the simulator


• In the ONE simulator directory, compile the source code: javac -d classes
-sourcepath src src/core/*.java
• Alternatively, use the provided build script: /compile.sh # For Linux/Mac
compile.bat # For Windows

Step 5: Configure for high mobility networks


• Navigate to the default_settings.txt file in the simulator directory
• Modify mobility settings to reflect high mobility scenarios:
• Increase node speed parameters
• Adjust update intervals
• Configure appropriate mobility models
Step 6: Run a test simulation
• Execute the simulator with default settings:
java -Xmx512M -cp classes:lib/ECLA.jar core.DTNSim
• (Use semicolons instead of colons on Windows) Or use the provided run
script : ./one.sh # For Linux/Mac
: one.bat # For Windows

Step 7: Visualize and analyze results


• After simulation completion, check the reports directory for generated
data
• Use the built-in visualization tools:
java -cp classes:lib/ECLA.jar gui.DTNSimGUI

Results - This report did not include any simulation results from the ONE, but it
has already been actively used for DTN and mobility research.

For example, the first published results using the ONE [15] looked into how
adding bits of realism change the connectivity patterns of wireless nodes and
how different DTN routing algorithms perform in these settings.

We ran over 1000 different scenarios and found out, e.g., that more realistic
movement (e.g., SPMB Mvs. RWP or MBM) increases substantially the
delivery probability and decreases latency for most of the routing modules if the
other variables are kept constant.
EXPERIMENT NO. 9

AIM - Configure 802.11 WLAN

Equipment Requirements
1. Wireless access point (AP) or wireless router
2. Multiple wireless network interface cards (NICs) for client computers
3. At least 2-3 computers/laptops for testing
4. Ethernet cables for initial configuration

Configuration Steps

Step 1: Basic Access Point Setup


1. Connect to the access point using an Ethernet cable
2. Access the administration interface (typically via web browser at
192.168.1.1 or similar)
3. Set administrator credentials (use a strong password)
4. Update firmware if available

Step 2: Configure Basic WLAN Settings


1. Set SSID (Network Name): "CN_Lab_WLAN"
2. Select operating channel:
o For 2.4 GHz: Choose channel 1, 6, or 11 to minimize interference
o For 5 GHz: Select a channel based on local regulations
3. Configure wireless mode:
o 802.11n/ac/ax for modern devices
o Include legacy modes (802.11g/b) if older equipment will be used

Step 3: Security Configuration


1. Set authentication method:
o WPA2-PSK (AES) for standard security
o WPA3-Personal for enhanced security if supported
2. Set a strong passphrase (at least 12 characters)
3. Disable WPS (Wi-Fi Protected Setup) for better security

Step 4: Network Settings


1. Configure DHCP server:
o Enable DHCP for automatic IP assignment
o Set IP range (e.g., 192.168.1.100 - 192.168.1.200)
o Set subnet mask (typically 255.255.255.0)
2. Configure DNS settings (use public DNS like 8.8.8.8 or your institution's
DNS)
3. Set default gateway to the AP's IP address

Step 5: Advanced Wireless Settings


1. Set beacon interval (typically 100ms)
2. Configure RTS/CTS threshold (typically 2347)
3. Set fragmentation threshold (typically 2346)
4. Enable QoS/WMM for better multimedia performance

Step 6: Testing Basic Connectivity


1. Connect a wireless client to the network using the configured SSID and
password
2. Verify IP address assignment via DHCP
3. Test connectivity using ping to the access point
4. Test internet connectivity (if applicable)

Step 7: Performance Analysis


1. Set up tools for monitoring:
o Wireshark for packet capture and analysis
o iperf3 for throughput testing
2. Measure baseline performance:
o Signal strength at various distances
o Throughput between clients
o Latency measurements

Step 8: Lab Exercises Configuration


1. Create multiple SSIDs for different experiments:
o "CN_Lab_Open" (no security for studying open authentication)
o "CN_Lab_WPA2" (standard security)
o "CN_Lab_Hidden" (hidden SSID for discovery exercises)
2. Configure MAC filtering for access control experiments
3. Set up virtual LANs if supported by the equipment
Step 9: Documentation
1. Document all configuration settings for lab manual
2. Create step-by-step guides for students to reproduce the setup
3. Include troubleshooting steps for common issues

Verification Tests

1. Connectivity tests between all configured clients


2. Security testing (attempting connections with incorrect credentials)
3. Performance measurements under various conditions (distance,
interference, etc.)
4. Packet capture analysis showing 802.11 frame structures
EXPERIMENT NO. 10

AIM - Implement & Simulate various types of routing algorithm.

Theory- Classification of Routing Algorithms

The routing algorithms can be classified as follows:


1.Adaptive Algorithms
2.Non-Adaptive Algorithms
3.Hybrid Algorithms

Prerequisites:
• Python 3.6 or higher
• NetworkX library (pip install networkx)
• Matplotlib library (pip install matplotlib)
• NS-3 Network Simulator (for advanced simulations)

Lab Environment Setup:


1. Install required dependencies:
pip install networkx matplotlib numpy pandas

2. Clone the lab repository:


git clone https://github.com/your-institution/cn-routing-lab.git
cd cn-routing-lab
❖ Distance Vector Routing

1. Algorithm Description
Distance Vector Routing is based on the Bellman-Ford algorithm where routers
exchange distance information with their neighbors. Each router maintains a
routing table containing the distance to all other nodes in the network.

2. Implementation
python
import networkx as nx
import matplotlib.pyplot as plt
import numpy as np

def create_network_topology():
G = nx.Graph()

for i in range(1, n):


G.add_node(i)
G.add_weighted_edges_from(edges)
return G

def visualize_network(G, title="Network Topology"):


plt.figure(figsize=(10, 8))
pos = nx.spring_layout(G, seed=42)

nx.draw_networkx_nodes(G, pos, node_size=700, node_color='skyblue')


nx.draw_networkx_edges(G, pos, width=2, alpha=0.7)

def initialize_distance_vectors(G):
dv_tables = {}
return dv_tables

def update_distance_vectors(G, dv_tables):


def run_distance_vector_algorithm(G, max_iterations=100):
dv_tables = initialize_distance_vectors(G)
if __name__ == "__main__":
simulate_distance_vector()
3. Simulation Steps
1. Run the Python script:
python distance_vector.py
2. Observe the network topology visualization
3. Review the convergence process (number of iterations)
4. Examine the final routing tables for each node

❖ Link State Routing

1. Algorithm Description
Link State Routing uses Dijkstra's shortest path algorithm where each router
builds a complete topology map of the network and independently calculates the
best path to each destination.

2. Implementation
python
import networkx as nx
import matplotlib.pyplot as plt
import heapq
import copy

def dijkstra_shortest_path(G, source):


distances = {node: float('inf') for node in G.nodes()}
distances[source] = 0
previous = {node: None for node in G.nodes()}
priority_queue = [(0, source)]

while priority_queue:
current_distance, current_node = heapq.heappop(priority_queue)
if current_distance > distances[current_node]:
continue

for neighbor in G.neighbors(current_node):


edge_weight = G[current_node][neighbor]['weight']
distance = current_distance + edge_weight
if distance < distances[neighbor]:
distances[neighbor] = distance
previous[neighbor] = current_node
heapq.heappush(priority_queue, (distance, neighbor))

paths = {}
for node in G.nodes():
if node == source:
paths[node] = {"distance": 0, "next_hop": source, "path": [source]}
continue

if __name__ == "__main__":
simulate_link_state()

3. Simulation Steps
1. Run the Python script:
bash
python link_state.py
2. Review the network topology visualization
3. Examine the calculated shortest paths from each source node
4. Study the routing tables with next-hop information for each node

❖ Path Vector Routing

1. Algorithm Description
Path Vector Routing extends distance vector routing by including the entire path
to destinations, not just the distance. This is similar to Border Gateway Protocol
(BGP) used in Internet routing.

2. Implementation
python
import networkx as nx
import matplotlib.pyplot as plt
import copy

def create_as_network():
G = nx.Graph()
for as_id, routers in as_info.items():
for router in routers:
G.add_node(router, AS=as_id)

G.add_weighted_edges_from(intra_as_edges:
return G, as_info

def visualize_as_network(G, as_info):


plt.figure(figsize=(12, 10))

for node, data in G.nodes(data=True):


as_id = data['AS']
as_center = as_positions[as_id]

pos[node] = (as_center[0] + offset[0], as_center[1] + offset[1])

inter_as_edges = [(u, v) for u, v, d in G.edges(data=True)


if G.nodes[u]['AS'] != G.nodes[v]['AS']]

for i in range(1, len(path)):


current_as = G.nodes[path[i]]['AS']
if current_as != as_path[-1]:
as_path.append(current_as)
return as_path

pv_tables = run_path_vector_algorithm(G, policies=policies)

display_path_vector_tables(G, pv_tables)
if __name__ == "__main__":
simulate_path_vector()

3. Simulation Steps
1. Run the Python script:
python path_vector.py
2. Observe the autonomous system network visualization
3. Review the path vector routing tables with AS path information
4. Analyze how routing policies affect the path selection
EXPERIMENT NO. 11

AIM: Study & Simulation of MAC Protocols like Aloha, CSMA, CSMA/CD
and CSMA/CA using Standard Network Simulators

Objective:
To study and simulate the functioning of various MAC (Medium Access
Control) layer protocols like:

• Pure ALOHA
• Slotted ALOHA
• CSMA (Carrier Sense Multiple Access)
• CSMA/CD (with Collision Detection)
• CSMA/CA (with Collision Avoidance)

Tools Required:

• NS2 or NS3 (Network Simulator)


• OR Cisco Packet Tracer / OMNeT++ (as per availability)
• Linux Environment (if using NS2/NS3)
• Gedit or any text editor

Theory:

1. ALOHA:
o Pure ALOHA: Nodes send whenever they have data; risk of
collisions is high.
o Slotted ALOHA: Time is divided into slots; reduces collisions.
o Throughput: Pure ALOHA = 18.4%, Slotted ALOHA = 36.8%
2. CSMA:
o Nodes listen before sending (carrier sensing).
o Variants:
▪ 1-persistent
▪ non-persistent
▪ p-persistent
3. CSMA/CD:
o Used in wired Ethernet.
o After detecting collision, nodes stop transmission, wait random
time, then resend.
4. CSMA/CA:
o Used in wireless networks (like Wi-Fi).
o Uses RTS/CTS mechanism to avoid collisions before transmission.
Simulation Plan (example with NS2/NS3):

A. For ALOHA (using NS2 or custom simulation in Python/C++):

• Define N nodes in a wireless environment.


• Assign random send times.
• Count how many packets successfully delivered.
• Plot: Throughput vs Offered Load

B. For CSMA/CD (Ethernet Simulation):

• Create a wired network topology.


• Enable collision detection logic.
• Simulate backoff algorithm (Binary Exponential Backoff).
• Observe time delay due to collisions.

C. For CSMA/CA (Wi-Fi Simulation):

• Use wireless nodes (802.11 protocol in NS2/NS3).


• Enable RTS/CTS handshake.
• Measure delay, throughput, and packet loss.

Sample Experiment Steps (for NS2):

1. Write a TCL script to simulate network (topology, nodes, links, MAC


protocol).
2. Set parameters (number of nodes, queue type, bandwidth, delay).
3. Define traffic (CBR or FTP).
4. Run simulation.
5. Use NAM or XGraph for visualization.
6. Analyze trace file for packet delivery ratio, collision rate.

Output Metrics:

• Throughput (bps)
• Delay (ms)
• Packet Delivery Ratio (%)
• Collision Rate (for ALOHA and CSMA/CD)
EXPERIMENT NO. 12

AIM: Study of Application layer protocols- DNS, HTTP, HTTPS, FTP and
TelNet

Objective:
To understand the purpose, working principles, port numbers, command-line
usage, and real-life applications of major Application Layer protocols – DNS,
HTTP, HTTPS, FTP, and Telnet – using simulations and practical tools.

Theory:

1. DNS (Domain Name System):

Purpose: Converts human-readable domain names (like


[www.google.com](http://www.google.com)) into IP addresses (like
142.250.182.132).

Type: Hierarchical and distributed system.


Ports: Uses UDP Port 53 (and TCP 53 for large queries like zone transfers).

Process:
1. Client types a domain name in browser.
2. DNS resolver (usually provided by ISP) checks local cache.
3. If not found, it queries root server → TLD server → authoritative server.
4. IP address is returned to the client.

Commands:
Windows: nslookup [www.example.com](http://www.example.com)
Linux: dig [www.example.com](http://www.example.com)

2. HTTP (HyperText Transfer Protocol):

Purpose: Used to access web pages on the Internet.


Port: TCP Port 80.
Type: Stateless protocol (each request is independent).
Request: GET /index.html HTTP/1.1
Response: HTTP/1.1 200 OK
Methods: GET, POST, PUT, DELETE, HEAD, OPTIONS
Tools: Browser, curl, Wireshark
Command: curl [http://example.com](http://example.com)

3. HTTPS (HTTP Secure):

Purpose: Secure version of HTTP using SSL/TLS encryption.


Port: TCP Port 443.
Benefits:
Data encryption
Server authentication using certificates
Data integrity

Difference vs HTTP:
HTTP sends data in plain text.
HTTPS encrypts data to protect from man-in-the-middle (MITM) attacks.

Command: curl [https://example.com](https://example.com)


Observation: Shows certificate details and secure connection status.

4. FTP (File Transfer Protocol):

Purpose: Transfer files between client and server.


Ports: TCP Port 21 (control), TCP Port 20 (data).
Modes: Active and Passive

Commands:
ftp ftp.dlptest.com
Username: dlpuser
Password: rNrKYTX9g7z3RgJRmxWuGHbeu
Inside FTP:
ls – list files
get filename – download file
put filename – upload file
bye or quit – exit session
Observation: Log shows authentication, data transfer.
5. Telnet (Telecommunication Network):

Purpose: Remotely access another device in plain text.


Port: TCP Port 23.
Security: Insecure (credentials sent in plain text)
Replacement: SSH (Secure Shell)

Command:
Windows: telnet towel.blinkenlights.nl
Linux: telnet 192.168.1.10 23

Observation: Text-based shell interface appears; user can execute remote


commands.

Tools & Environment:

• Cisco Packet Tracer (for simulated DNS, FTP, HTTP servers)


• Linux Terminal (for commands like dig, curl, ftp, telnet)
• Windows CMD or PuTTY (for Telnet)
• Browser (for checking HTTP vs HTTPS)
• Optional: Wireshark (to capture and analyze packets)

Procedure (Step-by-step Execution):

A. DNS:

1. Open CMD or Linux Terminal.


2. Run: nslookup [www.google.com](http://www.google.com) or dig
[www.google.com](http://www.google.com)
3. Note the IP address and DNS server used.
4. (Optional) Create a DNS server in Cisco Packet Tracer and configure a
domain entry.

B. HTTP & HTTPS:

1. Open Browser or terminal.


2. Run: curl [http://example.com](http://example.com) and curl
[https://example.com](https://example.com)
3. Observe status codes and certificate (for HTTPS).
4. In browser, open dev tools → Network tab → observe GET/POST requests.

C. FTP:

1. Open CMD or Linux Terminal.


2. Run: ftp ftp.dlptest.com
3. Login with demo credentials.
4. Try uploading or downloading a file.
5. Observe responses from server.

D. Telnet:

1. Install Telnet if not already (sudo apt install telnet on Linux).


2. Run: telnet towel.blinkenlights.nl (ASCII Star Wars animation)
3. OR connect to another device running Telnet server.
4. Login and try executing simple commands.

Result:
The working of DNS, HTTP, HTTPS, FTP, and Telnet protocols was
successfully observed through hands-on simulation and command-line
experiments. The behavior of each protocol, including port usage and
communication pattern, was analyzed.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy