?? 1hopudp.tcl
字號:
# Author: Dapeng Wang# Email: deeper.wang@gmail.com# Date: July 7th, 2007#s VARIABLE FOR WIRELESS PARTset val(chan) Channel/WirelessChannel ;# channel typeset val(prop) Propagation/TwoRayGround ;# radio-propagation modelset val(netif) Phy/WirelessPhy ;# network interface typeset val(mac) Mac/WiMedia ;# MAC typeset val(ifq) Queue/DropTail/PriQueue ;# interface queue typeset val(ll) LL ;# link layer typeset val(ant) Antenna/OmniAntenna ;# antenna modelset val(ifqlen) 50 ;# max packet in ifqset val(nn) 2 ;# number of mobilenodesset val(rp) MANUAL ;# routing protocolset val(x) 100set val(y) 100set filename result# Set New Prametersset bandwidth 100Mbset scheduler "standard"set pnc_type "802_15_3"set sim_duration 1set error_rate 0.0set start_time 1set traffic_end_time [expr $start_time + $sim_duration]set end_time [expr $traffic_end_time + 1]set deadline 33000set nMaxAcks_ 16set ACKType "ImmediateACK"set gts_time 4000set TrafficType "Traffic_CBR"# TRACE PARTset ns_ [new Simulator]set tracefd [open $filename.tr w]$ns_ use-newtrace$ns_ trace-all $tracefdset namtrace [open $filename.nam w]$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)set topo [new Topography]$topo load_flatgrid $val(x) $val(y)create-god $val(nn)# NODE CONFIG PART$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 \ -channelType $val(chan) \ -agentTrace ON \ -routerTrace ON \ -macTrace ON \ -movementTrace OFFset node_(0) [$ns_ node]$node_(0) random-motion 0set node_(1) [$ns_ node]$node_(1) random-motion 0# Add routing tag$node_(0) add-route-tag 1 999$node_(0) add-next-hop 1 999 1 0$node_(1) add-route-tag 0 999$node_(1) add-next-hop 0 999 0 0# GRAPH PART$node_(0) set X_ 11$node_(0) set Y_ 11$node_(0) set Z_ 0.0$node_(1) set X_ 111$node_(1) set Y_ 11 $node_(1) set Z_ 0.0for {set i 0} {$i < $val(nn) } {incr i} { $ns_ initial_node_pos $node_($i) 50}set udp0 [new Agent/UDP]set cbr0 [new Application/Traffic/CBR]set null2 [new Agent/Null]$cbr0 set packetSize_ 548$cbr0 set maxpkts_ 1$ns_ attach-agent $node_(1) $udp0$ns_ attach-agent $node_(0) $null2$udp0 set packetSize_ 1500$cbr0 attach-agent $udp0$ns_ connect $udp0 $null2$ns_ at $start_time "$cbr0 start"# End of Traffic$ns_ at 0.10 "[$node_(0) set mac_(0)] set-pnc-type $pnc_type"$ns_ at 0.11 "[$node_(0) set mac_(0)] set-scheduler $scheduler"$ns_ at 0.5 "[$node_(1) set mac_(0)] add-flow-out 1 $deadline $ACKType $nMaxAcks_"$ns_ at 0.6 "[$node_(0) set mac_(0)] add-flow-in 1 $ACKType $nMaxAcks_"$ns_ at 0.7 "[$node_(0) set mac_(0)] scheduler request-gts 1 1 $gts_time $TrafficType $ACKType"$ns_ at 0.9 "[$node_(0) set mac_(0)] run-pnc"for {set i 0} {$i < $val(nn) } {incr i} { $ns_ at $end_time "$node_($i) reset";}$ns_ at $end_time "stop"$ns_ at $end_time "puts \"NS Existing... \"; $ns_ halt"proc stop {} { global ns_ tracefd namtrace $ns_ flush-trace close $tracefd close $namtrace }puts "Starting Simulation..."$ns_ run
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -