To simulate Delay Tolerant Network (DTN) protocols in NS2 have includes setting up the network to manage the periodic connectivity, long latency, and the store-carry-forward mechanism usual of DTN routing. NS2 does not directly support DTN, however there are extension lead and patches, like NS2-DTN, that allow DTN-specific functionalities, that has numerous routing protocols such as Epidemic Routing, PRoPHET, Spray and Wait, and more.
Here’s a step-by-step guide to help you simulate DTN protocols in NS2.
Steps to Simulate DTN Protocols in NS2
- Set up NS2 with DTN Support
NS2 by default does not support DTN-specific protocols, so we want to patch NS2 or install an extension such as NS2-DTN. Follow these steps:
- Install NS2: If NS2 is not already installed, we can download it from here.
- Patch NS2 with DTN Extensions: We can identify patches for DTN support or utilize NS2-DTN. These patches incorporate DTN capabilities, like bundle protocols, store-carry-forward mechanisms, and common DTN routing protocols.
- Understand DTN Protocols
DTN protocols perform on the principle of store-carry-forward. Nodes store packets (bundles) when there is no instant connectivity to the destination and forward them when a communication opportunity rises.
- Epidemic Routing: Nodes flood bundles to other nodes they encounter, making sure that the data reaches the destination.
- PRoPHET: A probabilistic routing protocol that forwards bundles according to historical encounters among nodes.
- Spray and Wait: Restrictions the number of copies of a bundle spread via the network to minimize overhead.
- Download and Apply the DTN Patch
To permit DTN simulation in NS2:
- Download the NS2-DTN patch or extension (or the equivalent DTN patch).
- implement the patch to NS2 installation using:
patch -p1 < dtn_patch.diff
- Rebuild NS2:
make clean
make
This will incorporate DTN functionality to NS2, enabling you to replicate DTN routing protocols.
- TCL Script Structure for DTN Simulation
Here’s an instance TCL script for simulating a DTN network using Epidemic Routing or any other DTN protocol executed in NS2.
Example TCL Script for DTN Simulation
# Create a new simulator object
set ns [new Simulator]
# Open files for tracing and NAM visualization
set tracefile [open dtn.tr w]
$ns trace-all $tracefile
set namfile [open dtn.nam w]
$ns namtrace-all-wireless $namfile 500 500
# Define network topology and set up wireless channel
set topo [new Topography]
$topo load_flatgrid 500 500
set chan_1_ [new Channel/WirelessChannel]
set prop [new Propagation/TwoRayGround]
set netif [new Phy/WirelessPhy]
set mac [new Mac/802_11]
set ll [new LL]
set ifq [new Queue/DropTail/PriQueue]
set antenna [new Antenna/OmniAntenna]
# Set the routing protocol to Epidemic (or any other DTN protocol)
set routingProtocol Epidemic
# Node configuration for DTN with Epidemic Routing
$ns node-config -adhocRouting $routingProtocol \
-llType $ll \
-macType $mac \
-ifqType $ifq \
-ifqLen 50 \
-antType $antenna \
-propType $prop \
-phyType $netif \
-channel $chan_1_ \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON
# Create mobile nodes
set num_nodes 10
for {set i 0} {$i < $num_nodes} {incr i} {
set node($i) [$ns node]
}
# Set node positions (you can adjust positions for testing)
$node(0) set X_ 50.0
$node(0) set Y_ 50.0
$node(1) set X_ 150.0
$node(1) set Y_ 150.0
# Define positions for more nodes…
# Define mobility for nodes
for {set i 0} {$i < $num_nodes} {incr i} {
$ns at 0.0 “$node($i) setdest 250 250 10”
}
# Create a DTN application and attach to nodes
for {set i 0} {$i < $num_nodes} {incr i} {
set app($i) [new Application/DTN]
$app($i) attach-agent $node($i)
}
# Set up traffic sources for DTN nodes
set udp0 [new Agent/UDP]
$ns attach-agent $node(0) $udp0
set udp1 [new Agent/UDP]
$ns attach-agent $node(1) $udp1
# Create CBR traffic for DTN
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp0
$ns at 2.0 “$cbr start”
# Connect the traffic sources and sinks
$ns connect $udp0 $udp1
# Run the simulation for 100 seconds
$ns at 100.0 “finish”
# Define finish procedure
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam dtn.nam &
exit 0
}
# Run the simulation
$ns run
- Explanation of the Script
- Simulator Setup: The simulator object is generated, and trace files are opened for logging simulation events.
- Node Configuration: DTN nodes are generated using a certain DTN routing protocol, such as Epidemic Routing. Each node is ready with DTN capabilities.
- Node Mobility: Nodes are set to move around the simulation area, denotes the mobility of nodes in a DTN.
- Traffic Generation: CBR (Constant Bit Rate) traffic is created using UDP as the transport protocol to replicate data transfer among nodes.
- DTN Application: A DTN application is attached to each node, allowing them to store and forward packets when they encounter other nodes.
- Simulation End: The simulation executes for 100 seconds, and at the end, the trace files are flushed, and NAM is introduced for visualization.
- Running the Simulation
Once we have generated TCL script (e.g., dtn_simulation.tcl), we can execute the simulation using the following command:
ns dtn_simulation.tcl
- Analysing the Results
- NAM Visualization: we can open the .nam file in NAM (Network Animator) to envision on how nodes move and communicate in the DTN. Utilize the following command to envision the network:
nam dtn.nam
- Trace File Analysis: The .tr file logs events like packet transmissions, latency, and delivery. we can evaluate this file using AWK or Python scripts to extract parameters like:
- Packet Delivery Ratio (PDR)
- End-to-End Delay
- Overhead
- Buffer Utilization
- Performance Metrics for DTN
Typical parameters to measure DTN protocols that involves:
- Packet Delivery Ratio (PDR): The ratio of successfully delivered bundles to the total number of bundles sent.
- End-to-End Delay: The time taken for a bundle to reach the destination, deliberate latency because of store-carry-forward operations.
- Buffer Utilization: The amount of buffer space utilized at each node to store bundles while waiting for forwarding opportunities.
- Routing Overhead: The number of control messages interchanged in the network.
- Optional Extensions
We can expand the DTN simulation by:
- Implementing Different Routing Protocols: Replicate other DTN routing protocols such as PRoPHET, Spray and Wait, and relate their performance with Epidemic Routing.
- Varying Node Mobility: Establish different mobility models, like Random Waypoint or Gauss-Markov, to replicate more realistic movement patterns.
- Buffer Management: Validate different buffer management policies at nodes to enhance the delivery ratio and reduce latency.
Using the above procedures we completely get an advanced knowledge about the configuration setup and evaluation process to simulate the Delay Tolerant Network. More information will be shared about the Delay Tolerant Network and its execution in different simulations. Submit all your details to phdprime.com we assure you with good simulation guidance.