nslab_ex1b_06.tcl

来自「tcl程序demo by N. Sidiropoulos and R. Bro 」· TCL 代码 · 共 82 行

TCL
82
字号
set speed 250000000set distance 1120set rate 28Kbset packetSize 120set interval 120set delayS [expr $distance/$speed.0]set delayMs [expr $delayS*1000.0]set delay ${delayMs}msputs " DEaly = $delay rate = $rate"Queue set limit_ 6set ns [new Simulator]$ns color 0 blue$ns color 9 red$ns color 2 whiteset n0 [$ns node]set n1 [$ns node]set n2 [$ns node]puts n0=[$n0 id]puts n1=[$n1 id]puts n2=[$n2 id]set f [open out.tr w]$ns trace-all $fset nf [open out.nam w]$ns namtrace-all $nf#Create a duplex link between the nodes$ns duplex-link $n0 $n1 $rate $delay DropTail$ns duplex-link $n1 $n2 $rate $delay DropTail$ns duplex-link-op $n0 $n1 orient right$ns duplex-link-op $n1 $n2 orient right$ns duplex-link-op $n0 $n1 queuePos 0.5set udp0 [new Agent/UDP]$udp0 set fid_ 9$ns attach-agent $n0 $udp0$udp0 set class_ 9$udp0 set packetSize_ $packetSizeset cbr0 [new Application/Traffic/CBR]$cbr0 attach-agent $udp0puts "default [$cbr0 set packetSize_]"puts "default [$cbr0 set interval_]"$cbr0 set packetSize_ $packetSize#$cbr0 set interval_ $interval$cbr0 attach-agent $udp0puts [$cbr0 set packetSize_]puts [$cbr0 set interval_]set null0 [new Agent/Null]$ns attach-agent $n2 $null0$ns connect $udp0 $null0$ns at 0.5 "$cbr0 start"$ns at 2.0 "finish"proc finish {} {	puts "running nam..."	exec nam out.nam &	exit 0}$ns run

⌨️ 快捷键说明

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