How to Implement Network Chip System in NS2

To implement the Network-on-Chip (NoC) system within NS2 (Network Simulator 2), which includes replicating communication among the processing elements (PEs) or cores within a chip via a network of routers and communication links. This systems are used in multi-core processors to permit effective communication among various cores or modules on the similar chip. However NS2 is usually used for external network simulation, we can adjust it to mimic NoC systems by signifying the routers, links, and communication traffic between the processing elements. Given below is a step-by-step process to executing a Network-on-Chip (NoC) system in NS2:

Step-by-Step Implementation:

  1. Define the NoC Topology

Initially, describe the NoC topology. A general topology in NoC systems is a 2D Mesh that routers are arranged in a grid, as well as each router is connected to these neighbouring routers (north, south, east, and west) and a processing element (PE).

Example Topology (2D Mesh):

For simplicity, we will replicate a 3×3 mesh topology in which each router is related to a PE, and the routers are connected in the grid-like structure.

  1. Set up the Simulation Environment

Primarily, configure the simple simulation environment in NS2 by describing the nodes (representing routers and processing elements), links (representing communication links between routers), and bandwidth/delay settings to mimic the NoC.

Example TCL Script for Basic Setup:

# Create a simulator instance

set ns [new Simulator]

# Set link parameters

set bw 100Mb         ;# Bandwidth of each link

set delay 1ms        ;# Delay for each link

# Define the grid size (for a 3×3 mesh)

set grid_size 3

# Create nodes for routers and PEs (9 routers, each connected to a PE in a 3×3 mesh)

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

set router_($i) [$ns node]    ;# Routers

set pe_($i) [$ns node]        ;# Processing elements (PEs)

}

  1. Define the Mesh Topology

The next stage is to connect the routers in a 2D mesh topology. Every single router is connected to its nearby routers (north, south, east, and west), and each router is connected to these respective processing element.

Example of Defining the Mesh Topology:

# Connect routers in a 3×3 mesh topology (north, south, east, west connections)

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

# Connect horizontally (east-west)

if { [expr $i % $grid_size] != [expr $grid_size – 1] } {

set j [expr $i + 1]

$ns duplex-link $router_($i) $router_($j) $bw $delay DropTail

}

# Connect vertically (north-south)

if { $i < [expr 9 – $grid_size] } {

set j [expr $i + $grid_size]

$ns duplex-link $router_($i) $router_($j) $bw $delay DropTail

}

}

# Connect each router to its corresponding PE

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

$ns duplex-link $router_($i) $pe_($i) $bw $delay DropTail

}

It makes a 3×3 mesh of routers that each router is connected to its vertical and horizontal neighbours, and also its corresponding processing element.

  1. Configure Processing Elements (PEs)

The processing elements (PEs) are make a traffic in the NoC by forwarding data to other PEs via the network. We can model each PE as a traffic source using UDP or TCP agents with CBR (Constant Bit Rate) traffic to replicate continuous data transfer among the PEs.

Example of Configuring Traffic Sources (PEs):

# Create UDP agents and attach them to PEs

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

set udp($i) [new Agent/UDP]

$ns attach-agent $pe_($i) $udp($i)

}

# Create CBR traffic to simulate data transfer from one PE to another

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

set cbr($i) [new Application/Traffic/CBR]

$cbr($i) set packet_size_ 128      ;# Packet size in bytes

$cbr($i) set rate_ 10Mb            ;# Data rate to simulate NoC traffic

$cbr($i) attach-agent $udp($i)

}

Each PE is set up to forward data to another PE. The CBR traffic models continuous communication among PEs in the NoC.

  1. Simulate Communication between PEs

To mimic communication among PEs, describe pairs of PEs, which exchange data. For specimen, PE 0 may send data to PE 8 via the router network.

Example of Configuring Communication between PEs:

# Create UDP sinks (receivers) at the destination PEs

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

set null($i) [new Agent/Null]

$ns attach-agent $pe_($i) $null($i)

}

# Connect source PEs to destination PEs through the NoC

# Example: PE at node 0 sends data to PE at node 8

$ns connect $udp(0) $null(8)

$ns connect $udp(1) $null(7)

$ns connect $udp(2) $null(6)

$ns connect $udp(3) $null(5)

$ns connect $udp(4) $null(4)

$ns connect $udp(5) $null(3)

$ns connect $udp(6) $null(2)

$ns connect $udp(7) $null(1)

$ns connect $udp(8) $null(0)

