How to Start Hierarchical Topology Projects Using NS3

Starting a Hierarchical Topology Project in NS-3

To create a Hierarchical Topology, classify the nodes in layers in which nodes is one-layer act as gateways or routers for the later layer. These topologies are generally used in networks such as data centres and large-scale distributed systems.

Steps to Start Hierarchical Topology Projects Using NS3

Step 1: Set Up NS-3

  1. Install NS-3:
    • Download NS-3.
    • Observe the installation instructions.
  2. Verify Installation: Test we setting by a basic script:

./waf –run scratch/my_first

Step 2: Understand Hierarchical Topology

  • Hierarchical Topology:
    • The Nodes are ordered in layers such as core, aggregation, and access layers.
    • Every node in a layer are lined to the nodes in the later layer.

Step 3: Plan the Topology

  1. Define the structure:
    • For Sample:
      • Core layer: One node.
      • Aggregation layer: Two nodes.
      • Access layer: Four nodes per aggregation node.
  2. Set simulation goals:
    • Replicate the congestion among allocate the layer nodes.
    • Calculate the performance metrics such as throughput, latency, and packet loss.

Step 4: Set Up the Hierarchical Topology

  1. Create Nodes: Describe the nodes for every layer.

NodeContainer coreNode;

coreNode.Create(1); // Single core node

NodeContainer aggregationNodes;

aggregationNodes.Create(2); // Two aggregation nodes

NodeContainer accessNodes[2];

for (int i = 0; i < 2; ++i) {

accessNodes[i].Create(4); // Each aggregation node connects to 4 access nodes

}

  1. Set Up Point-to-Point Links: State the link properties using PointToPointHelper.

PointToPointHelper p2p;

p2p.SetDeviceAttribute(“DataRate”, StringValue(“10Mbps”));

p2p.SetChannelAttribute(“Delay”, StringValue(“2ms”));

  1. Connect Core to Aggregation Nodes: Builds a connection among the core node and every aggregation node.

NetDeviceContainer coreToAggregationDevices;

for (uint32_t i = 0; i < aggregationNodes.GetN(); ++i) {

NetDeviceContainer link = p2p.Install(coreNode.Get(0), aggregationNodes.Get(i));

coreToAggregationDevices.Add(link);

}

  1. Connect Aggregation Nodes to Access Nodes: Generate the links among every aggregation node and its corresponding the allocate nodes.

NetDeviceContainer aggregationToAccessDevices;

for (int i = 0; i < 2; ++i) {

for (uint32_t j = 0; j < accessNodes[i].GetN(); ++j) {

NetDeviceContainer link = p2p.Install(aggregationNodes.Get(i), accessNodes[i].Get(j));

aggregationToAccessDevices.Add(link);

}

}

  1. Install Internet Stack: Enhance the Internet stack to all nodes.

InternetStackHelper stack;

stack.Install(coreNode);

stack.Install(aggregationNodes);

for (int i = 0; i < 2; ++i) {

stack.Install(accessNodes[i]);

}

  1. Assign IP Addresses: Allocate the unique IP addresses to every connection.

Ipv4AddressHelper address;

uint32_t subnetIndex = 1;

// Assign IPs for core to aggregation links

for (uint32_t i = 0; i < coreToAggregationDevices.GetN(); ++i) {

std::ostringstream subnet;

subnet << “10.1.” << subnetIndex++ << “.0”;

address.SetBase(subnet.str().c_str(), “255.255.255.0”);

address.Assign(coreToAggregationDevices.Get(i));

}

// Assign IPs for aggregation to access links

for (uint32_t i = 0; i < aggregationToAccessDevices.GetN(); ++i) {

std::ostringstream subnet;

subnet << “10.1.” << subnetIndex++ << “.0”;

address.SetBase(subnet.str().c_str(), “255.255.255.0”);

address.Assign(aggregationToAccessDevices.Get(i));

}

Step 5: Set Up Applications

  1. Server Application: Dwelling a UDP echo server on one of the allocate nodes.

UdpEchoServerHelper echoServer(9); // Port 9

