93667922166023
set udp_(0) [new Agent/UDP]
$ns_ attach-agent $node_(0) $udp_(0)
set null_(0) [new Agent/Null]
$ns_ attach-agent $node_(0) $null_(0)
set cbr_(0) [new Application/Traffic/CBR]
$cbr_(0) set packetSize_ 64
$cbr_(0) set interval_ 0.005
$cbr_(0) set random_ 1
$cbr_(0) set maxpkts_ 10000
$cbr_(0) attach-agent $udp_(0)
$ns_ connect $udp_(0) $null_(0)
$ns_ at 10.93667922166023 "$cbr_(0) start"
set tcp [new Agent/TCP]
$tcp set class_ 1
set sink [new Agent/TCPSink]
$ns_ attach-agent $node_(21) $tcp
$ns_ attach-agent $node_(18) $sink
$ns_ connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns_ at 1.20000000000000 "$ftp start"
$ns_ at 1.90000000000000 "$ftp stop"
set tcp [new Agent/TCP]
$tcp set class_ 1
set sink [new Agent/TCPSink]
$ns_ attach-agent $node_(18) $tcp
$ns_ attach-agent $node_(2) $sink
$ns_ connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns_ at 2.05000000000000 "$ftp start"
$ns_ at 2.10000000000000 "$ftp stop"
set tcp [new Agent/TCP]
$tcp set class_ 1
set sink [new Agent/TCPSink]
$ns_ attach-agent $node_(18) $tcp
$ns_ attach-agent $node_(11) $sink
$ns_ connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns_ at 3.05000000000000 "$ftp start"
$ns_ at 3.15000000000000 "$ftp stop"
set tcp [new Agent/TCP]
$tcp set class_ 1
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(x)
set val(y)
set val(ifqlen)
50
set val(seed)
0.0
50
set val(cp)
set val(sc)
cbr
scen
set val(stop)
5.0
set val(traffic)
tcp
;# simulation time
set val(rxPower)
0.60175
;#Potencia recepcin en W
set val(txPower)
0.50175
;#Potencia transmisin en W
set val(energymodel)
EnergyModel ;
set val(initialenergy) 50
set val(sleeppower)
0.00005
# =====================================================================
# Main Program
# ======================================================================
Mac/802_15_4 wpanCmd verbose on
[new Simulator]
[new Topography]
[open chandini-out.tr w]
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON
# Energy Config to all nodes
$ns_ node-config -energyModel EnergyModel \
-initialEnergy $val(initialenergy) \
-txPower $val(txPower) \
-rxPower $val(rxPower) \
-idlePower 0.5 \
-sensePower 0.0175\
-sleeppower
# Create the specified number of nodes [$val(nn)] and "attach" them to the channel.
for {set i 0} {$i < $val(nn) } {incr i} {
set node_($i) [$ns_ node]
$node_($i) random-motion 0
}
# Define node movement model
puts "Loading connection pattern..."
source $val(cp)
# Define traffic model
puts "Loading scenario file..."
source $val(sc)
# Define node initial position in nam
for {set i 0} {$i < $val(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) 20
}
Mac/802_15_4 wpanNam FlowClr -p $pktType -s 1 -d 3 -c blue
Mac/802_15_4 wpanNam FlowClr -p $pktType -s 0 -d 2 -c blue
for {set i 0} {$i < $val(nn) } {incr i} {
$node_($i) color blue
}
$ns_ at 1.0 "$node_(18) add-mark m1 blue circle"
$ns_ at 1.0 "$node_(33) add-mark m1 blue circle"
$ns_ at 1.0 "$node_(1) add-mark m1 blue circle"
$ns_ at 1.0 "$node_(11) add-mark m1 blue circle"
#nam window comments
# Tell nodes when the simulation ends
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at $val(stop).0 "$node_($i) reset";
}
#finishing process
proc finish {} {
global ns_ tracefd namtrace
close $tracefd
close $namtrace
#exec awk -f graph.awk wireless-out.tr > efficiency
#exec xgraph efficiency &
exec nam wireless-out.nam &
}
$ns_ at $val(stop).0001 "finish"
$ns_ at $val(stop).0002 "puts \"NS EXITING...\" ; $ns_ halt"
puts $tracefd "M 0.0 nn $val(nn) x $val(x) y $val(y) rp $val(adhocRouting)"
puts $tracefd "M 0.0 sc $val(sc) seed $val(seed)"
puts $tracefd "M 0.0 prop $val(prop) ant $val(ant)"
puts "Starting Simulation..."
$ns_ run