How to Implement Hierarchical Topology in NS2

 

To implement the Hierarchical Topology within NS2 (Network Simulator 2) that denotes to a structured network topology in which the nodes are ordered in the layers or levels. Normally, there is a top layer (core) which is connects to intermediate layers (aggregation or distribution), and those layers are connect to the bottom layer (end devices or access nodes). Hierarchical topology is generally used in large-scale networks, like enterprise or campus networks in which the traffic is routed via these layers. We follow the given procedure is helps to execute it in NS2:

Steps to Implement Hierarchical Topology in NS2:

  1. Set Up the Hierarchical Network Topology:
    • State that nodes for each layer such as core, aggregation, and access layers.
    • Make links among the core nodes and the intermediate nodes or aggregation layer.
    • Relate to the intermediate nodes to the access nodes that forming a hierarchical structure.
  2. Simulate Traffic Flow:
    • To create the traffic among nodes in the access layer and route it via the aggregation and core layers.

Example of Hierarchical Topology Implementation in NS2:

Given below is an instance script that explained how to configure a hierarchical topology with a core layer, an aggregation layer, and an access layer:

# Create a new simulator

set ns [new Simulator]

# Open trace file for output

set tracefile [open out.tr w]

$ns trace-all $tracefile

# ======= CORE LAYER =======

# Define core layer nodes (top-level nodes)

set core0 [$ns node]    ;# Core node 0

set core1 [$ns node]    ;# Core node 1

# ======= AGGREGATION LAYER =======

# Define aggregation layer nodes (intermediate nodes)

set agg0 [$ns node]     ;# Aggregation node 0

set agg1 [$ns node]     ;# Aggregation node 1

set agg2 [$ns node]     ;# Aggregation node 2

# Create duplex links between core and aggregation layer nodes

$ns duplex-link $core0 $agg0 2Mb 10ms DropTail  ;# Link between core0 and agg0

$ns duplex-link $core0 $agg1 2Mb 10ms DropTail  ;# Link between core0 and agg1

$ns duplex-link $core1 $agg1 2Mb 10ms DropTail  ;# Link between core1 and agg1

$ns duplex-link $core1 $agg2 2Mb 10ms DropTail  ;# Link between core1 and agg2

# ======= ACCESS LAYER =======

# Define access layer nodes (end nodes)

set access0 [$ns node]  ;# Access node 0

set access1 [$ns node]  ;# Access node 1

set access2 [$ns node]  ;# Access node 2

set access3 [$ns node]  ;# Access node 3

# Create duplex links between aggregation and access layer nodes

$ns duplex-link $agg0 $access0 1Mb 10ms DropTail  ;# Link between agg0 and access0

$ns duplex-link $agg0 $access1 1Mb 10ms DropTail  ;# Link between agg0 and access1

$ns duplex-link $agg2 $access2 1Mb 10ms DropTail  ;# Link between agg2 and access2

$ns duplex-link $agg2 $access3 1Mb 10ms DropTail  ;# Link between agg2 and access3

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

# Define TCP agents for communication between access layer nodes

# Traffic from access0 to access2 (across aggregation and core layers)

set tcp0 [new Agent/TCP]

set sink0 [new Agent/TCPSink]

$ns attach-agent $access0 $tcp0

$ns attach-agent $access2 $sink0

$ns connect $tcp0 $sink0

# Simulate FTP traffic from access0 to access2

set ftp0 [new Application/FTP]

$ftp0 attach-agent $tcp0

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

# Traffic from access1 to access3 (across aggregation and core layers)

set tcp1 [new Agent/TCP]

set sink1 [new Agent/TCPSink]

$ns attach-agent $access1 $tcp1

$ns attach-agent $access3 $sink1

$ns connect $tcp1 $sink1

# Simulate FTP traffic from access1 to access3

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. Core Layer:
    • The core nodes are core 0 and core1 at the high level of the hierarchy. Those nodes are manage communication among the aggregation layer and other core nodes.
  2. Aggregation Layer:
    • These layer agg0, agg1, and agg2 are signify the intermediate nodes that aggregate traffic from the access nodes and forward it to the core layer.
  3. Access Layer:
    • The access layer access0, access1, access2, and access3 are the end nodes (users or devices) connected to the network through the aggregation layer.
  4. Links:
    • Duplex links are used to connect the aggregation nodes to the access nodes, and the core nodes to the aggregation nodes. It forms the hierarchical structure including the traffic flowing from the access layer via the aggregation layer and to the core layer.
  5. Traffic Simulation:
    • TCP agents mimic communication among the access nodes. Traffic flows from the layer access0 to access2 and from access1 to access3, navigating the aggregation and core layers.
    • FTP (File Transfer Protocol) applications are used to produce the traffic among the nodes. The FTP traffic begins at 1 second for the first connection and at 2 seconds for the second connection.
  6. Simulation Duration:
    • For 10 seconds, the simulation runs during that traffic flows via the hierarchical network.

Post-Simulation Analysis:

  1. Trace File Analysis:
    • Here, open the trace file (out.tr) to monitor how packets are sent among the access nodes, passing over the aggregation and core layers.
  2. NAM Visualization:
    • We can use the NAM (Network Animator) to envision this topology. We will observe the core, aggregation, and access layers, and how traffic flows via each layer.
  3. Performance Metrics:
    • Compute the network performance metrics like delay, throughput, and packet loss to evaluate how efficiently the hierarchical topology manages the traffic.

Enhancing the Simulation:

  1. Adding More Layers:
    • Append more layers among the core and access layers like distribution layers, to replicate the larger hierarchical topologies.
  2. Simulating Traffic in Both Directions:
    • Configure the bidirectional communication among access nodes to mimic more difficult traffic patterns over the hierarchical network.
  3. Changing Traffic Type:
    • Substitute the TCP with UDP or use CBR (Constant Bit Rate) rather than FTP to replicate various kinds of traffic and estimate how the network performs.
  4. Varying Link Parameters:
    • Test with various link parameters like bandwidth, delay, and queue type such as DropTail or RED to learn how the network performance modifies under several conditions.
  5. Simulating Traffic Across Multiple Core Nodes:
    • To replicate the traffic that needs routing over various core nodes for larger networks and assess the effectiveness of routing protocols in a hierarchical structure.

We conducted a detailed procedure on Hierarchical Topology, with execution and evaluation carried out through the simulation tool NS2. Additional informations will deliver based on your needs.

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