-
Notifications
You must be signed in to change notification settings - Fork 0
/
bus_tcp.tcl
59 lines (41 loc) · 981 Bytes
/
bus_tcp.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
#Creating Simulator
set ns [new Simulator]
# Network Animation
set nf [open t1.nam w]
$ns namtrace-all $nf
set nf1 [open t1.tr w]
$ns trace-all $nf1
#Creating nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
#Creating links between nodes
$ns duplex-link $n0 $n1 20Mb 10ms DropTail
$ns duplex-link $n1 $n2 20Mb 10ms DropTail
$ns duplex-link $n2 $n3 20Mb 10ms DropTail
$ns duplex-link $n3 $n4 20Mb 10ms DropTail
#Creation of Protocols
set tcp [new Agent/TCP]
$ns attach-agent $n0 $tcp
#Traffic Generation Initialize
set ftp [new Application/FTP]
$ftp attach-agent $tcp
#Setting Destination point
set null1 [new Agent/TCPSink]
$ns attach-agent $n3 $null1
#Connection of Protocol and Destination point
$ns connect $tcp $null1
#Finish Procedure
proc finish {} {
global ns nf null1 nf1
$ns flush-trace
close $nf
exec nam t1.nam &
exit 0
}
$ns at 0.1 "$ftp start"
$ns at 19.0 "$ftp stop"
$ns at 20.0 "finish"
$ns run