Linux and tcl are my new platform of operating system. So I am still in the process of learning and adapting. I am having problem with my tcl script in which during the simulation process, I got not the output, but the following message:
Num_node is set to 4
Wrong node routing agent!
oo..I forgot to mention that before this happened, I have been warned about the syntax error message in the following sentence:
set l2lat [lindex $argv 5]
set addrlatency [lindex $argv 6]
set l2latency [expr [string trim $l2lat "ms"] + [string trim
$addrlatency "ms"] ]ms
I have checked my script and I think everything is just working fine. But it is not!. Please someone help me..I really need to solve these out. I just want to know what has cause those two errors (syntax and routing agent) error message to occur and what will be the possible solution to solve the problem.
Might be helpful to post the entire script, or at least the proc and the input so we know what you're actually trying to do. The node error has nothing to do with anything you posted, as far as I can tell.
# SIGMA L2 SIMULATION
# ======================================================================
# Define options
# ======================================================================
Trace set show_sctphdr_ 1
set speed [lindex $argv 0]
set linkdelay [lindex $argv 1]
set addiprto [lindex $argv 2]
set regdelay [lindex $argv 3]
set l2beacon [lindex $argv 4]
set l2lat [lindex $argv 5]
set addrlatency [lindex $argv 6]
set l2latency [expr [string trim $l2lat "ms"] + [string trim $addrlatency "ms"] ]ms
#set fa1x [lindex $argv 0]
#set fa2x [lindex $argv 1]
ARPTable set delay 0us
Mac/Tdma set slot_packet_len_ 500
Mac/802_11 set dataRate_ 500Kb
Phy/WirelessPhy set bandwidth_ 500Kb
set opt(chan) Channel/WirelessChannel ;# channel type
set opt(prop) Propagation/FreeSpace ;# radio-propagation model
set opt(netif) Phy/WirelessPhy ;# network interface type
set opt(mac) Mac/802_11 ;# MAC type
#set opt(mac) Mac/Tdma ;# 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) 1 ;# number of multihomed mobilenodes
set opt(adhocRouting) NOAH ;# routing protocol
set opt(cp) "" ;# cp file not used
set opt(sc) "" ;# node movement file.
set opt(x) 1600 ;# x coordinate of topology
set opt(y) 800 ;# y coordinate of topology
set opt(seed) 0.0 ;# random seed
set opt(stop) 100 ;# time to stop simulation
set opt(ftp1-start) 0.00001
set num_wired_nodes 2
set interval 0.5
# ====================================================================
#RF configurations
#set up the antennas to be centered in the node and 50 meters above earth
Antenna/OmniAntenna set X_ 0
Antenna/OmniAntenna set Y_ 0
Antenna/OmniAntenna set Z_ 50 ;#BS height (ht)
Antenna/OmniAntenna set Gt_ 1.0
Antenna/OmniAntenna set Gr_ 1.0
Phy/WirelessPhy set RXThresh_ 2.87192e-07 ;#set the threshold s.t. handover distance is 350m
Phy/WirelessPhy set Pt_ 50 ;#transmitter power
Phy/WirelessPhy set freq_ 900e+6
Phy/WirelessPhy set L_ 1.0
# ======================================================================
# 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)
}
# ======================================================================
# some helper functions
proc get_distance {node1 node2} {
set x1 [$node1 set X_]
set y1 [$node1 set Y_]
set x2 [$node2 set X_]
set y2 [$node2 set Y_]
set distance [expr sqrt(pow(($x1-$x2),2)+pow(($y1-$y2),2))]
return $distance
}
set cellsize 350
proc get-handoff-ratio {} {
global FA FA2 cellsize
set txpower [Phy/WirelessPhy set Pt_]
set distance [get_distance $FA $FA2]
set overlap [expr 2*$cellsize-$distance ]
if { $overlap < 0 } {
set overlap 0;
}
set handoff_ratio [expr 1-($cellsize-$overlap/2)/$txpower]
puts "HANDOFF_RATION_ $handoff_ratio"
return $handoff_ratio
}
# ======================================================================
# create simulator instance
set ns_ [new Simulator]
# set up for hierarchical routing
$ns_ node-config -addressType hierarchical
#$ns_ set-address-format hierarchical 3 16 8 8
AddrParams set domain_num_ 4 ;# number of domains
lappend cluster_num 2 1 1 1 ;# number of clusters in each domain
AddrParams set cluster_num_ $cluster_num
lappend eilastlevel 1 1 2 1 1 ;# number of nodes in each cluster
AddrParams set nodes_num_ $eilastlevel ;# of each domain
set tracefd [open sigma-l2.tr w]
set namtrace [open sigma-l2.nam w]
set cwndtr [open sctpcwnd.tr w]
set cwndtr1 [open sctpcwnd1.tr w]
$ns_ trace-all $tracefd
$ns_ namtrace-all-wireless $namtrace $opt(x) $opt(y)
# Create topography object
set topo [new Topography]
# define topology
$topo load_flatgrid $opt(x) $opt(y)
# create God
create-god [expr 2*$opt(nn) +2]
#create wired node W(0)--- CN, W(1)--- router
set temp {0.0.0 0.1.0} ;# hierarchical addresses
for {set i 0} {$i < $num_wired_nodes} {incr i} {
set W($i) [$ns_ node [lindex $temp $i]]
}
set id [AddrParams addr2id 0.1.0]
$W(0) set X_ 698.0
$W(0) set Y_ 667.0
$W(0) set Z_ 0.0
$W(0) label CN
$W(1) set X_ 698.0
$W(1) set Y_ 452.0
$W(1) set Z_ 0.0
$W(1) label Router
set chan_1_ [new $opt(chan)]
set chan_2_ [new $opt(chan)]
# Configure for ForeignAgent and HomeAgent nodes
$ns_ node-config -mobileIP OFF \
-adhocRouting $opt(adhocRouting) \
-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
-ifqLen $opt(ifqlen) \
-antType $opt(ant) \
-propType $opt(prop) \
-phyType $opt(netif) \
-channel $chan_1_ \
-topoInstance $topo \
-wiredRouting ON \
-multihomed OFF \
-msctp ON \
-agentTrace ON \
-routerTrace OFF \
-macTrace ON
set llname [open "llname" w]
# Create HA and FA
#use chan_1_ for HA
set HA [$ns_ node 1.0.0]
# turns HA into a Point Coordinator
[$HA set mac_(0)] make-pc
# And here we set how long the time between beacons should be
[$HA set mac_(0)] beaconperiod $l2beacon
#use chan_2_ for FA
$ns_ node-config -channel $chan_2_
set FA [$ns_ node 2.0.0]
# turns FA into a Point Coordinator
[$FA set mac_(0)] make-pc
# And here we set how long the time between beacons should be
[$FA set mac_(0)] beaconperiod $l2beacon
#use chan_1_ for FA2
$ns_ node-config -channel $chan_1_
set FA2 [$ns_ node 3.0.0]
# This turns FA2 into a Point Coordinator
[$FA2 set mac_(0)] make-pc
# And here we set how long the time between beacons should be
[$FA2 set mac_(0)] beaconperiod $l2beacon
$HA random-motion 0
$FA random-motion 0
$FA2 random-motion 0
# Position (fixed) for base-station nodes (HA & FA).
$HA label LM
$HA set X_ 200.0
$HA set Y_ 300.0
$HA set Z_ 0.0
$FA label AR1
$FA set X_ 850.0
$FA set Y_ 300.0
$FA set Z_ 0.0
$FA2 label AR2
$FA2 set X_ 1500.0
$FA2 set Y_ 300.0
$FA2 set Z_ 0.0
[$HA set regagent_] priority 3
[$FA set regagent_] priority 3
[$FA2 set regagent_] priority 3
[$HA set regagent_] beacon-period 0.1
[$FA set regagent_] beacon-period 0.1
[$FA2 set regagent_] beacon-period 0.1
# create a mobilenode that would be moving between HA and FA.
# note address of MH indicates its in the same domain as HA.
$ns_ node-config -wiredRouting OFF \
-adhocRouting MHNOAH \
-multihomed ON \
-msctp ON \
-channel $chan_1_ \
-channel1 $chan_2_
set MH [$ns_ node 1.0.1 2.0.1]
set node_(0) $MH
$node_(0) random-motion 1
set HAaddress [AddrParams addr2id [$HA node-addr]]
[$MH set regagent_] set home_agent_ $HAaddress
[$MH set regagent_] set HANDOFF_RATIO_ [get-handoff-ratio]
$MH set-base $HA
#puts "homeaddr: [join [AddrParams id2addr [$MH address?]] .]"
$MH cmd home-addr [join [AddrParams id2addr [$MH address?]] .]
#set L2 and address resolution latency
[$MH set mac_(0)] L2-latency $l2latency
[$MH set mac_(1)] L2-latency $l2latency
$node_(0) label MH
$node_(0) set X_ 350.0
$node_(0) set Y_ 300.0
$node_(0) set Z_ 0.0
$node_(0) color "red"
# setup SCTP connections between a wired node and the MobileHost
set src1 [new Agent/SCTP/MhSCTP]
$src1 set addip_rto_ $addiprto
$src1 set debugFileIndex_ 0
$src1 set dataChunkSize_ 512
$src1 set mtu_ 576
$src1 set numOutStreams_ 1
$src1 set initialSsthresh_ 65536
$src1 set initialRwnd_ [expr [$src1 set dataChunkSize_] * 20 ]
$src1 set initialSsthresh_ [expr [$src1 set dataChunkSize_] * 20 ]
$src1 set initialCwndMultiplier_ 2
$src1 set useDelayedSacks_ 1
$src1 set useMaxBurst_ 1
$src1 set fid_ 1
$src1 set debugMask_ -1
$ns_ color 1 "blue"
set sink1 [new Agent/SCTP]
$sink1 set debugFileIndex_ 1
$sink1 set dataChunkSize_ 512
$sink1 set mtu_ 576
$sink1 set numOutStreams_ 1
$sink1 set initialSsthresh_ 65536
$sink1 set initialRwnd_ [expr [$sink1 set dataChunkSize_] * 20 ]
$sink1 set initialSsthresh_ [expr [$sink1 set dataChunkSize_] * 20 ]
$sink1 set initialCwndMultiplier_ 2
$sink1 set useDelayedSacks_ 1
$sink1 set useMaxBurst_ 1
$sink1 set debugMask_ -1
$sink1 set fid_ 1
$ns_ mhsctp-attach $MH $src1
$ns_ attach-agent $W(0) $sink1
$ns_ mhconnect $src1 $sink1
set ftp1 [new Application/FTP]
$ftp1 attach-agent $sink1
$ns_ at $opt(ftp1-start) "$ftp1 start"
# setup source agent trace
$sink1 set trace_all_oneline_ 1 # do not trace all variables
$sink1 trace cwnd_
$sink1 trace rto_
$sink1 attach $cwndtr
# source connection-pattern and node-movement scripts
if { $opt(cp) == "" } {
set opt(cp) "none"
} else {
puts "Loading connection pattern..."
source $opt(cp)
}
if { $opt(sc) == "" } {
set opt(sc) "none"
} else {
puts "Loading scenario file..."
source $opt(sc)
puts "Load complete..."
}
# Define initial node position in nam
# 30 defines the node size in nam
$ns_ initial_node_pos $W(0) 100
$ns_ initial_node_pos $W(1) 100
$ns_ initial_node_pos $MH 100
$ns_ initial_node_pos $HA 100
$ns_ initial_node_pos $FA 100
$ns_ initial_node_pos $FA2 100
$ns_ at 0.0 "$HA setdest 200 300 0"
$ns_ at 0.0 "$FA setdest 850 300 0"
$ns_ at 0.0 "$FA2 setdest 1500 300 0"
# create links between wired and BaseStation nodes
$ns_ duplex-link $W(0) $W(1) 500Kb $linkdelay DropTail
$ns_ duplex-link $W(1) $HA 500Kb $regdelay DropTail
$ns_ duplex-link $W(1) $FA 500Kb $regdelay DropTail
$ns_ duplex-link $W(1) $FA2 500Kb $regdelay 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
$ns_ duplex-link-op $W(1) $FA2 orient right-down
$ns_ at $opt(stop).0 "$HA reset";
$ns_ at $opt(stop).0 "$FA reset";
$ns_ at $opt(stop).0 "$FA2 reset";
$ns_ at $opt(stop).0 "$MH reset";
$ns_ at 0.000001 "$sink1 set-primary 4194305"
#$ns_ at 0.000001 "recordcwnd"
$ns_ at 5.000000000000 "$MH setdest 1350.0 300.0 $speed"
#$ns_ at 21.000001 "$sink1 set-primary 8388609"
$ns_ at $opt(stop).00002 "puts \"NS EXITING...\" ; $ns_ halt"
$ns_ at $opt(stop).00001 "stop"
proc stop {} {
global ns_ tracefd cwndtr cwndtr1 llname MH namtrace
$ns_ flush-trace
puts "MH entry: [$MH entry]"
close $tracefd
close $namtrace
close $cwndtr
close $cwndtr1
close $llname
exec ./xgcwnd &
exec nam sigma-l2.nam &
exit 0
}
# some useful headers for tracefile
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)"
proc recordcwnd {} {
global src1 interval cwndtr
#Get an instance of the simulator
set ns [Simulator instance]
#How many bytes have been received by the traffic sinks?
set cw1 [$src1 set cwnd_]
#Get the current time
set now [$ns now]
#Calculate the cwnd and write it to the files
puts $cwndtr "$now $cw1"
#Re-schedule the procedure
$ns at [expr $now+$interval] "recordcwnd"
}
puts "Starting Simulation..."
$ns_ run
ok..I just want to run the simulation and see the output..in terms of latency for example. i am using ns2.26 as the simulator. Hope u can help..
Oh my.. Is this an eggdrop script? I'm assuming it's also a ham radio thing? I dont know what a ns simulator is. I'm afraid I'd have no way to test/debug such a script. You'd probably be better off posting on usenet's tcl newsgroup or a ham radio group if anyone there also uses tcl.
As far as your original question, the only syntax error I see, would be in this line:
set l2latency [expr [string trim $l2lat "ms"] + [string trim $addrlatency "ms"] ]ms
Enclose that in double-quotes:
set l2latency "[expr [string trim $l2lat "ms"] + [string trim
$addrlatency "ms"] ]ms"
Other than that, I don't see any glaring errors in the line. I'm curious what the "Trace, ARPTable, Mac, AddrParams" and other commands are from, they're not tcl commands, and I don't see any procs within the script called that.
Hmm, I just did a quick google search for AddrParams and ARPTable, and yep I'd say you were in the wrong forum, as this looks like it has little to do with tcl and eggdrop, and more to do with some specific c++ classes relating to this network simulator: http://www.isi.edu/nsnam/ http://www.isi.edu/nsnam/ns/index.html
opsss..sorry, I dont even know about "eggdrop"..I just search in google for tcl forum and found some useful website including this..haha..sorry, I thought the eggdrop is just simpy a name for the forum..
anyway, thanks for your quick response, ur time, ur effort and everything.