Appendix A

Blackholeaodv TCL File

# blackholeaodv TCL file
#
# =======================================
# Define options
#
# =======================================
set val(Chan) Channel/WirelessChannel ;   #ChannelType
set val(prop) Propagation/TwoRayGround ;  # radio-propagation model
set val(netif) Phy/WirelessPhy ;      # network interface type
set val(mac) Mac/802_11 ;          # MAC type
set val(ifq) Queue/DropTail/PriQueue ;   # interface queue type
set val(ll) LL ;                # link layer type
set val(ant) Antenna/OmniAntenna ;     # antenna model
set val(ifqlen) 150 ;             # max packet in ifq
set val(nn) 6 ;               # total number of mobilenodes
set val(n6) 6;               # create 6 nodes
set val(nnaodv) 5 ;            # number of AODV mobilenodes
set val(rp) AODV ;             # routing protocol
set val(energymodel) EnergyModel ;  # Energy Model
set val(initialenergy) 100 ;      # value in joules
set val(x) 670 ;             # X dimension of topography
set val(y) 670 ;              # Y dimension of topography
set val(cstop) 500 ;            # time of connections end
set val(stop) 500 ;            # time of simulation end
# set val(cp) “scenarios/scen1forAODV-n20-t500-x750-y750” ; #Connection pattern
# set val(cc) “scenarios/cbr” ;        #CBR Connections
# Initialize Global Variables
set ns_ [new Simulator]
$ns_ use-newtrace
set tracefd [open sim1for1BlackHole6Mobility.tr w]
$ns_ trace-all $tracefd
set namtrace [open sim1for1BlackHole6Mobility.nam w]
$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)
# set up topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
# Create God
create-god $val(nn)
# Create channel #1 and #2
set chan_1_ [new $val(Chan)]
set chan_2_ [new $val(Chan)]
# configure node, please note the change below.
$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) 
-topoInstance $topo 
-energyModel $val(energymodel) 
-initialEnergy $val(initialenergy) 
-rxPower 35.28e-3 
-txPower 31.32e-3 
-idlePower 712e-6 
-sleepPower 144e-9 
-agentTrace ON 
-routerTrace ON 
-macTrace ON 
-movementTrace ON 
-channel $chan_1_ 
$ns_ node-config -adhocRouting AODV
set node_(0) [$ns_ node]
#set node_(1) [$ns_ node]
set node_(1) [$ns_ node]
set node_(2) [$ns_ node]
set node_(3) [$ns_ node]
set node_(4) [$ns_ node]
$ns_ node-config -adhocRouting blackholeAODV
#set node_(5) [$ns_ node]
#$ns_ at 0.0 “$node_(5) label “BlackHole Node””
#set node_(4) [$ns_ node]
#$ns_ at 0.0 “$node_(4) label “BlackHole Node””
set node_(5) [$ns_ node]
$ns_ at 0.0 “$node_(5) label “BlackHole Node””
# create 6 nodes
# define positions in X and Y axis
$node_(0) set X_ 345.0
$node_(0) set Y_ 201.0
$node_(0) set Z_ 0.0
$ns_ at 0.0 “$node_(0) label “Sending Node””
$node_(1) set X_ 330.0
$node_(1) set Y_ 500.0
$node_(1) set Z_ 0.0
$node_(2) set X_ 307.0
$node_(2) set Y_ 338.0
$node_(2) set Z_ 0.0
$node_(3) set X_ 261.0
$node_(3) set Y_ 578.0
$node_(3) set Z_ 0.0
$ns_ at 0.0 “$node_(3) label “Receiving Node””
$node_(4) set X_ 380.0
$node_(4) set Y_ 395.0
$node_(4) set Z_ 0.0
$node_(5) set X_ 253.0
$node_(5) set Y_ 500.0
$node_(5) set Z_ 0.0
# Now produce some simple node movements
$ns_ at 50.0 “$node_(1) setdest 25.0 20.0 10.0”
$ns_ at 10.0 “$node_(0) setdest 350.0 220.0 11.0”
$ns_ at 75.0 “$node_(2) setdest 125.0 270.0 12.0”
$ns_ at 37.0 “$node_(3) setdest 400.0 280.0 13.0”
$ns_ at 13.0 “$node_(4) setdest 261.0 560.0 14.0”
$ns_ at 43.0 “$node_(5) setdest 113.0 8.0 15.0”
$ns_ at 109.0 “$node_(1) setdest 254.0 450.0 10.0”
$ns_ at 300.0 “$node_(0) setdest 345.0 201.0 11.0”
$ns_ at 391.0 “$node_(2) setdest 490.0 181.0 12.0”
$ns_ at 320.0 “$node_(3) setdest 400.0 300.0 13.0”
$ns_ at 104.0 “$node_(4) setdest 261.0 578.0 14.0”
$ns_ at 200.0 “$node_(5) setdest 97.0 549.0 15.0”
# Setup traffic flow between nodes
#Set Udp, cbr agent and attach those with nodes
set udp1 [new Agent/UDP]
$ns_ attach-agent $node_(0) $udp1
$udp1 set class_ 0
#$udp1 set fid_ 2
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
$cbr1 set packetSize_ 512
$cbr1 set rate_ 10kb
$cbr1 set interval_ 1
# Attach null agent for sink
set null1 [new Agent/Null]
$ns_ attach-agent $node_(3) $null1
$ns_ connect $udp1 $null1
# Start the traffic generator
$ns_ at 2.0 “$cbr1 start”
#Define initial node position in NAM for 6 nodes
$ns_ initial_node_pos $node_(0) 20
$ns_ initial_node_pos $node_(1) 20
$ns_ initial_node_pos $node_(2) 20
$ns_ initial_node_pos $node_(3) 20
$ns_ initial_node_pos $node_(4) 20
$ns_ initial_node_pos $node_(5) 20
# Tell all nodes when the simulation ends
for {set i 0} {$i < $val(n6) } {incr i} {
$ns_ at $val(stop).000000001 “$node_($i) reset”;
}
# Ending nam and simulation
$ns_ at $val(stop) “finish”
$ns_ at $val(stop).0 “$ns_ trace-annotate ”Simulation has ended””
$ns_ at $val(stop).00000001 “puts ”NS EXITING…“; $ns_ halt”
proc finish {} {
global ns_ tracefd namtrace
$ns_ flush-trace
close $tracefd
close $namtrace
exec nam sim1for1BlackHole6Mobility.nam &
exit 0
}
puts “Starting Simulation…”
$ns_ run
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.43.26