How to Implement Fully Connected Topology in NS2

 

To implement the Fully Connected Topology is also called as a Full Mesh Topology that is a network topology in which each node is related to every other node. It delivers several redundant paths among the any set of nodes, maximizing the network reliability and fault tolerance. In Network Simulator 2 that is NS2, we can simulate a fully connected topology by making duplex links among each pair of nodes in the network. Given below is a procedure to execute it in NS2:

Steps to Implement Fully Connected Topology in NS2:

  1. Set Up the Fully Connected Network Topology:
    • Describe the nodes.
    • Make duplex links among every pair of nodes.
  2. Simulate Traffic Flow:
    • Make traffic among any pair of nodes, permitting the data to traverse directly among them because each node is connected to every other node.

Example of Fully Connected Topology Implementation in NS2:

Now, we given an example script that establishes how to configure a fully connected topology with 4 nodes and mimic traffic among them:

# Create a new simulator

set ns [new Simulator]

# Open trace file for output

set tracefile [open out.tr w]

$ns trace-all $tracefile

# Define nodes for the fully connected topology (4 nodes for simplicity)

set n0 [$ns node]  ;# Node 0

set n1 [$ns node]  ;# Node 1

set n2 [$ns node]  ;# Node 2

set n3 [$ns node]  ;# Node 3

# Create duplex links to fully connect every pair of nodes

$ns duplex-link $n0 $n1 1Mb 10ms DropTail  ;# Link between node 0 and node 1

$ns duplex-link $n0 $n2 1Mb 10ms DropTail  ;# Link between node 0 and node 2

$ns duplex-link $n0 $n3 1Mb 10ms DropTail  ;# Link between node 0 and node 3

$ns duplex-link $n1 $n2 1Mb 10ms DropTail  ;# Link between node 1 and node 2

$ns duplex-link $n1 $n3 1Mb 10ms DropTail  ;# Link between node 1 and node 3

$ns duplex-link $n2 $n3 1Mb 10ms DropTail  ;# Link between node 2 and node 3

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

# Define TCP agents for communication between nodes

# Traffic from node 0 to node 2

set tcp0 [new Agent/TCP]

set sink0 [new Agent/TCPSink]

$ns attach-agent $n0 $tcp0

$ns attach-agent $n2 $sink0

$ns connect $tcp0 $sink0

# Simulate FTP traffic from node 0 to node 2

set ftp0 [new Application/FTP]

$ftp0 attach-agent $tcp0

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

# Traffic from node 1 to node 3

set tcp1 [new Agent/TCP]

set sink1 [new Agent/TCPSink]

$ns attach-agent $n1 $tcp1

$ns attach-agent $n3 $sink1

$ns connect $tcp1 $sink1

# Simulate FTP traffic from node 1 to node 3

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:
    • n0, n1, n2, and n3 are denotes the four nodes in the fully connected topology.
  2. Links:
    • Duplex links are made among the every pair of nodes. It make sure that every node is directly connected to every other node, creating a fully connected (mesh) topology.
    • For sample, node n0 is connected to nodes n1, n2, and n3, and same connections exist for the other nodes.
  3. Traffic Simulation:
    • TCP agents are used to simulate communication between the nodes. For example, the traffic flows from the node n0 to n2 and from n1 to n3.
    • FTP (File Transfer Protocol) is used to produce file transfer traffic among the nodes and replicating data transmission over the network.
    • The FTP traffic begins at 1 second for traffic from n0 to n2 and at 2 seconds for traffic from n1 to n3.
  4. Simulation Duration:
    • The simulation runs for 10 seconds that permitting traffic to flow among the nodes via the fully connected network.

Post-Simulation Analysis:

  1. Trace File Analysis:
    • Here, open the trace file (out.tr) to monitor the packet flow among the nodes. We can compute the parameters such as packet delivery, delay, and throughput for the fully connected communication.
  2. NAM Visualization:
    • We can use the NAM (Network Animator) to envision the fully connected topology. We will observe all nodes connected to each other with several direct links, and the traffic flowing directly among the nodes without going via intermediate nodes.
  3. Performance Metrics:
    • Calculate the network performance metrics like delay, throughput, and packet loss to evaluate how effectively the fully connected topology manages the traffic.

Enhancing the Simulation:

  1. Adding More Nodes:
    • Append more nodes to mimic a larger fully connected topology and monitor how performance modifies with more nodes and links.
  2. Simulating Traffic in Both Directions:
    • Configure the bidirectional communication by appending traffic flows in the reverse direction such as from n2 to n0 and from n3 to n1.
  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 alter under numerous conditions.

The Fully Connected Topology was addressed through a sequential process, implemented and assessed with the help of the simulation tool NS2. We will present comprehensive details using various simulation tool according to your needs.

For assistance with your Fully Connected Topology in NS2, feel free to visit ns2project.com. We offer simulation support and focus on nodes relevant to our project specifications.