Skip to content

Commit af481ba

Browse files
Add files via upload
This is the program for study of Network Simulator using NS2.
1 parent ea069ce commit af481ba

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Study_Network_Simulator_using_NS2.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
set ns [new Simulator]
2+
set nf [open out.nam w]
3+
$ns namtrace-all $nf
4+
proc finish {} {
5+
global ns nf
6+
$ns flush-trace
7+
#Close the trace file
8+
close $nf
9+
#Execute nam on the trace file
10+
exec nam out.nam &
11+
exit 0
12+
}
13+
set n0 [$ns node]
14+
set n1 [$ns node]
15+
$ns duplex-link $n0 $n1 1Mb 10ms DropTail
16+
set udp0 [new Agent/UDP]
17+
$ns attach-agent $n0 $udp0
18+
set cbr0 [new Application/Traffic/CBR]
19+
$cbr0 set packetSize_ 500
20+
$cbr0 set interval_ 0.005
21+
$cbr0 attach-agent $udp0
22+
set null0 [new Agent/Null]
23+
$ns attach-agent $n1 $null0
24+
$ns connect $udp0 $null0
25+
$ns at 0.5 "$cbr0 start"
26+
$ns at 4.5 "$cbr0 stop"
27+
$ns at 5.0 "finish"
28+
$ns run

0 commit comments

Comments
 (0)