CN Almost
CN Almost
LAB MANUAL
Prepared By : Submitted to :
Roll No - 0105AL221108 Prof. Sandhya Vishwakarma
Name - Krity Kumari CSE-AIML, OIST
LIST OF EXPERIMENTS
1. Repeater
2. Hub
3. Switch
4. Bridge
5. Router
6. Gate Way
Apparatus Required
No software or hardware needed
Theory
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.
AIM: Study and verification of standard Network topologies i.e. Star, Bus,
Ring etc.
Theory
Types of Topology
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.
• Point-to-point
• Bus
• Star
• Ring or circular
• Mesh
• Tree
• Hybrid
• Daisy chain
EXPERIMENT NO. 3
Theory
Performance:
Perform the following steps as directed
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.
Result/ Conclusions
Windows workgroup is established and used for sharing and transferring data
between physically connected PCs.
EXPERIMENT NO. 4
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)
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
a) CHARACTER COUNT
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
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
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
Theory:
Features
▪ 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:
puts"Hello, world!"
# 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.
Theory:
▪ The behavior of the network and the various applications and services it
supports can then be observed in a test lab.
Network simulator
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 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.
1. Install CYGWIN
• 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”.
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.
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.
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
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
Verification Tests
Prerequisites:
• Python 3.6 or higher
• NetworkX library (pip install networkx)
• Matplotlib library (pip install matplotlib)
• NS-3 Network Simulator (for advanced simulations)
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()
def initialize_distance_vectors(G):
dv_tables = {}
return dv_tables
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
while priority_queue:
current_distance, current_node = heapq.heappop(priority_queue)
if current_distance > distances[current_node]:
continue
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
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
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:
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):
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:
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)
Difference vs HTTP:
HTTP sends data in plain text.
HTTPS encrypts data to protect from man-in-the-middle (MITM) attacks.
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):
Command:
Windows: telnet towel.blinkenlights.nl
Linux: telnet 192.168.1.10 23
A. DNS:
C. FTP:
D. Telnet:
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.