How to Start Delay Tolerant Networks Projects Using NS2
To start a Delay Tolerant Networks (DTN) project in NS2 (Network Simulator 2) includes replicating the networks, which function within environments in which traditional, continuous end-to-end connectivity cannot be assured. DTNs are normally utilised that there are long delays or intermittent connectivity like space interactions, rural networks, or mobile ad hoc networks (MANETs).
Store-and-forward and epidemic routing protocols are typically utilised in which nodes save the messages in anticipation of an appropriate connection for sending them, which is available in DTNs. While NS2 doesn’t advanced built-in DTN support, we can prolong it by means of executing the essential protocols in Tcl and OTcl scripting.
Steps to Start Delay Tolerant Networks Projects in NS2
- Install NS2
Initially, we make sure that NS2 installed properly. Unless, download it through official NS2 website or its repository based on the operating system.
- Download NS2 from: NS2 Website
- Adhere to the installation steps depends on the OS.
- Understand DTN Concepts
DTN concentrates on the networks including intermittent or delayed connectivity. In DTNs, core concepts are:
- Intermittent Connectivity: Connects among the nodes that are not dynamic every time, which means there is periods once a node isn’t associated to the network.
- Store-and-Forward: Messages are saved by intermediate nodes and shared if connectivity turns out to be available.
- Routing Protocols: DTNs frequently utilise certain routing mechanisms such as Epidemic Routing, Spray and Wait, and Probabilistic Routing.
The main challenges in DTN:
- Network partitioning.
- High delay within packet transmission.
- Limited bandwidth.
- Create a Basic Topology for DTN Simulation
We can make a simple network topology for a DTN project in NS2. Nodes are frequently contains mobile or intermittent connections in DTN scenarios. We will need to start with basic topologies such as mobile ad hoc network (MANET) or mobile nodes in a rural area to replicate how nodes can be transmitted the data in the course of connectivity.
Below is an example of making a simple mobile node network for DTN:
Example: Simple Topology for DTN
# Initialize the simulator
set ns [new Simulator]
# Create nodes
set node1 [$ns node]
set node2 [$ns node]
set node3 [$ns node]
# Create links (no physical links, as we want intermittent connectivity)
# Here, we simulate the lack of links with delayed forwarding
$ns duplex-link $node1 $node2 10Mb 10ms DropTail
$ns duplex-link $node2 $node3 10Mb 10ms DropTail
# Create mobile movement for nodes (simulate mobility)
$node1 random-motion 1
$node2 random-motion 2
$node3 random-motion 3
# Create the application layer (data generation)
set app1 [new Application/Traffic/CBR]
set app2 [new Application/Traffic/CBR]
set app3 [new Application/Traffic/CBR]
# Attach the applications to the nodes
$app1 attach-agent $node1
$app2 attach-agent $node2
$app3 attach-agent $node3
# Set the traffic for the CBR (Constant Bit Rate) application
$app1 set packetSize_ 512
$app1 set rate_ 1000
# Set the destination for the traffic flows
$app1 set dstNode $node2
$app2 set dstNode $node3
$app3 set dstNode $node1
# Run the simulation
$ns run
This script configures a basic network topology in which mobile nodes are made, then every single node contains a Constant Bit Rate (CBR) traffic generator (it replicates the application layer), and random motion is utilised for replicating node mobility.
- Implement Delay Tolerant Network Routing Protocols
DTN is routing protocol. While NS2 doesn’t offer advance support for DTN protocols but we can execute the routing protocols such as Epidemic Routing, Spray and Wait, or Probabilistic Routing. Following is an example of a simple Store-and-Forward protocol simulation:
Example: Simple Store-and-Forward Protocol
# Define a simple agent to represent DTN store-and-forward behavior
namespace eval StoreAndForward {
# Create a basic store-and-forward agent
proc forward {src dst packet} {
# Store the packet temporarily
puts “Storing packet from $src to forward to $dst later”
# Simulate the forwarding after a delay
$src at 5.0 “forward-packet $packet $dst”
}
proc forward-packet {packet dst} {
# After the delay, forward the packet
puts “Forwarding packet to $dst”
$dst send $packet
}
}
This instance is a simple execution in which packet is by a node, and it is sent to the next node after stipulated delay.
We need to execute various kinds of DTN protocols to utilise this structure. For instance:
- Epidemic Routing: Nodes simulate the messages and send them to any node they converge.
- Spray and Wait: A node scatters a small volume of message copies to other nodes and waits in anticipation of it can be distributed the message to end node.
- Probabilistic Routing: According to the likelihood of successful delivery for sending the decisions are probabilistically made.
Every protocol needs custom logic, and we want to construct them by means of describing new OTcl classes for the certain behavior of protocol and message handling.
- Simulate Intermittent Connectivity
Connectivity can be erratic in DTNs. We utilise mobility models for replicating it and describe the time intervals in the course of which nodes can interact.
For instance, nodes can change position and make intermittent connections with the support of random waypoint mobility,:
# Define node mobility (random waypoint model)
$node1 random-motion 1
$node2 random-motion 2
$node3 random-motion 3
On the other hand, we utilise more complex mobility models, which mimic real-world situations.
Example: Simulate Intermittent Connectivity
We should replicate intermittent nature of connections by way of enabling/disabling links among the nodes at particular intervals.
# Disable the link between node1 and node2 at 10 seconds
$ns at 10.0 “disable-link $node1 $node2”
# Re-enable the link at 20 seconds
$ns at 20.0 “enable-link $node1 $node2”
It mimics a scenario in which the connection among nodes is intermittently available in DTNs.
- Custom DTN Application Layer
We can replicate the delays within data transmission and store-and-forward protocols for applications in DTNs. We make a custom DTN application layer, which handles data packets and controls once and how data is sent depends on the network situations.
Example: Custom DTN Application Layer
namespace eval DTNApp {
# Procedure for generating data packets at a node
proc generatePacket {src dst} {
set packet [new Packet]
$packet set data “Data from $src”
# Store packet until the destination is reachable
StoreAndForward::forward $src $dst $packet
}
}
In this case, a node makes a data packet rather than immediately transmitting it and saves and sends it once the destination is available.
- Configure Simulation Parameters
In DTN simulations, we can set the simulation for exposing realistic network conditions:
- Bandwidth and delay: We will need to set bandwidth and delays among the nodes to utilise duplex-link or simple-link commands.
- Mobility models: We replicate node mobility by way of describing random waypoints or certain movement models.
- Traffic patterns: Make use of applications such as CBR, FTP, or custom traffic generators.
Example of configuring bandwidth and delay:
# Define a link with delay and bandwidth
$ns duplex-link $node1 $node2 1Mb 100ms DropTail
- Run the Simulation
When we have configured the nodes, applications, routing protocols, and network configurations then we execute the simulation:
ns dtn_simulation.tcl
This command executes the simulation script and makes trace files to examine DTN network behavior.
- Analyze Simulation Results
NS2 environment generates the trace files, which has records concerning the packet transmission, delays, and network events. These files can utilised for examining the performance parameters such as:
- Protocol efficiency.
- Packet delivery ratio.
- Number of hops per packet.
- End-to-end delay.
Make use of NAM (Network Animator) for envisioning the behavior of network or manage the trace files to obtain statistics.
- Extend the Simulation
When basic functionality is functioning then we can expand the DTN simulation in diverse ways:
- Execute the DTN routing protocols such as Epidemic or Spray and Wait.
- Replicate mobile nodes including further realistic movement models.
- Integrate fault tolerance aspects like node failures and recovery.
- Test with various kinds of applications such as file transfer, email systems to execute across a DTN.
Conclusion
To start a Delay Tolerant Network (DTN) project using NS2:
- Defining network topology: Configure a network in which nodes are intermittently associated in the topology.
- Implementing DTN protocols: Inscribe custom routing mechanisms like Store-and-Forward, Epidemic Routing.
- Simulating intermittent connectivity: Make use of mobility patterns and control link availability.
- Creating DTN applications: Replicate the applications like data generation, storage, and forwarding according to the network situations.
- Configuring simulation parameters: Configure metrics such as traffic, delays, and mobility models.
- Running and analyzing results: Examine the simulation to utilise trace files and NAM for visualization.
Here, NS2 environment permit us to design and replicate the Delay Tolerant Networks in a controlled environment utilise provided steps and sample coding, with more in-depth content to be available in the upcoming manual.