?? example.tcl
字號:
# Define optionsset opt(chan) Channel/WirelessChannel ;# channel typeset opt(prop) Propagation/TwoRayGround ;# radio-propagation modelset opt(netif) Phy/WirelessPhy ;# network interface typeset opt(mac) Mac/Gprs;# MAC typeset opt(ifq) Queue/DropTail/PriQueue ;# interface queue typeset opt(ll) LL ;# Link layer typeset opt(rlc) RLC set opt(ant) Antenna/OmniAntenna ;# antenna modelset opt(ifqlen) 5000 ;# max packet in ifqset opt(adhocRouting) NOAH ;#routing protocolset opt(x) 70 ;#x coordinate of topologyset opt(y) 70 ;#y coordinate of topologyset opt(seed) 0.0 ;#seed for random number gen.set opt(start) 0.0set num_bs_nodes 1set opt(nn) 1 ;# number of mobilenodesMac/Gprs set slot_packet_len_ 53; #safety margin. rlc pkt size is #50bytes; mac header's 1 byte Mac/Gprs set gprs_ 1; #whether its a GSM or GPRS simulationMac/Gprs set max_num_ms_ 15; Mac/Gprs set max_num_freq_ 2;Mac/Gprs set gprs_slots_per_frame_ 4;Mac/Gprs set rlc_error_ 1; #1=> error; 0=> no errorMac/Gprs set error_rate_ 1000; #max random num for error for err#model; 1000 is a pretty high error rate, but is used here jsut to#demonstrate Mac/Gprs set verbose_ 1;LL set acked_ 0 LL set llfraged_ 1;LL set llfragsz_ 1520; #to allow for the encap header of 20bytes.LL set llverbose_ 0;RLC set acked_ 1 ;#1 if acked..0 if non-ackedRLC set rlcfraged_ 1 ;#1-frag.......0-nofrag RLC set rlcfragsz_ 50;#to tranmit 50 bytes/sec per slotRLC set rlcverbose_ 1;set opt(ack) 0set opt(frag) 1set opt(tr) "gprs_err_acked.tr"set opt(stop) 10 ;# time to stop simulationset opt(rate) 12k ;# rate of exponential flows# ============================================================================# check for boundary parameters and random seedif { $opt(x) == 0 || $opt(y) == 0 } { puts "No X-Y boundary values given for wireless topology\n"}if {$opt(seed) > 0} { puts "Seeding Random number generator with $opt(seed)\n" ns-random $opt(seed)} #remove extrapkt headers else each pkt takes up too much space.remove-packet-header LDP MPLS Snoopremove-packet-header Ping TFRC TFRC_ACKremove-packet-header Diffusion RAP IMEP remove-packet-header AODV SR TORA IPinIP remove-packet-header MIP HttpInvalremove-packet-header MFTP SRMEXT SRM aSRMremove-packet-header mcastCtrl CtrMcast IVSremove-packet-header Resv UMP Flags# create simulator instanceset ns_ [new Simulator]# set up for hierarchical routing$ns_ node-config -addressType hierarchicalAddrParams set domain_num_ 1 ;# number of domainslappend cluster_num 1 ;# number of clusters in each domainAddrParams set cluster_num_ $cluster_numlappend eilastlevel 2 ;# number of nodes in each cluster AddrParams set nodes_num_ $eilastlevel ;# of each domainset tracefd [open $opt(tr) w]$ns_ trace-all $tracefd# Create topography objectset topo [new Topography]# define topology$topo load_flatgrid $opt(x) $opt(y)# create Godcreate-god $opt(nn)#set chan according to new nsset chan1 [new $opt(chan)] # configure for base-station node$ns_ node-config -adhocRouting $opt(adhocRouting) \ -llType $opt(ll) \ -rlcType $opt(rlc) \ -macType $opt(mac) \ -ifqType $opt(ifq) \ -ifqLen $opt(ifqlen) \ -antType $opt(ant) \ -propType $opt(prop) \ -phyType $opt(netif) \ -topoInstance $topo \ -wiredRouting ON \ -agentTrace ON \ -routerTrace OFF \ -macTrace ON \ -movementTrace OFF \ -channel $chan1 # hier address to be used for wireless domainset temp {1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.0.10} ;#create base-station nodeset BS(0) [$ns_ node [lindex $temp 0]]$BS(0) random-motion 0 ;# disable random motion#provide some co-ord (fixed) to base station node$BS(0) set X_ 1.0$BS(0) set Y_ 2.0$BS(0) set Z_ 0.0# create mobilenodes in the same domain as BS(0) #configure for mobilenodes$ns_ node-config -wiredRouting OFFfor {set j 0} {$j < $opt(nn)} {incr j} { set node_($j) [ $ns_ node [lindex $temp [expr $j+1]] ] $node_($j) base-station [AddrParams addr2id [$BS(0) node-addr]]}#default positions are used for each MS. Can put in your own. #exponential traffic is used here. Can use FTP/UDP/CBR instead.for {set j 0} {$j < $opt(nn)} {incr j} { set s($j) [new Agent/TCP] #$ns_ attach-agent $BS(0) $s($j) $ns_ attach-agent $node_($j) $s($j) $s($j) set packetSize_ 1500 set null($j) [new Agent/TCPSink] #$ns_ attach-agent $node_($j) $null($j) $ns_ attach-agent $BS(0) $null($j) $null($j) set packetSize_ 30 $ns_ connect $s($j) $null($j) set exp($j) [new Application/Traffic/Exponential] #$exp($j) set packetSize_ 200;#not used since default TCP pkt size #used. $exp($j) set burst_time_ 1500ms $exp($j) set idle_time_ 50ms $exp($j) set rate_ $opt(rate) $exp($j) attach-agent $s($j) $ns_ at $opt(start) "$exp($j) start" }# Tell all nodes when the simulation endsfor {set i 0} {$i < $opt(nn) } {incr i} { $ns_ at $opt(stop).0 "$node_($i) reset";}$ns_ at $opt(stop).0 "$BS(0) reset";$ns_ at $opt(stop).0002 "puts \" \" ; $ns_ halt" $ns_ at $opt(stop).0001 "stop"proc stop {} { global ns_ tracefd $ns_ flush-trace close $tracefd}# informative headers for CMUTracefileputs $tracefd "routing=$opt(adhocRouting)stoptime=$opt(stop) ack=$opt(ack) frag=$opt(frag)"puts $tracefd "num of mobiles=$opt(nn); x $opt(x) y $opt(y) "puts $tracefd "seed $opt(seed) prop $opt(prop) ant $opt(ant)"#puts "Starting Simulation..."$ns_ run
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -