How to Simulate GPSR Protocol Projects Using NS2

To simulate GPSR (Greedy Perimeter Stateless Routing) that contains valuable steps using NS2, which is a geographic routing protocol frequently utilized within mobile ad-hoc networks (MANETs) and Vehicular Ad-hoc Networks (VANETs). It consumes geographic location data to forward packets and switches among the Greedy forwarding and Perimeter routing when greedy forwarding flops. The network environment NS2 does not natively support GPSR, thus we will either require to execute GPSR manually or we will be used available patches or extensions.

Here, we will teach you through the simulation process on how to simulate GPSR protocol projects using NS2:

  1. Install NS2 with GPSR Support

Since NS2 doesn’t contain GPSR by default then we can look for patches or manually insert GPSR. If we discover a GPSR patch then we follow these steps to apply it:

Apply GPSR Patch to NS2

  1. Download the GPSR patch.
  2. Apply the patch to NS2.

cd ns-allinone-2.35/ns-2.35

patch -p1 < gpsr-patch.diff

  1. Rebuild NS2:

./configure

make clean

make

When the patch is applied then we can set up GPSR in the NS2 simulations.

  1. Configure Nodes and Wireless Topology

In GPSR, nodes are create forwarding decisions according to their own and their neighbours’ geographical positions. We will require to make a wireless network and allocate nodes’ locations.

Example TCL Script to Set Up a Wireless Topology:

# Create a new simulator instance

set ns [new Simulator]

# Set up network parameters (wireless channel, propagation, MAC, etc.)

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

set val(prop)           Propagation/TwoRayGround   ;# 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 type

set val(x)              1000                       ;# Topology X dimension

set val(y)              1000                       ;# Topology Y dimension

# Configure nodes to use GPSR routing protocol

$ns node-config -adhocRouting GPSR \

-llType $val(ll) \

-macType $val(mac) \

-ifqType $val(ifq) \

-ifqLen 50 \

-antType $val(ant) \

-propType $val(prop) \

-phyType $val(netif) \

-channelType $val(chan)

# Create nodes

set n0 [$ns node]

set n1 [$ns node]

set n2 [$ns node]

set n3 [$ns node]

set n4 [$ns node]

# Assign initial positions to nodes

$n0 set X_ 10; $n0 set Y_ 20; $n0 set Z_ 0.0

$n1 set X_ 300; $n1 set Y_ 200; $n1 set Z_ 0.0

$n2 set X_ 500; $n2 set Y_ 700; $n2 set Z_ 0.0

$n3 set X_ 700; $n3 set Y_ 500; $n3 set Z_ 0.0

$n4 set X_ 900; $n4 set Y_ 900; $n4 set Z_ 0.0

# Enable mobility (if needed)

$ns at 5.0 “$n0 setdest 400 300 10.0” ;# Move node n0 to new location at 10m/s

  1. Set Up GPSR Traffic

When the nodes and topology are set up then we can be described communication among the nodes. GPSR uses geographical forwarding thus we will monitor how nodes forward packets rely on proximity.

Example of TCP Traffic Over GPSR:

# Set up TCP connection between node 0 and node 4

set tcp0 [new Agent/TCP]

set sink0 [new Agent/TCPSink]

$ns attach-agent $n0 $tcp0

$ns attach-agent $n4 $sink0

$ns connect $tcp0 $sink0

# Create FTP traffic over TCP

set ftp0 [new Application/FTP]

$ftp0 attach-agent $tcp0

$ns at 2.0 “$ftp0 start”

$ns at 10.0 “$ftp0 stop”

Example of CBR Traffic Over GPSR:

# Set up UDP communication between node 1 and node 3

set udp0 [new Agent/UDP]

set null0 [new Agent/Null]

$ns attach-agent $n1 $udp0

$ns attach-agent $n3 $null0

$ns connect $udp0 $null0

# Generate CBR traffic over UDP

set cbr0 [new Application/Traffic/CBR]

$cbr0 set packetSize_ 512

$cbr0 set rate_ 100kb

$cbr0 attach-agent $udp0

$ns at 2.5 “$cbr0 start”

$ns at 9.5 “$cbr0 stop”

  1. Simulating Perimeter Routing in GPSR

GPSR changes to perimeter mode when greedy forwarding flops (i.e., when no closer node to the destination exists). We can be replicated this by positioning nodes when greedy forwarding will fail, activating perimeter routing.

For instance, make obstacles or node distributions in which greedy forwarding will not discover the destination directly.

  1. Run the Simulation

We can save TCL script (e.g., gpsr_simulation.tcl) and run the simulation using NS2:

ns gpsr_simulation.tcl

It will make trace files (.tr) and NAM files (.nam) for performance analysis and visualization in Network Animator (NAM).

  1. Analyze the Simulation Results

After running the simulation then we can investigate the outcomes utilizing the trace files. Significant parameters to estimate for GPSR performance contain:

  • Packet Delivery Ratio (PDR): The percentage of packets efficiently delivered.
  • End-to-End Delay: The total time it takes for packets to attain the destination.
  • Routing Overhead: The extra control packets made for conserving routes and executing perimeter routing.

Example AWK Script to Calculate Packet Delivery Ratio:

BEGIN { sent = 0; received = 0; }

{

if ($1 == “s” && $4 == “AGT”) { sent++; }

if ($1 == “r” && $4 == “AGT”) { received++; }

}

END { print “Packet Delivery Ratio = “, received/sent*100, “%”; }

  1. Example Project Ideas for GPSR Simulation
  1. Performance Comparison of GPSR vs. AODV:
    • Mimic both GPSR and AODV in the similar scenario and compare their performance such as packet delivery ratio, end-to-end delay, and routing overhead.
  2. Impact of Node Density on GPSR:
    • Examine how increasing or decreasing the amount of nodes within the network affects GPSR’s performance, specifically such as perimeter routing.
  3. GPSR in Vehicular Networks:
    • Replicate a VANET scenario with vehicles utilizing GPSR for communication, and learn how node mobility and network topology impact on routing performance.
  4. Energy-Efficient GPSR:
    • Change GPSR to encompasses energy-efficient metrics, and replicate it in a wireless sensor network to estimate node lifetime and energy consumption.
  5. Impact of Obstacles on GPSR:
    • Make an obstacles in the simulation (e.g., black-hole nodes or restricted areas) and focus on how GPSR switches among the greedy forwarding and perimeter routing.

Within NS2 simulator, we successfully done the simulation process and attain the results for Greedy Perimeter Stateless Routing (GPSR) protocol projects with the help of above fundamental concepts and procedure. Our team provide complete guidelines to assist you in replicating GPSR Protocol Projects utilizing NS2, tailored to your specific requirements. Additionally, you can obtain expert advice on mobile ad-hoc networks (MANETs) and Vehicular Ad-hoc Networks (VANETs) from phdprime.com, where we also present optimal research topics and exceptional writing services.

Opening Time

9:00am

Lunch Time

12:30pm

Break Time

4:00pm

Closing Time

6:30pm

  • award1
  • award2