How to Implement Hybrid Topology in NS2

 

To implement the Hybrid Topology is a mixture of two or more various network topologies, like a combination of star, ring, bus, or mesh topologies. In NS2 that is Network Simulator 2, we can execute a hybrid topology by merging several network structures to form multipurpose network and a more difficult. Each portion of the network follows these own topology, and those portions are related together. We are provided detailed instruction on how to execute this topology in the simulation NS2:

Steps to Implement a Hybrid Topology in NS2:

  1. Set Up the Hybrid Network Topology:
    • State several smaller topologies like a star topology, a ring topology, etc.
    • Connect those topologies together to form a larger hybrid network.
  2. Simulate Traffic Flow:
    • Traffic can be produced among the nodes in various topologies and mimicking communication over the hybrid network.

Example of Hybrid Topology Implementation in NS2:

This sample demonstrations how to execute a hybrid topology that merges a Star Topology and a Ring Topology.

# Create a new simulator

set ns [new Simulator]

# Open trace file for output

set tracefile [open out.tr w]

$ns trace-all $tracefile

# ======= PART 1: STAR TOPOLOGY =======

# Define nodes for the star topology (1 central hub and 3 leaf nodes)

set hub [$ns node]    ;# Central hub node (star topology)

set star_leaf1 [$ns node] ;# Leaf node 1

set star_leaf2 [$ns node] ;# Leaf node 2

set star_leaf3 [$ns node] ;# Leaf node 3

# Create duplex links for star topology

$ns duplex-link $hub $star_leaf1 1Mb 10ms DropTail  ;# Link between hub and leaf 1

$ns duplex-link $hub $star_leaf2 1Mb 10ms DropTail  ;# Link between hub and leaf 2

$ns duplex-link $hub $star_leaf3 1Mb 10ms DropTail  ;# Link between hub and leaf 3

# ======= PART 2: RING TOPOLOGY =======

# Define nodes for the ring topology (4 nodes in a ring)

set ring_node0 [$ns node]  ;# Ring node 0

set ring_node1 [$ns node]  ;# Ring node 1

set ring_node2 [$ns node]  ;# Ring node 2

set ring_node3 [$ns node]  ;# Ring node 3

# Create duplex links for ring topology

$ns duplex-link $ring_node0 $ring_node1 1Mb 10ms DropTail  ;# Link between ring node 0 and 1

$ns duplex-link $ring_node1 $ring_node2 1Mb 10ms DropTail  ;# Link between ring node 1 and 2

$ns duplex-link $ring_node2 $ring_node3 1Mb 10ms DropTail  ;# Link between ring node 2 and 3

$ns duplex-link $ring_node3 $ring_node0 1Mb 10ms DropTail  ;# Link between ring node 3 and 0 (closing the ring)

# ======= CONNECTING THE TOPOLOGIES =======

# Connecting the star hub to the ring topology

$ns duplex-link $hub $ring_node0 2Mb 10ms DropTail ;# Link between the star hub and ring node 0

# ======= TRAFFIC SIMULATION =======

# Traffic from star_leaf1 to ring_node2 (across topologies)

set tcp0 [new Agent/TCP]

set sink0 [new Agent/TCPSink]

$ns attach-agent $star_leaf1 $tcp0

$ns attach-agent $ring_node2 $sink0

$ns connect $tcp0 $sink0

# Simulate FTP traffic from star_leaf1 to ring_node2

set ftp0 [new Application/FTP]

$ftp0 attach-agent $tcp0

$ns at 1.0 “$ftp0 start”

# Traffic from ring_node3 to star_leaf3 (across topologies)

set tcp1 [new Agent/TCP]

set sink1 [new Agent/TCPSink]

$ns attach-agent $ring_node3 $tcp1

$ns attach-agent $star_leaf3 $sink1

$ns connect $tcp1 $sink1

# Simulate FTP traffic from ring_node3 to star_leaf3

set ftp1 [new Application/FTP]

$ftp1 attach-agent $tcp1

$ns at 2.0 “$ftp1 start”

# End the simulation after 10 seconds

$ns at 10.0 “finish”

proc finish {} {

global ns tracefile

$ns flush-trace

close $tracefile

exit 0

}

# Run the simulation

$ns run

Explanation of the Script:

  1. Star Topology:
    • Nodes: hub, star_leaf1, star_leaf2, star_leaf3 are signify the star topology in which all leaf nodes are connected to a central hub.
    • Links: Duplex links connect the hub to every leaf node and replicating a star topology.
  2. Ring Topology:
    • Nodes: ring_node0, ring_node1, ring_node2, ring_node3 are denote the ring topology in which every nodes are connected in a round fashion.
    • Links: Duplex links interconnect the ring nodes in a circular arrangement, closing the ring topology.
  3. Connecting the Topologies:
    • A duplex link associates the central hub of the star topology to one of the ring nodes such as ring_node0. It forms the hybrid topology, merging the ring topology and ring topology.
  4. Traffic Simulation:
    • TCP agents are used to replicate communication among the nodes in various portions of the hybrid topology.
    • For sample, the traffic flows from ring_node3 to star_leaf3, and from star_leaf1 (part of the star topology) to ring_node2 (part of the ring topology).
    • FTP applications produce the file transfer traffic among those nodes.
  5. Simulation Duration:
    • For the 10 seconds, the simulation runs during that the traffic flows among nodes in the hybrid topology.

Post-Simulation Analysis:

  1. Trace File Analysis:
    • Here, open the trace file (out.tr) to monitor how traffic flows over the hybrid topology then estimate how packets are routed among the nodes in the star and ring parts of the network.
  2. NAM Visualization:
    • We can use the NAM (Network Animator) to envision the hybrid topology and we will monitor the star and ring topologies connected together including traffic flowing among them.
  3. Performance Metrics:
    • Compute network performance metrics like delay, throughput, and packet loss to evaluate how the hybrid topology manages traffic over various sub-topologies.

Enhancing the Simulation:

  1. More Topologies:
    • We can append more topologies to the hybrid network. For instance, connect a bus topology to the existing star and ring topologies to form difficult hybrid network.
  2. Simulate Failures:
    • To replicate the node or link failures to see how the hybrid network reacts. For specimen, in the ring topology, disconnect a node and monitor how the star topology manages the traffic rerouting.
  3. Varying Traffic Patterns:
    • Analyse with various traffic types like UDP or CBR (Constant Bit Rate) traffic to observe how various kinds of data transmission impact the behaviour of the hybrid topology.
  4. Increasing Node Count:
    • Here, append more nodes to the star and ring topologies that to replicate a larger hybrid network and also assess how performance alters with scale.

We comprehensively followed an above simplified procedure on Hybrid Topology, implementing and estimating it through the simulation tool NS2. More required details will be shared based on your needs.

We can help you create your Hybrid Topology in NS2. For tailored solutions, visit ns2project.com. Get top-notch simulation support from us. We focus on end devices or access nodes based on our project information.