How to Start Overlay Topology Projects using NS3

To create an Overlay Topology is create a top of underlying physical network and permitting their nodes to communicate via virtual connections or paths. Overlay networks are used in content distribution, peer-to-peer networks, and VPNs.

Steps to Start Overlay Topology Projects using NS3

Step 1: Set Up NS-3

  1. Install NS-3:
    • Download NS-3.
    • Follow the installation instructions.
  2. Verify Installation: Test NS-3 with a basic script:

./waf –run scratch/my_first

Step 2: Understand Overlay Topology

  • Overlay Topology:
    • Logical topology over an underlying physical network.
    • The Nodes are connected in a virtual connection.
    • General applications:
      • Content delivery networks (CDNs).
      • Peer-to-peer systems (e.g., BitTorrent).
      • Virtual private networks (VPNs).

Step 3: Plan the Topology

  1. Define the physical and overlay networks:
    • For Sample:
      • Physical network: Mesh connected in five nodes.
      • Overlay network: Three virtual connections among specific nodes.
  2. Set simulation goals:
    • Replicate the data exchange over the overlay network.
    • Analyze performance metrics such as throughput and latency.

Step 4: Set Up the Physical Topology

  1. Create Physical Nodes: State the nodes for the physical network.

NodeContainer physicalNodes;

uint32_t numPhysicalNodes = 5; // Number of physical nodes

physicalNodes.Create(numPhysicalNodes);

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

PointToPointHelper p2p;

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

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

  1. Connect Physical Nodes: Build a mesh or custom topology for the physical network.

NetDeviceContainer physicalDevices;

for (uint32_t i = 0; i < numPhysicalNodes; ++i) {

for (uint32_t j = i + 1; j < numPhysicalNodes; ++j) {

NetDeviceContainer link = p2p.Install(physicalNodes.Get(i), physicalNodes.Get(j));

physicalDevices.Add(link);

}

}

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

InternetStackHelper stack;

stack.Install(physicalNodes);

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

Ipv4AddressHelper address;

uint32_t subnetIndex = 1;

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

std::ostringstream subnet;

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

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

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

}

Step 5: Set Up the Overlay Network

  1. Define Overlay Connections: Specify virtual connections for the overlay network.

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

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

};

  1. Create Applications for Overlay Communication: Utilizing their socket programming we create the virtual connections over the physical network.

for (auto &link : overlayLinks) {

Ptr<Node> src = physicalNodes.Get(link.first);

Ptr<Node> dest = physicalNodes.Get(link.second);

// Source application

OnOffHelper onOff(“ns3::UdpSocketFactory”, InetSocketAddress(dest->GetObject<Ipv4>()->GetAddress(1, 0).GetLocal(), 9));

onOff.SetAttribute(“DataRate”, StringValue(“1Mbps”));

onOff.SetAttribute(“PacketSize”, UintegerValue(1024));

ApplicationContainer srcApp = onOff.Install(src);

srcApp.Start(Seconds(1.0));

srcApp.Stop(Seconds(10.0));

// Sink application

PacketSinkHelper sink(“ns3::UdpSocketFactory”, InetSocketAddress(Ipv4Address::GetAny(), 9));

ApplicationContainer sinkApp = sink.Install(dest);

sinkApp.Start(Seconds(1.0));

sinkApp.Stop(Seconds(10.0));

}

Step 6: Run and Analyze

  1. Run the Simulation:

Simulator::Run();

Simulator::Destroy();

  1. Enable Packet Capture: Utilized the .pcap files for traffic analysis.

p2p.EnablePcapAll(“overlay_topology”);

  1. Trace Logs: Ensure the NS-3 logging for debugging:

export NS_LOG=”OnOffApplication=level_all|prefix_func”

./waf –run scratch/overlay_topology

Example: Minimal NS-3 Script for Overlay 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 numPhysicalNodes = 5;

// Create physical nodes

NodeContainer physicalNodes;

physicalNodes.Create(numPhysicalNodes);

// Set up Point-to-Point links

PointToPointHelper p2p;

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

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

// Connect physical nodes in a mesh

NetDeviceContainer physicalDevices;

for (uint32_t i = 0; i < numPhysicalNodes; ++i) {

for (uint32_t j = i + 1; j < numPhysicalNodes; ++j) {

NetDeviceContainer link = p2p.Install(physicalNodes.Get(i), physicalNodes.Get(j));

physicalDevices.Add(link);

}

}

