-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexp1.tcl
81 lines (69 loc) · 1.98 KB
/
exp1.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
set ns [new Simulator]
set namfile [open ex_05a.nam w]
$ns namtrace-all $namfile
set tracefile [open ex_05a.tr w]
$ns trace-all $tracefile
Agent/TCP set packetSize_ 1460
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
set n6 [$ns node]
set n7 [$ns node]
$n1 color blue
$n1 shape box
$n0 color red
$ns duplex-link $n0 $n2 1Mb 10ms DropTail
$ns duplex-link-op $n0 $n2 orient right-down
$ns duplex-link $n1 $n2 1Mb 10ms DropTail
$ns duplex-link-op $n1 $n2 orient right-up
$ns duplex-link $n2 $n3 2Mb 10ms DropTail
$ns duplex-link-op $n2 $n3 orient right
$ns duplex-link $n3 $n4 1Mb 10ms DropTail
$ns duplex-link-op $n3 $n4 orient right-up
$ns duplex-link $n3 $n5 1Mb 10ms DropTail
$ns duplex-link-op $n3 $n5 orient right-down
$ns duplex-link $n4 $n6 1Mb 10ms DropTail
$ns duplex-link-op $n4 $n6 orient right
$ns duplex-link $n5 $n7 1Mb 10ms DropTail
$ns duplex-link-op $n5 $n7 orient right
set tcp [new Agent/TCP]
$ns attach-agent $n0 $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $n6 $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns color 1 Blue
$tcp set class_ 2
set udp [new Agent/UDP]
$ns attach-agent $n1 $udp
set null [new Agent/Null]
$ns attach-agent $n7 $null
$ns connect $udp $null
$udp set class_ 1
set cbr [new Application/Traffic/CBR]
$cbr set packetSize_ 500
$cbr set interval_ 0.005
$cbr attach-agent $udp
$ns at 0.0 "$cbr start"
$ns at 9.0 "$cbr stop"
set filesize [expr 4*1024*1024]
$ns at 0.0 "$ftp start"
$ns at 0.0 "$ftp set type_ FTP"
$ns at 0.0 "$ftp set data_ $filesize"
$ns at 10.0 "$ftp stop"
proc finish {} {
global ns namfile tracefile
$ns flush-trace
close $namfile
close $tracefile
exec nam ex_05a.nam &
exec xgraph -bb -tk -x Time -y Bytes ex05a.data -bg white &
exec xgraph -bb -tk -x Time -y Packets ex05a_packets.data -bg white &
exit 0
}
$ns at 100.0 "finish"
$ns run