How to Start Proactive Protocols Projects Using NS2
To start a Proactive Protocols project in Network Simulator 2 (NS2), we can replicate the routing protocols which help to sustain the consistent, modern routing data at every time. OLSR (Optimized Link State Routing) or DSDV (Destination-Sequenced Distance-Vector) are appropriate proactive routing protocols for such projects. Following is a comprehensive mechanism to get started:
Steps to Start Proactive Protocols Projects in NS2
- Understand Proactive Protocols and NS2 Capabilities
- Proactive Protocols Overview:
- Sustain routing tables on every node, which are periodically modernised.
- It is appropriate for networks in which often interaction is needed.
- Examples: OLSR, DSDV are proactive routing protocols.
- NS2 Support:
- NS2 environment have direct support for DSDV.
- OLSR must require for extensions or custom executions.
- Set Up NS2 Environment
- Install NS2:
sudo apt-get install ns2
- Confirm installation by executing below command:
ns example.tcl
- Define the Project Scope
- Objectives:
- Replicate the behavior of proactive routing within a static or dynamic topology.
- Estimate the performance parameters such as packet delivery ratio, routing overhead, and delay.
- Then, equate proactive protocols like OLSR vs DSDV.
- Example Scenarios:
- Examine the performance in high node mobility.
- Scalability analysis including maximizing the volume of nodes.
- Design the Network Topology
- Topology Elements:
- Nodes: It denotes devices within the network.
- Links: Signify wireless or wired connections in the network topology.
- Example Topology:
- We can deliberate a network that has 20 nodes which are arbitrarily organized within a 1000m x 1000m area.
- Write the TCL Script
- Make use of NS2’s inherent support for DSDV or integrate the OLSR extensions using tcl simulation script.
Example TCL Script for DSDV Simulation:
# Initialize the simulator
set ns [new Simulator]
# Define trace and NAM files
set tracefile [open proactive_trace.tr w]
$ns trace-all $tracefile
set namfile [open proactive_simulation.nam w]
$ns namtrace-all-wireless $namfile 1000 1000
# Configure wireless topology
set val(chan) Channel/WirelessChannel
set val(prop) Propagation/TwoRayGround
set val(netif) Phy/WirelessPhy
set val(mac) Mac/802_11
set val(ifq) Queue/DropTail/PriQueue
set val(ll) LL
set val(ant) Antenna/OmniAntenna
set val(x) 1000
set val(y) 1000
set val(ifqlen) 50
set val(seed) 1.0
# Create nodes
set num_nodes 20
set nodes {}
for {set i 0} {$i < $num_nodes} {incr i} {
set node($i) [$ns node]
$node($i) random-motion 1
lappend nodes $node($i)
}
# Set routing protocol to DSDV
$ns rtproto DSDV
# Define traffic sources
set udp [new Agent/UDP]
set null [new Agent/Null]
$ns attach-agent $node(0) $udp
$ns attach-agent $node(19) $null
$ns connect $udp $null
# Create CBR traffic
set cbr [new Application/Traffic/CBR]
$cbr set packetSize_ 512
$cbr set interval_ 0.1
$cbr attach-agent $udp
# Start traffic
$ns at 5.0 “$cbr start”
$ns at 25.0 “$cbr stop”
# Terminate simulation
$ns at 30.0 “finish”
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam proactive_simulation.nam &
exit 0
}
$ns run
- Extend the Script for OLSR
- If OLSR isn’t directly supported within NS2 version then we can download an OLSR extension to utilise research repositories or manually execute it.
- In the script, modernize the routing protocol:
$ns rtproto OLSR
- Simulate Network Dynamics
- Node Mobility: Describe the movement models for analysing the flexibility of routing.
$node(0) setdest 500 500 10.0
$node(1) setdest 800 200 15.0
- Node Failures: Replicate node failures to measure the resilience of protocol.
$ns rtmodel-at 10.0 down $node(5) $node(6)
- Run the Simulation
- We can run the TCL simulation script:
ns proactive_simulation.tcl
- Utilize NAM for envisioning the simulation:
nam proactive_simulation.nam
- Analyze Performance
- Obtain performance parameters from the trace file as proactive_trace.tr:
- Packet Delivery Ratio (PDR): Estimate the percentage of packets that are efficiently distributed.
- Routing Overhead: Count the volume of control packets which are swapped for routing overhead.
- End-to-End Delay: Compute the average delay, attaining their destination node for a packet.
- Make use of external tools like AWK or Python scripts for automated investigation.
Example AWK Script for PDR:
BEGIN {sent=0; received=0;}
{
if ($1 == “s” && $4 == “UDP”) {
sent++;
} else if ($1 == “r” && $4 == “UDP”) {
received++;
}
}
END {
print “Packet Delivery Ratio:”, received/sent;
}
- Enhance Proactive Protocols
- Security Enhancements:
- Integrate the encryption or verification for security routing messages.
- QoS Features:
- Give precedence to real-time traffic such as VoIP applying QoS aspects.
- Energy Efficiency:
- Experiment the performance under power-constrained environments like IoT networks for energy utilization.
- Document the Project
- It has contains detailed insights like:
- Clear project goals and problem statement.
- Network topology and sets up.
- Simulation outcomes using graphs and tables.
- Explanations and future references.
Finally, we had shared a detailed simulation structure with sample coding to simulate and analyse the Proactive Protocols projects that contains OLSR and DSDV using NS2 simulation environment. If you’d like additional specifics, please feel free to ask.