To simulate Network on Chip (NoC) topologies in NS2 has includes to design a communication among the components on a chip using a structured network. NoC is a scalable response for on-chip communication in systems with multiple cores or handing out elements, that usually using mesh, torus, or other systematic topologies.
Since NS2 is usually utilized for replicating larger-scale networks, we can adjust it to mimic NoC-like behaviour by setting up the communication among numerous nodes demonstrating cores or processing variables on the chip. A common mesh topology is frequently utilized in NoC, in which each node (core) interacts with its neighbours, and routers are employed among the cores.
Steps to Simulate Network on Chip Topology Projects in NS2
Step 1: Understand NoC Topology
In a Network on Chip (NoC):
- Processing Elements (PE) or Cores are connected using a network structure, usual a mesh, torus, or other regular topologies.
- Routers are utilized to route packets among cores, and they associate to their neighbouring cores.
- Communication is usually packet-based, in which cores send and receive messages (data packets) via the routers.
Step 2: Design the NoC Topology
We will mimic 2D Mesh NoC Topology with a grid of cores and routers, on which:
- Each Processing Element (PE) interacts with its neighbors.
- Routers route packets among the cores according to their position in the mesh.
- Communication is introduced using custom links among the cores and routers.
Step 3: Create an NS2 TCL Script for Simulating a 2D Mesh NoC Topology
Below is a basic NS2 TCL script which replicates a 2D Mesh NoC Topology with communication among the cores using packet-based transmission.
Example: 2D Mesh NoC Topology Simulation in NS2
# Create a new NS2 simulator object
set ns [new Simulator]
# Set parameters for the NoC grid (2D Mesh)
set rows 3 ;# Number of rows in the mesh
set cols 3 ;# Number of columns in the mesh
set num_nodes [expr $rows * $cols] ;# Total number of nodes (PEs)
# Create a wireless channel to model NoC communication (can also use wired)
set chan [new Channel/WirelessChannel]
# Set the propagation model and network parameters (customize for NoC)
set opt(prop) Propagation/TwoRayGround
set opt(mac) Mac/802_11 ;# Custom MAC for NoC (approximation)
set opt(netif) Phy/WirelessPhy ;# Wireless Phy as an approximation for NoC Phy
set opt(ifq) Queue/DropTail/PriQueue
set opt(ant) Antenna/OmniAntenna
set opt(ll) LL
set opt(x) 300 ;# X dimension of the grid
set opt(y) 300 ;# Y dimension of the grid
# Create the topology object
set topo [new Topography]
$topo load_flatgrid $opt(x) $opt(y)
# Create God (General Operations Director) object for mobility
create-god $num_nodes
# Configure the nodes (representing cores or PEs)
$ns node-config -adhocRouting AODV \
-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
-ifqLen 50 \
-antType $opt(ant) \
-propType $opt(prop) \
-phyType $opt(netif) \
-channelType $opt(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON
# Create a 2D mesh topology for the NoC
set nodes {}
for {set i 0} {$i < $num_nodes} {incr i} {
set node [$ns node]
lappend nodes $node
}
# Position the nodes (cores) in a grid
for {set row 0} {$row < $rows} {incr row} {
for {set col 0} {$col < $cols} {incr col} {
set idx [expr $row * $cols + $col]
set node [lindex $nodes $idx]
set x_pos [expr $col * 100 + 50]
set y_pos [expr $row * 100 + 50]
$node set X_ $x_pos
$node set Y_ $y_pos
$node set Z_ 0.0
}
}
# Create links between neighboring nodes in the mesh
for {set row 0} {$row < $rows} {incr row} {
for {set col 0} {$col < $cols} {incr col} {
set idx [expr $row * $cols + $col]
set current_node [lindex $nodes $idx]
# Connect to the right neighbor
if { $col < [expr $cols – 1] } {
set right_idx [expr $row * $cols + $col + 1]
set right_node [lindex $nodes $right_idx]
$ns duplex-link $current_node $right_node 1Mb 10ms DropTail
}
# Connect to the bottom neighbor
if { $row < [expr $rows – 1] } {
set bottom_idx [expr ($row + 1) * $cols + $col]
set bottom_node [lindex $nodes $bottom_idx]
$ns duplex-link $current_node $bottom_node 1Mb 10ms DropTail
}
}
}
# Attach UDP agents to the nodes (cores) for communication
set udp_agents {}
for {set i 0} {$i < $num_nodes} {incr i} {
set udp [new Agent/UDP]
$ns attach-agent [lindex $nodes $i] $udp
lappend udp_agents $udp
}
# Create UDP traffic between the cores
set sinks {}
for {set i 0} {$i < $num_nodes} {incr i} {
set sink [new Agent/Null]
$ns attach-agent [lindex $nodes $i] $sink
lappend sinks $sink
}
# Create CBR traffic applications for communication between cores
for {set i 0} {$i < $num_nodes} {incr i} {
set cbr [new Application/Traffic/CBR]
$cbr set packetSize_ 100
$cbr set interval_ 0.1
$cbr attach-agent [lindex $udp_agents $i]
# Connect to a random sink in the grid for communication
set random_sink [lindex $sinks [expr ($i + 1) % $num_nodes]]
$ns connect [lindex $udp_agents $i] $random_sink
}
# Start the CBR traffic at different times to simulate NoC communication
for {set i 0} {$i < $num_nodes} {incr i} {
set start_time [expr $i * 0.5 + 1.0]
$ns at $start_time “[lindex $udp_agents $i] start”
}
# Trace file for recording the simulation events
set tracefile [open “noc_mesh.tr” w]
$ns trace-all $tracefile
# NAM file for network animation
set namfile [open “noc_mesh.nam” w]
$ns namtrace-all-wireless $namfile $opt(x) $opt(y)
# Define the finish procedure
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam noc_mesh.nam &
exit 0
}
# Finish the simulation after 10 seconds
$ns at 10.0 “finish”
# Run the simulation
$ns run
Step 4: Explanation of the Script
- Grid Setup:
- The script describes a 2D mesh topology with 3 rows and 3 columns, resultant in a grid of 9 nodes (cores or processing variables).
- Each core is located in a grid and associated to its right and bottom neighbours that construct a mesh structure.
- Communication Setup:
- UDP agents are attached to each core (node) to mimic packet-based communication among the cores.
- CBR (Constant Bit Rate) traffic is created among cores, and traffic flows among randomly chosen cores, replicating packet transfers in a NoC scenarios.
- Network Topology:
- The cores are associated by using duplex links with a bandwidth of 1Mb and a latency of 10ms.
- Communication flows are launched among neighbouring cores in the mesh, and the cores interact with each other through multi-hop paths.
- Tracing and Visualization:
- A trace file (noc_mesh.tr) logs all network events, like packet transmissions and receptions.
- A NAM file (noc_mesh.nam) is created to envision the 2D mesh NoC topology and the communication among the cores.
Step 5: Run the Simulation
- Save the script as noc_mesh.tcl.
- Execute the script in NS2:
ns noc_mesh.tcl
This will create two files:
- noc_mesh.tr: A trace files which logs packet-level information.
- noc_mesh.nam: A NAM file for envision the network behaviour using NAM.
Step 6: Visualize the Simulation Using NAM
To envision the NoC mesh topology in NAM:
nam noc_mesh.nam
In NAM, we will see:
- The 2D mesh NoC topology, in which each node interact with its neighbours.
- Packet transmission among cores (processing elements) as data is transmitted via the mesh.
Step 7: Analyse the Trace File
The trace file (noc_mesh.tr) encompasses detailed information about the following:
- Packet transmissions among cores.
- Packet drops or delays in communication.
We can utilize AWK, Python, or other tools to evaluate the trace file and extract significant parameters like:
- Packet delivery ratio (PDR).
- End-to-end delay.
- Throughput among cores.
Step 8: Enhance the Simulation
Here are some ways to expand or optimize the simulation:
- Introduce Traffic Patterns: mimic different traffic patterns such as hot-spot, random, or nearest-neighbor traffic to replicate realistic NoC workloads.
- Add Fault Tolerance: Establish node or link failures and monitor on how the network re-routes traffic in the presence of faults.
- Implement Routing Algorithms: Execute NoC-specific routing techniques like XY routing, to regulate on how packets are transmit via the mesh.
- Measure Performance Metrics: Evaluate NoC-specific parameters like latency, throughput, and network congestion, in different traffic loads.
- Energy-Aware Simulation: Incorporate energy replicas to mimic the power consumption of the cores and routers in the NoC.
We had explicit the information about the simulation process with examples regarding the Network-on-Chip that was executed using the tool of ns2 and also we provide the additional enhancement for this process. We plan to elaborate on the Network on Chip procedure in other simulation scenarios.
phdprime.com offer services for students and researchers of all ages. Our skilled team can help you create Network on Chip Topology Projects using the NS2 tool, and we work with different types of layouts like mesh, torus, and other organized topologies. If you need extra help, check out phdprime.com, where our experts are available to support you.