使用setdest和cbrgen工具
mflood-sceen.tcl代码如下:
#parameters
set val(ifqlen) 50
set val(nn) 50
set val(rp) MFlood
set val(chan) Channel/WirelessChannel
set val(prop) Propagation/TwoRayGround
set val(netif) Phy/WirelessPhy
set val(mac) Mac/802_11
set val(ifq) Queue/DropTail/PriQueue
set val(ll) LL
set val(ant) Antenna/OmniAntenna
set val(stop) 400
set ns_ [new Simulator]
set tracefd [open mflood-sceen.tr w]
$ns_ trace-all $tracefd
# topology
set topo [new Topography]
$topo load_flatgrid 1200 1200
create-god $val(nn)
set channel [new Channel/WirelessChannel]
$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) \
-channel $channel \
-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) random-motion 0
}
source "mflood/scene-50n-0p-40s-400t-1200-1200"
source "mflood/cbr-50n-30c-1p"
for {set i 0} { $i < $val(nn)} {incr i} {
$ns_ at $val(stop) "$node_($i) reset"
}
$ns_ at $val(stop) "stop"
$ns_ at $val(stop) "puts \"NS EXISTING...\";$ns_ halt"
proc stop {} {
global ns_ tracefd
$ns_ flush-trace
close $tracefd
}
puts "Starting Simulation"
$ns_ run
代码如下:
source "mflood/scene-50n-0p-40s-400t-1200-1200"
source "mflood/cbr-50n-30c-1p"