How to Simulate OLSR Protocol Projects Using NS2

To simulate an OLSR (Optimized Link State Routing) protocol project using NS2, we will require to follow a sequential steps, which contain writing a TCL script, allowing the OLSR protocol within NS2, and running the simulation. OLSR is a proactive routing protocol created for mobile ad-hoc networks (MANETs), and NS2 supports this protocol out of the box.

The following is a step-by-step instruction on how to simulate OLSR protocol in NS2:

Steps to Simulate OLSR Protocol Projects in NS2

  1. Install NS2 (Network Simulator 2)

Make sure NS2 is installed on the computer. Unless, we can install it using the below command on Linux:

sudo apt-get install ns2

For Windows, we can utilize Cygwin or download precompiled binaries.

  1. Create a TCL Simulation Script

Write a TCL script to describe simulation that containing the topology, node movement, traffic patterns, and the OLSR protocol.

Example TCL Script for OLSR Simulation

# Define simulator object

set ns [new Simulator]

# Open trace file for writing

set tracefile [open olsr.tr w]

$ns trace-all $tracefile

# Open NAM file for visualizing the simulation

set namfile [open olsr.nam w]

$ns namtrace-all $namfile

# Define the topology

set topo [new Topography]

$topo load_flatgrid 500 500

# Define the node parameters

set val(nn) 10               ;# Number of nodes

set val(stop) 100.0          ;# Simulation end time

set val(adhocRouting) OLSR   ;# Use OLSR routing protocol

set val(x) 500               ;# Topology X dimension

set val(y) 500               ;# Topology Y dimension

# Create the nodes

for {set i 0} {$i < $val(nn)} {incr i} {

set node_($i) [$ns node]

}

# Define the channel, propagation model, MAC type, and antenna

set val(chan)   Channel/WirelessChannel    ;# Channel type

set val(prop)   Propagation/TwoRayGround   ;# Radio-propagation model

set val(netif)  Phy/WirelessPhy            ;# Network interface type

set val(mac)    Mac/802_11                 ;# MAC type

set val(ifq)    Queue/DropTail/PriQueue    ;# Interface queue type

set val(ll)     LL                         ;# Link layer type

set val(ant)    Antenna/OmniAntenna        ;# Antenna model

set val(ifqlen) 50                         ;# Max packet in ifq

# Create the network using OLSR

$ns rtproto $val(adhocRouting)

# Set node positions and mobility

for {set i 0} {$i < $val(nn)} {incr i} {

$node_($i) set X_ [expr rand()*$val(x)]

$node_($i) set Y_ [expr rand()*$val(y)]

$node_($i) set Z_ 0.0

$ns at 0.0 “$node_($i) start”

}

# Attach agents (UDP) to nodes

set udp0 [new Agent/UDP]

$ns attach-agent $node_(0) $udp0

set udp1 [new Agent/UDP]

$ns attach-agent $node_(1) $udp1

# Create traffic between nodes

set null0 [new Agent/Null]

$ns attach-agent $node_(2) $null0

set null1 [new Agent/Null]

$ns attach-agent $node_(3) $null1

$ns connect $udp0 $null0

$ns connect $udp1 $null1

# Create a traffic pattern (CBR)

set cbr0 [new Application/Traffic/CBR]

$cbr0 set packetSize_ 512

$cbr0 set interval_ 0.005

$cbr0 attach-agent $udp0

set cbr1 [new Application/Traffic/CBR]

$cbr1 set packetSize_ 512

$cbr1 set interval_ 0.005

$cbr1 attach-agent $udp1

$ns at 1.0 “$cbr0 start”

$ns at 2.0 “$cbr1 start”

# Define the simulation end

$ns at $val(stop) “finish”

proc finish {} {

global ns tracefile namfile

$ns flush-trace

close $tracefile

close $namfile

exec nam olsr.nam &

exit 0

}

# Run the simulation

$ns run

  1. Explanation of the Script
  • Simulator Object: The simulator object ($ns) is made to manage the simulation.
  • Node Creation: A set of nodes ($node_) are made according to the defined by val(nn).
  • Routing Protocol: The OLSR protocol is triggered with $ns rtproto OLSR.
  • Traffic Pattern: Traffic is generated among the nodes utilizing UDP agents, and data is transmitted through CBR (Constant Bit Rate) sources.
  • Mobility and Topology: Nodes are located randomly in the described topology, and we can insert mobility models to replicate real-world scenarios.
  • End Simulation: The simulation runs until the specified time (val(stop)), after which the trace and NAM files are closed and the Network Animator (NAM) is introduced to envision the simulation.
  1. Run the TCL Script in NS2

We can save TCL script (e.g., olsr_simulation.tcl) and then run it in NS2 using the below command:

ns olsr_simulation.tcl

  1. Visualize the Simulation

To visualize the simulation, we can utilize NAM (Network Animator):

nam olsr.nam

It will open a graphical interface in which we can monitor the nodes, packet exchanges, and routing activity utilizing OLSR.

  1. Analyze the Trace File

The trace file (olsr.tr) encompasses detailed records of packet transmission, reception, drops, and other network events. We can process this file using tools such as AWK, Python, or other parsing tools to examine performance parameters such as:

  • Throughput: The total amount of data effectively delivered over the network.
  • Packet Delivery Ratio: The ratio of packets successfully delivered to the destination.
  • End-to-End Delay: The average time it takes for a packet to travel from the origin to the destination.
  • Packet Loss: The amount of packets, which were dropped or lost within the network.
  1. Customize the Simulation

We can extend the simple OLSR simulation by:

  • Adjusting Mobility Models: Insert random mobility or other mobility models to replicate node movement.
  • Increasing Node Density: Change the amount of nodes and link parameters (e.g., bandwidth, delay) to replicate larger or more complex networks.
  • Changing Traffic Types: Replicate TCP traffic or other application layer protocols such as HTTP or FTP.
  • Performance Metrics: Compute particular performance parameters like throughput, delay, jitter, and so on.
  1. Enhance the Project

We can insert distinct scenarios or extensions to this simulation like:

  • QoS Support: Execute and calculate Quality of Service (QoS) in OLSR networks.
  • Security Extensions: Replicate security mechanisms for OLSR, like avoiding malicious nodes from disrupting the network.
  • Performance Comparison: Compare OLSR performance with other MANET routing protocols such as AODV or DSR under distinct conditions (e.g., node mobility, density, traffic load).

From this manual, we comprehensively know the core concepts and replication procedure on how to simulate and enhance the OLSR projects within NS2 simulation environment. We are equipped to offer more insights related to this protocol in upcoming manual.

Achieve exceptional network comparisons with our expert services. You can rely on us for comprehensive guidance on optimal OLSR Protocol Projects using the ns2 simulation tool. At phdprime.com, we offer personalized support designed to address your unique requirements. Contact us to explore engaging OLSR Protocol Project topics and ideas specifically tailored for you. Our team specializes in mobile ad-hoc networks (MANETs) and NS2, so reach out to us for outstanding results.

Opening Time

9:00am

Lunch Time

12:30pm

Break Time

4:00pm

Closing Time

6:30pm

  • award1
  • award2