[ns] ad hoc networks

amela ksentini.amel at gmail.com
Tue Mar 4 09:32:36 PST 2008


Hi Adriano,
I think you should write 
"$ns initial_node_pos $node(0) 20"
instead of "..._position ..."
Let me know if it is OK!
good luck






Adriano Galati wrote:
> 
> 
> Hi, please, has anybody used ns2 for ad hoc networks?? It seems I have a 
> problem with positioning... in the code below initial_node_position launch 
> the following error 
> ===============================================================
> -bash-3.00$ 
> ns ex3.tcl num_nodes is set 3 INITIALIZE THE LIST xListHead
> 
>     (_o3 cmd line 1)
>     invoked from within
> "_o3 cmd initial_node_position _o14 20"
>     invoked from within
> "catch "$self cmd $args" ret"
>     invoked from within
> "if [catch "$self cmd $args" ret] {
> set cls [$self info class]
> global errorInfo
> set savedInfo $errorInfo
> error "error when calling class $cls: $args" $..."
>     (procedure "_o3" line 2)
>     (SplitObject unknown line 2)
>     invoked from within
> "$ns initial_node_position $node(0) 20"
>     (file "ex3.tcl" line 78)
> -bash-3.00$
> =================================================
> 
> And the tcl code is this:
> 
> # Create simulator
> set ns [new Simulator]
> 
> # Create a topology in a 670m x 670m area
> set topo [new Topography]
> $topo load_flatgrid 670 670
> 
> # ns trace and nam trace
> $ns trace-all [open ns.tr w]
> $ns namtrace-all-wireless [open ns.nam w] 670 670
> 
> # Create God
> set god [create-god 3]
> 
> # Define how to create a mobile node
> $ns node-config \
> -adhocRouting DSR \
> -llType LL \
> -macType Mac/802_11 \
> -ifqLen 50 \
> -ifqType Queue/DropTail/PriQueue \
> -phyType Phy/WirelessPhy \
> -antType Antenna/OmniAntenna \
> -propType Propagation/TwoRayGround \
> -channel [new Channel/WirelessChannel] \
> -topoInstance $topo \
> -agentTrace ON \
> -routerTrace OFF \
> -macTrace OFF \
> -movementTrace OFF
> 
> # Create mobile nodes
> for {set i 0} {$i<3} {incr i} {
> set node($i) [$ns node]
> # disable random motion for static network
> $node($i) random-motion 0
> }
> 
> # Define movement model (if applicable)
> #source movement-scenario-files
> # Define traffic model (if applicable)
> #source traffic-scenario-files
> 
> $node(0) set X_ 83.4
> $node(0) set Y_ 239.4
> $node(0) set Z_ 0.0
> $node(1) set X_ 257.1
> $node(1) set Y_ 345.4
> $node(1) set Z_ 0.0
> $node(2) set X_ 591.3
> $node(2) set Y_ 199.4
> $node(2) set Z_ 0.0
> $ns at 33.0 "$node(0) setdest 89.7 283.5 19.2"
> $ns at 51.0 "$node(1) setdest 221.8 80.9 14.9"
> $ns at 50.0 "$node(2) setdest 369.5 170.5 3.4"
> 
> 
> 
> set udp_(0) [new Agent/UDP]
> $ns attach-agent $node(0) $udp_(0)
> set null_(0) [new Agent/Null]
> $ns attach-agent $node(2) $null_(0)
> set cbr_(0) [new Application/Traffic/CBR]
> $cbr_(0) set packetSize_ 1000
> $cbr_(0) set interval_ 4.0
> $cbr_(0) set random_ 1
> $cbr_(0) set maxpkts_ 10000
> $cbr_(0) attach-agent $udp_(0)
> $ns connect $udp_(0) $null_(0)
> $ns at 20.0 "$cbr_(0) start"
> 
> 
> # Define node initial position in nam
> #for {set i 0} {$i < 3} {incr i} {
> #    $ns initial_node_position $node($i) 20
> #}
> 
> $ns initial_node_position $node(0) 20
> $ns initial_node_position $node(1) 20
> $ns initial_node_position $node(2) 20
> 
> # Tell ns/nam the simulation stop time
> $ns at 100.0 "$ns nam-end-wireless 100.0"
> $ns at 100.0 "$ns halt"
> # Start your simulation
> $ns run
> =====================================================
> 
> Any suggestion is more than welcome,
> Thanks,
> Adriano
> 
> This message has been checked for viruses but the contents of an
> attachment
> may still contain software viruses, which could damage your computer
> system:
> you are advised to perform your own checks. Email communications with the
> University of Nottingham may be monitored as permitted by UK legislation.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/ad-hoc-networks-tp15703113p15832609.html
Sent from the ns-users mailing list archive at Nabble.com.



More information about the Ns-users mailing list