# Start the traffic at different times to simulate realistic NoC communication

$ns at 1.0 “$cbr(0) start”

$ns at 2.0 “$cbr(1) start”

$ns at 3.0 “$cbr(2) start”

$ns at 4.0 “$cbr(3) start”

$ns at 5.0 “$cbr(4) start”

$ns at 6.0 “$cbr(5) start”

$ns at 7.0 “$cbr(6) start”

$ns at 8.0 “$cbr(7) start”

$ns at 9.0 “$cbr(8) start”

In this instance, each PE communicates with another PE via the NoC, mimicking the data transfer among various cores within a chip.

  1. Monitor Network Performance

To investigate the NoC performance, permit tracing in NS2 to observe the packet transmissions, queue behaviour, packet drops, and delays within the network.

Enable Trace Files:

# Enable tracing

set tracefile [open “noc_trace.tr” w]

$ns trace-all $tracefile

# Finish procedure to end the simulation and close the trace file

proc finish {} {

global ns tracefile

$ns flush-trace

close $tracefile

exit 0

}

# Set simulation end time

$ns at 20.0 “finish”

The trace file will record events like packet transmissions, delays, and losses, permitting to examine the behaviour of the NoC.

  1. Run the Simulation

Lastly, run the simulation to monitor the communication in the NoC and estimate its performance.

# Run the simulation

$ns run

Example Complete TCL Script for NoC Simulation

# Create a simulator instance

set ns [new Simulator]

# Set link parameters

set bw 100Mb

set delay 1ms

# Define a 3×3 mesh topology (9 routers, each connected to a PE)

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

set router_($i) [$ns node]    ;# Routers

set pe_($i) [$ns node]        ;# Processing elements (PEs)

}

# Connect routers in a 3×3 mesh topology

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

if { [expr $i % 3] != 2 } {

set j [expr $i + 1]

$ns duplex-link $router_($i) $router_($j) $bw $delay DropTail

}

if { $i < 6 } {

set j [expr $i + 3]

$ns duplex-link $router_($i) $router_($j) $bw $delay DropTail

}

}

# Connect each router to its corresponding PE

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

$ns duplex-link $router_($i) $pe_($i) $bw $delay DropTail

}

# Set up UDP agents and CBR traffic for each PE

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

set udp($i) [new Agent/UDP]

$ns attach-agent $pe_($i) $udp($i)

set cbr($i) [new Application/Traffic/CBR]

$cbr($i) set packet_size_ 128

$cbr($i) set rate_ 10Mb

$cbr($i) attach-agent $udp($i)

}

# Create UDP sinks at destination PEs

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

set null($i) [new Agent/Null]

$ns attach-agent $pe_($i) $null($i)

}

# Connect source PEs to destination PEs

$ns connect $udp(0) $null(8)

$ns connect $udp(1) $null(7)

$ns connect $udp(2) $null(6)

$ns connect $udp(3) $null(5)

$ns connect $udp(4) $null(4)

$ns connect $udp(5) $null(3)

$ns connect $udp(6) $null(2)

$ns connect $udp(7) $null(1)

$ns connect $udp(8) $null(0)

# Start traffic at different times

$ns at 1.0 “$cbr(0) start”

$ns at 2.0 “$cbr(1) start”

$ns at 3.0 “$cbr(2) start”

$ns at 4.0 “$cbr(3) start”

$ns at 5.0 “$cbr(4) start”

$ns at 6.0 “$cbr(5) start”

$ns at 7.0 “$cbr(6) start”

$ns at 8.0 “$cbr(7) start”

$ns at 9.0 “$cbr(8) start”

# Enable tracing

set tracefile [open “noc_trace.tr” w]

$ns trace-all $tracefile

# End simulation

$ns at 20.0 “finish”

proc finish {} {

global ns tracefile

$ns flush-trace

close $tracefile

exit 0

}

# Run the simulation

$ns run

In conclusion, you clearly understand on how to define the mesh and NoC topology, and how to implement and examine the Network Chip System in NS2 using the above methods. Furthermore, we will be delivered additional informations on this topic as per your needs.  When it comes to your projects, we prioritize the latest research methods to ensure optimal results. Reach out to ns2project.com for top-notch Network Chip System implementation using the ns2 tool, where we share the best outcomes tailored to your needs. Our developers are here to provide excellent project support, focusing on external network simulation based on your specific project requirements. Let us help you discover the best topics and ideas!