How to Start Point to Point Topology Projects Using NS2

To start simulating a Point-to-Point Topology in NS2 (Network Simulator 2) needs to make a direct connection among two nodes for swapping information. This topology is the easiest and generally utilised within small-scale simulations for fundamental communication or examining network protocols.

Below is a simplified technique to get started with Point-to-Point Topology projects in NS2:

Steps to Start Point-to-Point Topology in NS2

  1. Understand Point-to-Point Topology
  • Structure:
    • Use single direct link to link two nodes.
    • It is optimal to experiment the basic interaction or network protocols.
  • Applications:
    • Protocol validation such as TCP, UDP.
    • Performance examining in terms of throughput, delay, packet loss.
  1. Set Up NS2
  1. Install NS2:

sudo apt-get install ns2

  1. Verify Installation: Confirm installation including a simple example simulation script:

ns example.tcl

  1. Define Point-to-Point Topology
  • Make two nodes which are n0 and n1.
  • Launch a duplex link amongst them.
  1. TCL Script for Point-to-Point Topology

Below is a sample tcl script in NS2:

TCL Script Example

# Initialize NS2 Simulator

set ns [new Simulator]

set tracefile [open p2p_topology.tr w]

$ns trace-all $tracefile

# Create nodes

set n0 [$ns node]

set n1 [$ns node]

# Create a duplex point-to-point link

$ns duplex-link $n0 $n1 1Mb 10ms DropTail

# Attach agents for traffic

set tcp0 [new Agent/TCP]

$ns attach-agent $n0 $tcp0

set sink [new Agent/TCPSink]

$ns attach-agent $n1 $sink

$ns connect $tcp0 $sink

# Add a traffic generator

set ftp [new Application/FTP]

$ftp attach-agent $tcp0

# Start traffic

$ns at 1.0 “$ftp start”

# End simulation

$ns at 5.0 “finish”

proc finish {} {

global ns tracefile

$ns flush-trace

close $tracefile

exit 0

}

$ns run

  1. Key Features to Simulate
  1. Traffic Flow:
    • Make sure that data properly flows from n0 to n1.
  2. Performance Metrics:
    • Throughput: Estimate the rate of data transmits.
    • Delay: Examine interaction latency.
    • Packet Loss: Measure the reliability of packets.
  1. Analyze the Trace File
  • Make use of the trace file as p2p_topology.tr for in-depth analysis.
  • Obtain particular simulation parameters like:
    • Throughput:

grep “tcp” p2p_topology.tr > throughput.log

    • Dropped Packets:

grep “drop” p2p_topology.tr > dropped_packets.log

  1. Visualize Results

To envision the outcomes utilising Gnuplot or another plotting tool:

  1. Throughput Graph:

set title “Point-to-Point Throughput”

plot “throughput.log” using 1:2 with lines title “Throughput”

  1. Latency Graph: Examine the packet delay.
  1. Extend the Simulation
  2. Simulate Bi-Directional Communication
  • Connect a TCP or UDP agent on the node n1 for transmitting the data again to n0.

set tcp1 [new Agent/TCP]

$ns attach-agent $n1 $tcp1

set sink1 [new Agent/TCPSink]

$ns attach-agent $n0 $sink1

$ns connect $tcp1 $sink1

  1. Experiment with Different Protocols
  • For connectionless interaction, we can substitute TCP with UDP.

set udp [new Agent/UDP]

$ns attach-agent $n0 $udp

set null [new Agent/Null]

$ns attach-agent $n1 $null

$ns connect $udp $null

  1. Simulate Traffic Types
  • Make Constant Bit Rate (CBR) traffic for simulation:

set cbr [new Application/Traffic/CBR]

$cbr set packetSize_ 512

$cbr set interval_ 0.01

$cbr attach-agent $udp

  1. Test Performance Under Load
  • Replicate the high traffic volumes for examining the volume of link.
  1. Modify NS2 Core for Advanced Features

For further simulations aspects, we can:

  1. Custom Link Characteristics:
    • Alter the link features like bandwidth, delay, and queue type:

$ns duplex-link $n0 $n1 2Mb 20ms RED

  1. Dynamic Link Failure:
    • During the simulation, we will mimic a link failure:

$ns at 2.5 “$ns reset-links $n0 $n1”

Through this process, we successfully focused and learned about simulation and analysis methods of Point to Point Topology projects using NS2 simulation tool. If you have any requirement about this topic, we can offer you.