0% found this document useful (0 votes)
4 views

FH2025-NETWORK LAB- Expt 3

The document outlines a networking lab assignment for SEIT students at Finolex Academy, focusing on creating and analyzing network topologies using NS2 and TCL scripts. It includes objectives, prerequisites, hardware and software requirements, and detailed steps for writing and running TCL scripts for network simulations. The lab aims to enhance students' understanding of network initialization, node and link definitions, and traffic analysis.

Uploaded by

Prathamesh Gawas
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

FH2025-NETWORK LAB- Expt 3

The document outlines a networking lab assignment for SEIT students at Finolex Academy, focusing on creating and analyzing network topologies using NS2 and TCL scripts. It includes objectives, prerequisites, hardware and software requirements, and detailed steps for writing and running TCL scripts for network simulations. The lab aims to enhance students' understanding of network initialization, node and link definitions, and traffic analysis.

Uploaded by

Prathamesh Gawas
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Hope Foundation’s,

Finolex Academy of Management and Technology, Ratnagiri


Department of Information Technology

Subject Networking Lab Subject Code: ITL401


name:
Semester I
Class SEIT Academic year: 2024-2025
– V
(CBCGS
)
Name
QUIZ Score :
of Student
Assignment/Experiment
Roll No 03
No.
Title:Write TCL scripts to create topologies. Create and run traffics and analyze the result using NS2

Course objectives applicable:


Demonstrate and measure different network scenarios and their performance behavior.
Course outcomes applicable:
To Understand and implement any network topology.

Learning Objectives:
1. To get familiar with Initialization and termination aspects of network simulators.
2. To understand defining the network nodes, links, queues and topology.
3. To understand the agents and Network Animator (NAM) and tracing.

Prerequisites:Knowledge of
1. Network Topology
2. NS2 node and link commands
Hardware Requirements:
PC i3 processor and above
Software Requirements:
● Linux (Ubuntu 10.04)
● NS2.34 package
● gedit

Quiz Questions (if any): (Online Exam will be taken separately batchwise, attach the certificate/
Marks obtained)

Experiment/Assignment Evaluation:
Sr. Parameters Marks Out of
No. obtain
ed
1 Technical Understanding (Assessment may be done based on Q 6
& A or any other relevant method.) Teacher should mention the
other
method used -
2 Neatness/presentation 2
3 Punctuality 2
Date of performance Total marks obtained 10
(DOP)
Date of checking (DOC) Signature of teacher

THEORY <HANDWRITTEN>

Topology refers to the layout or structure of a network, which consists of nodes (representing computers,
routers, etc.) and links (representing communication paths between nodes).

In NS2, the network topology is specified using a TCL script by creating nodes and connecting them using
links. A node can be any network element (host, router, etc.), and a link represents the communication
channel between two nodes.

Basic Components in a Topology:


1. Nodes: Each node represents a network device. The command to create nodes is:
set node [$ns node]

2. Links: Links connect two nodes and can be defined with various parameters such as bandwidth, delay,
and queue type. The basic command to create a link between two nodes is:
$ns duplex-link $n0 $n1 10Mb 10ms DropTail
3. Running the Simulation: Once the topology and traffic have been set up, the simulation is run by
invoking the $ns run command.

$ns at 10.0 "finish" ;# Stop simulation at time 10 seconds $ns run

4. Analyzing the Results:

awk '{if ($1 == "r" && $4 == "1") print $0}' out.tr | awk
'{sum+=($10)} END {print sum/1000000}'

5. Visualizing the Results with NAM:


exec nam out.nam & ;# Open NAM for visualization
PERFORMANCE STEPS:

1. Open Gedit and Write the Tcl Script

Step 1.1: Open Gedit


Open a terminal and type the following command to launch the gedit editor:
gedit network_sim.tcl
Step 1.2: Write Your Tcl Script

In the gedit editor, write the Tcl script.

PROGRAM 1: SIMPLE 2 NODES AND 1 WIRE TOPOLOGY

# Create a new simulator object

set ns [new Simulator]

# Open a trace file for storing simulation data

set tracefile [open out.tr w]

$ns trace-all $tracefile

