How to Start Daisy Chain Topology Projects Using NS2

To start replicating a Daisy Chain Topology using NS2 (Network Simulator 2) that associating nodes within a linear sequence in which every single node is connected to the next making a chain. This is a simple topology but efficient to experiment and analyse the data propagation, latency, and performance within linear networks. Following is a series of steps to start the Daisy Chain Topology project in NS2:

Steps to Start Daisy Chain Topology in NS2

  1. Understand Daisy Chain Topology
  • Structure:
    • Nodes are associated in sequence, which is creating a chain-like topology.
    • Data normally flows from one end of the chain to the other or among the middle nodes.
  • Applications:
    • It supports to replicate the scenarios such as cascading systems, linear sensor networks, or daisy-chained devices.
  1. Set Up NS2
  1. Install NS2:

sudo apt-get install ns2

  1. Verify Installation: Confirm set up including a basic simulation script:

ns example.tcl

  1. Define Daisy Chain Topology
  • We can make nodes and successively link them.
  • For instance, n0 -> n1 -> n2 -> … -> nN.
  1. TCL Script for Daisy Chain Topology

Below is an instance of TCL script for replicating a Daisy Chain Topology:

TCL Script Example

# Initialize NS2 Simulator

set ns [new Simulator]

set tracefile [open daisy_chain_topology.tr w]

$ns trace-all $tracefile

# Number of nodes in the chain

set num_nodes 5

# Create nodes

for {set i 0} {$i < $num_nodes} {incr i} {

set n($i) [$ns node]

}

# Create links to form the daisy chain

for {set i 0} {$i < [expr $num_nodes – 1]} {incr i} {

set next [expr $i + 1]

$ns duplex-link $n($i) $n($next) 1Mb 10ms DropTail

}

# Attach agents to simulate traffic

# Example: n0 sends to n4

set udp0 [new Agent/UDP]

$ns attach-agent $n(0) $udp0

set null0 [new Agent/Null]

$ns attach-agent $n([expr $num_nodes – 1]) $null0

$ns connect $udp0 $null0

# Add a traffic generator

set cbr0 [new Application/Traffic/CBR]

$cbr0 set packetSize_ 512

$cbr0 set interval_ 0.1

$cbr0 attach-agent $udp0

# Start traffic

$ns at 1.0 “$cbr0 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:
    • Data linearly broadcasts through nodes within the chain.
  2. Performance Metrics:
    • Throughput: Estimate the rate of data that are transmitted at the destination node.
    • Latency: Examine the delays as packets pass through the chain.
    • Packet Loss: Measure the reliability of packets.
  1. Analyze the Trace File
  • Make use of the trace file as daisy_chain_topology.tr for in-depth analysis.
  • We can obtain certain parameters:
    • Throughput:

grep “tcp” daisy_chain_topology.tr > throughput.log

    • Dropped Packets:

grep “drop” daisy_chain_topology.tr > dropped_packets.log

  1. Visualize Results

To envision the outcomes to leverage the Gnuplot or another visualization tool:

  1. Throughput Graph:

set title “Daisy Chain Throughput”

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

  1. Latency Graph: Envision delays at each node.
  1. Extend the Simulation
  2. Simulate Bi-Directional Communication
  • Connect agents on both destinations of the chain for bidirectional communication traffic:

set udp1 [new Agent/UDP]

$ns attach-agent $n([expr $num_nodes – 1]) $udp1

set null1 [new Agent/Null]

$ns attach-agent $n(0) $null1

$ns connect $udp1 $null1

  1. Test Different Traffic Patterns
  • We need to integrate several CBR or FTP traffic flows:

set ftp [new Application/FTP]

$ftp attach-agent $udp1

  1. Introduce Node Failures
  • Mimic failures for monitoring the effect within middle nodes:

$ns at 2.5 “$ns reset-links $n(2) $n(3)”

  1. Experiment with Protocols
  • We should equate the performance of TCP and UDP protocols:

set tcp0 [new Agent/TCP]

$ns attach-agent $n(0) $tcp0

  1. Modify NS2 Core for Advanced Features

For furthered functionality, we can explore the project aspects:

  1. Dynamic Daisy Chain:
    • During the simulation, we will dynamically integrate or eliminate the nodes.
  2. Custom Node Behavior:
    • Execute the certain packet to manage the logic using recv() for intermediate nodes.

Finally, we can understand the process of simulating and analysing the Daisy Chain Topology projects utilising NS3 environment through this guide. If needed, we will also provide the additional information relevant to this topic.