How to Start Hierarchical Star Topology Projects Using NS2
To stimulate a Hierarchical Star Topology in NS2 (Network Simulator 2) has been includes their build a central “hub” node which handle the several sub-centers, by every sub-center has linked to the several leaf nodes. This topology is used for the network designing architecture such as data centres or network transmission through several levels for hierarchy.
Here’s how to start your Hierarchical Star Topology project in NS2:
Steps to Simulate Hierarchical Star Topology in NS2
- Understand Hierarchical Star Topology
- Structure:
- The central hubs are linked in several sub-centers for instance secondary hubs.
- Every sub-center is linked to several leaf nodes for sample workstations, devices.
- Hierarchy can have several levels: Hub → Sub-center → Leaf nodes.
- Applications:
- Data Centers: Topology has several racks and servers.
- Network Architectures: Multi-level communication networks have enterprises.
- Telecommunication: Networks by centralized management and distributed nodes.
- Set Up NS2
- Install NS2:
sudo apt-get install ns2
- Verify Installation: validate through a basic replication script:
ns example.tcl
- Define Hierarchical Star Topology
- Generate the central hub for sub-centers such as secondary hubs and leaf nodes.
- Link the nodes for star-like fashion in every sub-center.
- TCL Script for Hierarchical Star Topology
Under consider the TCL script for replicate a Hierarchical Star Topology:
TCL Script Example
# Initialize NS2 Simulator
set ns [new Simulator]
set tracefile [open hierarchical_star_topology.tr w]
$ns trace-all $tracefile
# Define the number of sub-centers and leaf nodes per sub-center
set num_sub_centers 2
set leaf_per_sub_center 3
# Create the central hub node
set hub [$ns node]
# Create sub-centers (secondary hubs) and leaf nodes
set sub_centers {}
# Create sub-centers and connect them to the central hub
for {set i 0} {$i < $num_sub_centers} {incr i} {
set sub_center($i) [$ns node]
$ns duplex-link $hub $sub_center($i) 1Mb 10ms DropTail
# Create leaf nodes for each sub-center and connect them
for {set j 0} {$j < $leaf_per_sub_center} {incr j} {
set leaf($i,$j) [$ns node]
$ns duplex-link $sub_center($i) $leaf($i,$j) 512Kb 20ms DropTail
}
}
# Attach agents for traffic simulation
# Example: Traffic from Leaf node 0,0 to Leaf node 1,2
set tcp0 [new Agent/TCP]
$ns attach-agent $leaf(0,0) $tcp0
set sink0 [new Agent/TCPSink]
$ns attach-agent $leaf(1,2) $sink0
$ns connect $tcp0 $sink0
# Add a traffic generator
set ftp [new Application/FTP]
$ftp attach-agent $tcp0
# Start traffic
$ns at 1.0 “$ftp 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:
- Assure the data flows by the hierarchical architecture: central hub → sub-centers → leaf nodes.
- Performance Metrics:
- Throughput: Calculate the data transfer rates among leaf nodes with sub-centers.
- Latency: Examine the delays for multi-hop communication.
- Packet Loss: Estimate the reliability and congestion network.
- Analyze Trace File
- Use the trace file such as hierarchical_star_topology.tr for complete analysis.
- Excerpt the detailed metrics:
- Throughput:
grep “tcp” hierarchical_star_topology.tr > throughput.log
-
- Dropped Packets:
grep “drop” hierarchical_star_topology.tr > dropped_packets.log
- Visualize Results
Use Gnuplot or another graphing tool:
- Throughput Graph:
set title “Hierarchical Star Topology Throughput”
plot “throughput.log” using 1:2 with lines title “Throughput”
- Latency Graph:
- It envision for the delays in congestion among the sub-centers and leaf nodes.
- Extend the Simulation
- Simulate Additional Traffic Flows
- Enhance the congestion flows among other leaf nodes in the similar or changed the sub-centers:
set tcp1 [new Agent/TCP]
$ns attach-agent $leaf(1,0) $tcp1
set sink1 [new Agent/TCPSink]
$ns attach-agent $leaf(0,2) $sink1
$ns connect $tcp1 $sink1
- Add More Sub-centers
- Establish the further sub-centers and leaf nodes:
set sub_center(2) [$ns node]
$ns duplex-link $hub $sub_center(2) 1Mb 10ms DropTail
for {set j 0} {$j < $leaf_per_sub_center} {incr j} {
set leaf(2,$j) [$ns node]
$ns duplex-link $sub_center(2) $leaf(2,$j) 512Kb 20ms DropTail
}
- Simulate Node Failures
- Validate the fault tolerance through replicating the node or connection failures:
$ns at 2.5 “$ns reset-links $sub_center(1) $leaf(1,2)”
- Experiment with Different Protocols
- It replicate the UDP or custom protocols for view the effect of topology.
set udp [new Agent/UDP]
$ns attach-agent $leaf(0,0) $udp
set null [new Agent/Null]
$ns attach-agent $leaf(1,1) $null
$ns connect $udp $null
- Modify NS2 Core for Advanced Features
- Custom Routing Protocols:
- Execute the detailed routing logic for maintain the congestion among sub-centers or sub-centers and leaf nodes.
- Traffic Shaping:
- Control the congestion flow for replicate the bandwidth constraints or prioritize some kinds of congestion.
In the entire page was successfully demonstrated the complete procedure to implement the hierarchical star topology that was executed using ns2 simulation tool. We will supply another manual to address your questions about this project.