-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexp3.tcl
72 lines (58 loc) · 1.55 KB
/
exp3.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
set ns [new Simulator]
$ns color 1 blue
$ns color 2 red
$ns rtproto DV
set nf [open out.nam w]
$ns namtrace-all $nf
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exec nam out.nam
exit 0
}
#creating Nodes
for {set i 0} {$i<6} {incr i} {
set n($i) [$ns node]
}
$ns duplex-link $n(0) $n(2) 2Mb 10ms DropTail
$ns duplex-link $n(1) $n(2) 2Mb 10ms DropTail
$ns simplex-link $n(2) $n(3) 0.3Mb 100ms DropTail
$ns simplex-link $n(3) $n(2) 0.3Mb 100ms DropTail
$ns duplex-link $n(3) $n(4) 0.5Mb 40ms DropTail
$ns duplex-link $n(3) $n(5) 0.5Mb 30ms DropTail
#Set Queue Size of link (n(2)-n3) to 10
$ns queue-limit $n(2) $n(3) 10
#Setup a TCP connection
set tcp [new Agent/TCP/Newreno]
$ns attach-agent $n(0) $tcp
set sink [new Agent/TCPSink/DelAck]
$ns attach-agent $n(4) $sink
$ns connect $tcp $sink
$tcp set fid_ 1
$tcp set window_ 8000
$tcp set packetSize_ 552
#Setup a FTP over TCP connection
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set type_ FTP
#Setup a UDP connection
set udp [new Agent/UDP]
$ns attach-agent $n(1) $udp
set null [new Agent/Null]
$ns attach-agent $n(5) $null
$ns connect $udp $null
$udp set fid_ 2
#Setup a CBR over UDP connection
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set type_ CBR
$cbr set packet_size_ 1000
$cbr set rate_ 0.01mb
$cbr set random_ false
$ns at 0.1 "$cbr start"
$ns at 1.0 "$ftp start"
$ns at 10.0 "$ftp stop"
$ns at 10.5 "$cbr stop"
$ns at 11.0 "finish"
$ns run