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

📄 nslab_ex2_06b.tcl

📁 TCL demo by N. Sidiropoulos and R. Bro clear all F=5 % users I=4 % antennas
💻 TCL
字号:
# Configuring the parameters :# ===============================set starttime  0.5set sendfilestarttime 0.6set numofarg  [llength $argv]if { $numofarg   < 6 } { 	puts "no arguments were supplied = using defaults" 	set  speed 250000000	set distance 10000	set rate 100Mb	set packetSize 1000	set numofnodes 6	set filesize  1500000} else {	set filesize  [lindex $argv 0]	set packetSize [lindex $argv 1]	set rate [lindex $argv 2]	set distance [lindex $argv 3]	set speed [lindex $argv 4]	set numofnodes [expr [lindex $argv 5] + 1]}set delayS [expr $distance/$speed.0]set delayMs [expr $delayS*1000.0]set delay ${delayMs}msputs " DEaly = $delay rate = $rate"#=======================================================#Create a simulator objectset ns [new Simulator]#Define different colors for data flows$ns color 0 blue$ns color 1 red#Open the nam trace fileset nf [open out.nam w]$ns namtrace-all $nf#Open the trace fileset tf [open out.tr w]$ns trace-all $tf#Define a 'finish' procedureproc finish {} {        global ns nf tf distance speed        $ns flush-trace	#Close the trace file        close $nf        close $tf	#Execute nam on the trace file        exec nam out.nam &        exit 0}#overloading the FTP start procedure Application/FTP instproc start {} {		[$self agent] send 0 	puts "This is the start proc. for FTP "}#Agent/TCP instproc done {} {#	global ns nf tf distance speed sendfilestarttime#	puts " This is done for TCP "#	puts " finish time : [ $ns now ] sec"#	puts " total time ( approx . ) :   [expr [ $ns now ] - $sendfilestarttime ] sec " #	"finish"#	#}#Create nodesfor {set i 0} {$i < $numofnodes} {incr i} {  set n($i) [$ns node]}# we'll take n0 as node A and n-numofnodes as node B#Create a duplex link between the nodesfor {set i 0} {$i < $numofnodes-1} {incr i} {  $ns duplex-link $n($i) $n([expr ($i+1)]) $rate $delay DropTail # $ns duplex-link-op $n($i) $n([expr ($i+1)]) orient right#  $ns duplex-link-op $n($i) $n([expr ($i+1)]) queuePos 0.5}#Create a TCP agent and attach it to node n0set tcp [new Agent/TCP]$tcp set packetSize_ $packetSizeset tcpsink [new Agent/TCPSink]$ns attach-agent $n(0) $tcp$ns attach-agent $n([expr ($numofnodes - 1)]) $tcpsink$ns connect $tcp $tcpsink$tcp set fid_ 4set ftp [new Application/FTP]$ftp attach-agent $tcp#Schedule events for the FTP agent#$ns at $starttime "$ftp start "$ns at $sendfilestarttime "$ftp send $filesize" $ns at [expr 10 + $sendfilestarttime] "finish"#Run the simulation$ns run# The simulation we'll end when the TCP connection will be closed .

⌨️ 快捷键说明

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