Ns3 Projects for B.E/B.Tech M.E/M.Tech PhD Scholars.  Phone-Number:9790238391   E-mail: ns3simulation@gmail.com

How to Begin Implement Bus Topology in NS3

To implement and simulate a bus topology using NS3, we have to need making a shared medium in which numerous nodes are associated to the similar network link. Every node distributes a general interaction medium, and only one node can be sent at a time in a bus topology.

We follow these step-by-step instructions to get started with implementing a bus topology in NS3:

Steps to Begin Implement Bus Topology in NS3

  1. Understand the Bus Topology

In a bus topology:

  • Every node is associated to a single communication medium.
  • A central medium such as Ethernet or Wi-Fi is designed for interaction.
  • Data is sent to all nodes, however only the proposed recipient manages it.

It can be executed by CSMA channel (Carrier Sense Multiple Access) that simulates a shared medium in NS3.

  1. Set Up NS3
  1. Install NS3:
    • We should install and download NS3 on the system.
    • Confirm the installation:

./waf –run hello-simulator

  1. Install Wireshark (optional):
    • Examine the .pcap files which are made by NS3 using Wireshark.
  1. Design a Bus Topology

A bus topology associates numerous nodes to a shared medium with the support of CSMA (Carrier Sense Multiple Access) channel.

Define the Nodes and Channel

NodeContainer nodes;

nodes.Create(5); // Create 5 nodes for the bus topology

CsmaHelper csma;

csma.SetChannelAttribute(“DataRate”, StringValue(“100Mbps”)); // Bus data rate

csma.SetChannelAttribute(“Delay”, TimeValue(NanoSeconds(6560))); // Propagation delay

NetDeviceContainer devices = csma.Install(nodes); // Install CSMA on all nodes

  1. Assign IP Addresses

In the bus topology, allocate an IP addresses to every node:

InternetStackHelper stack;

stack.Install(nodes);

Ipv4AddressHelper address;

address.SetBase(“192.168.1.0”, “255.255.255.0”);

Ipv4InterfaceContainer interfaces = address.Assign(devices);

  1. Simulate Communication

Make interaction among the nodes. For instance:

  • Node 0 performs as the sender.
  • Node 4 executes like a receiver.

UdpEchoServerHelper echoServer(9); // Server listens on port 9

ApplicationContainer serverApps = echoServer.Install(nodes.Get(4)); // Node 4 is the server

serverApps.Start(Seconds(1.0));

serverApps.Stop(Seconds(10.0));

UdpEchoClientHelper echoClient(Ipv4Address(“192.168.1.5”), 9); // Node 4’s IP

echoClient.SetAttribute(“MaxPackets”, UintegerValue(5));

echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0)));

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

ApplicationContainer clientApps = echoClient.Install(nodes.Get(0)); // Node 0 is the client

clientApps.Start(Seconds(2.0));

clientApps.Stop(Seconds(10.0));

  1. Enable Packet Capture

Examine the packets which are sent through the bus topology using .pcap tracing:

csma.EnablePcapAll(“bus-topology”);

  1. Run the Simulation

Now, we can run the simulation using the below command line:

./waf –run bus-topology

  1. Example Code Skeleton

Below is a sample NS3 script to replicate a bus topology:

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

#include “ns3/csma-module.h”

#include “ns3/applications-module.h”

using namespace ns3;

int main(int argc, char *argv[]) {

NodeContainer nodes;

nodes.Create(5); // Create 5 nodes

// Configure CSMA channel (Bus Topology)

CsmaHelper csma;

csma.SetChannelAttribute(“DataRate”, StringValue(“100Mbps”));

csma.SetChannelAttribute(“Delay”, TimeValue(NanoSeconds(6560)));

NetDeviceContainer devices = csma.Install(nodes);

// Install Internet stack

InternetStackHelper stack;

stack.Install(nodes);

// Assign IP addresses

Ipv4AddressHelper address;

address.SetBase(“192.168.1.0”, “255.255.255.0”);

Ipv4InterfaceContainer interfaces = address.Assign(devices);

// Set up communication

UdpEchoServerHelper echoServer(9);

ApplicationContainer serverApps = echoServer.Install(nodes.Get(4)); // Node 4 is the server

serverApps.Start(Seconds(1.0));

serverApps.Stop(Seconds(10.0));

UdpEchoClientHelper echoClient(interfaces.GetAddress(4), 9); // Node 4’s IP

echoClient.SetAttribute(“MaxPackets”, UintegerValue(5));

echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0)));

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

ApplicationContainer clientApps = echoClient.Install(nodes.Get(0)); // Node 0 is the client

clientApps.Start(Seconds(2.0));

clientApps.Stop(Seconds(10.0));

// Enable packet capture

csma.EnablePcapAll(“bus-topology”);

// Run the simulation

Simulator::Run();

Simulator::Destroy();

return 0;

}

  1. Extend the Simulation
  • Add More Nodes: Integrate additional nodes to prolong the bus topology.
  • Analyze Performance: Estimate the performance parameters such as packet delay, loss, and throughput in various loads.
  • Simulate Collisions: Launch concurrent transmissions for monitoring the collision handling within the CSMA channel.

In this manual, Bus Topology implementation has been demonstrated through a systematic approach and supported with NS3 snippets which were executed and simulated. We’re equipped to dive deeper into more advanced aspects if required.