Hi, I'm try to make a UDP multicast traffic from BS to a mobile node. But it doesn't work. Please help me! Here are my code and ns errors. Thanks. Kincider.
# lbp_mc.tcl # # Simulation of 1 Base Station sending multicast data to a group of mobile nodes. #Define a procedure which periodically records the bandwidth received by the #three traffic sinks sink0/1/2 and writes it to the three files f0/1/2. proc record {} { global sink_bs sink_n2 sink_n1 f1 f2 f3 #Get an instance of the simulator set ns_ [Simulator instance] #Set the time after which the procedure should be called again set time 0.5 #How many bytes have been received by the traffic sinks? set bw1 [$sink_bs set bytes_] set bw2 [$sink_n2 set bytes_] set bw3 [$sink_n1 set bytes_] #Get the current time set now [$ns_ now] #Calculate the bandwidth (in MBit/s) and write it to the files puts $f1 "$now [expr $bw1/$time*8/1000000]" puts $f2 "$now [expr $bw2/$time*8/1000000]" puts $f3 "$now [expr $bw3/$time*8/1000000]" #Reset the bytes_ values on the traffic sinks $sink_bs set bytes_ 0 $sink_n2 set bytes_ 0 $sink_n1 set bytes_ 0 #Re-schedule the procedure $ns_ at [expr $now+$time] "record" } proc stop {} { global ns_ tracefd namtrace f1 f2 f3 close $f1 close $f2 close $f3 $ns_ flush-trace exec nam lbptrace.nam & exec xgraph n0_bs.tr bs_n2.tr bs_n1.tr & ; #-geometry 800x400 & close $tracefd close $namtrace } # ====================================================================== # Define options # ====================================================================== set opt(chan) Channel/WirelessChannel ;# channel type set opt(prop) Propagation/TwoRayGround ;# radio-propagation model set opt(netif) Phy/WirelessPhy ;# network interface type set opt(mac) Mac/802_11 ;# MAC type set opt(ifq) Queue/DropTail/PriQueue ;# interface queue type set opt(ll) LL ;# link layer type set opt(ant) Antenna/OmniAntenna ;# antenna model set opt(ifqlen) 50 ;# max packet in ifq set opt(nn) 3 ;# number of mobilenodes #set opt(adhocRouting) DSDV ;# routing protocol set opt(adhocRouting) OMNIMCAST ;# routing protocol set opt(cp) "" ;# connection pattern file set opt(sc) "scen-3" ;# node movement file. #../indep-utils/cmu-scen-gen/setdest/setdest -v 2 -n 3 -s 1 -m 1 -M 10.0 -t 100 -P 1 -p 2.0 -x 670 -y 670 > scen-3 set opt(x) 670 ;# x coordinate of topology set opt(y) 670 ;# y coordinate of topology set opt(seed) 0.0 ;# seed for random number gen. set opt(stop) 100 ;# time to stop simulation set opt(ftp1-start) 20.0 set opt(ftp2-start) 50.0 set num_bs_nodes 1 # ============================================================================ # check for boundary parameters and random seed 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-random $opt(seed) } # create simulator instance #set ns_ [new Simulator] set ns_ [new Simulator -multicast on] # set up for hierarchical routing $ns_ node-config -addressType hierarchical AddrParams set domain_num_ 1 ;# number of domains lappend cluster_num 1 ;# number of clusters in each domain AddrParams set cluster_num_ $cluster_num lappend eilastlevel 4 ;# number of nodes in each cluster AddrParams set nodes_num_ $eilastlevel ;# of each domain set tracefd [open wireless2-out.tr w] set namtrace [open lbptrace.nam w] $ns_ trace-all $tracefd $ns_ namtrace-all-wireless $namtrace $opt(x) $opt(y) #Open the output files set f1 [open n0_bs.tr w] set f2 [open bs_n2.tr w] set f3 [open bs_n1.tr w] # Create topography object set topo [new Topography] # define topology $topo load_flatgrid $opt(x) $opt(y) # create God create-god [expr $opt(nn) + $num_bs_nodes] # configure for base-station node $ns_ node-config -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) \ -topoInstance $topo \ -wiredRouting OFF \ -agentTrace ON \ -routerTrace OFF \ -macTrace OFF #create base-station node set temp {0.0.0 0.0.1 0.0.2 0.0.3} ;# hier address to be used for wireless ;# domain set BS(0) [$ns_ node [lindex $temp 0]] $BS(0) color "red" $BS(0) random-motion 0 ;# disable random motion #provide some co-ord (fixed) to base station node $BS(0) set X_ [expr $opt(x)/2] $BS(0) set Y_ [expr $opt(y)/2] $BS(0) set Z_ 0.0 # create mobilenodes in the same domain as BS(0) # note the position and movement of mobilenodes is as defined # in $opt(sc) #configure for mobilenodes $ns_ node-config -wiredRouting OFF for {set j 0} {$j < $opt(nn)} {incr j} { set node_($j) [ $ns_ node [lindex $temp \ [expr $j+1]] ] $node_($j) base-station [AddrParams addr2id \ [$BS(0) node-addr]] } # setup TCP connections set tcp0 [new Agent/TCP] $tcp0 set class_ 2 set sink_bs [new Agent/TCPSink] $ns_ attach-agent $node_(0) $tcp0 $ns_ attach-agent $BS(0) $sink_bs $ns_ connect $tcp0 $sink_bs set ftp1 [new Application/FTP] $ftp1 attach-agent $tcp0 $ns_ at $opt(ftp1-start) "$ftp1 start" set tcp2 [new Agent/TCP] $tcp2 set class_ 2 set sink_n2 [new Agent/TCPSink] $ns_ attach-agent $BS(0) $tcp2 $ns_ attach-agent $node_(2) $sink_n2 $ns_ connect $tcp2 $sink_n2 set ftp2 [new Application/FTP] $ftp2 attach-agent $tcp2 $ns_ at $opt(ftp2-start) "$ftp2 start" set mproto DM set mrthandle [$ns_ mrtproto $mproto {}] set group0 [Node allocaddr] set udp1 [new Agent/UDP] $udp1 set dst_addr_ $group0 $udp1 set dst_port_ 0 $udp1 set class_ 1 $ns_ attach-agent $BS(0) $udp1 set cbr1 [new Application/Traffic/CBR] $cbr1 attach-agent $udp1 set sink_n1 [new Agent/LossMonitor] $ns_ attach-agent $node_(1) $sink_n1 #$ns_ connect $udp1 $sink_n1 $ns_ at 20.0 "$node_(1) join-group $sink_n1 $group0" $ns_ at 50.0 "$node_(1) leave-group $sink_n1 $group0" $ns_ at 75.0 "$node_(1) join-group $sink_n1 $group0" $ns_ at 0.0 "$cbr1 start" #Start logging the received bandwidth $ns_ at 0.0 "record" # source connection-pattern and node-movement scripts 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..." } # Define initial node position in nam for {set i 0} {$i < $opt(nn)} {incr i} { # 20 defines the node size in nam, must adjust it according to your # scenario # The function must be called after mobility model is defined $ns_ initial_node_pos $node_($i) 9 } # Tell all nodes when the simulation ends for {set i } {$i < $opt(nn) } {incr i} { $ns_ at $opt(stop).0 "$node_($i) reset"; } $ns_ at $opt(stop).0 "$BS(0) reset"; $ns_ at $opt(stop).0002 "puts \"NS EXITING...\" ; $ns_ halt" $ns_ at $opt(stop).0001 "stop" # informative headers for CMUTracefile 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 ------------- Ns-2 errors ------------- [EMAIL PROTECTED] 1_lbp]# ns lbp_mc.tcl num_nodes is set 4 warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl INITIALIZE THE LIST xListHead invalid command name "(null)" while executing "[$self set classifier_] install $dst $target" (procedure "_o21" line 3) (RtModule add-route line 3) invoked from within "$rtnotif_ add-route $dst $target" (procedure "_o20" line 5) (Node add-route line 5) invoked from within "$self add-route $address_ $dmux_" (procedure "_o20" line 8) (Node attach line 8) invoked from within "$node attach $ragent [Node set rtagent_port_]" (procedure "_o3" line 72) (Simulator create-wireless-node line 72) invoked from within "_o3 create-wireless-node 0.0.0" ("eval" body line 1) invoked from within "eval $self create-wireless-node $args" (procedure "_o3" line 23) (Simulator node line 23) invoked from within "$ns_ node [lindex $temp 0]" invoked from within "set BS(0) [$ns_ node [lindex $temp 0]]" (file "lbp_mc.tcl" line 131)