Add the following code to the new file and named it with the extension of tcl. i.e. filename.tcl . To create the file go to the terminal.
Write
gedit filename.tcl
This above command will open a file with the name filename.tcl. Add the following code to the file and save the file.
Now, in order to run the file go to the Terminal and write the following command.
ns filename.tcl
Code:
#Create a simulator object
set ns [new Simulator]
#Open the NAM trace file
set nf [open o.nam w]
$ns namtrace-all $nf
# create nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
set n7 [$ns node]
set n8 [$ns node]
set n10 [$ns node]
#Create links between the nodes
$ns duplex-link $n0 $n2 2Mb 10ms DropTail
$ns duplex-link $n1 $n2 2Mb 10ms RED
$ns duplex-link $n2 $n3 1.7Mb 20ms RED
$ns duplex-link $n4 $n5 2Mb 10ms RED
$ns duplex-link $n2 $n8 2Mb 10ms RED
$ns duplex-link $n4 $n10 2Mb 5ms DropTail
#Define a 'finish' procedure
proc finish {} {
global ns nf
$ns flush-trace
#Close the NAM trace file
close $nf
#Execute NAM on the trace file
exec nam o.nam &
exit 0
}
#Call the finish procedure
$ns at 1.0 "finish"
#Run the simulation
$ns run
The following output will be generated after running the code.
Type the following in terminal.
ns filename.tcl
Type the following in terminal.
ns filename.tcl
please help us in executing this program in cygwin window .. actually i am not aware of the correct command instruction
ReplyDeletesorry for late reply. though there are ways available to execute it using cygwin, but they are not reliable, i wouldnt recommend using those, ways. There are easier ways to install ns2 on linux based environment just go through the following tutorials.
Deletehttp://cs-study.blogspot.com/2013/09/ubuntu-installation-using-windows.html
http://cs-study.blogspot.com/2012/12/ns2-installation-and-ubuntu.html
hi sir,
ReplyDeletecan i have the tcl syntax to know the node position and energy...,
for ex: position of node 1 is: x:____ y:_____
energy of node 1 is: ___________
.
.
.
.
for all or for the required nodes...,
sir ha bht talented...par install abitak kch ni kia
ReplyDeletesir ke apke knowledge ne to anni dal di ha mjhe bht pasnd aye han apke notes
ReplyDeletesir ha bht payare..>3
Deletesir a msg is displayed while executing the progam
can't read "val(x)": no such variable
while executing
"$ns namtrace-all-wireless $namtrace $val(x) $val(y)"
(file "wireless1.tcl" line 15)
can help me.....
me 2 same problem
DeleteI am getting an error " can't read "i":no such variable while executing " for{set i 0}{$i<$val(nn)}{incr i}{"
Deletedid you have any experience on MANETs? I need code for this network. I'm working on wormhole attacks on MANETs. can you give me some suggestion how to do it? if please send email to maka.enzo@gmail.com
ReplyDeleteI tried installing TKN's 802.11e EDCA on ns 2.35(ubuntu 13.04)...followed all the steps in read me file..but on executing the example file getting error
ReplyDelete"invalid command name "Mac/802_11e".
Please help.
i need code for this network.am working on blackhole attacks on manet .so can u give some suggestion? please
ReplyDeletehello everyone
ReplyDeleteplease someone tell me how to change traffic like frst i have find results using CBR traffic now i want to use PARETO bt i dnt knw how to change traffic and where, if someone knws then please help me ..........thnx
any one can help me the ns2 source code or tcl,awk and xgraph for dynamic redundancy management of multipath routing using heterogenous wireless sensor networks.
ReplyDeletemail id:sweetrathicse@gmail.com
Sir plz help in creating a wormhole code for the network in ns2
ReplyDeleteSir plz help in creating a wormhole code for the network in ns2
ReplyDeletehow to make a node execute some command and send the result to other node..? can someone help me please.. It'll be very helpful
ReplyDeletewhy I got an error on this ? help me please ! -_-
ReplyDeleteset nf [open o.nam w]
$ns namtrace-all $nf
ns: finish: couldn't execute "nam": no such file or directory
ReplyDeletewhile executing
"exec nam o.nam &"
(procedure "finish" line 7)
invoked from within
"finish"
^^ anyone can help me on this error ??
sir please send me tcl file of wormhole attack in my email neerajsharma3027@gmail.com
ReplyDeletehow can I create node with loop.
ReplyDeletethank you so much for your sharing this good informations
ReplyDeletegoldenslot casino
บาคาร่าออนไลน์
gclub casino
thank you so much for you sharing this good infomations
ReplyDeletethank you for the reply.
goldenslot casino
บาคาร่าออนไลน์
gclub casino
can you post how to create nodes using for loop
ReplyDeleteI have a same
DeleteIf u get the answer help me sir ?
Pls i need help on how to simulate 10, 20, 30, 40 and 50 nodes simultaneously in manet
ReplyDeletenice info but give the positions of nodes
ReplyDelete