How to Start Dual Ring Topology Projects Using NS2

To start replicating a Dual Ring Topology in NS2 (Network Simulator 2), it has encompasses to make a network in which nodes are linked in two concentric rings, one primary and one secondary (backup). This topology is normally utilized within networks, which need fault tolerance and high availability like metropolitan area networks (MANs) and high-speed backbones.

Below is a structured outline to start Dual Ring Topology project using NS2:

Steps to Simulate Dual Ring Topology in NS2

  1. Understand Dual Ring Topology
  • Structure:
    • Nodes are organized in two rings; one is primary ring which is frequently utilised for typical interaction and another one is secondary ring supports for redundancy.
    • Traffic can change to the secondary ring if failure occurs in the primary ring.
  • Applications:
    • High-speed metropolitan area networks (MANs).
    • Resilient packet rings (RPR).
    • Fault-tolerant networks.
  1. Set Up NS2
  1. Install NS2: We can set up NS2 on the system properly using below command line.

sudo apt-get install ns2

  1. Verify Installation: Confirm installation including a basic example simulation script:

ns example.tcl

  1. Define Dual Ring Topology
  • In Dual Ring Topology, we make nodes and then link them within two unidirectional rings (primary and secondary ring).
  • Execute the fault-tolerant approaches, during a failure to modify the traffic among rings.
  1. TCL Script for Dual Ring Topology

Here’s an instance of TCL script for replicating a Dual Ring Topology:

TCL Script Example

# Initialize NS2 Simulator

set ns [new Simulator]

set tracefile [open dual_ring_topology.tr w]

$ns trace-all $tracefile

# Define number of nodes in the dual ring

set num_nodes 5

# Create nodes

for {set i 0} {$i < $num_nodes} {incr i} {

set n($i) [$ns node]

}

# Create primary ring (unidirectional)

for {set i 0} {$i < $num_nodes} {incr i} {

set next [expr ($i + 1) % $num_nodes]

$ns simplex-link $n($i) $n($next) 1Gb 5ms DropTail

}

# Create secondary ring (reverse unidirectional)

for {set i 0} {$i < $num_nodes} {incr i} {

set prev [expr ($i – 1 + $num_nodes) % $num_nodes]

$ns simplex-link $n($i) $n($prev) 1Gb 5ms DropTail

}

# Attach agents for traffic simulation

# Example: Traffic from Node 0 to Node 3 via primary ring

set tcp0 [new Agent/TCP]

$ns attach-agent $n(0) $tcp0

set sink0 [new Agent/TCPSink]

$ns attach-agent $n(3) $sink0

$ns connect $tcp0 $sink0

# Add a traffic generator

set ftp [new Application/FTP]

$ftp attach-agent $tcp0

# Start traffic

$ns at 1.0 “$ftp start”

# End simulation

$ns at 5.0 “finish”

proc finish {} {

global ns tracefile

$ns flush-trace

close $tracefile

exit 0

}

$ns run

  1. Key Features to Simulate
  1. Fault Tolerance:
    • We need to execute the approaches for changing the traffic into the secondary ring if failure occurs in the primary ring.
  2. Performance Metrics:
    • Throughput: Assess the rate of data delivery through the primary and secondary rings.
    • Latency: Examine delays for traffic transmitted via diverse routes.
    • Packet Loss: During failover scenarios, we can measure the reliability.
  1. Enhancing Fault Tolerance

To replicate the fault tolerance for enhancement:

  1. Switch Traffic to Secondary Ring:
    • Describe a function to switch traffic if failure link is occur.

proc switch_to_secondary {src dst packet} {

global ns

# Logic to reroute traffic via the secondary ring

reroute $packet $src $dst

}

  1. Simulate Link Failures:
    • During the simulation, detach a link to utilise reset-links.

$ns at 2.5 “$ns reset-links $n(1) $n(2)”

  1. Analyze the Trace File
  • Make use of the trace file as dual_ring_topology.tr for in-depth analysis.
  • Obtain certain performance parameters such as:
    • Throughput:

grep “tcp” dual_ring_topology.tr > throughput.log

    • Dropped Packets:

grep “drop” dual_ring_topology.tr > dropped_packets.log

  1. Visualize Results

We want to examine the outcomes with the support of Gnuplot or another graphing tool:

  1. Throughput Graph:

set title “Dual Ring Throughput”

plot “throughput.log” using 1:2 with lines title “Throughput”

  1. Latency Graph:
    • Before and after failover, envision the duration to the secondary ring.
  1. Extend the Simulation
  2. Dynamic Traffic Patterns
  • Integrate the simultaneous traffic flows among diverse nodes:

set tcp1 [new Agent/TCP]

$ns attach-agent $n(2) $tcp1

set sink1 [new Agent/TCPSink]

$ns attach-agent $n(4) $sink1

$ns connect $tcp1 $sink1

  1. Simulate Node Failures
  • We should replicate a node failure and then monitor the influence over both rings:

$ns at 3.0 “$ns reset-links $n(2)”

  1. Experiment with Protocols
  • Substitute TCP with UDP protocols and also we can equate the performance:

set udp [new Agent/UDP]

$ns attach-agent $n(0) $udp

set null [new Agent/Null]

$ns attach-agent $n(3) $null

$ns connect $udp $null

  1. Modify NS2 Core for Advanced Features
  1. Dynamic Path Switching:
    • We will execute the dynamic failover approaches within the core recv() mechanisms.
  2. Custom Link Behavior:
    • We want to alter link behavior to give precedence specific traffic models in the course of failover scenarios.

From the demonstration we completely aggregate the information about the simulation procedure for replicating and analysing the Dual Ring Topology projects and we see how it evaluate the outcomes that were deploy in the tool of NS2 environment. Any doubts regarding this subject will be explained in an additional guide.