How to Simulate Circular Topology Projects Using NS2

To simulate Circular Topology (ring topology) using ns2 has numerous steps to follow and usually it is a network configuration in which every node is attached to accurately two other nodes that construct a closed loop. Data transmit around the ring, and nodes interact by transmitting data to their adjacent neighbours up to it extents the destination.

phdprime.com will guide you to Simulate Circular Topology Projects Using NS2 tool. So if you are in search of good research guidance along with simulation assistance then you can rely on our experts.

Here’s how to simulate a Circular Topology in NS2:

Steps to Simulate Circular Topology Projects in NS2

  1. Set up NS2 Environment:

Make sure that NS2 is installed and configured properly on the system. We will compose a TCL script to describe and replicate the circular topology.

  1. Understanding Circular Topology:
  • In a Circular Topology, nodes are associated in a loop, implication that each node has two neighbours. Data transmit in a circular path from one node to another.
  • This topology deliver some level of redundancy, by way of data can travel in either direction from place to place the ring that rely on the techniques that were used.
  1. Create a TCL Script for Circular Topology:

Below is an instance of TCL script to mimic a Circular Topology with 5 nodes in NS2:

# Create a new simulator instance

set ns [new Simulator]

# Open a NAM trace file for visualization

set nf [open out.nam w]

$ns namtrace-all $nf

# Create nodes for the circular topology

set n0 [$ns node]

set n1 [$ns node]

set n2 [$ns node]

set n3 [$ns node]

set n4 [$ns node]

# Create duplex links between nodes to form a circular topology

$ns duplex-link $n0 $n1 10Mb 10ms DropTail

$ns duplex-link $n1 $n2 10Mb 10ms DropTail

$ns duplex-link $n2 $n3 10Mb 10ms DropTail

$ns duplex-link $n3 $n4 10Mb 10ms DropTail

$ns duplex-link $n4 $n0 10Mb 10ms DropTail  ;# Closing the ring

# Attach a UDP agent to the first node (n0)

set udp0 [new Agent/UDP]

$ns attach-agent $n0 $udp0

# Attach a Null agent (traffic sink) to the last node (n3)

set null0 [new Agent/Null]

$ns attach-agent $n3 $null0

# Connect the UDP agent to the Null agent (n0 to n3 via circular path)

$ns connect $udp0 $null0

# Create a Constant Bit Rate (CBR) traffic generator and attach it to the UDP agent

set cbr0 [new Application/Traffic/CBR]

$cbr0 attach-agent $udp0

$cbr0 set packetSize_ 512    ;# Packet size of 512 bytes

$cbr0 set rate_ 100Kb        ;# Data rate of 100Kb

# Schedule the CBR traffic to start and stop

$ns at 1.0 “$cbr0 start”

$ns at 5.0 “$cbr0 stop”

# End the simulation at 6 seconds

$ns at 6.0 “finish”

proc finish {} {

global ns nf

$ns flush-trace

close $nf

exec nam out.nam &

exit 0

}

# Run the simulation

$ns run

  1. Explanation of the Code:
  • Nodes: Five nodes (n0, n1, n2, n3, and n4) are generated to construct the circular topology.
  • Links: Duplex links are generated among each pair of successive nodes that construct a circular topology. The most recent link attached the node n4 back to node n0, carrying out the circle.
  • UDP Traffic: A UDP agent is connected to node n0, and a Null agent is attached to node n3 to obtain the traffic.
  • CBR Traffic: A Constant Bit Rate (CBR) traffic generator sends packets from n0 to n3 at a rate of 100Kb with packet sizes of 512 bytes.
  • Traffic Scheduling: The traffic starts at 1 second and stops at 5 seconds.
  • Simulation End: The replication terminates at 6 seconds, and the outcomes are saved in a .nam file for envisioned.
  1. Run the Simulation:
  1. Save the script as circular_topology.tcl.
  2. Open a terminal and navigate to the folder in which the script is saved.
  3. Execute the simulation using the following command:

ns circular_topology.tcl

  1. The simulation will create out.nam file that can be opened using Network Animator (NAM).
  1. Visualization in NAM:
  • Open the out.nam file in NAM to envision the circular topology. We have to see a closed loop of nodes, with traffic flowing from node n0 to node n3 via the circular network.
  1. Customization and Enhancements:
  • More Nodes: we can upsurge the amount of nodes by incorporating the additional nodes and associating them in a loop.
  • TCP Traffic: We can exchange the UDP agent with a TCP agent for reliable communication:

set tcp0 [new Agent/TCP]

$ns attach-agent $n0 $tcp0

set sink0 [new Agent/TCPSink]

$ns attach-agent $n3 $sink0

$ns connect $tcp0 $sink0

  • Traffic Flow in Both Directions: To mimic traffic flow in both directions around the circular topology, we can incorporate another traffic flow in the opposite direction:

set udp1 [new Agent/UDP]

$ns attach-agent $n3 $udp1

set null1 [new Agent/Null]

$ns attach-agent $n0 $null1

$ns connect $udp1 $null1

  • Performance Metrics: we can incorporate the trace files to evaluate key metrics like packet loss, delay, and throughput:

set tracefile [open trace.tr w]

$ns trace-all $tracefile

  1. Performance Analysis:

To evaluate the performance of the circular topology, we can:

  • Assess throughput to monitor the number of data successfully routed among nodes.
  • Evaluate latency (delay) as data transmit via the circular network.
  • Measure packet loss if the network experiences congestion or if the link capacity is surpassed.

Using ns2 tool, we illustrated the fundamental approach with the sample coding for Circular Topology project that were simulated and visualized the outcomes. We plan to deliver more information regarding the Circular Topology.

Opening Time

9:00am

Lunch Time

12:30pm

Break Time

4:00pm

Closing Time

6:30pm

  • award1
  • award2