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

How to Implement Extended Star Topology in ns3

To implement Extended Star Topology in ns3, we want to generate the network for star topology and that has a central hub, and these hubs are connected to form extended network.in star topologies multiple start topologies were interconnected with each other. Below is the procedure on how to setup a Star Topology in ns3.

Steps to Implement an Extended Star Topology in ns3

  1. Set Up the ns3 Environment:
    • Make sure ns3 is installed in the computer and configure it.
  2. Create the Nodes:
    • Create nodes to represent the hubs and the peripheral nodes for each star.
  3. Set Up the Point-to-Point Channels:
    • Use point-to-point helpers to connect each hub to its peripheral nodes and to connect the hubs to each other.
  4. Install Network Stack:
    • Install the internet stack on all nodes.
  5. Assign IP Addresses:
    • Assign IP addresses to the nodes connected by the point-to-point links.
  6. Set Up Applications:
    • Install applications to generate traffic and demonstrate communication between nodes.

Example Code

Here, we deliver the sample on how to create the basic extended star topology in ns3:

#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;

NS_LOG_COMPONENT_DEFINE (“ExtendedStarTopologyExample”);

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

{

CommandLine cmd;

cmd.Parse (argc, argv);

// Create nodes

NodeContainer hubs;

hubs.Create (2); // Two hub nodes

NodeContainer star1Nodes;

star1Nodes.Create (4); // Four peripheral nodes for the first star

NodeContainer star2Nodes;

star2Nodes.Create (4); // Four peripheral nodes for the second star

// Create point-to-point links

PointToPointHelper pointToPoint;

pointToPoint.SetDeviceAttribute (“DataRate”, StringValue (“100Mbps”));

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

InternetStackHelper stack;

stack.Install (hubs);

stack.Install (star1Nodes);

stack.Install (star2Nodes);

Ipv4AddressHelper address;

int subnet = 1;

// Connect first hub to its peripheral nodes

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

{

NetDeviceContainer link = pointToPoint.Install (NodeContainer (hubs.Get (0), star1Nodes.Get (i)));

std::ostringstream subnetStream;

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

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

address.Assign (link);

}

// Connect second hub to its peripheral nodes

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

{

NetDeviceContainer link = pointToPoint.Install (NodeContainer (hubs.Get (1), star2Nodes.Get (i)));

std::ostringstream subnetStream;

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

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

address.Assign (link);

}

// Connect the two hubs

NetDeviceContainer hubLink = pointToPoint.Install (NodeContainer (hubs.Get (0), hubs.Get (1)));

std::ostringstream subnetStream;

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

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

address.Assign (hubLink);

// Enable routing

Ipv4GlobalRoutingHelper::PopulateRoutingTables ();

// Create a UDP server on one of the peripheral nodes in the second star

UdpServerHelper udpServer (9);

ApplicationContainer serverApp = udpServer.Install (star2Nodes.Get (0));

serverApp.Start (Seconds (1.0));

serverApp.Stop (Seconds (10.0));

// Create a UDP client on one of the peripheral nodes in the first star

UdpClientHelper udpClient (address.NewAddress (), 9); // IP of the server node

udpClient.SetAttribute (“MaxPackets”, UintegerValue (320));

udpClient.SetAttribute (“Interval”, TimeValue (MilliSeconds (50)));

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

ApplicationContainer clientApp = udpClient.Install (star1Nodes.Get (0));

clientApp.Start (Seconds (2.0));

clientApp.Stop (Seconds (10.0));

// Enable packet capture

pointToPoint.EnablePcapAll (“extended-star-topology”);

// Enable logging

LogComponentEnable (“UdpClient”, LOG_LEVEL_INFO);

LogComponentEnable (“UdpServer”, LOG_LEVEL_INFO);

Simulator::Run ();

Simulator::Destroy ();

return 0;

}

Explanation

  1. Setup: The code sets up an extended star topology with two hubs and four peripheral nodes for each hub.
  2. Point-to-Point Links: Point-to-point links are created to connect each hub to its peripheral nodes and to connect the two hubs together. The data rate and delay are configured for the links.
  3. Network Stack: The internet stack is installed on all nodes.
  4. IP Addresses: IP addresses are assigned to the nodes connected by the point-to-point links.
  5. Applications: A UDP server is installed on one of the peripheral nodes in the second star, and a UDP client is installed on one of the peripheral nodes in the first star to generate traffic and demonstrate communication.
  6. Packet Capture: Packet capture is enabled for the point-to-point links to observe network traffic.
  7. Logging: Logging is enabled for the UDP client and server applications to provide detailed output during the simulation.

Running the Simulation

Compile and run the simulation using the following commands in your ns3 environment:

./waf configure

./waf build

./waf –run extended-star-topology-example

Replace extended-star-topology-example with the actual name of your script file.

We understand the star topology has always interconnected with multiple nodes and also we see how to implement the star topology in ns3 framework. We will give more details regarding to start topology.

Our developers ensures the best programming results for your project by implementing the Extended Star Topology in ns3 to generate the network. We create the network for star topology and central hub according to your project concept.