Anda di halaman 1dari 8

# 0 connecting to 2 at time 127.

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 sink [new Agent/TCPSink]


$ns_ attach-agent $node_(11) $tcp
$ns_ attach-agent $node_(28) $sink
$ns_ connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns_ at 3.25000000000000 "$ftp start"
$ns_ at 3.30000000000000 "$ftp stop"
set tcp [new Agent/TCP]
$tcp set class_ 1
set sink [new Agent/TCPSink]
$ns_ attach-agent $node_(28) $tcp
$ns_ attach-agent $node_(1) $sink
$ns_ connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns_ at 3.45000000000000 "$ftp start"
$ns_ at 3.55000000000000 "$ftp stop"
set tcp [new Agent/TCP]
$tcp set class_ 1
set sink [new Agent/TCPSink]
$ns_ attach-agent $node_(1) $tcp
$ns_ attach-agent $node_(27) $sink
$ns_ connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp

$ns_ at 4.05000000000000 "$ftp start"


$ns_ at 4.60000000000000 "$ftp stop"
set tcp [new Agent/TCP]
$tcp set class_ 1
set sink [new Agent/TCPSink]
$ns_ attach-agent $node_(27) $tcp
$ns_ attach-agent $node_(33) $sink
$ns_ connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns_ at 4.75000000000000 "$ftp start"
$ns_ at 4.80000000000000 "$ftp stop"
set tcp [new Agent/TCP]
$tcp set class_ 1
set sink [new Agent/TCPSink]
$ns_ attach-agent $node_(33) $tcp
$ns_ attach-agent $node_(25) $sink
$ns_ connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns_ at 4.95000000000000 "$ftp start"
$ns_ at 5.00000000000000 "$ftp stop"
# ======================================================================
# Define options
# ======================================================================
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(x)

400 ;# X dimension of the topography

set val(y)

400 ;# Y dimension of the topography

set val(ifqlen)

50

set val(seed)

0.0

;# max packet in ifq

set val(adhocRouting) AODV


set val(nn)

50

;# how many nodes are simulated

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

;# Initial energy in Joules


;#sleep power W 15 uA =I*I*R=11.25*10E-9 W

# =====================================================================
# Main Program
# ======================================================================
Mac/802_15_4 wpanCmd verbose on

Mac/802_15_4 wpanNam namStatus on


#
# Initialize Global Variables
#
# create simulator instance
set ns_

[new Simulator]

# setup topography object


set topo

[new Topography]

# create trace object for ns and nam


set tracefd

[open chandini-out.tr w]

set namtrace [open chandini-out.nam w]


$ns_ trace-all $tracefd
$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)
# define topology
$topo load_flatgrid $val(x) $val(y)
# Create God
set god_ [create-god $val(nn)]
# define how node should be created
#global node setting
$ns_ node-config -adhocRouting $val(adhocRouting) \
-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 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..."

;# disable random motion

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

Anda mungkin juga menyukai