# Create a NAM file for visualization

set namfile [open out.nam w]

$ns namtrace-all $namfile


# Define nodes

set n0 [$ns node]

set n1 [$ns node]

# Create a link between the nodes

$ns duplex-link $n0 $n1 1Mb 10ms DropTail

# Run the simulation

$ns at 5.0 "finish" ;# Stop simulation at 5 seconds

# Finish procedure

proc finish {} {

global ns tracefile namfile

$ns flush-trace

close $tracefile

close $namfile

exec nam out.nam & ;# Open NAM for visualization

exit 0

}
# Run the simulator

$ns run

NS2 PROGRAM FOR ATTACHING AGENTS AND SENDING TRAFFIC

# Step 1: Create a new simulator object

set ns [new Simulator]

# Step 2: Open trace files for simulation and visualization

set tracefile [open out.tr w]

$ns trace-all $tracefile

set namfile [open out.nam w]

$ns namtrace-all $namfile

# Step 3: Create two nodes

set n0 [$ns node]

set n1 [$ns node]

# Step 4: Create a link between the nodes

$ns duplex-link $n0 $n1 1Mb 10ms DropTail

# Step 5: Attach agents (UDP in this case) to the nodes

# Node 0: Create a UDP agent and attach it to node n0

set udp0 [new Agent/UDP]


$ns attach-agent $n0 $udp0

# Node 1: Create a UDP agent and attach it to node n1

set udp1 [new Agent/UDP]

$ns attach-agent $n1 $udp1

# Step 6: Set up a connection (one-way communication)

# Connect node 0's UDP agent to node 1's UDP agent

$ns connect $udp0 $udp1

# Step 7: Create a simple application to send data (CBR)

set cbr0 [new Application/Traffic/CBR]

$cbr0 attach-agent $udp0

$cbr0 set rate 50000 ;# Set the rate to 50 KBps

$ns at 1.0 "$cbr0 start" ;# Start sending at time 1 second

# Step 8: Schedule the finish time for the simulation

$ns at 3.0 "finish" ;# End the simulation at time 3 seconds

# Step 9: Finish procedure (close files and run NAM for visualization)

proc finish {} {

global ns tracefile namfile

$ns flush-trace

close $tracefile
close $namfile

exec nam out.nam & ;# Open NAM for visualization

exit 0

# Step 10: Run the simulation

$ns run

Step 1.3: Save the File

1. After writing the script, click on Save (or use Ctrl+S).


2. Make sure the file is saved with a .tcl extension.

2. Run the Tcl Script Using NS-2

Step 2.1: Open a Terminal

1. Open a terminal in Ubuntu.


Step 2.2: Navigate to the Directory Containing Your Script

Use the cd command to navigate to the directory where the network_sim.tcl file is saved.
For example:

cd /path/to/your/script/directory

Step 2.3: Run the Tcl Script with NS-2

To run the script using the NS-2 simulator, use the following command:

ns FILENAME.tcl
RESULTS: <PASTE OUTPUT HERE>

Learning Outcomes Achieved <Handwritten>


a. Got familiar with Initialization and termination aspects of network simulators.
b. Learned how to define the network nodes, links, queues and topology.
c. Gained the knowledge of the agents and Network Animator (NAM) and tracing.

Conclusion: <Handwritten>
1. Applications of the studied technique in industry – Understand network administration.

2. Engineering Relevance – Understanding the basics of computer networking.

3. Skills Developed –
Understanding the user system requirements and dependencies prior to any actual design and
development work.

References:
1. J. F. Kurose and K. W. Ross, Computer Networking: A Top-Down Approach, 7th ed., Pearson
Education, 2017.
2. R. W. Stevens, Unix Network Programming: Volume 1: The Sockets Networking API, 3rd ed.,
Prentice Hall, 1994.
3. D. E. Comer, Computer Networks and Internets, 6th ed., Pearson Education, 2018.
4. Cisco Networking Academy, Networking Essentials, Cisco Press, 2022.
5. Microsoft, "Network Command Line Tools," Microsoft Docs, 2021. [Online]. Available:
https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/network-too
ls.

You might also like