// Install Internet stack

InternetStackHelper stack;

stack.Install(physicalNodes);

// Assign IP addresses

Ipv4AddressHelper address;

uint32_t subnetIndex = 1;

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

std::ostringstream subnet;

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

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

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

}

// Define overlay links

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

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

};

// Create overlay applications

for (auto &link : overlayLinks) {

Ptr<Node> src = physicalNodes.Get(link.first);

Ptr<Node> dest = physicalNodes.Get(link.second);

// Source application

OnOffHelper onOff(“ns3::UdpSocketFactory”, InetSocketAddress(dest->GetObject<Ipv4>()->GetAddress(1, 0).GetLocal(), 9));

onOff.SetAttribute(“DataRate”, StringValue(“1Mbps”));

onOff.SetAttribute(“PacketSize”, UintegerValue(1024));

ApplicationContainer srcApp = onOff.Install(src);

srcApp.Start(Seconds(1.0));

srcApp.Stop(Seconds(10.0));

// Sink application

PacketSinkHelper sink(“ns3::UdpSocketFactory”, InetSocketAddress(Ipv4Address::GetAny(), 9));

ApplicationContainer sinkApp = sink.Install(dest);

sinkApp.Start(Seconds(1.0));

sinkApp.Stop(Seconds(10.0));

}

// Enable packet capture

p2p.EnablePcapAll(“overlay_topology”);

// Run the simulation

Simulator::Run();

Simulator::Destroy();

return 0;

}

Step 7: Compile and Run

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

./waf –run overlay_topology

Step 8: Enhance the Simulation

  • Experiment with Traffic Models:
    • Validate the various traffic models such as FTP, HTTP.
  • Simulate Dynamic Overlays:
    • Dynamically improve or remove the overlay connections during the replication.
  • Analyze Performance:
    • Calculate the parameter metrics such as throughput, delay, jitter, and packet loss.
  • Visualize:
    • Utilized their NetAnim we show together the physical and overlay topologies.

Next Steps

  • Incorporate Real Protocols:
    • Execute the P2P protocols such as BitTorrent or application-layer routing.
  • Add Scalability:
    • Size of the physical and overlay networks are increased.
  • Dynamic Reconfiguration:
    • Replicate the overlay adaptation we alter in the physical network.

Step 1: Set Up NS-3

  1. Install NS-3:
    • Download NS-3.
    • Observe the installation Process.
  2. Verify Installation: Run a basic NS-3 script:

./waf –run scratch/my_first

Step 2: Understand Overlay Topology

  • Overlay Topology:
    • The Logical connections among nodes over a physical network.
    • The Nodes are communicating by virtual connections state at the application layer.
    • General use cases:
      • Peer-to-peer applications like BitTorrent.
      • Virtual private networks (VPNs).
      • Content delivery networks (CDNs).

Step 3: Plan the Topology

  1. Define the physical network:
    • For example:
      • Mesh topology has included in five nodes.
  2. Define the overlay network:
    • Logical connections among nodes and independent of physical topology.

Step 4: Set Up the Physical Network

  1. Create Physical Nodes: State the nodes in the physical topology.

NodeContainer physicalNodes;

uint32_t numPhysicalNodes = 5;

physicalNodes.Create(numPhysicalNodes);

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

PointToPointHelper p2p;

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

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

  1. Connect Physical Nodes: Build a mesh topology for the physical network.

NetDeviceContainer physicalDevices;

for (uint32_t i = 0; i < numPhysicalNodes; ++i) {

for (uint32_t j = i + 1; j < numPhysicalNodes; ++j) {

NetDeviceContainer link = p2p.Install(physicalNodes.Get(i), physicalNodes.Get(j));

physicalDevices.Add(link);

}

}

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

InternetStackHelper stack;

stack.Install(physicalNodes);

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

Ipv4AddressHelper address;

uint32_t subnetIndex = 1;

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

std::ostringstream subnet;

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

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

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

}

Step 5: Set Up the Overlay Network

  1. Define Overlay Links: Specify logical connections for the overlay network.

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

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

};

  1. Set Up Virtual Connections: Utilized their UDP sockets we create overlay communication.

