+91 94 448 29 228 --- E-Mail ID:networksimulators2@gmail.com

Ns2 Multicast Projects

What is multicasting?

  • Multicast is communication between a single sender and multiple receivers on a network
  • Multicasting is similar to broadcasting, but only transmits information to specific users. It is used to efficiently transmit streaming media and other types of data to multiple users at one time.


Applications of Ns2 Multicasting Projects

  •  Streaming multimedia over internet like live TV and internet radio.
  • Video conferencing and webcasts.
  • Stock quotes.
  • Digital copies of software
  • News.

Advantages of Ns2 Multicasting Projects

  • Reduce internet bandwidth usage.
  • It will increases the productivity.
  • Use group address.
  • Can be used across a WAN.
  • Datagram received only by the interfaces that want it.
  • Messages are UDP so there is no connection setup or teardown.

Sample NS2 code for Multicasting Projects

set ns [new Simulator]
$ns multicast
set f [open out.tr w]
$ns trace-all $f
$ns namtrace-all [open out.nam w]
# allocate a multicast address;
set group [Node allocaddr]                   
# nod is the number of nodes
set nod 6                          
# create multicast capable nodes;
for {set i 1} {$i <= $nod} {incr i} {
   set n($i) [$ns node]                      
#Create links between the nodes
$ns duplex-link $n(1) $n(2) 0.3Mb 10ms DropTail 
$ns duplex-link $n(2) $n(3) 0.3Mb 10ms DropTail
$ns duplex-link $n(2) $n(4) 0.5Mb 10ms DropTail
$ns duplex-link $n(2) $n(5) 0.3Mb 10ms DropTail
# configure multicast protocol;
DM set CacheMissMode dvmrp
set mproto DM                                
# all nodes will contain multicast protocol agents;
set mrthandle [$ns mrtproto $mproto]         
set udp1 [new Agent/UDP]                     
set udp2 [new Agent/UDP]                    
$ns attach-agent $n(1) $udp1
$ns attach-agent $n(2) $udp2
set src1 [new Application/Traffic/CBR]
$src1 attach-agent $udp1
$udp1 set dst_addr_ $group
$udp1 set dst_port_ 0
$src1 set random_ false
set src2 [new Application/Traffic/CBR]
$src2 attach-agent $udp2
$udp2 set dst_addr_ $group
$udp2 set dst_port_ 1
$src2 set random_ false
# create receiver agents
set rcvr [new Agent/LossMonitor]      
# joining and leaving the group;
$ns at 0.6 "$n(3) join-group $rcvr $group"
$ns at 1.3 "$n(4) join-group $rcvr $group"
$ns at 1.6 "$n(5) join-group $rcvr $group"
$ns at 1.9 "$n(4) leave-group $rcvr $group"
$ns at 2.3 "$n(6) join-group $rcvr $group"
$ns at 3.5 "$n(3) leave-group $rcvr $group"
$ns at 0.4 "$src1 start"
$ns at 2.0 "$src2 start"
$ns at 4.0 "finish"
proc finish {} {
        global ns
        $ns flush-trace
        exec nam out.nam &
        exit 0
$ns run

NS2 Member Accounts | |
© 2005 - 2020 Vanet Projects

© 2005 - 2020 Matlab Projects