0% found this document useful (0 votes)
64 views5 pages

Experiment-1: Aim: Software Required: Operating System Required: Procedure For Generating TCL Script Using NSG2.1

The document describes an experiment to generate a TCL script using NSG2.1 that creates two nodes and a link between them in ns-2. It involves opening NSG2.1, placing two nodes and connecting them with a drop-tail link, setting simulation parameters like time and files, then generating and running the TCL script which creates the nodes and link and outputs trace files. Screenshots are taken of the animation and output files.

Uploaded by

Tarika Saij
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)
64 views5 pages

Experiment-1: Aim: Software Required: Operating System Required: Procedure For Generating TCL Script Using NSG2.1

The document describes an experiment to generate a TCL script using NSG2.1 that creates two nodes and a link between them in ns-2. It involves opening NSG2.1, placing two nodes and connecting them with a drop-tail link, setting simulation parameters like time and files, then generating and running the TCL script which creates the nodes and link and outputs trace files. Screenshots are taken of the animation and output files.

Uploaded by

Tarika Saij
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/ 5

EXPERIMENT- 1

1) AIM : Write a TCL Script to create two nodes and links between
nodes.

2) Software Required : ns2 & NSG2.1

3) Operating System Required : Ubuntu

4 Procedure for generating tcl script using


NSG2.1:
1.Open terminal type “ java –jar NSG2.1.jar ”,click on enter.
2.Click on scenario and select new wired scenario.
3. Click on Node -Place 2 nodes in the work area
4. Click on the Link,and select link as Drop-Tail and connect
the nodes.
5. Click on parameters and select timulation time as 10.0
sec,trace file as e1.tr,nam file as e1.nam, click on done. Save
the file on the Desktop with file name e1.tcl.
6. Locate the generated e1.tcl file & open it & make sure that
the desired code is generated & save the file.
7. Go to terminal and change directory to desktop as: cd Desktop.
6.Run the tcl file by giving command: ns <filename>.tcl.
7.The generated nodes with link can be seen under NAM Console.
8.Corresponding trace file and nam file are generated on the
desktop.
9.Take screenshot of ↳ 4
a) Animation containing nodes
b) e1.tr file
c) e1.nam file
5 CODE :
# This script is created by NSG2 beta1
# <http://wushoupong.googlepages.com/nsg>
#===================================
# Simulation parameters setup
#===================================
set val(stop) 10.0 ;# time of simulation end
#===================================
# Initialization
#===================================
#Create a ns simulator
set ns [new Simulator]

#Open the NS trace file


set tracefile [open e1.tr w]
$ns trace-all $tracefile

#Open the NAM trace file


set namfile [open e1.nam w]
$ns namtrace-all $namfile

#===================================
# Nodes Definition
#===================================
#Create 2 nodes
set n0 [$ns node]
set n1 [$ns node]

#===================================
# Links Definition
#===================================
#Createlinks between nodes
$ns duplex-link $n0 $n1 100.0Mb 10ms DropTail
$ns queue-limit $n0 $n1 50

#Give node position (for NAM)


$ns duplex-link-op $n0 $n1 orient right
#===================================
# Agents Definition
#===================================
#===================================
# Applications Definition
#===================================
#===================================
# Termination
#===================================
#Define a 'finish' procedure
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam 1eL101213.nam &
exit 0
}
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "finish"
$ns at $val(stop) "puts \"done\" ; $ns halt"
$ns run
6) OBSERVATIONS :
a)Animation Containg nodes

b)e1.nam file
c)e1.tr file
7) RESULT: Hence we have written a TCL Script to create two nodes
and links between nodes.

You might also like