⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.tcl

📁 ns2.31下的UWB(Ultra WideBand)实现
💻 TCL
字号:
set val(chan)    Channel/WirelessChannel;    #channel typeset val(prop)    Propagation/TwoRayGround;   #radio-propagation modelset val(ant)     Antenna/OmniAntenna;        #Antenna typeset val(ll)      LL;                         #Link layer typeset val(ifq)     Queue/DropTail/PriQueue;    #Interface queue typeset val(ifqlen)  50;                         #max packet in ifqset val(netif)   Phy/WirelessPhy;            #network interface typeset val(mac)     Mac/WiMedia;                 #MAC typeset val(nn)      2;                          #number of mobilenodesset val(rp)      AODV;                       #ad-hoc routing protocolset ns_ [new Simulator]#set the color of the flow$ns_ color 1 Blue$ns_ color 2 Redset tracefd [open test.tr w]$ns_ use-newtrace;$ns_ trace-all $tracefdset namnf [open test.nam w]$ns_ namtrace-all-wireless $namnf 700 300set topo [new Topography]$topo load_flatgrid 400 300create-god $val(nn)#set chan0 [new $val(chan)]#Configure nodes     $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 OFFfor {set i 0} {$i < $val(nn) } {incr i} {        set node_($i) [$ns_ node]        $node_($i) random-motion 0;     #disable random motion}#provide initial (X,Y, for now Z=0) co-ordinates for node_(0) and node_(1)$node_(0) set X_ 150.0$node_(0) set Y_ 100.0$node_(0) set Z_ 0.0$node_(1) set X_ 400.0$node_(1) set Y_ 100.0$node_(1) set Z_ 0.0for {set i 0} {$i < $val(nn) } {incr i} {       $ns_ initial_node_pos $node_($i) 30}set udp0 [new Agent/UDP]set cbr0 [new Application/Traffic/CBR]set null2 [new Agent/Null]$cbr0 set packetSize_ 548$cbr0 set maxpkts_ 20$ns_ attach-agent $node_(0) $udp0$ns_ attach-agent $node_(1) $null2$udp0 set packetSize_ 1500$cbr0 attach-agent $udp0$ns_ connect $udp0 $null2#set ftp [new Application/FTP]#$ftp attach-agent $tcp$ns_ at 0.01 "$cbr0 start"#tell nodes when the simulation endsfor {set i 0} {$i < $val(nn) } {incr i} {    $ns_ at 5.0 "$node_($i) reset";}$ns_ at 20.0001 "stop"$ns_ at 20.0002 "puts \"NS EXITING... \"; $ns_ halt"proc stop {} {     global ns_ tracefd     global ns_ namnf     $ns_ flush-trace     close $tracefd     close $namnf}puts "Starting Simulation..."$ns_ run

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -