How to Implement Network DTN Management in NS2

To implement the Delay Tolerant Network (DTN) management within NS2 that has encompasses to simulating networks in which connectivity among the nodes is intermittent, and data need to transmit using a store-and-forward method. This management are especially helpful within environments in which continuous network connectivity is not guaranteed, like disaster recovery, space communications, and vehicular ad hoc networks. For more project guidance you can be in touch with us we give you best implementation guidance.

Key Concepts in DTN Management:

  1. Store-and-Forward: These nodes are store data while no path is obtainable and forward it while connectivity is restored.
  2. Custody Transfer: The nodes can be taken responsibility for a message (bundle) and make sure its distribution to the next node.
  3. Intermittent Connectivity: This connectivity between the nodes are not continuous, and delays in data transmission are predictable.
  4. Buffer Management: Nodes are handle their buffer space to store messages up to them can be forwarded.
  5. Routing Protocol: DTNs frequently use a particular routing protocols such as Epidemic Routing, Prophet Routing, or Spray-and-Wait.

Steps to Implement DTN Management in NS2

  1. Define Network with Intermittent Connectivity: To replicate a network in which nodes are not always connected, and data must be stored and forwarded.
  2. Implement Store-and-Forward Mechanism: These nodes are store messages in a buffer and forward them while they are able to associate to the next node.
  3. Buffer Management: Execute the logic to handle the buffer at every node.
  4. Routing Strategy: Describe a routing protocol that manages intermittent connections, like Epidemic Routing or Prophet Routing.
  5. Custody Transfer: Optionally execute custody transfer, in which nodes are take responsibility for make sure message delivery.

Example: Simulating DTN Management in NS2

This sample establishes how to replicate a basic DTN in NS2, in which nodes are store and forward data as connectivity becomes obtainable. It also launches a simple buffer management system to manage message storage at intermediate nodes.

Step 1: Set Up the Network with Intermittent Connectivity

# Define the simulator object

set ns [new Simulator]

# Define trace and nam files for output

set tracefile [open out.tr w]

set namfile [open out.nam w]

$ns trace-all $tracefile

$ns namtrace-all $namfile

# Define a ‘finish’ procedure to end the simulation and visualize in NAM

proc finish {} {

global ns tracefile namfile

$ns flush-trace

close $tracefile

close $namfile

exec nam out.nam &

exit 0

}

# Set up the topography for the simulation area

set topo [new Topography]

$topo load_flatgrid 1000 1000

# Define the wireless channel

set chan [new Channel/WirelessChannel]

# Configure wireless nodes (representing DTN nodes)

$ns node-config -adhocRouting DSDV \

-llType LL \

-macType Mac/802_11 \

-ifqType Queue/DropTail/PriQueue \

-ifqLen 50 \

-antType Antenna/OmniAntenna \

-propType Propagation/TwoRayGround \

-phyType Phy/WirelessPhy \

-channel $chan

# Create three DTN nodes: sender, forwarder, and receiver

set sender [$ns node]

set forwarder [$ns node]

set receiver [$ns node]

# Set node positions (for visualization in NAM)

$sender set X_ 100; $sender set Y_ 100; $sender set Z_ 0

$forwarder set X_ 500; $forwarder set Y_ 500; $forwarder set Z_ 0

$receiver set X_ 800; $receiver set Y_ 800; $receiver set Z_ 0

# Create duplex links between sender and forwarder, and forwarder and receiver

# Links will be activated and deactivated to simulate intermittent connectivity

$ns duplex-link $sender $forwarder 2Mb 10ms DropTail

$ns duplex-link $forwarder $receiver 2Mb 10ms DropTail

# Step 2: Implement Store-and-Forward Logic for DTN Nodes

# Procedure to simulate data bundling and store-and-forward transmission

proc store_and_forward {src dst bundle_size delay} {

global ns

# Create a TCP agent at the source and a sink at the destination

set tcp [new Agent/TCP]

set sink [new Agent/TCPSink]

$ns attach-agent $src $tcp

$ns attach-agent $dst $sink

# Connect the TCP agent to the sink

$ns connect $tcp $sink

# Simulate the transmission of a bundle of data (large data transfer)

set ftp [new Application/FTP]

$ftp attach-agent $tcp

$ftp start 1.0   ;# Start transmission at 1 second

$ftp stop 3.0    ;# Stop transmission at 3 seconds (simulating a bundle)

# After some delay (simulating intermittent connectivity), forward the bundle

$ns at [expr 3.0 + $delay] “forward_bundle $src $dst $bundle_size”

}

