?? eth-lan.tcl
字號:
set ns [new Simulator]proc finish {} { global ns nf tf nf_name tf_name $ns flush-trace close $nf close $tf# exec ../../../nam-1.0a10/nam $nf_name & exit 0}proc create-trace-files {num_nodes start_time end_time interval pkt_size} { global ns nf tf nf_name tf_name set ival [expr $interval * 1000] set nf_name "e-$num_nodes-$ival-$pkt_size.nam" set tf_name "e-$num_nodes-$ival-$pkt_size.tr" set nf [open $nf_name w] set tf [open $tf_name w] $ns namtrace-all $nf $ns trace-all $tf}proc create-lan {num_nodes start_time end_time interval pkt_size} { global ns nodes udp cbr null0 # create nodes for {set i 0} {$i < $num_nodes} {incr i} { set node($i) [$ns node] lappend nodelist $node($i) } set lan [$ns newLan $nodelist -bw 10Mb -delay 5ms \ -llType LL -ifqType Queue/DropTail -macType Mac/802_3 \ -chanType Channel -phyType Phy/WiredPhy -mactrace false] set null0 [new Agent/Null] $ns attach-agent $node(0) $null0 # add agents and applications for {set j 1} {$j < $num_nodes} {incr j} { # create UDP agent and attach it to node j set udp($j) [new Agent/UDP] $ns attach-agent $node($j) $udp($j) # create CBR source and attach it to udp set cbr($j) [new Application/Traffic/CBR] $cbr($j) set packetSize_ $pkt_size $cbr($j) set interval_ $interval $cbr($j) attach-agent $udp($j) # connect udp agent with null agent $ns connect $udp($j) $null0 $ns at $start_time "$cbr($j) start" $ns at $end_time "$cbr($j) stop" } return $lan}create-trace-files 2 0.2 0.8 0.005 500create-lan 2 0.2 0.8 0.005 500$ns at 1.0 "finish"$ns run
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -