To implement Bus-Star Hybrid Topology merges the bus topology (a central shared communication medium) and star topology (which nodes are linked to a central hub) elements. This is frequently leveraged for improving the flexibility and scalability whereas sustaining the effective interaction. We will guide you on how to begin executing the Bus-Star Hybrid Topology using NS3:
Steps to Begin Bus-Star Hybrid Topology in NS3
- Understand Bus-Star Hybrid Topology
- Bus Segment: A backbone interconnecting numerous star set up.
- Star Segments: Every single star configuration includes a central node (hub) and their associated nodes.
- Hybrid Nature: It merges the bus and star topologies’ strengths.
- Set Up NS3
- Install NS3:
- We can download and install NS3 simulator on the computer properly.
- Confirm set up by executing:
./waf –run hello-simulator
- Install Wireshark:
- To examine the network traffic utilising .pcap files, we can install the tools like Wireshark.
- Create the Bus-Star Hybrid Topology
Step 1: Define Nodes
Make a topology with nodes for the bus backbone and star segments:
NodeContainer busNodes, star1Nodes, star2Nodes;
busNodes.Create(3); // Bus segment: 3 nodes
star1Nodes.Create(4); // Star segment 1: 1 hub + 3 spokes
star2Nodes.Create(4); // Star segment 2: 1 hub + 3 spokes
Step 2: Configure the Bus Segment
Design the bus backbone to leverage CSMA:
CsmaHelper csma;
csma.SetChannelAttribute(“DataRate”, StringValue(“100Mbps”));
csma.SetChannelAttribute(“Delay”, TimeValue(NanoSeconds(6560)));
NetDeviceContainer busDevices = csma.Install(busNodes);
Step 3: Configure the Star Segments
Associate every single hub within the star segments to their corresponding end devices with the support of Point-to-Point (P2P) links:
PointToPointHelper p2p;
p2p.SetDeviceAttribute(“DataRate”, StringValue(“10Mbps”));
p2p.SetChannelAttribute(“Delay”, StringValue(“2ms”));
// Star segment 1
NetDeviceContainer star1Devices;
for (uint32_t i = 1; i < star1Nodes.GetN(); ++i) {
star1Devices.Add(p2p.Install(star1Nodes.Get(0), star1Nodes.Get(i))); // Node 0 is the hub
}
// Star segment 2
NetDeviceContainer star2Devices;
for (uint32_t i = 1; i < star2Nodes.GetN(); ++i) {
star2Devices.Add(p2p.Install(star2Nodes.Get(0), star2Nodes.Get(i))); // Node 0 is the hub
}
Step 4: Connect the Stars to the Bus
Link the star segments’ hubs to the bus backbone:
NetDeviceContainer connectionDevices;
connectionDevices.Add(p2p.Install(busNodes.Get(0), star1Nodes.Get(0))); // Bus Node 0 to Star 1 Hub
connectionDevices.Add(p2p.Install(busNodes.Get(1), star2Nodes.Get(0))); // Bus Node 1 to Star 2 Hub
- Assign IP Addresses
We need to install the Internet stack and then allocate an IP addresses:
InternetStackHelper stack;
stack.Install(busNodes);
stack.Install(star1Nodes);
stack.Install(star2Nodes);
Ipv4AddressHelper address;
Ipv4InterfaceContainer interfaces;
// Bus IP addresses
address.SetBase(“192.168.1.0”, “255.255.255.0”);
interfaces = address.Assign(busDevices);
// Star segment 1 IP addresses
address.SetBase(“192.168.2.0”, “255.255.255.0”);
interfaces = address.Assign(star1Devices);
// Star segment 2 IP addresses
address.SetBase(“192.168.3.0”, “255.255.255.0”);
interfaces = address.Assign(star2Devices);
// Connections between stars and bus
address.SetBase(“192.168.4.0”, “255.255.255.0”);
interfaces = address.Assign(connectionDevices);
- Configure Communication
Server Application
In the bus topology, we set up a UDP Echo Server at one of the nodes:
UdpEchoServerHelper echoServer(9); // Server listens on port 9
ApplicationContainer serverApps = echoServer.Install(busNodes.Get(2)); // Node 2 in the bus
serverApps.Start(Seconds(1.0));
serverApps.Stop(Seconds(10.0));
Client Applications
Interact with the server, we require installing the UDP Echo Clients at nodes within the star segments:
UdpEchoClientHelper echoClient(Ipv4Address(“192.168.1.3”), 9); // Server’s IP address
echoClient.SetAttribute(“MaxPackets”, UintegerValue(5));
echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0))); // 1-second intervals
echoClient.SetAttribute(“PacketSize”, UintegerValue(1024)); // 1 KB packets
// Star segment 1 clients
for (uint32_t i = 1; i < star1Nodes.GetN(); ++i) {
ApplicationContainer clientApps = echoClient.Install(star1Nodes.Get(i));
clientApps.Start(Seconds(2.0 + i));
clientApps.Stop(Seconds(10.0));
}
// Star segment 2 clients
for (uint32_t i = 1; i < star2Nodes.GetN(); ++i) {
ApplicationContainer clientApps = echoClient.Install(star2Nodes.Get(i));
clientApps.Start(Seconds(2.0 + i));
clientApps.Stop(Seconds(10.0));
}
- Enable Packet Capture
Allow .pcap tracing for packet-level inspection:
csma.EnablePcapAll(“bus-star-hybrid-topology”);
p2p.EnablePcapAll(“bus-star-hybrid-topology”);
- Run the Simulation
Construct the script and also run the simulation:
./waf –run bus-star-hybrid-topology
- Complete Code Skeleton
Below is a comprehensive NS3 script:
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/internet-module.h”
#include “ns3/csma-module.h”
#include “ns3/point-to-point-module.h”
#include “ns3/applications-module.h”
using namespace ns3;
int main(int argc, char *argv[]) {
// Create nodes
NodeContainer busNodes, star1Nodes, star2Nodes;
busNodes.Create(3);
star1Nodes.Create(4);
star2Nodes.Create(4);
// Configure bus backbone
CsmaHelper csma;
csma.SetChannelAttribute(“DataRate”, StringValue(“100Mbps”));
csma.SetChannelAttribute(“Delay”, TimeValue(NanoSeconds(6560)));
NetDeviceContainer busDevices = csma.Install(busNodes);
// Configure star segments
PointToPointHelper p2p;
p2p.SetDeviceAttribute(“DataRate”, StringValue(“10Mbps”));
p2p.SetChannelAttribute(“Delay”, StringValue(“2ms”));
NetDeviceContainer star1Devices, star2Devices;
for (uint32_t i = 1; i < star1Nodes.GetN(); ++i) {
star1Devices.Add(p2p.Install(star1Nodes.Get(0), star1Nodes.Get(i)));
}
for (uint32_t i = 1; i < star2Nodes.GetN(); ++i) {
star2Devices.Add(p2p.Install(star2Nodes.Get(0), star2Nodes.Get(i)));
}
// Connect star hubs to bus backbone
NetDeviceContainer connectionDevices;
connectionDevices.Add(p2p.Install(busNodes.Get(0), star1Nodes.Get(0)));
connectionDevices.Add(p2p.Install(busNodes.Get(1), star2Nodes.Get(0)));
// Install Internet stack
InternetStackHelper stack;
stack.Install(busNodes);
stack.Install(star1Nodes);
stack.Install(star2Nodes);
// Assign IP addresses
Ipv4AddressHelper address;
address.SetBase(“192.168.1.0”, “255.255.255.0”);
address.Assign(busDevices);
address.SetBase(“192.168.2.0”, “255.255.255.0”);
address.Assign(star1Devices);
address.SetBase(“192.168.3.0”, “255.255.255.0”);
address.Assign(star2Devices);
address.SetBase(“192.168.4.0”, “255.255.255.0”);
address.Assign(connectionDevices);
// Set up server
UdpEchoServerHelper echoServer(9);
ApplicationContainer serverApps = echoServer.Install(busNodes.Get(2));
serverApps.Start(Seconds(1.0));
serverApps.Stop(Seconds(10.0));
// Set up clients
UdpEchoClientHelper echoClient(Ipv4Address(“192.168.1.3”), 9);
echoClient.SetAttribute(“MaxPackets”, UintegerValue(5));
echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0)));
echoClient.SetAttribute(“PacketSize”, UintegerValue(1024));
for (uint32_t i = 1; i < star1Nodes.GetN(); ++i) {
ApplicationContainer clientApps = echoClient.Install(star1Nodes.Get(i));
clientApps.Start(Seconds(2.0 + i));
clientApps.Stop(Seconds(10.0));
}
for (uint32_t i = 1; i < star2Nodes.GetN(); ++i) {
ApplicationContainer clientApps = echoClient.Install(star2Nodes.Get(i));
clientApps.Start(Seconds(2.0 + i));
clientApps.Stop(Seconds(10.0));
}
// Enable tracing
csma.EnablePcapAll(“bus-star-hybrid-topology”);
p2p.EnablePcapAll(“bus-star-hybrid-topology”);
// Run simulation
Simulator::Run();
Simulator::Destroy();
return 0;
}
- Extend the Simulation
- Increase Complexity: Integrate additional bus or star segments.
- Analyze Performance: Estimate the performance metrics such as throughput, latency, and packet loss.
- Simulate Failures: Detach nodes or links to learn about the network resilience.
We illustrated the basic methodology using example code for Bus Star Hybrid Topology that were implemented and analyzed in NS3 simulation tool, with further details to be offered in another manual.
