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

Download as pdf or txt
Download as pdf or txt
You are on page 1of 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