How to Start Circular Topology Projects Using NS2

To start a Circular Topology using Network Simulator 2 (NS2) comprise of organizing the nodes within a circular pattern in which each node is linked into two adjacent nodes. This kind of topology is also named as ring topology, which is frequently utilized within token-passing networks or simple fault-tolerant systems. Below is an in-depth simulation process to get started Circular Topology project in NS2:

Steps to Start Circular Topology Project in NS2

  1. Understand Circular Topology
  • Circular (Ring) Topology:
    • Every single node associates to two other nodes accurately, which are making a closed loop.
    • Interaction frequently flows within a unidirectional or bidirectional method.
  • Applications:
    • Small-scale IoT systems or control systems.
    • Token Ring Networks.
  1. Set Up NS2
  1. Install NS2:
    • We can set up NS2 and confirm functionality including a simple script:

ns example.tcl

  1. Required Tools:
    • NAM (Network Animator) tools which is designed for visualization.
    • Trace Analysis Tools supports to estimate the performance parameters.
  1. Plan the Circular Topology
  • Topology Structure:
    • Nodes make a closed loop, for instance Node 1 associates to Node 2, Node 2 links to Node 3, and the last node attaches again to Node 1.
  • Traffic Pattern:
    • Data flows over the ring within unidirectional or bidirectional mode.
  1. Write the Simulation Script

Step 4.1: Create the TCL Script

We need to store the tcl simulation script like circular_topology.tcl.

Step 4.2: Initialize the Simulator

Initially, we can describe the simulator and to allow tracing:

set ns [new Simulator]

set tracefile [open trace.tr w]

$ns trace-all $tracefile

set namfile [open circular_topology.nam w]

$ns namtrace-all $namfile

Step 4.3: Create Nodes

In the circular topology, we can make the nodes with NS2:

# Create nodes

set n1 [$ns node]

set n2 [$ns node]

set n3 [$ns node]

set n4 [$ns node]

set n5 [$ns node]

Step 4.4: Configure Links

Associate nodes, making a circular topology:

# Unidirectional circular links

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

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

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

$ns duplex-link $n4 $n5 1Mb 10ms DropTail

$ns duplex-link $n5 $n1 1Mb 10ms DropTail

Set up duplex links within both directions for bidirectional interaction:

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

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

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

$ns duplex-link $n5 $n4 1Mb 10ms DropTail

$ns duplex-link $n1 $n5 1Mb 10ms DropTail

Step 4.5: Setup Traffic

We will want to integrate the traffic flows among nodes:

# Traffic from n1 to n3

set udp1 [new Agent/UDP]

$ns attach-agent $n1 $udp1

set null1 [new Agent/Null]

$ns attach-agent $n3 $null1

$ns connect $udp1 $null1

set cbr1 [new Application/Traffic/CBR]

$cbr1 attach-agent $udp1

$cbr1 set packetSize_ 512

$cbr1 set rate_ 100kb

$ns at 1.0 “$cbr1 start”

# Traffic from n4 to n2

set udp2 [new Agent/UDP]

$ns attach-agent $n4 $udp2

set null2 [new Agent/Null]

$ns attach-agent $n2 $null2

$ns connect $udp2 $null2

set cbr2 [new Application/Traffic/CBR]

$cbr2 attach-agent $udp2

$cbr2 set packetSize_ 512

$cbr2 set rate_ 100kb

$ns at 2.0 “$cbr2 start”

Step 4.6: Add Routing Protocol

  • Make use of a dynamic routing protocol such as AODV:

$ns rtproto DV

Step 4.7: Finalize the Script

Integrate simulation conditions in the end of the script:

$ns at 10.0 “finish”

proc finish {} {

global ns tracefile namfile

$ns flush-trace

close $tracefile

close $namfile

exec nam circular_topology.nam &

exit 0

}

$ns run

  1. Run the Simulation
  1. We can store the tcl simulation script like circular_topology.tcl.
  2. Then execute the simulation with NS2:

ns circular_topology.tcl

  1. Go to the NAM file for envisioning the circular topology:

nam circular_topology.nam

  1. Analyze Results
  • Trace File Analysis:
    • Examine performance metrics like throughput, latency, and packet delivery ratio utilising trace.tr.
    • Example AWK script for throughput:

awk ‘{if ($1 == “r” && $4 == “udp”) sum += $8} END {print “Throughput: “, sum}’

  • Key Metrics:
    • Throughput: Compute the rate of data that are effectively distributed.
    • Latency: Estimate the delays within data delivery.
    • Packet Delivery Ratio (PDR): Measure the network’s reliability.
  1. Expand the Simulation
  1. Add Failure Scenarios:
    • Replicate a node or link failure for analysing the fault tolerance:

$ns at 5.0 “$ns link-fail $n3 $n4”

  1. Vary Traffic Patterns:
    • We may integrate the TCP or FTP traffic models for mimicking diverse applications:

set tcp [new Agent/TCP]

$ns attach-agent $n2 $tcp

  1. Increase Network Size:
    • Insert additional nodes to monitor the scalability as network size maximizes.
  2. Test Multicast Traffic:
    • Combine multicast flows to experiment the effectiveness of data delivery within the topology.
  1. Document the Project
  • Objective: Define the project’s objectives that replicating a circular topology.
  • Setup: It has specifics regarding the nodes, links, and traffic set up.
  • Results: It offers performance parameters and graphs for throughput, latency, and PDR.
  • Conclusions: Sum up explanations and recommend enhancements.

By following these procedures, you can start the simulation of Circular Topology Projects in NS2 and extend it to explore diverse simulation scenarios. If you need assistance with code implementation or other expansion, feel free to ask!