# M Tech Projects in NS2

Research students enhance any one routing protocol performance for their academic research. EGPSR is one the research routing protocol.M Tech Students prefer EGPSR Topic using NS2 Simulation.

What is EGPSR?Writing EGPSR Source Code using NS2 Simulation?

EGPSR (Energy Aware Greedy Perimeter Stateless Routing ) is incorporated with GPSR for each node broadcasts HELLO packets.HELLO packet contains the location information of the node, rate of energy consumption and fraction of energy consumption. M Tech Projects in NS2 for EGPSR is implemented with source code and guaranteed output.

Input: Forwarding Node F, Destination D, Neighbor-List (F)
Auxiliary Variables: Progress (F, I) where I£Neighbor-List (F)
Candidate-Neighbor-List (F), ResidualEnergy (I),
AvailableEnergy (I), InitialEnergy (I), Weight(I),
I £Candidate-Neighbor-List (F), Maximum-Weight
Output: Next-Hop-Node // if Greedy forwarding is successful
NULL // if Greedy forwarding is not successful and
// perimeter forwarding is needed
Initialization: Next-Hop-Node = NULL; Maximum-Weight  0.0
Candidate-Neighbor-List (F) Φ
Begin E-GPSR Greedy Forwarding Algorithm
DistanceF-D = (XF – XD )2 + (YF – YD )2
for every neighbor node I£Neighbor-List (F) do
DistanceI-D = (XF – XD )2 + (YF – YD )2
if (DistanceI-D < DistanceF-D) then
Candidate-Neighbor-List(F)Candidate-Neighbor-List(F)U{I}
end if
end for
for every neighbor node I£Candidate-Neighbor-List (F) do
ResidualEnergy (I) = AvailableEnergy (I) / InitialEnergy( I)
Progress (F, I) = Distance F-D – Distance I-D / Distance F-D
Weight (I)  ResidualEnergy (I) + Progress (F, I)
if (Maximum-Weight < Weight (I) ) then
Maximum-Weight = Weight (I)
Next-Hop-Node  I
end if
end for
if (Maximum-Weight > 0.0) then
return Next-Hop-Node
else
return NULL
end if
End E-GPSR Greedy Forwarding Algorithm

.Features of EGPSR routing protocol:

• Maintain route table to forward packets to the required destination.
• Achieves enhanced network performance in terms of delivery ratio
• Table row contain information of identification number, geographical location, rate of energy consumption and fraction of energy consumption.
• The rate of energy consumption and fraction of energy consumption are used to determine the energy level needed for neighbor node to transmit the packet in EGPSR scheme.

#### Journal Support for NS2 Projects: Sample code for EGPSR:

From this code we learn information of how routing mechanism is processed.

```RTMechanisms instproc sched-reward {} {
\$self instvar Reward_interval_ reward_pending_
\$self instvar ns_
if { \$reward_pending_ == "true" } {
\$self vprint 2 "SCHEDULING REWARD (NO, ALREADY PENDING)"
return
}
set now [\$ns_ now]
set then [expr \$now + \$Reward_interval_]
set reward_pending_ true
\$ns_ at \$then "\$self do_reward"
\$self vprint 1 "SCHEDULING REWARD for \$then"
}
RTMechanisms instproc do_reward {} {
\$self instvar ns_
\$self instvar last_reward_ reward_pending_
\$self instvar Mintime_
\$self instvar state_
\$self instvar pboxfm_ okboxfm_
\$self instvar npenalty_
\$self instvar Mtu_ Rtt_
\$pboxfm_ dump
set reward_pending_ false
set now [\$ns_ now]
\$self vprint 2 "DO_REWARD starting at \$now, last: \$last_reward_"
set elapsed [expr \$now - \$last_reward_]
set last_reward_ \$now
if { \$npenalty_ == 0 } {
return
}
set parrivals [\$pboxfm_ set parrivals_]
set pdepartures [\$pboxfm_ set pdepartures_]
set pdrops [\$pboxfm_ set pdrops_]
set barrivals [\$pboxfm_ set barrivals_]
set badBps [expr \$barrivals / \$elapsed]
set pflows [\$pboxfm_ flows] ; # all penalized flows

\$self vprint 1 "DO_REWARD: droprateB: [\$self frac \$pdrops \$parrivals] (pdrops: \$pdrops, parr: \$parrivals pdep: \$pdepartures)"
\$self vprint 1 "DO_REWARD: badbox pool of flows: \$pflows"

if { \$parrivals == 0 &amp;&amp; \$elapsed &gt; \$Mintime_ } {
# nothing!, everybody becomes good
\$self vprint 1 "do_reward: no bad flows, reward all"
foreach f \$pflows {
\$self unpenalize \$f
}
set npenalty_ 0
return
}
```