How to Start Star Bus Hybrid Topology Projects Using NS2

To start a Star-Bus Hybrid Topology using NS2 (Network Simulator 2), we need to integrate the Star Topology and Bus Topology to a single network. This hybrid topology permits to learn the networks in which a central hub (star) is linked into numerous devices (nodes), which are associated within a bus-like structure, to provide stimulating mixture of centralized control and linear interaction.

Below is an exhaustive procedure to get started with Star-Bus Hybrid Topology project in NS2:

Steps to Start Star-Bus Hybrid Topology in NS2

  1. Understand Star-Bus Hybrid Topology
  • Structure:
    • A central hub or switch/router links to numerous subnetworks like bus topology.
    • In the bus topology, every single subnet is a linear network in which devices are associated in a successive manner such as a bus.
    • The hub functions like a gateway to the external world per subnet.
  • Applications:
    • It directly support small to medium-sized LANs (Local Area Networks) in which central control is necessary, however the nodes require to be linearly associated.
    • Hybrid network topologies within multi-purpose interaction systems.
  1. Set Up NS2
  1. Install NS2:

sudo apt-get install ns2

  1. Verify Installation: Confirm the installation including a simple example simulation script:

ns example.tcl

  1. Define Star-Bus Hybrid Topology
  • Initially, we make a central hub (node).
  • Link numerous subnets to this central hub, every single subnet to be a bus topology.
  • Allocate the nodes in a linear method such as bus topology for each subnet.
  1. TCL Script for Star-Bus Hybrid Topology

Here’s a sample TCL script to replicate a Star-Bus Hybrid Topology:

TCL Script Example

# Initialize NS2 Simulator

set ns [new Simulator]

set tracefile [open star_bus_hybrid_topology.tr w]

$ns trace-all $tracefile

# Define the central hub (star topology) node

set hub [$ns node]

# Define the number of subnets and nodes per subnet

set num_subnets 2

set nodes_per_subnet 3

# Create subnets (bus topology)

for {set i 0} {$i < $num_subnets} {incr i} {

# Create a bus for each subnet (connected linearly)

set subnet($i) {}

for {set j 0} {$j < $nodes_per_subnet} {incr j} {

set node($i,$j) [$ns node]

lappend subnet($i) $node($i,$j)

# Connect nodes within the subnet in a bus topology

if {$j > 0} {

$ns duplex-link $node($i,[expr $j – 1]) $node($i,$j) 1Mb 10ms DropTail

}

}

# Connect the last node of the subnet to the hub

$ns duplex-link $node($i,[expr $nodes_per_subnet – 1]) $hub 1Mb 10ms DropTail

}

# Attach agents for traffic simulation

# Example: Traffic from a node in subnet 0 to a node in subnet 1 via the hub

set tcp0 [new Agent/TCP]

$ns attach-agent $node(0,0) $tcp0

set sink0 [new Agent/TCPSink]

$ns attach-agent $node(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

  1. Key Features to Simulate
  1. Traffic Flow:
    • We will want to replicate the interaction among nodes in each subnet and over subnets (via the central hub).
  2. Performance Metrics:
    • Throughput: Estimate the rate of data delivery in and among the subnets.
    • Latency: Examine delays among the nodes within the bus and over the hub.
    • Packet Loss: In the hybrid network, assess reliability of packets.
  1. Analyze the Trace File
  • Examine the network performance using the trace file as star_bus_hybrid_topology.tr.
  • We can obtain the certain performance parameters:
    • Throughput:

grep “tcp” star_bus_hybrid_topology.tr > throughput.log

    • Dropped Packets:

grep “drop” star_bus_hybrid_topology.tr > dropped_packets.log

  1. Visualize Results

Make use of Gnuplot or another graphing tool for visualization:

  1. Throughput Graph:

set title “Star-Bus Hybrid Topology Throughput”

plot “throughput.log” using 1:2 with lines title “Throughput”

  1. Latency Graph:
    • Envision the delays among the nodes under diverse subnets for traffic.
  1. Extend the Simulation
  2. Simulate Additional Traffic Flows
  • Integrate additional traffic flows among the nodes within various subnets.

set tcp1 [new Agent/TCP]

$ns attach-agent $node(1,1) $tcp1

set sink1 [new Agent/TCPSink]

$ns attach-agent $node(0,2) $sink1

$ns connect $tcp1 $sink1

  1. Add More Subnets
  • Launch more subnets for prolonging the topology.

set subnet(2) {}

for {set j 0} {$j < $nodes_per_subnet} {incr j} {

set node(2,$j) [$ns node]

lappend subnet(2) $node(2,$j)

# Connect nodes in the new subnet in a bus topology

if {$j > 0} {

$ns duplex-link $node(2,[expr $j – 1]) $node(2,$j) 1Mb 10ms DropTail

}

}

# Connect the last node of the new subnet to the hub

$ns duplex-link $node(2,[expr $nodes_per_subnet – 1]) $hub 1Mb 10ms DropTail

  1. Simulate Node or Link Failures
  • Experiment the hybrid network’s fault tolerance by way of replicating the node or link failures:

$ns at 2.5 “$ns reset-links $node(0,0) $node(1,2)”

  1. Experiment with Different Protocols
  • For observing the performance in diverse traffic types, we need replicate the UDP or custom protocols:

set udp [new Agent/UDP]

$ns attach-agent $node(0,1) $udp

set null [new Agent/Null]

$ns attach-agent $node(1,0) $null

$ns connect $udp $null

  1. Modify NS2 Core for Advanced Features
  1. Custom Routing Protocols:
    • Execute particular routing protocols, managing traffic among the nodes in the subnets and through the hub.
  2. Traffic Shaping:
    • Manage the traffic flow for mimicking bandwidth constraints or give precedence to specific kinds of traffic.

Tools and Resources

  • Wireshark: In the hybrid network, examine the traffic models.
  • Gnuplot: Envision the performance parameters such as throughput, delay, and packet loss to leverage the Gnuplot tools.
  • NS2 Documentation: We can refer NS2 documentation for more customization and further aspects.

Enhancements

  • Wireless Star-Bus Hybrid Topology:
    • Mimic real-world communication scenarios to utilise wireless connections among the nodes.
  • QoS Models:
    • Execute the traffic prioritization and quality of service (QoS) within the simulation.
  • Compare Hybrid Topologies:
    • We will need to equate the performance of star-bus hybrid topology with other hybrid topologies like star-ring or mesh-bus for estimating performance, scalability, and fault tolerance.

We have outlined the detailed structure with sample snippets that contains simulation setup, key features, required resources and tools to replicate and examine the Star Bus Hybrid Topology Projects using NS2 environment. If you need further insights on this projects, don’t hesitate to ask.