How to Start Daisy Chain Topology Projects Using NS3

To start Daisy Chain Topology in NS3 that sequentially associates several nodes in which each node is connected to their immediate neighbor within a linear fashion. This topology is helpful for analysing linear data transmission, link behavior, and end-to-end performance. We follow below given process to get started:

Steps to Start Daisy Chain Topology Projects in NS3

Step 1: Set Up NS3

  1. Install NS3:
    • From NS3 webpage, we can download NS3 on the system.
    • We adhere to the installation guidance.
  2. Verify Installation: We execute a simple script making sure that NS3 is functioning:

./waf –run scratch/my_first

Step 2: Understand Daisy Chain Topology

  • Daisy Chain Topology:
    • Nodes are linked within a linear fashion to make a “chain.”
    • Data moves in sequence via each link among the nodes.

Step 3: Set Up the Daisy Chain Topology

  1. Create Nodes: We describe the nodes within the daisy chain.

NodeContainer nodes;

uint32_t numNodes = 5; // Number of nodes in the chain

nodes.Create(numNodes);

  1. Set Up Point-to-Point Links: Describe the each link’s properties to utilize PointToPointHelper.

PointToPointHelper p2p;

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

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

  1. Connect Nodes: Make a chain by linking each node to their neighbor.

NetDeviceContainer devices;

for (uint32_t i = 0; i < numNodes – 1; ++i) {

NetDeviceContainer link = p2p.Install(nodes.Get(i), nodes.Get(i + 1));

devices.Add(link);

}

  1. Install Internet Stack: We execute the IP stack at every node.

InternetStackHelper stack;

stack.Install(nodes);

  1. Assign IP Addresses: Then, allocate a unique IP addresses to each link.

Ipv4AddressHelper address;

for (uint32_t i = 0; i < numNodes – 1; ++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 4: Set Up Applications

  1. Install a Server Application: Set a UDP echo server on chain’s one end.

UdpEchoServerHelper echoServer(9); // Port 9

ApplicationContainer serverApp = echoServer.Install(nodes.Get(numNodes – 1)); // Last node

serverApp.Start(Seconds(1.0));

serverApp.Stop(Seconds(10.0));

  1. Install Client Applications: Locate UDP echo clients on other nodes transmitting information to 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 5: Run and Analyze

  1. Run the Simulation:

Simulator::Run();

Simulator::Destroy();

  1. Enable Packet Capture: We can seize traffic for analysis to utilize .pcap files.

p2p.EnablePcapAll(“daisy_chain”);

  1. Trace Logs: For debugging, allow NS3 logging.

export NS_LOG=”UdpEchoClientApplication=level_all|prefix_func”

./waf –run scratch/daisy_chain_topology

Example: Minimal NS3 Script for Daisy Chain 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 daisy chain

NetDeviceContainer devices;

for (uint32_t i = 0; i < numNodes – 1; ++i) {

NetDeviceContainer link = p2p.Install(nodes.Get(i), nodes.Get(i + 1));

devices.Add(link);

}

// Install Internet stack

InternetStackHelper stack;

stack.Install(nodes);

// Assign IP addresses

Ipv4AddressHelper address;

for (uint32_t i = 0; i < numNodes – 1; ++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(“daisy_chain”);

// Run the simulation

Simulator::Run();

Simulator::Destroy();

return 0;

}

Step 6: Compile and Run

  1. We can store the script like daisy_chain_topology.cc.
  2. Then, we compile and execute it to utilize following command:

./waf –run daisy_chain_topology

Step 7: Enhance the Simulation

  • Experiment with Traffic:
    • Make use of TCP or replicate FTP/HTTP traffic rather than UDP.
  • Analyze Performance:
    • Estimate the performance indicators such as throughput, delay, and jitter.
  • Simulate Failures:
    • Launch link or node failures monitoring the effect.
  • Visualize:
    • Envision the topology and traffic flow to utilize NetAnim tool.

Next Steps

  • Thereafter, we measure the topology by maximizing the volume of nodes.
  • To equate the performance of daisy chain including other topologies like bus or ring.
  • Launch more applications or protocols for furthered simulations.

In the end, we had effectively simulated and analysed the daisy chain topology in NS3 by generating the nodes, assign the IP address and install the application. We will give further insights about how the daisy chain topology will perform in other simulation tool.

Provide us with the details of your Daisy Chain Topology project, and we will offer you customized research support. We conduct analyses on linear data transmission, link behavior, and end-to-end performance.