Hello,I'm having trouble with a tcl script for AntNet in WSNs. i tried a simple
topology of 3 nodes. It seems like it's working (in NAM) but the file
containing the routing table (rtable.txt) is generated empty. i don't know if
there's something wrong with my TCL script or my C++ code for AntNet protocol.
I have tried before this AntNet in wired network and it worked fine, generating
trace files and full routing table at each node. Can anybody help me? Here's my
TCL script:
# A 100-node example for ad-hoc simulation with AODV
# Define optionsset val(chan) Channel/WirelessChannel ;# channel
typeset val(prop) Propagation/TwoRayGround ;# radio-propagation
modelset val(netif) Phy/WirelessPhy ;# network interface
type
set val(mac) Mac/802_11 ;# MAC typeset val(ifq)
Queue/DropTail/PriQueue ;# interface queue typeset val(ll)
LL ;# link layer typeset val(ant)
Antenna/OmniAntenna ;# antenna modelset val(ifqlen) 50
;# max packet in ifqset val(nn) 3
;# number of mobilenodesset val(rp) Antnet
;# routing protocolset val(x) 500 ;# X
dimension of topographyset val(y) 400 ;# Y
dimension of topographyset val(stop) 15 ;# time
of simulation end
set ns [new Simulator]set tracefd [open testAntNet.tr w]set
namtrace [open testAntNet.nam w]
$ns trace-all $tracefd$ns namtrace-all-wireless $namtrace $val(x) $val(y)
# set up topography objectset topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)
## Create nn mobilenodes [$val(nn)] and attach them to the channel.#
# configure the nodes $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) \
-channelType $val(chan) \ -topoInstance $topo \
-agentTrace ON \ -routerTrace ON \ -macTrace OFF \
-movementTrace ON
for {set i 0} {$i < $val(nn) } { incr i } { set node_($i) [$ns node]
$node_($i) set X_ [ expr 10+round(rand()*480) ] $node_($i) set Y_
[ expr 10+round(rand()*380) ] $node_($i) set Z_ 0.0 }
#Create Antnet agentsfor {set i 0} {$i < $val(nn)} {incr i} { set na($i) [
new Agent/Antnet $i]}
#Attach each node with Antnet agentfor {set i 0} {$i < $val(nn)} {incr i} {
$ns attach-agent $node_($i) $na($i)}
# Set parameters and start timefor {set i 0} {$i < $val(nn)} {incr i} { $na($i)
set num_nodes_ $val(nn) $na($i) set timer_ant_ 0.03 $na($i) set r_factor_
0.05 $ns at 2.0 "$na($i) start"}
# Define node initial position in namfor {set i 0} {$i < $val(nn)} { incr i }
{# 30 defines the node size for nam$ns initial_node_pos $node_($i) 30}
# Telling nodes when the simulation endsfor {set i 0} {$i < $val(nn) } { incr i
} { $ns at $val(stop) "$node_($i) reset";}
#Print routing tables generated by AntNetfor {set i 0} {$i < $val(nn)} {incr i}
{ $ns at 13.0 "$na($i) print_rtable"}
# ending nam and the simulation$ns at $val(stop) "$ns nam-end-wireless
$val(stop)"$ns at $val(stop) "stop"$ns at 15.0 "puts \"end simulation\" ; $ns
halt"proc stop {} { global ns tracefd namtrace $ns flush-trace close
$tracefd close $namtrace}
$ns run
Please help me out, thank you :)