How to Implement Extended Star Topology in NS2

 

To implement the Extended Star Topology in ns2, this topology is a hierarchical kind of star topology that has several star networks which are interconnected, usually via central node or hub. It offers scalability when more devices or nodes can be attached by linking extra stars to the central node. Now, you can follow the procedure on how to execute this topology in ns2:

Steps to Implement Extended Star Topology in NS2:

  1. Set Up the Extended Star Network Topology:
    • Build numerous nodes for each star topology.
    • Develop duplex links to connect the central hub to its leaf nodes, forming multiple star topologies.
    • Link the central nodes of each star topology to a mutual core node, forming an extended star.
  2. Simulate Traffic Flow:
    • Produce traffic amongst nodes in various star networks by routing through the core node.

Example of Extended Star Topology Implementation in NS2:

Below is an example that demonstrates how to configure an extended star topology with two star networks linked to a common core node:

# Create a new simulator

set ns [new Simulator]

# Open trace file for output

set tracefile [open out.tr w]

$ns trace-all $tracefile

# Define the core node that connects two star networks

set core [$ns node]    ;# Core node

# Define nodes for star network 1 (1 hub and 3 leaf nodes)

set hub1 [$ns node]     ;# Hub for star network 1

set leaf1_1 [$ns node]  ;# Leaf node 1 of star network 1

set leaf1_2 [$ns node]  ;# Leaf node 2 of star network 1

set leaf1_3 [$ns node]  ;# Leaf node 3 of star network 1

# Create duplex links for star network 1

$ns duplex-link $hub1 $leaf1_1 1Mb 10ms DropTail  ;# Link between hub1 and leaf1_1

$ns duplex-link $hub1 $leaf1_2 1Mb 10ms DropTail  ;# Link between hub1 and leaf1_2

$ns duplex-link $hub1 $leaf1_3 1Mb 10ms DropTail  ;# Link between hub1 and leaf1_3

# Define nodes for star network 2 (1 hub and 3 leaf nodes)

set hub2 [$ns node]     ;# Hub for star network 2

set leaf2_1 [$ns node]  ;# Leaf node 1 of star network 2

set leaf2_2 [$ns node]  ;# Leaf node 2 of star network 2

set leaf2_3 [$ns node]  ;# Leaf node 3 of star network 2

Create duplex links for star network 2

$ns duplex-link $hub2 $leaf2_1 1Mb 10ms DropTail  ;# Link between hub2 and leaf2_1

$ns duplex-link $hub2 $leaf2_2 1Mb 10ms DropTail  ;# Link between hub2 and leaf2_2

$ns duplex-link $hub2 $leaf2_3 1Mb 10ms DropTail  ;# Link between hub2 and leaf2_3

# Connect the hub1 and hub2 to the core node

$ns duplex-link $core $hub1 2Mb 10ms DropTail     ;# Link between core and hub1

$ns duplex-link $core $hub2 2Mb 10ms DropTail     ;# Link between core and hub2

# Define TCP agents for communication between star networks

# Traffic from leaf1_1 to leaf2_3 (across star networks via core node)

set tcp0 [new Agent/TCP]

set sink0 [new Agent/TCPSink]

$ns attach-agent $leaf1_1 $tcp0

$ns attach-agent $leaf2_3 $sink0

$ns connect $tcp0 $sink0

# Simulate FTP traffic from leaf1_1 to leaf2_3

set ftp0 [new Application/FTP]

$ftp0 attach-agent $tcp0

$ns at 1.0 “$ftp0 start”   ;# Start traffic at 1 second

# Traffic from leaf1_2 to leaf2_2

set tcp1 [new Agent/TCP]

set sink1 [new Agent/TCPSink]

$ns attach-agent $leaf1_2 $tcp1

$ns attach-agent $leaf2_2 $sink1

$ns connect $tcp1 $sink1

# Simulate FTP traffic from leaf1_2 to leaf2_2

set ftp1 [new Application/FTP]

$ftp1 attach-agent $tcp1

$ns at 2.0 “$ftp1 start”   ;# Start traffic at 2 seconds

# 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. Nodes:
    • core: The core node that interrelates the two star networks.
    • hub1, hub2: Hubs for the two star networks.
    • leaf1_1, leaf1_2, leaf1_3: Leaf nodes in the first star network.
    • leaf2_1, leaf2_2, leaf2_3: Leaf nodes in the second star network.
  2. Links:
    • Duplex links connect each hub to its corresponding leaf nodes, forming two star networks.
    • The core node is linked to both hubs, forming the extended star topology.
  3. Traffic Simulation:
    • TCP agents simulate communication amongst the leaf nodes in various star networks. Traffic flows from leaf1_1 in star network 1 to leaf2_3 in star network 2 via the core node, and from leaf1_2 to leaf2_2.
    • FTP (File Transfer Protocol) applications produce traffic between the leaf nodes.
    • The traffic begins at 1.0 seconds for the first connection and at 2.0 seconds for the second connection.
  4. Simulation Duration:
    • The simulation executes for 10 seconds, permitting traffic to flow amongst nodes in various star networks over the core node.

Post-Simulation Analysis:

  1. Trace File Analysis:
    • Monitor how packets are forwarded amongst the leaf nodes, passing through the core node by opening the trace file (out.tr).
    • Compute metrics like packet delivery, delay, and throughput for communication between star networks.
  2. NAM Visualization:
    • NAM (Network Animator) is used to visualize the extended star topology. You will see two star networks linked to a core node, and you can see the traffic flowing through the core node to various leaf nodes.
  3. Performance Metrics:
    • Estimate network performance metrics like delay, throughput, and packet loss to measure how well the extended star topology manages traffic.

Enhancing the Simulation:

  1. Adding More Star Networks:
    • Attach more star networks linked to the core node to replicate a larger extended star topology.
  2. Simulating Traffic in Both Directions:
    • Configure bidirectional communication amongst leaf nodes to mimic more advanced traffic patterns through the extended star.
  3. Changing Traffic Type:
    • Swap TCP with UDP or use CBR (Constant Bit Rate) rather than FTP to simulate various kinds of traffic and estimate how the network functions.
  4. Varying Link Parameters:
    • Examine with different link parameters includes bandwidth, delay, and queue type (for instance: DropTail or RED) to learn how the network performance differs under various conditions.

From this procedure, we successfully learned the information about how to implement the extended star topologies and how it handles the network traffic and how to enhance the simulation using ns2. Whenever, you have doubt about this approach we will clarify it.

Contact us for customized services on implementing Extended Star Topology in NS2. Our developers can provide various analysis results for star networks.