How to Start Partial Mesh Topology Projects using NS3

To create a Partial Mesh Topology is a difference of full mesh topology in which only a subset of the possible connections among nodes is created. This decreases the redundancy and cost compared to a full mesh while handling the connectivity and robustness.

Steps to Start Partial Mesh Topology Projects using NS3

Step 1: Set Up NS-3

  1. Install NS-3:
    • Download NS-3.
    • Follow the installation steps.
  2. Verify Installation: Run a sample NS-3 script to ensure everything is working:

./waf –run scratch/my_first

Step 2: Understand Partial Mesh Topology

  • Partial Mesh Topology:
    • The Nodes are connected to a subset of other nodes.
    • Some nodes are fully connected although others can be only connected to specific nodes.
    • Suggestions a balance among cost, complexity, and fault tolerance.

Step 3: Plan the Topology

  1. Decide the number of nodes:
    • For Sample, create a six nodes.
  2. Define connections:
    • Choose that nodes will connect directly to every other such as a configuration matrix or adjacency list.

Step 4: Set Up the Partial Mesh Topology

  1. Create Nodes: State the nodes in the network.

NodeContainer nodes;

uint32_t numNodes = 6; // Number of nodes in the partial mesh

nodes.Create(numNodes);

  1. Set Up Point-to-Point Links: Utilized their PointToPointHelper we describe the properties of the connections.

PointToPointHelper p2p;

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

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

  1. Connect Nodes Based on Partial Mesh Design: Describe the subset of connections utilizing an adjacency list or matrix.

// Define adjacency list for partial mesh connections

std::vector<std::pair<uint32_t, uint32_t>> connections = {

{0, 1}, {0, 2}, {1, 2}, {1, 3}, {3, 4}, {4, 5}, {2, 5}

};

NetDeviceContainer devices;

for (auto &connection : connections) {

uint32_t nodeA = connection.first;

uint32_t nodeB = connection.second;

NetDeviceContainer link = p2p.Install(nodes.Get(nodeA), nodes.Get(nodeB));

devices.Add(link);

}

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

InternetStackHelper stack;

stack.Install(nodes);

  1. Assign IP Addresses: Allocate the unique IP addresses to each link.

Ipv4AddressHelper address;

uint32_t subnetIndex = 1;

for (auto &connection : connections) {

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

  1. Server Applications: Dwelling a UDP echo server on one or more nodes.

UdpEchoServerHelper echoServer(9); // Port 9

ApplicationContainer serverApp = echoServer.Install(nodes.Get(5)); // Last node as server

serverApp.Start(Seconds(1.0));

serverApp.Stop(Seconds(10.0));

  1. Client Applications: Dwelling the UDP echo clients on other nodes to communicate 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

  1. Run the Simulation:

Simulator::Run();

Simulator::Destroy();

  1. Enable Packet Capture: Capture traffic on the links for analysis.

p2p.EnablePcapAll(“partial_mesh”);

  1. Trace Logs: Enable logging for debugging and analysis.

export NS_LOG=”UdpEchoClientApplication=level_all|prefix_func”

./waf –run scratch/partial_mesh_topology

Example: Minimal NS-3 Script for Partial Mesh 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

PointToPointHelper p2p;

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

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

// Define adjacency list for partial mesh

std::vector<std::pair<uint32_t, uint32_t>> connections = {

{0, 1}, {0, 2}, {1, 2}, {1, 3}, {3, 4}, {4, 5}, {2, 5}

};

// Connect nodes

NetDeviceContainer devices;

for (auto &connection : connections) {

uint32_t nodeA = connection.first;

uint32_t nodeB = connection.second;

NetDeviceContainer link = p2p.Install(nodes.Get(nodeA), nodes.Get(nodeB));

devices.Add(link);

}

// Install Internet stack

InternetStackHelper stack;

stack.Install(nodes);

// Assign IP addresses

Ipv4AddressHelper address;

uint32_t subnetIndex = 1;

for (auto &connection : connections) {

std::ostringstream subnet;

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

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

address.Assign(devices.Get(subnetIndex – 1));

}

// Set up UDP echo server on the last node

UdpEchoServerHelper echoServer(9);

ApplicationContainer serverApp = echoServer.Install(nodes.Get(5));

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(“partial_mesh”);

// Run the simulation

Simulator::Run();

Simulator::Destroy();

return 0;

}

Step 7: Compile and Run

  1. Save the script as partial_mesh_topology.cc.
  2. We compile and run it:

./waf –run partial_mesh_topology

Step 8: Enhance the Simulation

  • Experiment with Traffic Models:
    • Utilized their TCP instead of UDP.
    • Replicate their FTP or HTTP traffic.
  • Analyze Performance:
    • Calculate the throughput, delay, jitter, and packet loss.
  • Simulate Failures:
    • Establish the connection failures we analysis the robustness.
  • Visualize:
    • Utilized their NetAnim to show the partial mesh topology and traffic flow.

Next Steps

  • The larger network is a scale topology.
  • Compared the performance metrices of partial mesh by full mesh and other topologies such as tree or star.
  • Validate the routing protocols such as OLSR or AODV we maintain the dynamic paths in the mesh.

In this manual we entirely aggregate the data about the installation process and simulation procedure for Partial Mesh Topology projects that were deploy in the tool of NS3. Additional information about the Partial Mesh Topology will also be offered.

Getting started with a Partial Mesh Topology Project in NS-3 can be challenging. That’s why at phdprojects.org, we provide tailored support whenever you need it. Just drop us a message, and we’ll help you with the best simulations and topics.