How to Start Star Topology Projects Using NS2
To start a Star Topology project using NS2 (Network Simulator 2) it has configuring a network in which a central node directly associated to numerous peripheral nodes, which is normally utilised within wireless and sensor networks. Below is a step-by-step guide on how to configure and execute Star Topology project in NS2:
Steps to Start Star Topology Project in NS2
- Understand Star Topology
- Star Topology:
- Central node (hub) associates to numerous peripheral nodes.
- Peripheral nodes interact via central node.
- It is frequently utilised in IoT networks, wireless sensor networks, and basic LAN configurations.
- Advantages:
- It is very simple to set up and handle.
- Fault in peripheral nodes are doesn’t impact the complete network.
- Disadvantages:
- Central node breakdown interrupts the entire network.
- Set Up NS2
- Install NS2:
- We can install and set up NS2 environment on the machine.
- Confirm installation including a simple example TCL simulation script:
ns example.tcl
- Required Tools:
- Trace Analysis: Make use of tools such as AWK to examine the output.
- NAM: Network Animator for envisioning the Star Topology.
- Design the Star Topology
- Components:
- Peripheral Nodes (spokes).
- Central Node (hub).
- Communication connections among the central node and peripherals.
- Write the Simulation Script
Step 4.1: Create a TCL Script
We can start to make a tcl file as star_topology.tcl in NS2.
Step 4.2: Define Simulator and Variables
- Set the simulator and trace file:
set ns [new Simulator]
set tracefile [open trace.tr w]
$ns trace-all $tracefile
set namfile [open star_topology.nam w]
$ns namtrace-all $namfile
Step 4.3: Create Nodes
- Describe the central node and peripheral nodes:
# Create central node
set hub [$ns node]
# Create peripheral nodes
set node1 [$ns node]
set node2 [$ns node]
set node3 [$ns node]
set node4 [$ns node]
set node5 [$ns node]
Step 4.4: Configure Links
- Associate the peripheral nodes to the hub:
$ns duplex-link $hub $node1 1Mb 10ms DropTail
$ns duplex-link $hub $node2 1Mb 10ms DropTail
$ns duplex-link $hub $node3 1Mb 10ms DropTail
$ns duplex-link $hub $node4 1Mb 10ms DropTail
$ns duplex-link $hub $node5 1Mb 10ms DropTail
Step 4.5: Setup Traffic
- Describe traffic among the hub and peripheral nodes:
# Traffic from node1 to hub
set udp1 [new Agent/UDP]
$ns attach-agent $node1 $udp1
set null1 [new Agent/Null]
$ns attach-agent $hub $null1
$ns connect $udp1 $null1
# Application on UDP
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
$cbr1 set packetSize_ 512
$cbr1 set rate_ 100kb
$ns at 1.0 “$cbr1 start”
$ns at 5.0 “$cbr1 stop”
We need to reiterate the same traffic sets up for other nodes.
Step 4.6: Finish the Script
- We will want to specify the simulation end and visualization configuration to finalize the script:
$ns at 6.0 “finish”
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam star_topology.nam &
exit 0
}
$ns run
- Run the Simulation
- We must store the TCL simulation script and then run the simulation with NS2:
ns star_topology.tcl
- Go to NAM for envisioning the network:
nam star_topology.nam
- Analyze Results
- Trace File Analysis:
- Examine performance parameters such as throughput, delay, and packet delivery ratio utilising trace.tr.
- Example AWK script for estimating the throughput:
awk ‘{if ($1 == “r” && $4 == “tcp”) sum += $8} END {print “Throughput: “, sum}’
- Performance Metrics:
- Assess performance parameters such as network latency and packet loss.
- Expand the Simulation
- Add Failure Scenarios:
- Replicate central node failure and then monitor the effect.
- Example:
$ns at 3.0 “$hub down”
- Introduce Routing Protocols:
- Make use of dynamic routing protocols such as AODV for wireless scenarios.
- Vary Traffic:
- Integrate various traffic models like TCP, FTP.
- Document the Project
- Objective: Define the purpose of replicating a Star Topology network.
- Setup: Demonstrate nodes, links, and traffic sets up.
- Results: It provides graphs and parameters in terms of throughput, latency.
- Conclusions: Sum up outcomes and insights.
We had shown fundamental method with example coding to start and replicate the Star Topology Projects through NS2 tools. More specifics on this subject will be added in future.