How to Start Circular Topology Projects Using NS3
To start Circular Topology in NS3 that intercepts the nodes within a loop where each node is associated to two neighbouring nodes. For learning the ring-based networks, resilience, and fault tolerance, this topology is very helpful.
Steps to Start Circular Topology Project in NS3
Step 1: Set Up NS3
- Install NS3:
- We go to NS3 website to download and install NS3.
- We adhere to the installation guidance.
- Verify Installation: Confirm the NS3 including a simple script:
./waf –run scratch/my_first
Step 2: Understand Circular Topology
- Circular Topology:
- Nodes are organized within a ring, and every single node is natively linked to their neighbouring nodes.
- This topology is helpful within distributed networks and token-ring systems.
Step 3: Plan the Topology
- Decide the number of nodes:
- Instance: In circular topology we make 5 nodes.
- Set simulation goals:
- To replicate the traffic through nodes.
- We estimate the performance parameters such as delay, throughput, and packet loss.
Step 4: Set Up the Circular Topology
- Create Nodes: In the network, we make nodes.
NodeContainer nodes;
uint32_t numNodes = 5; // Number of nodes in the ring
nodes.Create(numNodes);
- Set Up Point-to-Point Links: Describe link properties to utilize PointToPointHelper.
PointToPointHelper p2p;
p2p.SetDeviceAttribute(“DataRate”, StringValue(“10Mbps”));
p2p.SetChannelAttribute(“Delay”, StringValue(“2ms”));
- Connect Nodes in a Ring: Associate each node to their nearby neighbors to contain the last node to the first node.
NetDeviceContainer devices;
for (uint32_t i = 0; i < numNodes; ++i) {
NetDeviceContainer link = p2p.Install(nodes.Get(i), nodes.Get((i + 1) % numNodes)); // Connect in a ring
devices.Add(link);
}
- Install Internet Stack: Insert the Internet stack to every node.
InternetStackHelper stack;
stack.Install(nodes);
- Assign IP Addresses: We allocate a unique IP addresses to each link.
Ipv4AddressHelper address;
for (uint32_t i = 0; i < numNodes; ++i) {
std::ostringstream subnet;
subnet << “10.1.” << i + 1 << “.0”;
address.SetBase(subnet.str().c_str(), “255.255.255.0”);
address.Assign(devices.Get(i));
}
Step 5: Set Up Applications
- Server Application: We want to locate a UDP echo server on one node.
UdpEchoServerHelper echoServer(9); // Port 9
ApplicationContainer serverApp = echoServer.Install(nodes.Get(numNodes – 1)); // Last node as server
serverApp.Start(Seconds(1.0));
serverApp.Stop(Seconds(10.0));
- Client Applications: We can install UDP echo clients on other nodes interacting with the server.
for (uint32_t i = 0; i < numNodes – 1; ++i) {
UdpEchoClientHelper echoClient(Ipv4Address(“10.1.1.1”), 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(i));
clientApp.Start(Seconds(2.0));
clientApp.Stop(Seconds(10.0));
}
Step 6: Run and Analyze
- Run the Simulation:
Simulator::Run();
Simulator::Destroy();
- Enable Packet Capture: To seize traffic for analysis utilising .pcap files.
p2p.EnablePcapAll(“circular_topology”);
- Trace Logs: Allow NS3 logging for debugging:
export NS_LOG=”UdpEchoClientApplication=level_all|prefix_func”
./waf –run scratch/circular_topology
Example: Minimal NS3 Script for Circular 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 = 5;
// Create nodes
NodeContainer nodes;
nodes.Create(numNodes);
// Set up Point-to-Point links
PointToPointHelper p2p;
p2p.SetDeviceAttribute(“DataRate”, StringValue(“10Mbps”));
p2p.SetChannelAttribute(“Delay”, StringValue(“2ms”));
// Connect nodes in a circular topology
NetDeviceContainer devices;
for (uint32_t i = 0; i < numNodes; ++i) {
NetDeviceContainer link = p2p.Install(nodes.Get(i), nodes.Get((i + 1) % numNodes));
devices.Add(link);
}
// Install Internet stack
InternetStackHelper stack;
stack.Install(nodes);
// Assign IP addresses
Ipv4AddressHelper address;
for (uint32_t i = 0; i < numNodes; ++i) {
std::ostringstream subnet;
subnet << “10.1.” << i + 1 << “.0”;
address.SetBase(subnet.str().c_str(), “255.255.255.0”);
address.Assign(devices.Get(i));
}
// Set up UDP echo server on the last node
UdpEchoServerHelper echoServer(9);
ApplicationContainer serverApp = echoServer.Install(nodes.Get(numNodes – 1));
serverApp.Start(Seconds(1.0));
serverApp.Stop(Seconds(10.0));
// Set up UDP echo clients on other nodes
for (uint32_t i = 0; i < numNodes – 1; ++i) {
UdpEchoClientHelper echoClient(Ipv4Address(“10.1.1.1”), 9);
echoClient.SetAttribute(“MaxPackets”, UintegerValue(10));
echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0)));
echoClient.SetAttribute(“PacketSize”, UintegerValue(1024));
ApplicationContainer clientApp = echoClient.Install(nodes.Get(i));
clientApp.Start(Seconds(2.0));
clientApp.Stop(Seconds(10.0));
}
// Enable packet capture
p2p.EnablePcapAll(“circular_topology”);
// Run the simulation
Simulator::Run();
Simulator::Destroy();
return 0;
}
Step 7: Compile and Run
- We can store the script as circular_topology.cc.
- Then, we compile and execute it:
./waf –run circular_topology
Step 8: Enhance the Simulation
- Experiment with Traffic Models:
- Make use of TCP rather than UDP.
- To replicate the FTP or HTTP traffic.
- Analyze Performance:
- We need to calculate the performance metrics like throughput, delay, and packet loss.
- Simulate Failures:
- Detach links or nodes to experiment the fault tolerance.
- Visualize:
- Show the circular topology and traffic flow to utilize NetAnim.
Next Steps
- Scale Up:
- We maximize the volume of nodes within the ring.
- Compare Topologies:
- We able to equate the circular topology including line, star, or mesh topologies.
- Implement Protocols:
- For data flow, experiment routing or token-passing protocols within the ring.
In this simulation, we discussed the project’s outline in sequence with sample coding for Circular Topology Projects that were simulated and examined using NS3 environment and can share more detailed information on this subject.
Please provide us with all the details of your project to receive optimal guidance. At phdprojects.org, we offer a comprehensive procedure for initiating and simulating Circular Topology using the NS3 tool. Our developers are available to assist you in enhancing your project’s performance.