ApplicationContainer serverApp = echoServer.Install(accessNodes[1].Get(3)); // One access node as server

serverApp.Start(Seconds(1.0));

serverApp.Stop(Seconds(10.0));

  1. Client Applications: Install the UDP echo clients on other access nodes to communicate through the server.

for (int i = 0; i < 2; ++i) {

for (uint32_t j = 0; j < accessNodes[i].GetN(); ++j) {

if (i == 1 && j == 3) continue; // Skip the server node

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(accessNodes[i].Get(j));

clientApp.Start(Seconds(2.0));

clientApp.Stop(Seconds(10.0));

}

}

Step 6: Run and Analyze

  1. Run the Simulation:

Simulator::Run();

Simulator::Destroy();

  1. Enable Packet Capture: Save .pcap files for traffic analysis.

p2p.EnablePcapAll(“hierarchical_topology”);

  1. Trace Logs: Enable NS-3 logging for debugging:

export NS_LOG=”UdpEchoClientApplication=level_all|prefix_func”

./waf –run scratch/hierarchical_topology

Example: Minimal NS-3 Script for Hierarchical 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[]) {

NodeContainer coreNode;

coreNode.Create(1);

NodeContainer aggregationNodes;

aggregationNodes.Create(2);

NodeContainer accessNodes[2];

for (int i = 0; i < 2; ++i) {

accessNodes[i].Create(4);

}

PointToPointHelper p2p;

p2p.SetDeviceAttribute(“DataRate”, StringValue(“10Mbps”));

p2p.SetChannelAttribute(“Delay”, StringValue(“2ms”));

NetDeviceContainer coreToAggregationDevices;

for (uint32_t i = 0; i < aggregationNodes.GetN(); ++i) {

NetDeviceContainer link = p2p.Install(coreNode.Get(0), aggregationNodes.Get(i));

coreToAggregationDevices.Add(link);

}

NetDeviceContainer aggregationToAccessDevices;

for (int i = 0; i < 2; ++i) {

for (uint32_t j = 0; j < accessNodes[i].GetN(); ++j) {

NetDeviceContainer link = p2p.Install(aggregationNodes.Get(i), accessNodes[i].Get(j));

aggregationToAccessDevices.Add(link);

}

}

InternetStackHelper stack;

stack.Install(coreNode);

stack.Install(aggregationNodes);

for (int i = 0; i < 2; ++i) {

stack.Install(accessNodes[i]);

}

 

Ipv4AddressHelper address;

uint32_t subnetIndex = 1;

for (uint32_t i = 0; i < coreToAggregationDevices.GetN(); ++i) {

std::ostringstream subnet;

subnet << “10.1.” << subnetIndex++ << “.0”;

address.SetBase(subnet.str().c_str(), “255.255.255.0”);

address.Assign(coreToAggregationDevices.Get(i));

}

for (uint32_t i = 0; i < aggregationToAccessDevices.GetN(); ++i) {

std::ostringstream subnet;

subnet << “10.1.” << subnetIndex++ << “.0”;

address.SetBase(subnet.str().c_str(), “255.255.255.0”);

address.Assign(aggregationToAccessDevices.Get(i));

}

UdpEchoServerHelper echoServer(9);

ApplicationContainer serverApp = echoServer.Install(accessNodes[1].Get(3));

serverApp.Start(Seconds(1.0));

serverApp.Stop(Seconds(10.0));

for (int i = 0; i < 2; ++i) {

for (uint32_t j =

We had done the simulation process successfully for network Hierarchical Topology project using the tool of NS3 and it also deliver the complete procedures to simulate the process, detailed explanation for the given code snippets and deliver the sample project ideas for future enhancement. If you need more details regarding this process, we will provide you.

Please contact us for research guidance and a concise explanation. We provide comprehensive step-by-step instructions for your research, ensuring you can depend on us for innovative and relevant topics. At phdprojects.org, we are here to assist you in initiating Hierarchical Topology Projects using NS3, offering personalized support whenever you need it. Our expertise spans core, aggregation, and access layers, tailored to meet your specific research requirements.