How to Start Extended Star Topology Projects Using NS3
To start an Extended Star Topology using NS3 environment that has a central node like a hub or router, which are associated to the several kinds of peripheral nodes in which every single peripheral node also can be performed like a central node for more nodes. This topology needs to makes a hierarchical star topology.
We will instruct you on how to start and replicate an Extended Star Topology in NS3:
Steps to Start an Extended Star Topology Project in NS3
Step 1: Set Up NS3
- Install NS3:
- Go to NS3 webpage to download NS3 on the computer.
- We stick to the installation steps.
- Verify Installation: We can confirm NS3 installed properly including a simple script:
./waf –run scratch/my_first
Step 2: Understand Extended Star Topology
- Extended Star Topology:
- In extended start topology, central node interacts to numerous peripheral nodes.
- To make hierarchical levels, every single peripheral node can work like the center of their individual star topology.
Step 3: Plan the Topology
- Define the structure:
- For instance, we can define the topology structure that contains one central node, 3 peripheral nodes, and each peripheral node associated to 2 more nodes.
- Set goals:
- We need to replicate the data flow among nodes.
- Then, we estimate the performance indicators such as delay, throughput, and packet loss in extended star topology.
Step 4: Set Up the Extended Star Topology
- Create Nodes: We should describe the nodes for the central hub, peripheral nodes, and leaf nodes.
NodeContainer centralNode;
centralNode.Create(1); // Central node
NodeContainer firstLevelNodes;
firstLevelNodes.Create(3); // Peripheral nodes at level 1
NodeContainer secondLevelNodes[3]; // Nodes connected to each level-1 node
for (int i = 0; i < 3; ++i) {
secondLevelNodes[i].Create(2); // Each level-1 node has 2 children
}
- Set Up Point-to-Point Links: We follow the below command to describe link properties to utilize PointToPointHelper.
PointToPointHelper p2p;
p2p.SetDeviceAttribute(“DataRate”, StringValue(“10Mbps”));
p2p.SetChannelAttribute(“Delay”, StringValue(“2ms”));
- Connect the Central Node to First-Level Nodes: We make links among the central node and the first-level peripheral nodes for connect those nodes.
NetDeviceContainer devices;
for (uint32_t i = 0; i < firstLevelNodes.GetN(); ++i) {
NetDeviceContainer link = p2p.Install(centralNode.Get(0), firstLevelNodes.Get(i));
devices.Add(link);
}
- Connect First-Level Nodes to Second-Level Nodes: We generate links among each first-level node and their respective second-level nodes for associate this nodes.
for (int i = 0; i < 3; ++i) {
for (uint32_t j = 0; j < secondLevelNodes[i].GetN(); ++j) {
NetDeviceContainer link = p2p.Install(firstLevelNodes.Get(i), secondLevelNodes[i].Get(j));
devices.Add(link);
}
}
- Install Internet Stack: We insert the Internet stack to every node using the below command.
InternetStackHelper stack;
stack.Install(centralNode);
stack.Install(firstLevelNodes);
for (int i = 0; i < 3; ++i) {
stack.Install(secondLevelNodes[i]);
}
- Assign IP Addresses: Allocate a unique IP addresses to every single link like central node links and first-level node links.
Ipv4AddressHelper address;
uint32_t subnetIndex = 1;
// Assign IP addresses to central node links
for (uint32_t i = 0; i < firstLevelNodes.GetN(); ++i) {
std::ostringstream subnet;
subnet << “10.1.” << subnetIndex++ << “.0”;
address.SetBase(subnet.str().c_str(), “255.255.255.0”);
address.Assign(devices.Get(i));
}
// Assign IP addresses to first-level node links
for (int i = 0; i < 3; ++i) {
for (uint32_t j = 0; j < secondLevelNodes[i].GetN(); ++j) {
std::ostringstream subnet;
subnet << “10.1.” << subnetIndex++ << “.0”;
address.SetBase(subnet.str().c_str(), “255.255.255.0”);
address.Assign(devices.Get(subnetIndex – 1));
}
}
Step 5: Set Up Applications
- Server Application: We can set a UDP echo server at one of the second-level nodes.
UdpEchoServerHelper echoServer(9); // Port 9
ApplicationContainer serverApp = echoServer.Install(secondLevelNodes[2].Get(1)); // Last node as server
serverApp.Start(Seconds(1.0));
serverApp.Stop(Seconds(10.0));
- Client Applications: We need to install the UDP echo clients at other nodes interacting with the server.
for (uint32_t i = 0; i < firstLevelNodes.GetN(); ++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(firstLevelNodes.Get(i));
clientApp.Start(Seconds(2.0));
clientApp.Stop(Seconds(10.0));
}
Step 6: Run and Analyze
- Run the Simulation: We should execute the simulation to utilize following code.
Simulator::Run();
Simulator::Destroy();
- Enable Packet Capture: Allow packet to seize and we can store .pcap files for traffic analysis.
p2p.EnablePcapAll(“extended_star”);
- Trace Logs: For debugging, we can allow NS3 logging:
export NS_LOG=”UdpEchoClientApplication=level_all|prefix_func”
./waf –run scratch/extended_star_topology
Example: Minimal NS3 Script for Extended Star 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[]) {
// Create central and peripheral nodes
NodeContainer centralNode;
centralNode.Create(1);
NodeContainer firstLevelNodes;
firstLevelNodes.Create(3);
NodeContainer secondLevelNodes[3];
for (int i = 0; i < 3; ++i) {
secondLevelNodes[i].Create(2);
}
// Set up Point-to-Point links
PointToPointHelper p2p;
p2p.SetDeviceAttribute(“DataRate”, StringValue(“10Mbps”));
p2p.SetChannelAttribute(“Delay”, StringValue(“2ms”));
// Connect central node to first-level nodes
NetDeviceContainer devices;
for (uint32_t i = 0; i < firstLevelNodes.GetN(); ++i) {
NetDeviceContainer link = p2p.Install(centralNode.Get(0), firstLevelNodes.Get(i));
devices.Add(link);
}
// Connect first-level nodes to second-level nodes
for (int i = 0; i < 3; ++i) {
for (uint32_t j = 0; j < secondLevelNodes[i].GetN(); ++j) {
NetDeviceContainer link = p2p.Install(firstLevelNodes.Get(i), secondLevelNodes[i].Get(j));
devices.Add(link);
}
}
// Install Internet stack
InternetStackHelper stack;
stack.Install(centralNode);
stack.Install(firstLevelNodes);
for (int i = 0; i < 3; ++i) {
stack.Install(secondLevelNodes[i]);
}
// Assign IP addresses
Ipv4AddressHelper address;
uint32_t subnetIndex = 1;
for (uint32_t i = 0; i < devices.GetN(); ++i) {
std::ostringstream subnet;
subnet << “10.1.” << subnetIndex++ << “.0”;
address.SetBase(subnet.str().c_str(), “255.255.255.0”);
address.Assign(devices.Get(i));
}
// Set up UDP echo server on a second-level node
UdpEchoServerHelper echoServer(9);
ApplicationContainer serverApp = echoServer.Install(secondLevelNodes[2].Get(1));
serverApp.Start(Seconds(1.0));
serverApp.Stop(Seconds(10.0));
// Set up UDP echo clients on first-level nodes
for (uint32_t i = 0; i < firstLevelNodes.GetN(); ++i) {
UdpEchoClientHelper echoClient(Ipv4Address(“10.
Here, we had presented the detailed explanation that covers the sequential approach of the project including sample snippets which are useful to simulate and examine the Extended Star Topology projects within NS3 environment and we are ready to provide additional specifies upon demand.
We take care of the peripheral nodes and also help you with the overall performance. Just shoot us a message with the details of your Extended Star Topology project, and we’ll hook you up with personalized research support. Drop us an email with all your project info, and we’ll make sure you get the best advice possible.