How to Start Dual Ring Topology Projects Using NS3
To start Dual Ring Topology using NS3 that associates the nodes within two concentric rings to offer fault tolerance and redundancy. This topology is generally utilized within high-reliability networks such as FDDI (Fiber Distributed Data Interface) or SONET/SDH.
While NS3 environment doesn’t support built-in dual-ring functionality, permits to execute it to utilize custom logic and point-to-point links designing the primary and secondary rings, we follow these instructions.
Steps to Start Dual Ring Topology Project in NS3
Step 1: Set Up NS3
- Install NS3:
- Go to NS3 webpage to download NS3 environment.
- We adhere to the installation guidance.
- Verify Installation: Make sure a simple script to confirm NS3 is configured properly:
./waf –run scratch/my_first
Step 2: Understand Dual Ring Topology
- Dual Ring Characteristics:
- It has two rings one is primary ring and another one is secondary or backup ring.
- Data emerges clockwise within the primary ring anticlockwise within the secondary ring.
- Backup ring is utilized lest of a failure within the primary ring.
Step 3: Plan the Topology
- Define the number of nodes:
- For instance, we can define the number of nodes that contain 6 nodes associated within two rings.
- Set simulation goals:
- We replicate data flow within both primary and secondary rings.
- To execute the fault tolerance and failover among the rings.
Step 4: Set Up the Physical Dual Ring Topology
- Create Nodes: In the dual ring, we describe the nodes.
NodeContainer nodes;
uint32_t numNodes = 6;
nodes.Create(numNodes);
- Set Up Point-to-Point Links: Make links for both the primary and secondary rings.
PointToPointHelper p2p;
p2p.SetDeviceAttribute(“DataRate”, StringValue(“10Mbps”));
p2p.SetChannelAttribute(“Delay”, StringValue(“2ms”));
NetDeviceContainer primaryDevices, secondaryDevices;
for (uint32_t i = 0; i < numNodes; ++i) {
// Primary ring (clockwise)
NetDeviceContainer primaryLink = p2p.Install(nodes.Get(i), nodes.Get((i + 1) % numNodes));
primaryDevices.Add(primaryLink);
// Secondary ring (counterclockwise)
NetDeviceContainer secondaryLink = p2p.Install(nodes.Get((i + 1) % numNodes), nodes.Get(i));
secondaryDevices.Add(secondaryLink);
}
- Install Internet Stack: We need to insert the Internet stack to every node.
InternetStackHelper stack;
stack.Install(nodes);
Ipv4AddressHelper address;
address.SetBase(“10.1.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer primaryInterfaces = address.Assign(primaryDevices);
address.SetBase(“10.2.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer secondaryInterfaces = address.Assign(secondaryDevices);
Step 5: Simulate Traffic
- Install Applications: Replicate the data flow within primary ring in typical conditions and failover to the secondary ring lest of failure.
- UDP Echo Server:
UdpEchoServerHelper echoServer(9); // Port 9
ApplicationContainer serverApp = echoServer.Install(nodes.Get(0)); // Server on Node 0
serverApp.Start(Seconds(1.0));
serverApp.Stop(Seconds(10.0));
-
- UDP Echo Client:
UdpEchoClientHelper echoClient(primaryInterfaces.GetAddress(0), 9); // Server’s IP
echoClient.SetAttribute(“MaxPackets”, UintegerValue(10));
echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0)));
echoClient.SetAttribute(“PacketSize”, UintegerValue(1024));
ApplicationContainer clientApp = echoClient.Install(nodes.Get(3)); // Client on Node 3
clientApp.Start(Seconds(2.0));
clientApp.Stop(Seconds(10.0));
Step 6: Implement Fault Tolerance
- Simulate Link Failure: In the primary ring, inactivate a link to impose data flow across the secondary ring.
Simulator::Schedule(Seconds(5.0), &NetDevice::SetAttribute, primaryDevices.Get(2), “DataRate”, StringValue(“0Mbps”));
NS_LOG_UNCOND(“Primary ring link failure simulated at 5 seconds.”);
- Implement Failover Logic: Switch traffic dynamically across the secondary ring to utilize routing protocols like OSPF or AODV.
Step 7: Run and Analyze
- Run the Simulation:
Simulator::Run();
Simulator::Destroy();
- Enable Packet Capture: We can store .pcap files for analysis.
p2p.EnablePcapAll(“dual_ring_topology”);
- Trace Logs: Allow logging to monitor the data flow and behavior of the failover:
export NS_LOG=”UdpEchoClientApplication=level_all|prefix_func”
./waf –run scratch/dual_ring_topology
Example: Minimal NS3 Script for Dual Ring Topology
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/internet-module.h”
#include “ns3/point-to-point-module.h”
#include “ns3/applications-module.h”
using namespace ns3;
int main(int argc, char *argv[]) {
uint32_t numNodes = 6;
// Create nodes
NodeContainer nodes;
nodes.Create(numNodes);
// Set up Point-to-Point links for primary and secondary rings
PointToPointHelper p2p;
p2p.SetDeviceAttribute(“DataRate”, StringValue(“10Mbps”));
p2p.SetChannelAttribute(“Delay”, StringValue(“2ms”));
NetDeviceContainer primaryDevices, secondaryDevices;
for (uint32_t i = 0; i < numNodes; ++i) {
// Primary ring (clockwise)
NetDeviceContainer primaryLink = p2p.Install(nodes.Get(i), nodes.Get((i + 1) % numNodes));
primaryDevices.Add(primaryLink);
// Secondary ring (counterclockwise)
NetDeviceContainer secondaryLink = p2p.Install(nodes.Get((i + 1) % numNodes), nodes.Get(i));
secondaryDevices.Add(secondaryLink);
}
// Install Internet stack
InternetStackHelper stack;
stack.Install(nodes);
// Assign IP addresses
Ipv4AddressHelper address;
address.SetBase(“10.1.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer primaryInterfaces = address.Assign(primaryDevices);
address.SetBase(“10.2.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer secondaryInterfaces = address.Assign(secondaryDevices);
// Set up UDP echo server
UdpEchoServerHelper echoServer(9);
ApplicationContainer serverApp = echoServer.Install(nodes.Get(0));
serverApp.Start(Seconds(1.0));
serverApp.Stop(Seconds(10.0));
// Set up UDP echo client
UdpEchoClientHelper echoClient(primaryInterfaces.GetAddress(0), 9);
echoClient.SetAttribute(“MaxPackets”, UintegerValue(10));
echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0)));
echoClient.SetAttribute(“PacketSize”, UintegerValue(1024));
ApplicationContainer clientApp = echoClient.Install(nodes.Get(3));
clientApp.Start(Seconds(2.0));
clientApp.Stop(Seconds(10.0));
// Simulate link failure in the primary ring at 5 seconds
Simulator::Schedule(Seconds(5.0), &NetDevice::SetAttribute, primaryDevices.Get(2), “DataRate”, StringValue(“0Mbps”));
NS_LOG_UNCOND(“Primary ring link failure simulated at 5 seconds.”);
// Enable packet capture
p2p.EnablePcapAll(“dual_ring_topology”);
// Run simulation
Simulator::Run();
Simulator::Destroy();
return 0;
}
Step 8: Enhance the Simulation
- Dynamic Routing:
- For automatic failover, we can utilize protocols such as OSPF or AODV.
- Analyze Performance:
- We need to estimate the performance metrics like throughput, latency, and packet loss in the course of failover.
- Simulate Multiple Failures:
- Launch several link or node failures to experiment the network resilience.
- Visualize:
- Monitor primary and secondary ring activity to utilize NetAnim tool.
We illustrated the core concepts, procedure with example coding for Dual Ring Topology projects that were simulated, analysed, and visualized using NS3 tools. Additional specifics regarding this project will be included.
We specialize in high-reliability networks, including FDDI (Fiber Distributed Data Interface) and SONET/SDH, and we also assist you in achieving optimal end-to-end performance. Please provide us with the details of your Dual Ring Topology project, and we will offer you customized research support.