for (auto &link : overlayLinks) {

Ptr<Node> src = physicalNodes.Get(link.first);

Ptr<Node> dest = physicalNodes.Get(link.second);

// Source application

OnOffHelper onOff(“ns3::UdpSocketFactory”, InetSocketAddress(dest->GetObject<Ipv4>()->GetAddress(1, 0).GetLocal(), 9));

onOff.SetAttribute(“DataRate”, StringValue(“1Mbps”));

onOff.SetAttribute(“PacketSize”, UintegerValue(1024));

ApplicationContainer srcApp = onOff.Install(src);

srcApp.Start(Seconds(1.0));

srcApp.Stop(Seconds(10.0));

// Sink application

PacketSinkHelper sink(“ns3::UdpSocketFactory”, InetSocketAddress(Ipv4Address::GetAny(), 9));

ApplicationContainer sinkApp = sink.Install(dest);

sinkApp.Start(Seconds(1.0));

sinkApp.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(“overlay_topology”);

  1. Trace Logs: Ensure the NS-3 logging for debugging:

export NS_LOG=”UdpClientApplication=level_all|prefix_func”

./waf –run scratch/overlay_topology

Example: Minimal NS-3 Script for Overlay 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 numPhysicalNodes = 5;

// Create physical nodes

NodeContainer physicalNodes;

physicalNodes.Create(numPhysicalNodes);

// Set up Point-to-Point links

PointToPointHelper p2p;

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

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

// Connect physical nodes in a mesh

NetDeviceContainer physicalDevices;

for (uint32_t i = 0; i < numPhysicalNodes; ++i) {

for (uint32_t j = i + 1; j < numPhysicalNodes; ++j) {

NetDeviceContainer link = p2p.Install(physicalNodes.Get(i), physicalNodes.Get(j));

physicalDevices.Add(link);

}

}

// Install Internet stack

InternetStackHelper stack;

stack.Install(physicalNodes);

// Assign IP addresses

Ipv4AddressHelper address;

uint32_t subnetIndex = 1;

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

std::ostringstream subnet;

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

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

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

}

// Define overlay links

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

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

};

// Create overlay applications

for (auto &link : overlayLinks) {

Ptr<Node> src = physicalNodes.Get(link.first);

Ptr<Node> dest = physicalNodes.Get(link.second);

// Source application

OnOffHelper onOff(“ns3::UdpSocketFactory”, InetSocketAddress(dest->GetObject<Ipv4>()->GetAddress(1, 0).GetLocal(), 9));

onOff.SetAttribute(“DataRate”, StringValue(“1Mbps”));

onOff.SetAttribute(“PacketSize”, UintegerValue(1024));

ApplicationContainer srcApp = onOff.Install(src);

srcApp.Start(Seconds(1.0));

srcApp.Stop(Seconds(10.0));

// Sink application

PacketSinkHelper sink(“ns3::UdpSocketFactory”, InetSocketAddress(Ipv4Address::GetAny(), 9));

ApplicationContainer sinkApp = sink.Install(dest);

sinkApp.Start(Seconds(1.0));

sinkApp.Stop(Seconds(10.0));

}

 

// Enable packet capture

p2p.EnablePcapAll(“overlay_topology”);

// Run the simulation

Simulator::Run();

Simulator::Destroy();

return 0;

}

Step 7: Compile and Run

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

./waf –run overlay_topology

Step 8: Enhance the Simulation

  • Simulate Dynamic Overlays:
    • Enhance or eliminate the overlay connections during the replication.
  • Analyze Performance:
    • Calculate their throughput, latency, jitter, and packet loss.
  • Visualize:
    • Utilized their NetAnim we display together physical and overlay topologies.
  • Scale Up:
    • Number of physical nodes and overlay connections are increased.

Next Steps

  • Simulate Real Applications:
    • Validate through real-world P2P protocols such as BitTorrent.
  • Implement Advanced Overlays:
    • Research through content delivery or distributed hash table systems.
  • Incorporate Failures:
    • Replicate the connection or node failures we analysis the fault tolerance.

In this manual, we illustrate the Overlay topology performed a comprehensive project analysis through given simulation process. We will also deliver further additional details about this topology in another report work.

Our team of developers focuses on content distribution, peer-to-peer networks, and VPNs, so feel free to reach out for more help. If you’re looking to start an Overlay Topology Project in NS-3, it can be quite challenging. That’s why at phdprojects.org, we provide tailored support whenever you need it. Just drop us a message, and we’ll assist you with the best simulations and topics.