Research Article

Energy-Efficient Cluster Based Routing Protocol in Mobile Ad Hoc Networks Using Network Coding

Algorithm 1

Packet encoding procedure.
Coding Procedure
{
  Pick packet p at the head of the output queue
  Createtopology(n);
  UpdateNbrRecTable(P);
  U = tdpFwdnode(n);
   if u is not equal to Fwder(P) return;
   if allNbrRecv(P) return;
   if(Natives(p))
  { if(Prob(p)>0.4 and DelayTolerance(p)>0.8)
   { if size(p) > 100 bytes then
    { which queue = 1
    }
    else
    { which queue = 0
    }
   ObtainCodeSet(C)
   {// Pick packet p at the head of the output queue
      C = p
      for each remaining packet r in the queue
      {  for each neighbor v
         {if (cannot decode(p r)) then
         {  goto Continue
         }
      }
      C = C r
      p = p r
      Continue
   }
   return C
   }
   if ( > 1) then
    { sendCodedPkts(C);
   }
   else if (!Timeout(p)
   {  Queue(p,t);
   }
   else {  send Native(p);
   }
   }  else
   {
      for each r = decode(P)
      {  TDP_NC(P);
      }
   }
   }