To simulate Dual Ring Topology in ns2 has needs to follow numerous steps and it is an expansion of the Ring Topology in which two rings are usually a one primary and one secondary happen for redundancy. The primary ring manages normal data traffic, and the secondary ring performs as a backup in circumstance of failure under the primary ring. This topology is frequently employed in networks that need high fault tolerance and reliability, like Fibber Distributed Data Interface (FDDI) networks.
To replicate a Dual Ring Topology in NS2, we need to configure two ring networks in which nodes are associated in two loops, and apply the control over which ring is utilized for communication.
Here’s how to simulate a Dual Ring Topology project using NS2:
Steps to Simulate Dual Ring Topology Projects in NS2
- Set up NS2 Environment:
Make sure that NS2 is installed and working correctly. While NS2 doesn’t directly support dual ring protocols such as FDDI, we can physically generate the primary and secondary rings, and switch among them according to the conditions (for instance, using the secondary ring when the primary ring is “down”).
- Understanding Dual Ring Topology:
- Primary Ring: The main ring in which the normal communication takes place.
- Secondary Ring: The backup ring which can take over communication in instance of the primary ring miscarries.
- In this replication, we will regulate the flow of data over both rings, replicates a failover mechanism.
- Create a TCL Script for Dual Ring Topology:
The given below is a TCL script to mimic a Dual Ring Topology with 4 nodes in NS2. The nodes are associated in two rings: a primary ring and a secondary ring.
Dual Ring Topology Simulation
# 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
# ======= Dual Ring Topology =======
# Create 4 nodes for the dual ring topology
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
# ======= Primary Ring Links =======
# Create duplex links between nodes to form the primary ring
$ns duplex-link $n0 $n1 10Mb 10ms DropTail
$ns duplex-link $n1 $n2 10Mb 10ms DropTail
$ns duplex-link $n2 $n3 10Mb 10ms DropTail
$ns duplex-link $n3 $n0 10Mb 10ms DropTail ;# Close the primary ring
# ======= Secondary Ring Links =======
# Create duplex links between nodes to form the secondary ring (reverse direction)
$ns duplex-link $n0 $n3 10Mb 10ms DropTail
$ns duplex-link $n3 $n2 10Mb 10ms DropTail
$ns duplex-link $n2 $n1 10Mb 10ms DropTail
$ns duplex-link $n1 $n0 10Mb 10ms DropTail ;# Close the secondary ring
# ======= Traffic Generation =======
# Attach UDP agents to simulate communication over the rings
set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0
set udp1 [new Agent/UDP]
$ns attach-agent $n1 $udp1
# Attach Null agents (traffic sinks) for receiving packets
set null0 [new Agent/Null]
$ns attach-agent $n2 $null0
set null1 [new Agent/Null]
$ns attach-agent $n3 $null1
# ======= Primary Ring Traffic =======
# Connect the UDP agents over the primary ring
$ns connect $udp0 $null0
$ns connect $udp1 $null1
# Create CBR traffic generators and attach them to the UDP agents on the primary ring
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp0
$cbr0 set packetSize_ 512
$cbr0 set rate_ 100Kb
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
$cbr1 set packetSize_ 512
$cbr1 set rate_ 100Kb
# Schedule the CBR traffic to start on the primary ring
$ns at 1.0 “$cbr0 start”
$ns at 1.5 “$cbr1 start”
# Simulate failure of the primary ring at 3.0 seconds
$ns at 3.0 “$cbr0 stop”
$ns at 3.0 “$cbr1 stop”
# ======= Secondary Ring Traffic (Failover) =======
# Reconnect the UDP agents over the secondary ring after failure
$ns connect $udp0 $null1
$ns connect $udp1 $null0
# Schedule the CBR traffic to resume on the secondary ring after 3.5 seconds
$ns at 3.5 “$cbr0 start”
$ns at 4.0 “$cbr1 start”
# Stop the traffic at 6 seconds
$ns at 6.0 “$cbr0 stop”
$ns at 6.5 “$cbr1 stop”
# End the simulation at 7.0 seconds
$ns at 7.0 “finish”
# Procedure to end the simulation
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 (n0, n1, n2, and n3) signify the machines in the dual ring network.
- Primary Ring: Duplex links are generated among nodes in a clockwise manner to establish the primary ring.
- Secondary Ring: Duplex links are generated among nodes in a counterclockwise manner to construct the secondary ring that performs as the backup.
- Traffic Generation: UDP agents are attached to nodes to mimic traffic over the primary ring. The nodes utilize CBR (Constant Bit Rate) traffic generators to transmit packets.
- Simulated Failure: At 3.0 seconds, traffic in excess of the primary ring is terminates, then it replicates a failure in the primary ring.
- Failover to Secondary Ring: At 3.5 seconds, traffic is rerouted to the secondary ring that replicates a failover mechanism.
- Simulation End: The simulation terminates at 7.0 seconds, and the outcomes are saved in a .nam file for envisioned.
- Run the Simulation:
- Save the script as dual_ring_topology.tcl.
- Open a terminal and navigate to the folder in which the script is saved.
- Execute the simulation using:
ns dual_ring_topology.tcl
- The replication will create an out.nam file that can be opened using Network Animator (NAM) for visualization.
- Visualization in NAM:
- Open the out.nam file in NAM to envision the dual ring topology. We will see the four nodes associated in two rings, with traffic flowing over the primary ring primarily, and then switching to the secondary ring after the simulated failure.
- Customization and Enhancements:
- Increase the Number of Nodes: we can incorporate additional nodes to the topology by generating additional nodes and associates them in both the primary and secondary rings.
- Multiple Failures: we can mimic multiple failures in both rings by terminating the traffic on certain links and rerouting to other links.
- TCP Traffic: Interchange the UDP agents with TCP agents to mimic reliable communication:
set tcp0 [new Agent/TCP]
$ns attach-agent $n0 $tcp0
set sink0 [new Agent/TCPSink]
$ns attach-agent $n2 $sink0
$ns connect $tcp0 $sink0
- Performance Metrics: we can incorporate trace files to evaluate parameters like throughput, delay, and packet loss:
set tracefile [open trace.tr w]
$ns trace-all $tracefile
- Performance Analysis:
To evaluate the performance of the dual ring topology, we can:
- Measure throughput to control how much data is accomplished successfully over both the primary and secondary rings
- Evaluate latency to see the latency established in the course of the failover from the primary ring to the secondary ring.
- In the period of the failover environment we need to measure the reliability of network for assess the packet loss.
With this configuration, we can exhaustively make you understand the implementation steps of offered example regarding Dual Ring Topology using ns2 simulator tools. For further queries regarding this manual, we will resolve it over another manual.
Fibber Distributed Data Interface (FDDI) networks are managed by our team. For optimal results, stay connected with us! At phdprime.com, we can help you simulate Dual Ring Topology Projects using the NS2 tool. If you’re looking for excellent research guidance and simulation support, our experts are here to assist you.