[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ns] Wireless example



If you are using 2.1b7, try that wireless3 in
tcl/test/test-suite-WLtutorial.tcl.

- Haobo

On Tue, 28 Nov 2000, [iso-8859-1] Peter Koh wrote:

> I had tried Marc Greis' tutorial example on the
> wireless link as follow, and when I compiled, it's
> give me some errors. Can someone help me on this.
> Thank you in advance.
> 
> set opt(chan)  Channel/WirelessChannel
> set opt(prop)  Propagation/TwoRayGround
> set opt(netif) Phy/WirelessPhy
> set opt(mac)   Mac/802_11
> set opt(ifq)   Queue/DropTail/PriQueue
> set opt(ll)    LL
> set opt(ant)   Antenna/OmniAntenna
> set opt(ifqlen) 50
> set opt(nn)    1
> set opt(adhocRouting)  DSDV
> 
> set opt(cp) ""
> set opt(sc) ""
> 
> set opt(x)   670
> set opt(y)   670
> set opt(seed) 0.0
> set opt(stop) 250
> 
> set opt(ftp1-start)  100.0
>  
> set num_wired_nodes   2
> 
> 
> if {$opt(x) == 0 || $opt(y)==0} {
>    puts "No X-Y boundary values given for wireless
> topology \n"
> }
> 
> if {$opt(seed) > 0} {
>    puts "Seeding Random number generator with
> $opt(seed)\n"
>    ns-randoom $opt(seed)
> }
> 
> set ns_ [new Simulator]
> 
> $ns_ node-config -addressType hierarchical
> 
> AddrParams set domain_num_ 3
> lappend cluster_num 2 1 1
> AddrParams set cluster_num_ $cluster_num
> lappend eilastlevel 1 1 2 1
> AddrParams set nodes_num_ $eilastlevel
> 
> set tracefd [open wireless3-out.tr w]
> set namtrace [open wireless3-out.nam w]
> $ns_ trace-all $tracefd
> $ns_ namtrace-all-wireless $namtrace $opt(x) $opt(y)
> 
> set topo [new Topography]
> 
> $topo load_flatgrid $opt(x) $opt(y)
> 
> create-god $opt(nn)
> 
> set temp {0.0.0.0.1.0}
> for {set i 0} {$i < $num_wired_nodes} {incr i} {
>   set W($i) [$ns_ node [lindex $temp $i]]
> }
> 
> $ns_ node-config -mobileIP ON\
>                  -adhocRouting $opt(adhocRouting) \
>                  -llType $opt(ll) \
>                  -macType $opt(mac) \
>                  -ifqType $opt(ifq) \
>                  -ifqLen $opt(ifqlen) \
>                  -antType $opt(ant) \
>                  -propType $opt(prop)\
>                  -phyType $opt(netif) \
>                  -channelType $opt(chan) \
>                  -topolnstance $topo \
>                  -wiredRouting ON \
>                  -agentTrace ON \
>                  -routerTrace OFF \
>                  -macTrace OFF 
> 
> set HA [$ns_ node 1.0.0]
> set FA [$ns_ node 2.0.0]
> $HA random-motion 0
> $FA random-motion 0
> 
> $HA set X_ 1.000000000000
> $HA set Y_ 2.000000000000
> $HA set Z_ 0.000000000000
> 
> $FA set X_ 650.000000000000
> $FA set X_ 600.000000000000
> $FA set X_ 0.000000000000
> 
> $ns_ node-config -wiredRouting OFF
>  
> set MH [$ns_ node 1.0.1]
> set node_(0) $MH
> set HAaddress [AddrParams set-hieraddr [$HA
> node-addr]]
> [$MH set regagent_] set home_agent_ $HAaddress
> 
> $MH set Z_ 0.000000000000
> $MH set Y_ 2.000000000000
> $MH set X_ 2.000000000000
> 
> $ns_ at 100.000000000000 "$MH setdest 640.000000000000
> 610.000000000000 20.000000000000"
> 
> $ns_ at 200.000000000000 "$MH setdest 2.000000000000
> 2.000000000000 20.000000000000"
> 
> $ns_ duplex-link $W(0) $W(1) 5Mb 2ms DropTail
> $ns_ duplex-link $W(1) $HA  5Mb 2ms DropTail
> $ns_ duplex-link $W(1) $FA  5Mb 2ms DropTail
> 
> $ns_ duplex-link-op $W(0) $W(1) orient down
> $ns_ duplex-link-op $W(1) $HA orient left-down 
> $ns_ duplex-link-op $W(1) $FA orient right-down
> 
> set tcp1 [new Agent/TCP]
> $tcp1 set class_ 2
> set sink1 [new Agent/TCPSink]
> $ns_ attach-agent $W(0) $tcp1
> $ns_ attach-agent $MH $sink1
> $ns_ connect $tcp1 $sink1
> set ftp1 [new Application/FTP]
> $ftp1 attach-agent $tcp1
> $ns_ at $opt(ftp1-start) "$ftp1 start"
> 
> if {$opt(cp) == ""} {
>     puts "*** Note : no connection pattern specified."
>     set opt(cp) "none"
> }
> else {
>     puts "Loading connection pattern ..."
>     source $opt(cp)
> }
> if {$opt(sc) == ""} {
>     puts "*** NOTE: no scenario file specified."
>     set opt(sc) "none"
> } else {
>     puts "Loading scenario file ... "
>     source $opt(sc)
>     puts "Load complete ... "
> }
> 
> for {set i 0} {$i < $opt(nn)} {incr i} {
>    $ns_ initial_node_pos $node_($i) 20
> }
> 
> for {set i 0} {$i < $opt(nn)} {incr i} {
>    $ns_ at $opt(stop).0 "$node_($i) reset ";
> }
> 
> $ns_ at $opt(stop).0 "$HA reset";
> $ns_ at $opt(stop).0 "$FA reset";
> 
> $ns_ at $opt(stop).0002 "puts\"NS EXITING...\"; $ns_
> halt"
> $ns_ at $opt(stop).0001 "stop"
> proc stop {} {
>    global ns_ tracefd namtrace
>    close $tracefd
>    close $namtrace
> }
> 
> puts $tracefd "M 0.0 nn $opt(nn) x $opt(x) y $opt(y)
> rp \
>      $opt(adhocRouting)"
> puts $tracefd "M 0.0 sc $opt(sc) cp $opt(cp) seed
> $opt(seed)"
> puts $tracefd "M 0.0 prop $opt(prop) ant $opt(ant)"
> 
> puts "Starting Simulation..."
> $ns_ run
> 
> 
> ERROR
> num_nodes is set 1
> can't read "": no such variable
>     (Object set line 1)
>     invoked from within
> "Node set nn_"
>     (procedure "Node" line 2)
>     (Node getid line 2)
>     invoked from within
> "Node getid"
>     (procedure "_o23" line 7)
>     (Node init line 7)
>     invoked from within
> "_o23 init {}"
>     (Class create line 1)
>     invoked from within
> "Node create _o23 {}"
>     invoked from within
> "catch "$className create $o $args" msg"
>     (procedure "new" line 3)
>     invoked from within
> "new Node {}"
>     ("eval" body line 1)
>     invoked from within
> "eval new [Simulator set node_factory_] $args"
>     (procedure "_o3" line 21)
>     (Simulator node line 21)
>     invoked from within
> "$ns_ node [lindex $temp $i"
>     ("for" body line 2)
>     invoked from within
> "for {set i 0} {$i < $num_wired_nodes} {incr i} {
>   set W($i) [$ns_ node [lindex $temp $i]]
> }"
>     (file "wireless3a.tcl" line 56)
> 
> 
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Shopping - Thousands of Stores. Millions of Products.
> http://shopping.yahoo.com/
>