How to Simulate Logical Topology Projects Using NS2

To simulate a Logical Topology in NS2 has includes to generate an abstracted network that occurs on eminent of a physical network. A logical topology described as the paths in which the data takes among the nodes, independent of the original physical connections. Logical topologies are usual in overlay networks, virtual private networks (VPNs), and peer-to-peer networks, in which the logical links extent multiple physical links.

Here’s how to simulate a Logical Topology in NS2:

Steps to Simulate Logical Topology Projects in NS2

  1. Set up NS2 Environment:

Make sure NS2 is installed and configured properly. The simulation will contained to describe a physical topology and generating logical links across the physical topology to replicate the logical network.

  1. Understanding Logical Topology:
  • Physical Topology: it signifies the actual connections among network devices (such as routers, switches, and physical links).
  • Logical Topology: Characterizes the virtual or abstracted connections (logical links) among devices. Logical links can span multiple physical links, and nodes interact by using these logical paths.
  1. Create a TCL Script for Logical Topology:

Below is a TCL script to mimic a Logical Topology on upper of a Physical Network with 6 physical nodes and 4 logical nodes in NS2:

# Create a new simulator instance

set ns [new Simulator]

# Open a NAM trace file for visualization

set nf [open out.nam w]

$ns namtrace-all $nf

# ======= Physical Network Topology =======

# Create 6 physical nodes representing the physical network

set p0 [$ns node]

set p1 [$ns node]

set p2 [$ns node]

set p3 [$ns node]

set p4 [$ns node]

set p5 [$ns node]

# Create physical links between the physical nodes

$ns duplex-link $p0 $p1 10Mb 10ms DropTail

$ns duplex-link $p1 $p2 10Mb 10ms DropTail

$ns duplex-link $p2 $p3 10Mb 10ms DropTail

$ns duplex-link $p3 $p4 10Mb 10ms DropTail

$ns duplex-link $p4 $p5 10Mb 10ms DropTail

$ns duplex-link $p5 $p0 10Mb 10ms DropTail

# ======= Logical Topology =======

# Define logical nodes mapped to physical nodes

set logical0 $p0   ;# Logical node 0 mapped to physical node p0

set logical1 $p2   ;# Logical node 1 mapped to physical node p2

set logical2 $p4   ;# Logical node 2 mapped to physical node p4

set logical3 $p1   ;# Logical node 3 mapped to physical node p1

# Create logical links between logical nodes to form the logical network

# These logical links represent paths that may span multiple physical links

$ns simplex-link $logical0 $logical1 10Mb 50ms DropTail  ;# Logical link from logical0 to logical1

$ns simplex-link $logical1 $logical2 10Mb 50ms DropTail  ;# Logical link from logical1 to logical2

$ns simplex-link $logical2 $logical3 10Mb 50ms DropTail  ;# Logical link from logical2 to logical3

$ns simplex-link $logical3 $logical0 10Mb 50ms DropTail  ;# Logical link from logical3 to logical0

# ======= Traffic Generation =======

# Attach UDP agents to the logical nodes

set udp0 [new Agent/UDP]

$ns attach-agent $logical0 $udp0

set udp1 [new Agent/UDP]

$ns attach-agent $logical2 $udp1

# Attach Null agents (traffic sinks) to other logical nodes

set null0 [new Agent/Null]

$ns attach-agent $logical1 $null0

set null1 [new Agent/Null]

$ns attach-agent $logical3 $null1

# Connect the UDP agents to Null agents (logical communication over physical network)

$ns connect $udp0 $null0

$ns connect $udp1 $null1

# Create CBR traffic generators and attach them to UDP agents in the logical network

set cbr0 [new Application/Traffic/CBR]

$cbr0 attach-agent $udp0

$cbr0 set packetSize_ 512

$cbr0 set rate_ 100Kb

set cbr1 [new Application/Traffic/CBR]

$cbr1 attach-agent $udp1

$cbr1 set packetSize_ 512

$cbr1 set rate_ 100Kb

# Schedule the CBR traffic

$ns at 1.0 “$cbr0 start”

$ns at 1.5 “$cbr1 start”

$ns at 5.0 “$cbr0 stop”

$ns at 5.5 “$cbr1 stop”

# End the simulation at 6 seconds

$ns at 6.0 “finish”

proc finish {} {

global ns nf

$ns flush-trace

close $nf

exec nam out.nam &

exit 0

}

# Run the simulation

$ns run

  1. Explanation of the Code:
  • Physical Network: Six physical nodes (p0, p1, p2, p3, p4, p5) signify the fundamental physical infrastructure. Physical links are generated among them to form a looped network.
  • Logical Nodes: Four logical nodes (logical0, logical1, logical2, logical3) are represented to physical nodes. Logical links signify virtual connections among logical nodes that span multiple physical links.
  • Logical Links: Logical links are generated among the logical nodes. These signify paths in the logical topology, while actual data flow happens over the physical links.
  • UDP Traffic: UDP agents are attached to logical nodes to replicate communication via the logical topology. Null agents are attached because of traffic sinks.
  • CBR Traffic: Constant Bit Rate (CBR) traffic is created among logical nodes to replicate data flow via the logical network.
  • Traffic Scheduling: Traffic initiate at 1.0 and 1.5 seconds and ends at 5.0 and 5.5 seconds, correspondingly.
  • Simulation End: The simulation terminates at 6 seconds, and the outcomes are saved in a .nam file for visualization.
  1. Run the Simulation:
  1. Save the script as logical_topology.tcl.
  2. Open a terminal and navigate to the folder in which the script is saved.
  3. Execute the simulation using:

ns logical_topology.tcl

  1. The simulation will create an out.nam file that can open by using Network Animator (NAM).
  1. Visualization in NAM:
  • Open the out.nam file in NAM to envision both the physical and logical topologies. We will see the physical network links and the logical traffic flowing among the logical nodes, traversing the physical network.
  1. Customization and Enhancements:
  • Increase Number of Nodes: we can incorporate more physical and logical nodes by expanding the script. Make sure that logical nodes are represented to physical nodes and associated by logical links.
  • TCP Traffic: Replace the UDP agents with TCP agents to replicate reliable communication via the logical topology:

set tcp0 [new Agent/TCP]

$ns attach-agent $logical0 $tcp0

set sink0 [new Agent/TCPSink]

$ns attach-agent $logical1 $sink0

$ns connect $tcp0 $sink0

  • Different Traffic Patterns: insert more traffic flows to replicate different communication patterns via the logical network.
  • Performance Metrics: incorporate trace files to evaluate parameters such as packet loss, delay, and throughput:

set tracefile [open trace.tr w]

$ns trace-all $tracefile

  1. Performance Analysis:

To measure the performance of the logical topology, we can:

  • Evaluate throughput to track the data successfully routed over the logical links.
  • Evaluate latency to measure the latency experienced by logical traffic by way of it traverses multiple physical links.
  • Measure packet loss to assess the reliability of communication via the logical topology.

From the demonstration we completely aggregate the information about the installation process and simulation procedure for Logical Topology projects that were deploy in the tool of ns2. More information regarding the Logical Topology projects will also be provided.

Get expert help on overlay networks, VPNs, and peer-to-peer networks for your projects. We specialize in simulating logical topology projects using NS2. Contact us for top-notch research support and unique topic ideas.

Opening Time

9:00am

Lunch Time

12:30pm

Break Time

4:00pm

Closing Time

6:30pm

  • award1
  • award2