# Procedure to forward the bundle when the connection is restored

proc forward_bundle {src dst bundle_size} {

global ns

puts “Forwarding bundle of size $bundle_size bytes from $src to $dst…”

# Simulate bundle forwarding after connection restoration

# Create a TCP agent at the intermediate node and forward the data

set tcp_forward [new Agent/TCP]

set sink_forward [new Agent/TCPSink]

$ns attach-agent $src $tcp_forward

$ns attach-agent $dst $sink_forward

$ns connect $tcp_forward $sink_forward

set ftp_forward [new Application/FTP]

$ftp_forward attach-agent $tcp_forward

$ftp_forward start 5.0   ;# Forward the bundle after the connection is restored

$ftp_forward stop 6.5    ;# Stop forwarding after 1.5 seconds

}

# Step 3: Simulate Intermittent Connectivity

# Initially, the connection between the forwarder and receiver is down

$ns lossmodel $ns at 1.0 “disable-link $forwarder $receiver”

# Enable the connection after some delay (simulating intermittent connectivity)

$ns at 5.0 “enable-link $forwarder $receiver”

# Step 4: Schedule Store-and-Forward Operations

# Schedule the store-and-forward operation between sender and forwarder

$ns at 0.5 “store_and_forward $sender $forwarder 5000 2.0”

# Step 5: Finish the Simulation

# Schedule the end of the simulation

$ns at 10.0 “finish”

# Run the simulation

$ns run

  1. Explanation of the Script
  • Store-and-Forward Mechanism: The store_and_forward technique that replicates the procedure of bundling data at the sender node and storing it up to the connection to the next hop (forwarder) is obtainable. When available, the data is forwarded using the forward_bundle technique.
  • Intermittent Connectivity: The link among the forwarder and receiver is primarily inactivated to mimic a disconnection, and after a delay, it is permitted. The forwarder stores the bundle up to the connection is restored.
  • TCP for Data Transmission: The script uses TCP to mimic large bundle transmissions among the nodes.
  1. Run the Simulation

We can save the script as dtn_management.tcl then run it using:

ns dtn_management.tcl

It will produce a trace file (out.tr) and a NAM file (out.nam). The trace file records the packet transmissions, and the NAM file permits to envision the DTN store-and-forward behaviour.

  1. Visualize the Simulation in NAM

To envision the simulation in NAM, use the below command:

nam out.nam

In NAM, we will see the sender transmitting data to the forwarder, followed by the forwarder storing the data and sending it when the link to the receiver is restored.

  1. Advanced DTN Management Features
  • Custody Transfer: Execute a custody transfer in which a node takes responsibility for make sure the delivery of the bundle.

Example of Custody Transfer:

proc custody_transfer {node} {

puts “Custody transfer at node $node: Node now responsible for bundle delivery.”

}

# Schedule custody transfer at the forwarder node

$ns at 2.5 “custody_transfer $forwarder”

  • Buffer Management: Execute buffer management at the forwarder node to store several bundles until, theycan be sent.

Example of Buffer Management:

set buffer_size 10000  ;# Define a buffer size

proc store_bundle_in_buffer {forwarder bundle_size} {

global buffer_size

if { $bundle_size <= $buffer_size } {

puts “Bundle stored in buffer at forwarder.”

set buffer_size [expr $buffer_size – $bundle_size]

} else {

puts “Buffer full at forwarder! Cannot store bundle.”

}

}

# Simulate storing a bundle in the buffer at the forwarder

$ns at 3.0 “store_bundle_in_buffer $forwarder 5000”

  • DTN Routing: We can execute furthered DTN routing protocols such as Epidemic Routing, Spray-and-Wait, or Prophet Routing by changing how nodes are forward bundles.

Through these methods you can get to know more regarding to execution and their methods about the network DTN management with sample snippets NS2. More informations will be presented regarding this topic in another manual.