File tree Expand file tree Collapse file tree 6 files changed +192
-21
lines changed Expand file tree Collapse file tree 6 files changed +192
-21
lines changed Original file line number Diff line number Diff line change 1
- * .nam
1
+ * .nam
2
2
* .tr
Original file line number Diff line number Diff line change 1
- Repository for storing everything related to my Network Simulation 2 (NS2) experiments.
2
-
3
- ## Installation
4
- Please refer to [ Installation.md] ( Installation.md ) for installation instructions.
5
-
6
- ## Learn TCL
7
- Cheatsheet at [ cheatseet.tcl] ( learn\cheatsheet.tcl )
8
-
9
- Some useful links to learn TCL:
10
- - [ TCL Tutorial] ( https://www.tutorialspoint.com/tcl-tk/index.htm )
11
-
12
- ## Learn NS2
13
- Some useful links to learn about NS2:
14
- - [ NS2 Sample] ( https://www.educative.io/answers/ns2-simulator )
15
- - [ Youtube Playlist] ( https://youtube.com/playlist?list=PLbu9W4c-C0iChBaAUcl5Bvne4oCPTC7hO )
16
-
17
- ## Learn Basic Linux
18
- Some useful links to learn about Linux:
1
+ Repository for storing everything related to my Network Simulation 2 (NS2) experiments.
2
+
3
+ ## Installation
4
+ Please refer to [ Installation.md] ( Installation.md ) for installation instructions.
5
+
6
+ ## Learn TCL
7
+ Cheatsheet at [ cheatseet.tcl] ( learn\cheatsheet.tcl )
8
+
9
+ Some useful links to learn TCL:
10
+ - [ TCL Tutorial] ( https://www.tutorialspoint.com/tcl-tk/index.htm )
11
+
12
+ ## Learn NS2
13
+ Some useful links to learn about NS2:
14
+ - [ NS2 Sample] ( https://www.educative.io/answers/ns2-simulator )
15
+ - [ Youtube Playlist] ( https://youtube.com/playlist?list=PLbu9W4c-C0iChBaAUcl5Bvne4oCPTC7hO )
16
+
17
+ ## Learn Basic Linux
18
+ Some useful links to learn about Linux:
19
19
- [ Must Know Commands] ( https://www.hostinger.in/tutorials/linux-commands )
Original file line number Diff line number Diff line change @@ -3,8 +3,6 @@ set ns [new Simulator]
3
3
$ns color 1 blue
4
4
$ns color 2 red
5
5
6
- $ns rtproto DV
7
-
8
6
set nf [open out.nam w]
9
7
$ns namtrace-all $nf
10
8
Original file line number Diff line number Diff line change
1
+ set ns [new Simulator]
2
+ set tr [open " out.tr" w]
3
+ $ns trace-all $tr
4
+
5
+ set nf [open " out.nam" w]
6
+ $ns namtrace-all $nf
7
+
8
+ proc finish {} {
9
+ global ns nf tr
10
+ $ns flush-trace
11
+ close $nf
12
+ close $tr
13
+ exec nam out.nam &
14
+ exit 0
15
+ }
16
+ set sender [$ns node]
17
+ set reciever [$ns node]
18
+
19
+ $ns duplex-link $sender $reciever 1Mb 10ms DropTail
20
+
21
+ set udp [new Agent/UDP]
22
+ set null0 [new Agent/Null]
23
+
24
+ $ns attach-agent $sender $udp
25
+ $ns attach-agent $reciever $null0
26
+
27
+ $ns connect $udp $null0
28
+
29
+ set cbr [new Application/Traffic/CBR]
30
+
31
+ $cbr attach-agent $udp
32
+
33
+ $ns at 0.5 " $cbr start"
34
+ $ns at 4.5 " $cbr stop"
35
+ $ns at 5.0 " finish"
36
+
37
+ $ns run
38
+
39
+
Original file line number Diff line number Diff line change
1
+ set ns [new Simulator]
2
+
3
+ $ns color 1 blue
4
+ $ns color 2 red
5
+
6
+ $ns rtproto DV
7
+
8
+ set nf [open out.nam w]
9
+ $ns namtrace-all $nf
10
+
11
+ proc finish {} {
12
+ global ns nf
13
+ $ns flush-trace
14
+ close $nf
15
+ exec nam out.nam
16
+ exit 0
17
+ }
18
+
19
+ # creating Nodes
20
+ for {set i 0} {$i <6} {incr i} {
21
+ set n($i ) [$ns node]
22
+ }
23
+
24
+ $ns duplex-link $n(0) $n(2) 2Mb 10ms DropTail
25
+ $ns duplex-link $n(1) $n(2) 2Mb 10ms DropTail
26
+ $ns simplex-link $n(2) $n(3) 0.3Mb 100ms DropTail
27
+ $ns simplex-link $n(3) $n(2) 0.3Mb 100ms DropTail
28
+ $ns duplex-link $n(3) $n(4) 0.5Mb 40ms DropTail
29
+ $ns duplex-link $n(3) $n(5) 0.5Mb 30ms DropTail
30
+ # Set Queue Size of link (n(2)-n3) to 10
31
+
32
+ $ns queue-limit $n(2) $n(3) 10
33
+ # Setup a TCP connection
34
+
35
+ set tcp [new Agent/TCP/Newreno]
36
+ $ns attach-agent $n(0) $tcp
37
+ set sink [new Agent/TCPSink/DelAck]
38
+ $ns attach-agent $n(4) $sink
39
+ $ns connect $tcp $sink
40
+ $tcp set fid_ 1
41
+ $tcp set window_ 8000
42
+ $tcp set packetSize_ 552
43
+
44
+ # Setup a FTP over TCP connection
45
+ set ftp [new Application/FTP]
46
+ $ftp attach-agent $tcp
47
+ $ftp set type_ FTP
48
+ # Setup a UDP connection
49
+
50
+ set udp [new Agent/UDP]
51
+ $ns attach-agent $n(1) $udp
52
+ set null [new Agent/Null]
53
+ $ns attach-agent $n(5) $null
54
+ $ns connect $udp $null
55
+ $udp set fid_ 2
56
+
57
+ # Setup a CBR over UDP connection
58
+
59
+ set cbr [new Application/Traffic/CBR]
60
+ $cbr attach-agent $udp
61
+ $cbr set type_ CBR
62
+ $cbr set packet_size_ 1000
63
+ $cbr set rate_ 0.01mb
64
+ $cbr set random_ false
65
+
66
+ $ns at 0.1 " $cbr start"
67
+ $ns at 1.0 " $ftp start"
68
+ $ns at 10.0 " $ftp stop"
69
+ $ns at 10.5 " $cbr stop"
70
+
71
+ $ns at 11.0 " finish"
72
+ $ns run
Original file line number Diff line number Diff line change
1
+ set ns [new Simulator]
2
+
3
+ set nf [open out.nam w]
4
+ $ns namtrace-all $nf
5
+
6
+ proc finish {} {
7
+ global ns nf
8
+ $ns flush-trace
9
+ close $nf
10
+ exec nam out.nam
11
+ exit 0
12
+ }
13
+
14
+ # creating Nodes
15
+ for {set i 0} {$i <4} {incr i} {
16
+ set n($i ) [$ns node]
17
+ }
18
+
19
+ $ns duplex-link $n(1) $n(2) 0.3Mb 100ms DropTail
20
+
21
+ $ns duplex-link $n(0) $n(2) 0.5Mb 40ms DropTail ;# simplex
22
+ $ns duplex-link $n(2) $n(3) 2Mb 10ms DropTail
23
+
24
+ # Set Queue Size of link (n(2)-n3) to 40
25
+ $ns queue-limit $n(2) $n(3) 40
26
+
27
+ set tcp [new Agent/TCP/Newreno]
28
+ $ns attach-agent $n(0) $tcp
29
+ set sink [new Agent/TCPSink/DelAck]
30
+ $ns attach-agent $n(2) $sink
31
+ $ns connect $tcp $sink
32
+ $tcp set window_ 8000
33
+ $tcp set fid_ 1
34
+ $tcp set packetSize_ 512
35
+
36
+ # Setup a FTP over TCP connection
37
+ set ftp [new Application/FTP]
38
+ $ftp attach-agent $tcp
39
+ $ftp set type_ FTP
40
+
41
+ # Setup a UDP connection
42
+ set udp [new Agent/UDP]
43
+ $ns attach-agent $n(1) $udp
44
+ set null [new Agent/Null]
45
+ $ns attach-agent $n(3) $null
46
+ $ns connect $udp $null
47
+ $udp set fid_ 2
48
+
49
+ # Setup a CBR over UDP connection
50
+ set cbr [new Application/Traffic/CBR]
51
+ $cbr attach-agent $udp
52
+ $cbr set type_ CBR
53
+ $cbr set packet_size_ 1000
54
+ # Setup a FTP over
55
+
56
+ $ns at 0.1 " $cbr start"
57
+ $ns at 1.0 " $ftp start"
58
+ $ns at 10.0 " $ftp stop"
59
+ $ns at 10.5 " $cbr stop"
60
+
61
+ $ns at 11.0 " finish"
62
+ $ns run
You can’t perform that action at this time.
0 commit comments