How to Start Bus Star Hybrid Topology Projects Using NS2
To start a Bus-Star Hybrid Topology project using Network Simulator 2 (NS2) encompasses to integrate the bus topology’s features which every device are associated to a general backbone and a star topology that centralized hub to link the devices. This hybrid topology is appropriate for LANs and IoT systems including centralized hubs for certain sub-networks. Below is a simple guide to configure and replicate Bus-Star Hybrid Topology project in NS2:
Steps to Start Bus-Star Hybrid Topology Projects in NS2
- Understand Bus-Star Hybrid Topology
- Bus-Star Hybrid Topology:
- It integrates a bus backbone to associating star networks.
- Every single star network contains a central hub or switch to link the nodes.
- Applications:
- LAN extensions.
- IoT systems with centralized hubs.
- Office networks.
- Key Features:
- High scalability and fault isolation.
- Centralized management for each star.
- Set Up NS2
- Install NS2:
- We can install and confirm the NS2 functionality:
ns example.tcl
- Tools for Analysis:
- NAM (Network Animator) is utilised for topology visualization.
- Trace Analysis Tools helps to estimate the parameters such as latency, throughput, and packet delivery ratio (PDR).
- Plan the Bus-Star Hybrid Topology
- Network Design:
- A bus backbone connecting several star networks.
- Every single star network includes a central hub and linked nodes.
- Metrics to Analyze:
- Latency.
- Packet delivery ratio (PDR).
- Throughput.
- Write the Simulation Script
Step 4.1: Create the TCL Script
We can store the tcl script like bus_star_hybrid_topology.tcl using NS2.
Step 4.2: Initialize the Simulator
Configure the simulator:
# Initialize the simulator
set ns [new Simulator]
set tracefile [open trace.tr w]
$ns trace-all $tracefile
set namfile [open bus_star_hybrid_topology.nam w]
$ns namtrace-all $namfile
Step 4.3: Create Nodes
We need to describe the backbone nodes and star hubs:
# Backbone nodes
set bus1 [$ns node]
set bus2 [$ns node]
set bus3 [$ns node]
# Star network hubs
set hub1 [$ns node]
set hub2 [$ns node]
set hub3 [$ns node]
# Nodes in star networks
set node1_1 [$ns node]
set node1_2 [$ns node]
set node1_3 [$ns node]
set node2_1 [$ns node]
set node2_2 [$ns node]
set node2_3 [$ns node]
set node3_1 [$ns node]
set node3_2 [$ns node]
set node3_3 [$ns node]
Step 4.4: Configure Links
Associate hubs to the bus and link the nodes to hubs:
# Bus backbone links
$ns duplex-link $bus1 $bus2 1Gb 10ms DropTail
$ns duplex-link $bus2 $bus3 1Gb 10ms DropTail
# Hubs to bus links
$ns duplex-link $hub1 $bus1 100Mb 5ms DropTail
$ns duplex-link $hub2 $bus2 100Mb 5ms DropTail
$ns duplex-link $hub3 $bus3 100Mb 5ms DropTail
# Nodes to hub1 (Star 1)
$ns duplex-link $node1_1 $hub1 10Mb 2ms DropTail
$ns duplex-link $node1_2 $hub1 10Mb 2ms DropTail
$ns duplex-link $node1_3 $hub1 10Mb 2ms DropTail
# Nodes to hub2 (Star 2)
$ns duplex-link $node2_1 $hub2 10Mb 2ms DropTail
$ns duplex-link $node2_2 $hub2 10Mb 2ms DropTail
$ns duplex-link $node2_3 $hub2 10Mb 2ms DropTail
# Nodes to hub3 (Star 3)
$ns duplex-link $node3_1 $hub3 10Mb 2ms DropTail
$ns duplex-link $node3_2 $hub3 10Mb 2ms DropTail
$ns duplex-link $node3_3 $hub3 10Mb 2ms DropTail
Step 4.5: Configure Traffic
We will need to configure the traffic flows among nodes through diverse star networks:
# Traffic from node1_1 to node3_3
set udp1 [new Agent/UDP]
$ns attach-agent $node1_1 $udp1
set null1 [new Agent/Null]
$ns attach-agent $node3_3 $null1
$ns connect $udp1 $null1
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
$cbr1 set packetSize_ 512
$cbr1 set rate_ 50Mb
$ns at 1.0 “$cbr1 start”
# Traffic from node2_1 to node1_3
set udp2 [new Agent/UDP]
$ns attach-agent $node2_1 $udp2
set null2 [new Agent/Null]
$ns attach-agent $node1_3 $null2
$ns connect $udp2 $null2
set cbr2 [new Application/Traffic/CBR]
$cbr2 attach-agent $udp2
$cbr2 set packetSize_ 512
$cbr2 set rate_ 50Mb
$ns at 2.0 “$cbr2 start”
Step 4.6: Enable Routing Protocol
- Make use of a routing protocol like AODV for the network:
$ns rtproto AODV
Step 4.7: Finalize the Script
Integrate the simulation final conditions in the script:
# End simulation
$ns at 10.0 “finish”
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam bus_star_hybrid_topology.nam &
exit 0
}
$ns run
- Run the Simulation
- We want to store the script like bus_star_hybrid_topology.tcl.
- Then run the simulation using NS2:
ns bus_star_hybrid_topology.tcl
- Go to NAM for visualizing the topology:
nam bus_star_hybrid_topology.nam
- Analyze Results
- Trace File Analysis:
- Measure the simulation parameters such as throughput, latency, and PDR to leverage trace.tr for analysis.
- Example AWK script for throughput:
awk ‘{if ($1 == “r” && $4 == “udp”) sum += $8} END {print “Throughput: “, sum}’
- Metrics:
- Packet Delivery Ratio (PDR): Estimate the network reliability.
- Latency: Examine delays within interaction.
- Throughput: Measure the data delivery effectiveness.
- Expand the Simulation
- Increase Network Size:
- Integrate additional star networks and then prolong the bus backbone to maximize the size of network.
- Simulate Link Failures:
- Experiment the fault tolerance of network by inactivating links:
$ns at 5.0 “$ns link-fail $bus2 $bus3”
- Vary Traffic Patterns:
- Incorporate further diverse traffic flows or utilise the multicast/broadcast traffic.
- Test Different Routing Protocols:
- We can equate the performance of diverse routing protocols like DSR, DSDV, or other protocols.
- Document the Project
- Objective: Define the primary aim of the project that is replicating a bus-star hybrid topology.
- Setup: Specify the network structure, routing protocols, and traffic sets up.
- Results: It provides performance parameters such as throughput, latency, and PDR.
- Conclusions: Sum up outcomes and recommend optimizations.
In the above procedures is often support to simulate and analyze the Bus Star Hybrid Topology using sample coding in NS3 environment. We also provide additional information regarding this subject in other simulation scenarios.