How to Implement Network on Chip NoC Topology in NS2

To implement a Network on Chip (NoC) topology in Network Simulator 2 (NS2) has needs to configure a grid or mesh-based topology that is the most common structure for NoC systems. A NoC topology usually interconnects numerous processing elements (PEs) in a grid, in which each node interacts with its neighbours using routers. Share with us all your project details we guide you in performance analysis. Get implementation support from us.  The communication among the nodes is mimicked using wired or wireless links. The below is the detailed procedure to implement the NoC topology in ns2:

Steps for Implementing NoC Topology in NS2

  1. Set up NS2

Make sure we have NS2 installed on system. we can install it on Linux/Ubuntu systems with:

sudo apt-get update

sudo apt-get install ns2

  1. NoC Topology Design

The most common NoC topologies include:

  • Mesh Topology: Nodes are arranged in a 2D grid.
  • Torus Topology: A mesh in which the edges wrap around.
  • Star Topology: All nodes interconnect to a central node (less common for NoC).

We will concentrate on mesh topology that is widely used in NoC systems.

  1. Define Nodes and Links for Mesh Topology

The nodes in a mesh topology denote processing elements or routers. Each node is associated to its adjacent nodes (north, south, east, west). The link among the nodes mimics the data transfer among the processing elements.

  1. Create the TCL Script for NoC

Below is a sample TCL script to execute a simple 2D mesh NoC topology:

Example TCL Script for 2D Mesh NoC Topology:

# Define the simulator

set ns [new Simulator]

# Open trace files

set tracefile [open noc_out.tr w]

set namfile [open noc_out.nam w]

$ns trace-all $tracefile

$ns namtrace-all $namfile

# Create the topography object for the NoC nodes

set topo [new Topography]

$topo load_flatgrid 500 500

# Define the channel for wired links

set chan [new Channel/WirelessChannel]

# Define NoC size (NxN mesh)

set N 3 ;# 3×3 mesh NoC, adjust for larger grids

# Create a 2D array of nodes to represent NoC processing elements (PEs)

for {set i 0} {$i < $N} {incr i} {

for {set j 0} {$j < $N} {incr j} {

set node_($i,$j) [$ns node]

$node_($i,$j) set X_ [expr $i * 100]

$node_($i,$j) set Y_ [expr $j * 100]

$node_($i,$j) set Z_ 0.0

}

}

# Connect the nodes in a mesh topology

# Each node connects to its north, south, east, and west neighbors

for {set i 0} {$i < $N} {incr i} {

for {set j 0} {$j < $N} {incr j} {

# Connect to the east neighbor

if {$i < [expr $N – 1]} {

$ns duplex-link $node_($i,$j) $node_([expr $i+1],$j) 100Mb 1ms DropTail

}

# Connect to the south neighbor

if {$j < [expr $N – 1]} {

$ns duplex-link $node_($i,$j) $node_($i,[expr $j+1]) 100Mb 1ms DropTail

}

}

}

# Set up traffic between nodes

# Traffic from node (0,0) to node (2,2)

set udp0 [new Agent/UDP]

set null0 [new Agent/Null]

$ns attach-agent $node_(0,0) $udp0

$ns attach-agent $node_(2,2) $null0

$ns connect $udp0 $null0

set cbr0 [new Application/Traffic/CBR]

$cbr0 set packetSize_ 512

$cbr0 set interval_ 0.01

$cbr0 attach-agent $udp0

# Start traffic at time 1.0 seconds

$ns at 1.0 “$cbr0 start”

# Stop simulation at 10 seconds

$ns at 10.0 “finish”

# Finish procedure

proc finish {} {

global ns tracefile namfile

$ns flush-trace

close $tracefile

close $namfile

exec nam noc_out.nam &

exit 0

}

# Run the simulation

$ns run

Key Elements of the Script:

  1. Mesh Topology:
    • The script generated a 3×3 mesh topology (adjustable by modifying the value of N).
    • Each node is associated to its neighboring nodes (north, south, east, west) using duplex links.
  2. Node Coordinates:
    • Each node in the 2D array is given a distinct position using the set X_ and set Y_ commands. These positions are spaced by 100 units for visual clarity in NAM.
  3. Link Parameters:
    • The links among the nodes are configured with a bandwidth of 100Mb and a delay of 1ms (typical NoC parameters can be adjusted as needed).
  4. Traffic Setup:
    • A UDP agent is attached to one of the nodes (node_(0,0)) and delivers traffic to another node (node_(2,2)).
    • The CBR (Constant Bit Rate) application creates traffic that initiates at time 1.0 seconds.
  5. Simulation Output:
    • The replication creates output trace (noc_out.tr) and NAM files (noc_out.nam) for analysis.
    • The final procedure flushes the trace files and opens the NAM animator.
  1. Run the Simulation

Save the script as noc_mesh.tcl and execute it in NS2:

ns noc_mesh.tcl

We can envision the topology using NAM (Network Animator):

nam noc_out.nam

Customization:

  1. Mesh Size: Adjust the value of N to generate larger or smaller mesh topologies.
  2. Torus Topology: We can adapt the script to generate a torus topology by connecting the edge nodes of the mesh to wrap around.
  3. Traffic: We can add multiple traffic flows among diverse nodes by attaching more traffic agents and applications.
  4. Link Parameters: varying the bandwidth, delay, and packet size to fit the NoC features that want to simulate.
  5. Routing Algorithms: If we need to mimic the particular NoC routing techniques like XY routing, we can adjust the way packets are forwarded among nodes in the simulation.

We had unambiguously accumulated and presented the steps that are vital while implementing the Network on Chip (NoC) topology in the ns2 environment. You can go through the provided samples and customization for future enhancement.