How to Simulate Delay Tolerant Networks Projects Using NS2

To simulate Delay Tolerant Networks (DTNs) within NS2 that includes setting nodes to manage intermittent connectivity, long delays, and disruptions. DTNs use store-and-forward methods at each node to manage situations in which continuous end-to-end connectivity is unobtainable.

Even though NS2 does not have built-in modules for DTNs by default, a patch or extension called as NS2-DTN or the DTN patch for NS2 can be applied to replicate Delay Tolerant Networks effectively. These patches launch DTN-specific protocols such as Bundle Protocol, buffer management, and node mobility aspects, which can replicate normal DTN environments.

Below is a simple steps to simulate Delay Tolerant Networks (DTNs) using NS2:

Steps to Simulate DTN in NS2:

  1. Install NS2 and DTN Patch:
    • Initially, we install NS2 (version 2.35 or earlier is recommended) and apply the DTN patch. We can discover the patch from repositories such as NS2-DTN Extension or SourceForge NS2-DTN Project.

Download NS2:

sudo apt-get install ns2

Download and apply the DTN patch:

cd ~

git clone https://github.com/cornell-dtg/ns2-dtn.git

cd ns2-dtn

./install

After applying the patch, recompile NS2:

cd ns-2.35

./configure

make clean

make

  1. Create a DTN Scenario Using a Tcl Script: When the DTN extension is installed then we can make a Tcl script to replicate a DTN scenario. The simple DTN functionality contains:
    • Bundle Protocol: The protocol utilized for data delivery in DTNs.
    • Store-and-Forward Buffers: To store packets when no immediate route is obtainable.
    • Node Mobility Models: To replicate dynamic and intermittent network connectivity.

Here’s a simple DTN Tcl script:

# Create a new simulator object

set ns [new Simulator]

# Open trace and NAM files

set tracefile [open dtn_out.tr w]

$ns trace-all $tracefile

set namfile [open dtn_out.nam w]

$ns namtrace-all-wireless $namfile 500 500

# Define a wireless channel for DTN nodes

set chan_1_ [new Channel/WirelessChannel]

# Create mobile DTN nodes

set n0 [$ns node]

$n0 set X_ 100

$n0 set Y_ 100

set n1 [$ns node]

$n1 set X_ 200

$n1 set Y_ 200

# Define mobility (simple random waypoint mobility)

set mobility [new Mobility/RandomWaypoint]

$n0 attach-mobility $mobility

$n1 attach-mobility $mobility

# Create a DTN agent (Bundle Protocol)

set dtnAgent0 [new Agent/DTN]

set dtnAgent1 [new Agent/DTN]

$ns attach-agent $n0 $dtnAgent0

$ns attach-agent $n1 $dtnAgent1

# Connect agents to send bundles (messages)

$ns connect $dtnAgent0 $dtnAgent1

# Create traffic sources (DTN applications)

set app0 [new Application/Traffic/CBR]

$app0 set packetSize_ 512

$app0 set interval_ 1.0

$app0 attach-agent $dtnAgent0

# Schedule traffic generation and simulation events

$ns at 1.0 “$app0 start”

$ns at 100.0 “$app0 stop”

$ns at 200.0 “finish”

# Define the end of the simulation

proc finish {} {

global ns tracefile namfile

$ns flush-trace

close $tracefile

close $namfile

exec nam dtn_out.nam &

exit 0

}

# Run the simulation

$ns run

Explanation of the Tcl Script:

  1. Simulator Object:
    • The line set ns [new Simulator] initializes the NS2 simulator.
  2. Trace and NAM Files:
    • The trace-all and namtrace-all-wireless commands make trace (dtn_out.tr) and NAM files (dtn_out.nam) to put in strorage simulation data and visualization.
  3. Wireless Channel:
    • DTN nodes are described to communicate wirelessly with WirelessChannel that manages the wireless medium.
  4. Node Creation and Mobility:
    • Nodes (n0 and n1) are made with initial positions (X, Y coordinates) and use RandomWaypoint mobility that mimics nodes moving randomly in a defined area.
  5. DTN Agent:
    • The DTN Agent is responsible for managing the Bundle Protocol and store-and-forward mechanism of DTN communication. Each node is allocated a DTN agent (dtnAgent0 and dtnAgent1).
  6. Traffic Source:
    • A CBR (Constant Bit Rate) traffic generator is connected to the DTN agent, which signifies the message generation from n0 to n1. The messages are made every 1 second with a size of 512 bytes.
  7. Scheduling Events:
    • The traffic source begins at 1.0 seconds and ends at 100.0 seconds, and the simulation stops at 200.0 seconds.
  1. Running the Simulation:

To run the simulation, we can save the Tcl script (e.g., dtn_simulation.tcl) and run it using NS2:

ns dtn_simulation.tcl

After the simulation finishes then we can open the NAM visualization tool to observe the node movements and packet exchanges:

nam dtn_out.nam

  1. Analyzing Results:
  • The trace file (dtn_out.tr) records packet-level events that comprising message forwarding, delivery, and drops. We can investigate this file to assess the performance of the DTN, concentrating on the parameters such as delivery ratio, delay, buffer usage, and latency.
  • We can be used AWK scripts or tools such as TraceGraph to analyze performance parameters like:
    • Message delivery ratio: The percentage of messages effectively delivered.
    • End-to-end delay: The time taken for a message to navigate the network from the source to the destination.
    • Buffer utilization: The storage capacity usage of nodes within the network.

Extending the Model:

  1. Buffer Management:
    • Execute custom buffer management policies (FIFO, LRU, etc.) to replicate how nodes manage the message storage in the course of high traffic or disconnections.
  2. Routing Protocols:
    • Replicate distinct DTN routing protocols such as Epidemic Routing, PRoPHET, Spray and Wait, and MaxProp by changing the message forwarding logic.
  3. Node Mobility:
    • Integrate more complex mobility models such as Random Waypoint, Random Walk, or real-world mobility traces to better reflect the behaviour of mobile nodes.
  4. Node Failures and Disruptions:
    • Replicate node failures or link disruptions to estimate how the network performs in the event of outages or network partitioning.

Here, we had offered a primary method with necessary examples and extension of the model for Delay Tolerant Networks projects, simulated and analysed through the NS2 tool. More specifics will be inserted in another manual.

For simulating Delay Tolerant Network projects using NS2, the team at phdprime.com is uniquely equipped to manage your work with exceptional efficiency. Simply provide us with your project details, and we will offer comprehensive research guidance tailored to your needs. Our technical experts are available to assist you with DTN-specific protocols, including Bundle Protocol, buffer management, and node mobility, ensuring you receive thorough explanations and support.

Opening Time

9:00am

Lunch Time

12:30pm

Break Time

4:00pm

Closing Time

6:30pm

  • award1
  • award2