1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
set opt(stop) 15
set nodes 25
set mobility 1
set scenario 1
set pausetime 0
set traffic cbr
set senders 5
set receivers 20
set X 1000
set Y 1000
set ns_ [new Simulator]
set topo [new Topography]
$topo load_flatgrid $X $Y
set tracenam [open puma.nam w]
$ns_ namtrace-all-wireless $tracenam $X $Y
set tracefd [open puma.tr w]
#$ns_ use-newtrace
$ns_ trace-all $tracefd
set god_ [create-god $nodes]
$ns_ node-config -adhocRouting PUMA \
-llType LL \
-macType Mac/802_11 \
-ifqLen 50 \
-ifqType Queue/DropTail/PriQueue \
-antType Antenna/OmniAntenna \
-propType Propagation/TwoRayGround \
-phyType Phy/WirelessPhy \
-channel [new Channel/WirelessChannel] \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF
for {set i 0} {$i < $nodes} {incr i} {
set node_($i) [$ns_ node]
$node_($i) random-motion 0;
}
puts "Loading connection pattern ..."
source "puma-cbr-ex"
puts "Loading scenarios file..."
source "puma-scenario-ex"
for {set i 0} {$i < $nodes} {incr i} {
$ns_ at $opt(stop) "$node_($i) reset";
}
Node instproc join { group } {
$self instvar ragent_
set group [expr $group]
$ragent_ join $group
}
Node instproc leave { group } {
$self instvar ragent_
set group [expr $group] ;
$ragent_ leave $group
}
$ns_ at $opt(stop) "$ns_ halt"
puts "Starting Simulation ..."
$ns_ run
puts "NS EXITING..."
|