📄 rs.tcl
字号:
# route shortening testsource cmu/dsr/srnode.tclTrace set show_tcphdr_ 1LL set delay_ 5usAgent/TCP set packetSize_ 1460set opt(ifq) Queue/DropTailset opt(ifqsize) 50set opt(prop) Propagation/FreeSpaceset 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) 4 ;# Number of Nodesset opt(stop) 100.0 ;# secondsset opt(rt_port) 128 ;# must agree with packet.hset opt(seed) 0set opt(sc) ""set opt(geo) "500x500"Simulator instproc srnode { chan } { global ns_ prop tracefd topo opt set node [new SRNode] $node topography $topo $node add-if $chan $prop $tracefd $opt(ll) $opt(mac) # # 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 } 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 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" puts " \[-seed int\] \[-sc scenariofile\]\n"}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 $godtrace## The following creates a flat grid that is 100m X 1000m#if {$opt(geo) == "100x1500"} { $topo load_flatgrid 100 1500} elseif {$opt(geo) == "500x500"} { $topo load_flatgrid 500 1500} else { $topo load_flatgrid 100 100}## 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} { puts "Making node $i" set node($i) [$ns_ srnode $channel_(0)] $ns_ at 0.0 "$node($i) start-dsr"}set tcpcnt 0set tcp_($tcpcnt) [$ns_ create-connection \ TCP $node(0) TCPSink $node(3) 0]$tcp_($tcpcnt) set window_ 32set ftp_($tcpcnt) [$tcp_($tcpcnt) attach-source FTP]$ns_ at 0.1 "$ftp_($tcpcnt) start"$node(0) set X_ 0$node(0) set Y_ 500$node(1) set X_ 200$node(1) set Y_ 500$node(2) set X_ 400$node(2) set Y_ 500$node(3) set X_ 500$node(3) set Y_ 550#$node(4) set X_ #$node(4) set Y_ #$node() set X_ #$node() set Y_ $ns_ at 0 "$node(3) setdest 0 550 5" $ns_ at $opt(stop) "$ns_ halt"if {$opt(sc) != "" } { source $opt(sc) }puts "Starting Simulation..."$ns_ run
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -