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

How to Implement Network on Chip Topology in ns3

To implement a Network on Chip (NoC) topology in ns3, a network has to be created. In that network each node should represent a processing element or router within a chip.

Below given steps will guide on how to implement Network on Chip Topology in ns3.

Step-by-step to implement Network on chip topology in ns3

Step 1: Install ns-3

Make sure ns3 is installed on the system

Step 2: Create a New Simulation Script

Create a new C++ script for the simulation.

Step 3: Include Necessary Headers

In the script, include the necessary ns3 headers:

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

#include “ns3/mobility-module.h”

Step 4: Set Up the NoC Topology

Below an example given for setting up a simple 3×3 NoC mesh topology:

using namespace ns3;

 

NS_LOG_COMPONENT_DEFINE (“NoCTopology”);

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

{

// Configure command line parameters

CommandLine cmd;

cmd.Parse (argc, argv);

// Create nodes

NodeContainer nodes;

nodes.Create (9); // Create 9 nodes for the 3×3 mesh network

// Create point-to-point links to form a 3×3 mesh

PointToPointHelper pointToPoint;

pointToPoint.SetDeviceAttribute (“DataRate”, StringValue (“1Gbps”));

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

NetDeviceContainer devices;

Ipv4AddressHelper address;

Ipv4InterfaceContainer interfaces;

// Configure the links between the nodes

for (uint32_t i = 0; i < 3; ++i)

{

for (uint32_t j = 0; j < 3; ++j)

{

uint32_t nodeIndex = i * 3 + j;

// Connect to the right neighbor

if (j < 2)

{

NodeContainer pair (nodes.Get (nodeIndex), nodes.Get (nodeIndex + 1));

NetDeviceContainer devicePair = pointToPoint.Install (pair);

devices.Add (devicePair);

std::ostringstream subnet;

subnet << “10.1.” << nodeIndex << “.0”;

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

interfaces.Add (address.Assign (devicePair));

}

// Connect to the bottom neighbor

if (i < 2)

{

NodeContainer pair (nodes.Get (nodeIndex), nodes.Get (nodeIndex + 3));

NetDeviceContainer devicePair = pointToPoint.Install (pair);

devices.Add (devicePair);

 

std::ostringstream subnet;

subnet << “10.2.” << nodeIndex << “.0”;

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

interfaces.Add (address.Assign (devicePair));

}

}

}

// Install the internet stack

InternetStackHelper stack;

stack.Install (nodes);

// Set up mobility model (optional)

MobilityHelper mobility;

Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();

for (uint32_t i = 0; i < 3; ++i)

{

for (uint32_t j = 0; j < 3; ++j)

{

positionAlloc->Add (Vector (50.0 * j, 50.0 * i, 0.0));

}

}

mobility.SetPositionAllocator (positionAlloc);

mobility.SetMobilityModel (“ns3::ConstantPositionMobilityModel”);

mobility.Install (nodes);

// Set up applications (e.g., UDP echo server and client)

uint16_t port = 9; // Port number for applications

// Install UDP Echo Server on node 0

UdpEchoServerHelper echoServer (port);

ApplicationContainer serverApps = echoServer.Install (nodes.Get (0));

serverApps.Start (Seconds (1.0));

serverApps.Stop (Seconds (10.0));

// Install UDP Echo Clients on other nodes to communicate with node 0

for (uint32_t i = 1; i < nodes.GetN (); ++i)

{

UdpEchoClientHelper echoClient (interfaces.GetAddress (0), port);

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

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

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

ApplicationContainer clientApps = echoClient.Install (nodes.Get (i));

clientApps.Start (Seconds (2.0));

clientApps.Stop (Seconds (10.0));

}

// Run simulation

Simulator::Stop (Seconds (10.0));

Simulator::Run ();

Simulator::Destroy ();

return 0;

}

Step 5: Build and Run the Simulation

  1. Save the script as noc-topology.cc.
  2. Build the script using waf:

./waf configure –enable-examples

./waf build

  1. Run the simulation:

./waf –run scratch/noc-topology

Explanation of the Script

  • Node Creation: Creates nine nodes for a 3×3 mesh network.
  • Point-to-Point Links: Configures point-to-point links to form the mesh. Each node is connected to its right and bottom neighbors.
  • Internet Stack: Installs the internet stack on all nodes.
  • IP Addressing: Assigns IP addresses to each link using different subnets for right and bottom links.
  • Mobility Model: Sets the position of nodes in a grid layout using ListPositionAllocator and ConstantPositionMobilityModel.
  • Applications: Sets up a UDP echo server on node 0 and UDP echo clients on other nodes to demonstrate communication between nodes.

At last, the implementation process of Network on chip topology is successfully done by configuring point-to point link and using mobility model to set the position of the nodes in a grid layout.

Please provide us with the details of your criteria, and we will assist you in performing a comparison of networking Chip Topology in ns3.