Aim:
To
write a ns2 program for implementing multicasting routing protocol.
Algorithm:
Step
1: start the program.
Step
2: declare the global variables ns for creating a new simulator.
Step
3: set the color for packets.
Step
4: open the network animator file in the name of file2 in the write
mode.
Step
5: open the trace file in the name of file 1 in the write mode.
Step
6: set the multicast routing protocol to transfer the packets in
network.
Step
7: create the multicast capable no of nodes.
Step
8: create the duplex-link between the nodes including the delay
time,bandwidth and dropping
. queue mechanism.
Step
9: give the position for the links between the nodes.
Step
10: set a udp connection for source node.
Step
11: set the destination node ,port and random false for the source
and destination files.
Step
12: setup a traffic generator CBR for the source and destination
files.
Step
13: down the connection between any nodes at a particular time.
Step
14: create the receive agent for joining and leaving if the nodes in
the group.
Step
15: define the finish procedure.
Step
16: in the definition of the finish procedure declare the global
variables.
Step
17: close the trace file and namefile and execute the network
animation file.
Step
18: at the particular time call the finish procedure.
Step
19: stop the program.
Program:
#
Create scheduler
#Create
an event scheduler wit multicast turned on
set
ns [new Simulator -multicast on]
#$ns
multicast
#Turn
on Tracing
set
tf [open output.tr w]
$ns
trace-all $tf
#
Turn on nam Tracing
set
fd [open mcast.nam w]
$ns
namtrace-all $fd
#
Create nodes
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]