LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-29-2015, 03:13 AM   #1
rc49
LQ Newbie
 
Registered: May 2015
Posts: 25

Rep: Reputation: Disabled
nam file is empty


i create a simple wireless scenerio in ns2
simulator version ns2.35
ubuntu 12.04
i m new to ns2, trying to create a simple tcl script but nam dosnt even shows nodes
here is my tcl script

set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(ant) Antenna/OmniAntenna ;# Antenna type
set val(ll) LL ;# Link layer type
set val(ifq) Queue/DropTail/PriQueue ;# Interface queue type
set val(ifqlen) 50 ;# max packet in ifq
set val(netif) Phy/WirelessPhy ;# network interface type
set val(mac) Mac/802_11 ;# MAC type
set val(nn) 5 ;# number of mobilenodes
set val(rp) DSR ;# routing protocol
set val(x) 800
set val(y) 800

set ns [new Simulator]

set f [open wsn1.tr w]
$ns trace-all $f

set namtrace [open 5nodes.nam w]
$ns namtrace-all-wireless $namtrace $val(x) $val(y)

set topo [new Topography]
$topo load_flatgrid 800 800

create-god $val(nn)

set chan_1 [new $val(chan)]

$ns node-config -adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-topoInstance $topo \
-agentTrace OFF \
-routerTrace ON \
-macTrace ON \
-movementTrace OFF \
-channel $chan_1

proc finish {} {
global ns f namtrace
$ns flush-trace
close $namtrace
exec nam 5nodes.nam &
exit 0
}

#for {set i 0} {$i < $val(nn) } { incr i } {
# set n($i) [$ns node]
#}
set n0 [ns node]
$n0 set X_ 76.998
$n0 set Y_ 417.21
$n0 set Z_ 0.0

set n1 [ns node]
$n1 set X_ 73.375
$n1 set Y_ 563.431
$n1 set Z_ 0.0

set n2 [ns node]
$n2 set X_ 69.6029
$n2 set Y_ 431.775
$n2 set Z_ 0.0

set n3 [ns node]
$n3 set X_ 62.2278
$n3 set Y_ 313.445
$n3 set Z_ 0.0

set n4 [ns node]
$n4 set X_ -81.7832
$n4 set Y_ 294.637
$n4 set Z_ 0.0

#for {set i 0} {$i < $val(nn)} { incr i } {
# $ns initial_node_pos $n($i) 35
#}

set tcp0 [new Agent/TCP]
$ns attach-agent $n0 $tcp0

set tcp1 [new Agent/TCP]
$ns attach-agent $n1 $tcp1

set tcp2 [new Agent/TCP]
$ns attach-agent $n2 $tcp2

set tcp3 [new Agent/TCP]
$ns attach-agent $n3 $tcp3

set tcp4 [new Agent/TCP]
$ns attach-agent $n4 $tcp4

set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.05
$cbr0 attach-agent $tcp0
#$udp0 set class_ 1

set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.05
$cbr1 attach-agent $tcp1
#$udp1 set class_ 2

set cbr2 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.05
$cbr1 attach-agent $tcp2

set cbr3 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.05
$cbr1 attach-agent $tcp3

set cbr4 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.05
$cbr1 attach-agent $tcp4

set sink0 [new Agent/LossMonitor]
set sink1 [new Agent/LossMonitor]
set sink2 [new Agent/LossMonitor]
set sink3 [new Agent/LossMonitor]
set sink4 [new Agent/LossMonitor]

$ns attach-agent $n0 $sink0
$ns attach-agent $n1 $sink1
$ns attach-agent $n2 $sink2
$ns attach-agent $n3 $sink3
$ns attach-agent $n4 $sink4

$ns connect $tcp0 $sink0
$ns connect $tcp1 $sink1
$ns connect $tcp2 $sink2
$ns connect $tcp3 $sink3
$ns connect $tcp4 $sink4


$ns at 0.5 "$cbr0 start"
$ns at 1.0 "$cbr1 start"
$ns at 4.0 "$cbr0 stop"
$ns at 4.5 "$cbr1 stop"

$ns at 5.0 "finish"
$ns run

please help
 
Old 07-29-2015, 07:40 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154
Probably have a look at some other examples ...
http://www.isi.edu/nsnam/ns/tutorial...pt5.html#first
.. etc. etc., ref. http://www.isi.edu/nsnam/ns/tutorial...pt1.html#first


All ns2 simulation examples :
"all_tcl-examples-2.tar.gz" ( 41.8MB, ~2,000 examples )
https://drive.google.com/file/d/0B7S...ew?usp=sharing


-
 
  


Reply

Tags
ns2, ubuntu 12.04, wirelessnetworking


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
NS2 Nam and Trace Files are always empty RSM_smile Linux - Newbie 28 09-07-2015 03:43 AM
running nam file in ns2 it gives warning as trace file events are not sorted by time s20 Linux - Software 0 07-19-2013 10:45 PM


All times are GMT -5. The time now is 10:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration