- set ns [new Simulator]
- $ns color 1 Blue
- $ns color 2 Red
- $ns color 3 Green
- set nf [open out.nam w]
- $ns namtrace-all $nf
- set tf [open out.tr w]
- $ns trace-all $tf
- proc finish {} {
- global ns nf tf
- $ns flush-trace
- close $nf
- close $tf
- exec nam out.nam &
- exit 0
- }
- set Z 18
- for {set i 0} {$i<$Z} { incr i } {
- set n($i) [$ns node]
- }
- set lan0 [$ns newLan "$n(0) $n(6) $n(12) " 1Mb 10ms LL Queue/DropTail MAC/Csma/Ca Channel]
- set lan1 [$ns newLan " $n(0) $n(1) $n(2) $n(3) $n(4) $n(5)" 1.5Mb 10ms LL Queue/DropTail MAC/Csma/Ca Channel]
- set lan2 [$ns newLan "$n(6) $n(7) $n(8) $n(9) $n(10) $n(11)" 1.5Mb 10ms LL Queue/DropTail MAC/Csma/Ca Channel]
- set lan3 [$ns newLan "$n(12) $n(13) $n(14) $n(15) $n(16) $n(17)" 1.5Mb 10ms LL Queue/DropTail MAC/Csma/Ca Channel]
- set tcp1 [new Agent/TCP]
- $ns attach-agent $n(1) $tcp1
- set tcp2 [new Agent/TCP]
- $ns attach-agent $n(1) $tcp2
- set tcp3 [new Agent/TCP]
- $ns attach-agent $n(1) $tcp3
- set sink(2) [new Agent/TCPSink]
- $ns attach-agent $n(2) $sink(2)
- $ns connect $tcp1 $sink(2)
- set sink(8) [new Agent/TCPSink]
- $ns attach-agent $n(8) $sink(8)
- $ns connect $tcp2 $sink(8)
- set sink(16) [new Agent/TCPSink]
- $ns attach-agent $n(16) $sink(16)
- $ns connect $tcp3 $sink(16)
- $tcp1 set fid_ 1
- $tcp2 set fid_ 2
- $tcp3 set fid_ 3
- set ftp(1) [new Application/FTP]
- $ftp(1) attach-agent $tcp1
- $ftp(1) set type_ FTP
- set ftp(2) [new Application/FTP]
- $ftp(2) attach-agent $tcp2
- $ftp(2) set type_ FTP
- set ftp(3) [new Application/FTP]
- $ftp(3) attach-agent $tcp3
- $ftp(3) set type_ FTP
- $ns at 0.1 "$ftp(1) start"
- $ns at 2.1 "$ftp(2) start"
- $ns at 4.1 "$ftp(3) start"
- $ns at 2 "$ftp(1) stop"
- $ns at 4 "$ftp(2) stop"
- $ns at 6 "$ftp(3) stop"
- $ns at 7 "finish"
- $ns run