How to Implement Star Bus Hybrid Topology in NS2
To implement a Star-Bus Hybrid Topology in Network Simulator 2 (NS2) has needs to integrate the features of both the star topology and the bus topology. In this hybrid topology:
- Star topology: Numerous nodes are associated to a central hub or switch.
- Bus topology: Multiple hubs or switches are interconnected through a common bus (shared backbone).
Steps to Implement Star-Bus Hybrid Topology in NS2
- Set up NS2
Make sure that NS2 is installed on system. If it is not installed, we can install it using the following command on Ubuntu/Linux:
sudo apt-get update
sudo apt-get install ns2
- Define the Star-Bus Hybrid Topology
In the Star-Bus Hybrid Topology:
- Star Topology: Multiple nodes are associated to a central hub or switch in each star network.
- Bus Topology: The hubs or switches from diverse star networks are interconnected via a bus or backbone.
- Create a TCL Script for Star-Bus Hybrid Topology
The given below is a sample of a TCL script to deploy a Star-Bus Hybrid Topology. In this sample, two star topologies are generated, and the central hubs of both star networks are associated through a bus (a shared link).
Example TCL Script for Star-Bus Hybrid Topology:
# Define the simulator
set ns [new Simulator]
# Open trace files
set tracefile [open star_bus_out.tr w]
set namfile [open star_bus_out.nam w]
$ns trace-all $tracefile
$ns namtrace-all $namfile
# Create a topography object for layout
set topo [new Topography]
$topo load_flatgrid 500 500
# Create a channel for wired links
set chan [new Channel/WiredChannel]
# Central hubs (representing star centers) for each star topology
set hub_0 [$ns node]
set hub_1 [$ns node]
# Define nodes for the first star topology connected to hub_0
set node_0 [$ns node]
set node_1 [$ns node]
set node_2 [$ns node]
# Define nodes for the second star topology connected to hub_1
set node_3 [$ns node]
set node_4 [$ns node]
set node_5 [$ns node]
# Position the hubs and nodes (for visualization in NAM)
$hub_0 set X_ 200.0
$hub_0 set Y_ 300.0
$hub_1 set X_ 400.0
$hub_1 set Y_ 300.0
# Position the nodes connected to hub_0 (first star topology)
$node_0 set X_ 150.0
$node_0 set Y_ 350.0
$node_1 set X_ 200.0
$node_1 set Y_ 250.0
$node_2 set X_ 250.0
$node_2 set Y_ 350.0
# Position the nodes connected to hub_1 (second star topology)
$node_3 set X_ 350.0
$node_3 set Y_ 350.0
$node_4 set X_ 400.0
$node_4 set Y_ 250.0
$node_5 set X_ 450.0
$node_5 set Y_ 350.0
# Create links for the first star topology (hub_0)
$ns duplex-link $hub_0 $node_0 100Mb 10ms DropTail
$ns duplex-link $hub_0 $node_1 100Mb 10ms DropTail
$ns duplex-link $hub_0 $node_2 100Mb 10ms DropTail
# Create links for the second star topology (hub_1)
$ns duplex-link $hub_1 $node_3 100Mb 10ms DropTail
$ns duplex-link $hub_1 $node_4 100Mb 10ms DropTail
$ns duplex-link $hub_1 $node_5 100Mb 10ms DropTail
# Create the bus (backbone) by connecting the hubs (hub_0 and hub_1)
# The bus is represented as a high-bandwidth link
$ns duplex-link $hub_0 $hub_1 1Gb 5ms DropTail
# Setup traffic flow between nodes in different star clusters
# Traffic from node_0 (in hub_0’s star) to node_5 (in hub_1’s star)
set udp0 [new Agent/UDP]
set null0 [new Agent/Null]
$ns attach-agent $node_0 $udp0
$ns attach-agent $node_5 $null0
$ns connect $udp0 $null0
# Create CBR (Constant Bit Rate) traffic
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 512
$cbr0 set interval_ 0.05
$cbr0 attach-agent $udp0
# Start traffic at time 1.0 second
$ns at 1.0 “$cbr0 start”
# Schedule simulation end
$ns at 10.0 “finish”
# Finish procedure to close the simulation
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam star_bus_out.nam &
exit 0
}
# Run the simulation
$ns run
Explanation of the Script:
- Star Topologies:
- Two star topologies are generated. In each star topology, multiple nodes are associated to a central hub.
- In the first star, nodes node_0, node_1, and node_2 are connected to hub_0.
- In the second star, nodes node_3, node_4, and node_5 are associated to hub_1.
- Bus Backbone:
- The two central hubs (hub_0 and hub_1) are associated through a high-speed link demonstrating a bus.
- The link among the hubs to mimic the shared backbone of the bus topology with a bandwidth of 1Gbps and a delay of 5ms.
- Traffic Flow:
- Traffic is created from node_0 (in the first star) to node_5 (in the second star).
- A UDP agent is used on the sending node (node_0), and a null agent is used on the receiving node (node_5).
- A CBR (Constant Bit Rate) traffic generator delivers data packets at regular intervals.
- Trace and NAM Visualization:
- The simulation creates trace files (star_bus_out.tr) and a NAM file (star_bus_out.nam). We can use NAM (Network Animator) to envision the network.
- Run the Simulation
Save the script as star_bus_hybrid.tcl and execute it in NS2:
ns star_bus_hybrid.tcl
To view the network using NAM, use:
nam star_bus_out.nam
Customization:
- Expanding the Topology:
- We can add more star topologies by generating additional hubs and associating them to the bus backbone.
- For instance, we could generate a third star topology by describing a hub_2 and associate more nodes to it, then connecting hub_2 to the bus.
- Traffic Flows:
- Configure extra traffic flows among diverse nodes via the star topologies. For instance, we can add traffic from node_1 (in the first star) to node_4 (in the second star).
- Link Parameters:
- Adjust the bandwidth and latency of the links to replicate diverse network conditions. For instance, modify the link among the hubs (bus) to mimic slower or faster data transfer rates.
In the end, we had explored the basic implementation process on how to execute the Star-Bus Hybrid Topology in ns2 tool. If you need additional information regarding the Star-Bus Hybrid Topology we will provide it too.
At ns2project.com, we offer professional assistance for implementing the Star Bus Hybrid Topology using the NS2 tool. Share your project details with us, and we’ll help you perform a complete comparison analysis. Get full support for your implementation needs.