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

📄 ex2.tcl

📁 NS的一些例子
💻 TCL
字号:
set ns [new Simulator]#Define different colors for data flows (for NAM)$ns color 1 Blue$ns color 2 Red#Open the Trace fileset file1 [open out.tr w]$ns trace-all $file1#Open the NAM trace fileset file2 [open out.nam w]$ns namtrace-all $file2#Define a 'finish' procedureproc finish {} {        global ns file1 file2        $ns flush-trace        close $file1        close $file2        exec nam out.nam &        exit 0}# Next line should be commented out to have the static routing$ns rtproto DV#Create six nodesset n0 [$ns node]set n1 [$ns node]set n2 [$ns node]set n3 [$ns node]set n4 [$ns node]set n5 [$ns node]#Create links between the nodes$ns duplex-link $n0 $n1 0.3Mb 10ms DropTail$ns duplex-link $n1 $n2 0.3Mb 10ms DropTail$ns duplex-link $n2 $n3 0.3Mb 10ms DropTail$ns duplex-link $n1 $n4 0.3Mb 10ms DropTail$ns duplex-link $n3 $n5 0.5Mb 10ms DropTail$ns duplex-link $n4 $n5 0.5Mb 10ms DropTail#Give node position (for NAM)$ns duplex-link-op  $n0 $n1 orient right$ns duplex-link-op  $n1 $n2 orient right$ns duplex-link-op $n2 $n3 orient up$ns duplex-link-op $n1 $n4 orient up-left$ns duplex-link-op  $n3 $n5 orient left-up$ns duplex-link-op  $n4 $n5 orient right-up#Setup a TCP connectionset tcp [new Agent/TCP/Newreno]$ns attach-agent $n0 $tcpset sink [new Agent/TCPSink/DelAck]$ns attach-agent $n5 $sink$ns connect $tcp $sink$tcp set fid_ 1#Setup a FTP over TCP connectionset ftp [new Application/FTP]$ftp attach-agent $tcp$ftp set type_ FTP$ns rtmodel-at 1.0 down $n1 $n4$ns rtmodel-at 4.5 up $n1 $n4$ns at 0.1 "$ftp start"$ns at 6.0 "finish"$ns run

⌨️ 快捷键说明

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