How to Start Extended Star Topology Projects Using NS2
To start replicating an Extended Star Topology in NS2 (Network Simulator 2), we can make a hierarchical structure including a central node that are associated to other sub-central nodes, each node links to further nodes. This topology integrates the star and hierarchical topologies’ benefits, to create it which is appropriate for scenarios such as data centers or enterprise networks.
Below is a detailed mechanism to get start the Extended Star Topology project in NS2:
Steps to Start Extended Star Topology in NS2
- Understand Extended Star Topology
- Structure:
- A central node (main hub) associates to several sub-central nodes.
- Every single sub-central node links to more leaf nodes.
- Applications:
- It is appropriate for hierarchical networks such as data centers or organizational networks.
- Enables centralized management including the decentralized interaction.
- Set Up NS2
- Install NS2:
sudo apt-get install ns2
- Verify Installation: Confirm installation including an example simulation script:
ns example.tcl
- Define Extended Star Topology
- Make topology with nodes for the central hub, sub-central nodes, and leaf nodes.
- Associate the central hub to sub-central nodes.
- Link sub-central nodes to leaf nodes.
- TCL Script for Extended Star Topology
Here’s a sample script for replicating an Extended Star Topology:
TCL Script Example
# Initialize NS2 Simulator
set ns [new Simulator]
set tracefile [open extended_star_topology.tr w]
$ns trace-all $tracefile
# Create central hub node
set central_hub [$ns node]
# Create sub-central nodes
set sub_central1 [$ns node]
set sub_central2 [$ns node]
# Create leaf nodes for sub-central1
set leaf1_1 [$ns node]
set leaf1_2 [$ns node]
# Create leaf nodes for sub-central2
set leaf2_1 [$ns node]
set leaf2_2 [$ns node]
# Connect central hub to sub-central nodes
$ns duplex-link $central_hub $sub_central1 1Mb 10ms DropTail
$ns duplex-link $central_hub $sub_central2 1Mb 10ms DropTail
# Connect sub-central1 to its leaf nodes
$ns duplex-link $sub_central1 $leaf1_1 512Kb 20ms DropTail
$ns duplex-link $sub_central1 $leaf1_2 512Kb 20ms DropTail
# Connect sub-central2 to its leaf nodes
$ns duplex-link $sub_central2 $leaf2_1 512Kb 20ms DropTail
$ns duplex-link $sub_central2 $leaf2_2 512Kb 20ms DropTail
# Attach agents for traffic simulation
# Traffic from central hub to leaf2_1
set tcp0 [new Agent/TCP]
$ns attach-agent $central_hub $tcp0
set sink0 [new Agent/TCPSink]
$ns attach-agent $leaf2_1 $sink0
$ns connect $tcp0 $sink0
# Traffic from leaf1_2 to central hub
set udp0 [new Agent/UDP]
$ns attach-agent $leaf1_2 $udp0
set null0 [new Agent/Null]
$ns attach-agent $central_hub $null0
$ns connect $udp0 $null0
# Add traffic generators
set ftp [new Application/FTP]
$ftp attach-agent $tcp0
set cbr [new Application/Traffic/CBR]
$cbr set packetSize_ 512
$cbr set interval_ 0.1
$cbr attach-agent $udp0
# Start traffic
$ns at 1.0 “$ftp start”
$ns at 1.5 “$cbr start”
# End simulation
$ns at 5.0 “finish”
proc finish {} {
global ns tracefile
$ns flush-trace
close $tracefile
exit 0
}
$ns run
- Key Features to Simulate
- Traffic Flow:
- Make sure that data flows traffic from the central hub to sub-central nodes with leaf nodes.
- Performance Metrics:
- Throughput: We can estimate the data delivery on leaf nodes.
- Latency: Examine delays among the central hub, sub-central nodes, and leaf nodes.
- Packet Loss: Measure the reliability of packet drop.
- Analyze Trace File
- We will want to utilise the trace file as extended_star_topology.tr for analysis.
- Obtain certain parameters:
- Throughput:
grep “tcp” extended_star_topology.tr > throughput.log
-
- Dropped Packets:
grep “drop” extended_star_topology.tr > dropped_packets.log
- Visualize Results
For envisioning the metrics, we can utilise tools like Gnuplot or another graphing tool:
- Throughput Graph:
set title “Extended Star Topology Throughput”
plot “throughput.log” using 1:2 with lines title “Throughput”
- Latency Graph:
- We need to equate the delays for traffic among diverse hierarchy stages.
- Extend the Simulation
- Simulate Bi-Directional Communication
- Connect the agents to sub-central or leaf nodes for bidirectional communication traffic:
set tcp1 [new Agent/TCP]
$ns attach-agent $leaf2_2 $tcp1
set sink1 [new Agent/TCPSink]
$ns attach-agent $central_hub $sink1
$ns connect $tcp1 $sink1
- Simulate Fault Tolerance
- Replicate the link or node failures for monitoring the rerouting or interaction effect:
$ns at 2.5 “$ns reset-links $central_hub $sub_central1”
- Experiment with Traffic Patterns
- We should integrate additional traffic sources and sinks to experiment the scalability.
- QoS Simulation
- Launch delay-sensitive traffic and then we learn the quality of service (QoS) for simulation.
- Modify NS2 Core for Advanced Features
For further functionality, we can alter:
- Dynamic Topology:
- During the simulation, we will dynamically integrate or eliminate the sub-central or leaf nodes.
$ns at 3.0 “$ns duplex-link $sub_central2 $leaf2_3 512Kb 20ms DropTail”
- Custom Traffic Handling:
- Alter packet forwarding or prioritization logic using the recv() mechanism for certain nodes.
In this demonstration, we had delivered the simulation process regarding the Extended Star Topology Projects that were replicated and extended by NS2 simulation tool. We will give further insights on this topic as required.