Sunteți pe pagina 1din 6

Appendix 2

TCL Script of OLSRQSUP Protocol

#----------------------PFE 2005----------------------------------------#This script was written by MAAMER MANEL #in purpose of simulating OLSRQSUP on ns-2.27 #----------------------------------------------------------------------#================================================== # Define options #================================================== set opt(chan) Channel/WirelessChannel; # channel type set opt(prop) Propagation/TwoRayGround; # radio-propagation model set opt(netif) Phy/WirelessPhy; # network interface type set opt(mac) Mac/802_11; # MAC type set opt(ifq) Queue/DropTail/PriQueue; # interface queue type set opt(ll) LL; # link layer type set opt(ant) Antenna/OmniAntenna; # antenna model set opt(ifqlen) 50; # max packet in ifq set opt(nn) 50; # number of mobilenodes set opt(adhocRouting) OLSRQSUP; # routing protocol

Ad Hoc Networks: Routing, Q oS and Optimization 2011 ISTE Ltd. Published 2011 by ISTE Ltd.

Mounir Frikha

256

Ad Hoc Networks

set opt(cp) set opt(sc)

"/root/scenario/traf_50_15_1000"; "/root/scenario/mvn_50_5";

# connection pattern file # node movement file.

set opt(x) 1000; set opt(y) 1000; set opt(seed) 0.0; set opt(stop) 300;

# x coordinate of topology # y coordinate of topology # seed for random number gen. # time to stop simulation

set opt(cbr-start) 30.0; #time of starting trafic emission set opt(time) 10 #================================================== # # check for random seed # if {$opt(seed) > 0} { puts "Seeding Random number generator with $opt(seed)\n" ns-random $opt(seed) } # # create simulator instance # set ns_ [new Simulator] # # control OLSRQSUP behaviour from this script # commented lines are not needed because # those are default values in ns-default.tcl # which are the same as in RFC 3626 # but if we need to change them # we have just to act here # #Agent/OLSRQSUP set use_mac_ true #Agent/OLSRQSUP set debug_ false #Agent/OLSRQSUP set willingness 3

Appendix 2

257

#Agent/OLSRQSUP set hello_ival_ 2 #Agent/OLSRQSUP set tc_ival_ 5 #Agent/OLSRQSUP set bw_ival_ 0.5 #we compute avail bw each 0.5s (QoS) $ns_ use-newtrace set tracefd [open out_OLSRQSUP.tr w] set namtrace [open out_OLSRQSUP.nam w] $ns_ trace-all $tracefd $ns_ namtrace-all-wireless $namtrace $opt(x) $opt(y) # # create topography object # set topo [new Topography] # # define topology # $topo load_flatgrid $opt(x) $opt(y) # # create God # set god_ [create-god $opt(nn)] # # configure mobile nodes # $ns_ node-config -adhocRouting $opt(adhocRouting) \ -llType $opt(ll) \ -macType $opt(mac) \ -ifqType $opt(ifq) \ -ifqLen $opt(ifqlen) \

258

Ad Hoc Networks

-antType $opt(ant) \ -propType $opt(prop) \ -phyType $opt(netif) \ -channelType $opt(chan) \ -topoInstance $topo \ -wiredRouting OFF \ -agentTrace ON \ -routerTrace ON \ -macTrace OFF for {set i 0} {$i < $opt(nn)} {incr i} { set node_($i) [$ns_ node] } # # print (in the trace file) routing table and other # internal data structures on a per-node basis # for {set i 0} {$i < $opt(nn)} {incr i} { $ns_ at 28 "[$node_($i) agent 255] print_rtable" $ns_ at 28 "[$node_($i) agent 255] print_linkset" $ns_ at 28 "[$node_($i) agent 255] print_nbset" $ns_ at 28 "[$node_($i) agent 255] print_nb2hopset" $ns_ at 28 "[$node_($i) agent 255] print_mprset" $ns_ at 28 "[$node_($i) agent 255] print_mprselset" $ns_ at 28 "[$node_($i) agent 255] print_topologyset" } # # source connection-pattern and node-movement scripts # if { $opt(cp) == "" } { puts "*** NOTE: no connection pattern specified." set opt(cp) "none" } else {

Appendix 2

259

puts "Loading connection pattern..." source $opt(cp) } if { $opt(sc) == "" } { puts "*** NOTE: no scenario file specified." set opt(sc) "none" } else { puts "Loading scenario file..." source $opt(sc) puts "Load complete..." } # # define initial node position in nam # for {set i 0} {$i < $opt(nn)} {incr i} { $ns_ initial_node_pos $node_($i) 20 } # # tell all nodes when the simulation ends # for {set i 0} {$i < $opt(nn) } {incr i} { $ns_ at $opt(stop).0 "$node_($i) reset"; } $ns_ at $opt(stop).0002 "puts \"NS EXITING...\" ; $ns_ halt" $ns_ at $opt(stop).0001 "stop" proc stop {} { global ns_ tracefd namtrace $ns_ flush-trace close $tracefd close $namtrace }

260

Ad Hoc Networks

# # begin simulation # puts "Starting Simulation..." $ns_ run

S-ar putea să vă placă și