To simulate a Point-to-Multipoint Topology within NS2 that encompasses associating a unique source node to numerous destination nodes via dedicated links. This topology is generally utilized within networks in which node (the source) communicates with various other nodes (the receivers). In the simulation platform NS2, we can replicate this configuration by connecting single node to several other nodes with the help of duplex links.
Steps to Simulate Point-to-Multipoint Topology in NS2
- Set up NS2 Environment:
Make certain NS2 is installed and functioning properly on the machine. We will make a TCL script to replicate the Point-to-Multipoint topology.
- Understanding Point-to-Multipoint Topology:
- In Point-to-Multipoint Topology, single node performs as the source (or central point), even though numerous nodes are related to it and it performs as the receivers.
- The source transmits data to several destination nodes that can receive data concurrently.
- Create a TCL Script for Point-to-Multipoint Topology:
Following is an instance of a Point-to-Multipoint Topology simulation in NS2:
# Create a new simulator instance
set ns [new Simulator]
# Open a NAM trace file for visualization
set nf [open out.nam w]
$ns namtrace-all $nf
# Create nodes
set source [$ns node] ;# Source node (point)
set dest1 [$ns node] ;# Destination node 1 (multipoint)
set dest2 [$ns node] ;# Destination node 2 (multipoint)
set dest3 [$ns node] ;# Destination node 3 (multipoint)
# Create duplex links between source and destinations
$ns duplex-link $source $dest1 10Mb 10ms DropTail
$ns duplex-link $source $dest2 10Mb 10ms DropTail
$ns duplex-link $source $dest3 10Mb 10ms DropTail
# Create a UDP agent and attach it to the source node
set udp0 [new Agent/UDP]
$ns attach-agent $source $udp0
# Create Null agents and attach them to the destination nodes
set null1 [new Agent/Null]
$ns attach-agent $dest1 $null1
set null2 [new Agent/Null]
$ns attach-agent $dest2 $null2
set null3 [new Agent/Null]
$ns attach-agent $dest3 $null3
# Connect the UDP agent to the Null agents at the destination nodes
$ns connect $udp0 $null1
$ns connect $udp0 $null2
$ns connect $udp0 $null3
# Create a CBR traffic generator and attach it to the UDP agent
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp0
$cbr0 set packetSize_ 512 ;# Packet size of 512 bytes
$cbr0 set rate_ 100Kb ;# Data rate of 100Kb
# Schedule the CBR traffic to start and stop
$ns at 1.0 “$cbr0 start” ;# Start the traffic at 1 second
$ns at 5.0 “$cbr0 stop” ;# Stop the traffic at 5 seconds
# End the simulation at 6 seconds
$ns at 6.0 “finish”
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exec nam out.nam &
exit 0
}
# Run the simulation
$ns run
- Explanation of the Code:
- Nodes: Four nodes are made they are one source (source) and three destination nodes (dest1, dest2, dest3). The source is the unique node, which transmits data, even though the destinations obtain data.
- Links: Duplex links are ascertained among the source and each destination node, including a bandwidth of 10Mb and a delay of 10ms.
- UDP Traffic: A UDP agent is connected to the source node and the null agents (data sinks) are associated to each of the destination nodes to obtain the traffic.
- Traffic Generator (CBR): A Constant Bit Rate (CBR) traffic generator is connected to the UDP agent at the source node that making packets of 512 bytes at a rate of 100Kb.
- Scheduling Traffic: Traffic is scheduled to begin at 1 second and end at 5 seconds.
- Simulation End: The simulation stops after 6 seconds, then for visualization the outcomes are saved within a NAM file.
- Run the Simulation:
- We want to save the script as point_to_multipoint.tcl.
- Open a terminal and traverse to the directory in which the script is saved.
- We can execute the simulation using the below command:
ns point_to_multipoint.tcl
- The outcome will generate an out.nam file, which we can envision utilizing the NAM tool.
- Visualization in NAM:
- After running the simulation then we can open the out.nam file within Network Animator (NAM) to envision the Point-to-Multipoint topology. We should monitor a single source node transmitting the data to several destination nodes across direct links.
- Customization and Enhancements:
- TCP Traffic: We can substitute the UDP agent with a TCP agent to replicate additional reliable connection. Instance for TCP:
set tcp0 [new Agent/TCP]
$ns attach-agent $source $tcp0
set sink1 [new Agent/TCPSink]
$ns attach-agent $dest1 $sink1
$ns connect $tcp0 $sink1
- Different Bandwidth and Delay: We can test with diverse link metrics by modifying the bandwidth or delay in the duplex-link configuration.
- Multiple Traffic Flows: We can make several traffic generators to replicate distinct flows among the source and each destination.
- Performance Analysis: We can insert tracing to examine the performance parameters like packet loss, delay, and throughput by utilizing trace files:
set tracefile [open trace.tr w]
$ns trace-all $tracefile
- Performance Metrics:
To examine the performance of the Point-to-Multipoint topology, we can:
- Assess throughput by verifying how much data is effectively sent to every single destination.
- Estimate delay by computing the time taken for packets to attain the destination nodes.
- Investigate packet loss by calculating the amount of packets, which fail to attain their destination.
Through this manual, we successfully focused and learned about Point to Multipoint Topology project’s simulation strategy that includes more insights with examples, which were simulated and analysed its performance using NS2 tool. If you have any requirement regarding this project, we will be provided it too. To simulate point-to-multipoint topology projects using NS2, phdprime.com will provide top-notch simulation results along with excellent topic ideas in this area.