📄 ultra.tcl
字号:
source cmu/mobile_node.tclsource cmu/dsdvnode.tclTrace set show_tcphdr_ 1LL set delay_ 5usAgent/TCP set packetSize_ 1460NetHold set offset_ [Classifier set offset_]NetHold set shift_ [Classifier/Addr set shift_]NetHold set mask_ [Classifier/Addr set mask_]NetHold set ifq_maxlen_ 50set opt(ifq) Queue/DropTailset opt(ifqsize) 50set opt(prop) Propagation/TwoRayGroundset opt(chan) Channelset opt(netif) NetIf/WaveLANset opt(ll) LL#set opt(mac) Mac/802_3set opt(mac) Mac/802_11set opt(tr) out.trset opt(nc) 1 ;# Number of Channelsset opt(nn) 50 ;# Number of Nodesset opt(stop) 900.0 ;# secondsset opt(routes) Staticset opt(movement) 500x500-1.0-1Simulator instproc mobile-node { chan } { global ns_ prop tracefd topo opt set node [new DSDVNode $tracefd] ;# create a mobile node# $node mobile_ 0 ;# enable mobility# $node forwarding_ 0 ;# not a router $node topography $topo # # This Trace Target is used to log changes in direction # and velocity for the mobile node. # if {$tracefd != ""} { set T [new Trace/Generic] $T target [$ns_ set nullAgent_] $T attach $tracefd $T set src_ [$node id] $node tracetarget $T } $node add-if $chan $prop $tracefd $opt(ll) $opt(mac) return $node}proc getopt {argc argv} { global opt lappend optlist tr stop num seed tmp lappend optlist qsize bw delay ll ifq mac chan tp sink source cbr lappend optlist movement for {set i 0} {$i < $argc} {incr i} { set arg [lindex $argv $i] if {[string range $arg 0 0] != "-"} continue set name [string range $arg 1 end] set opt($name) [lindex $argv [expr $i+1]] }}# *** MAIN PROGRAM ***if {$argc == 0} { puts "Usage: $argv0 \[-stop sec\] \[-nn nodes\] \[-tr tracefile\]\n" exit 1}getopt $argc $argv## Initialize Global Variables#set ns_ [new Simulator]set prop [new $opt(prop)]set tracefd [open $opt(tr) w]set topo [new Topography]set godtrace [new Trace/Generic]$godtrace target [$ns_ set nullAgent_]$godtrace attach $tracefdset god_ [new God]$god_ num_nodes $opt(nn)$god_ tracetarget $godtraceset dsdvtrace [new Trace/Generic]$dsdvtrace target [$ns_ set nullAgent_]$dsdvtrace attach [open /dev/null w]## The following creates a flat grid that is 100m X 100m## now 500mx500m$topo load_flatgrid 500 500## Create the specified number of channels $opt(nc) and their# corresponding network interfaces.#for {set i 0} {$i < $opt(nc) } {incr i} { set channel_($i) [new $opt(chan)] set iflist_($i) "" ;# interface list for channel $i}## Create the specified number of nodes $opt(nn) and "attach" them# to channel 0.#for {set i 0} {$i < $opt(nn) } {incr i} { set node($i) [$ns_ mobile-node $channel_(0)] [$node($i) set forwarder_] tracetarget $dsdvtrace $ns_ at 0.0 "$node($i) start-dsdv"}$ns_ at $opt(stop) "exit"source cmu/scenarios/$opt(movement)source cmu/scenarios/COMMPATTERN$ns_ run
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -