Research Article

Directional Itinerary Planning for Multiple Mobile Agents in Wireless Sensor Networks

Algorithm 4

Mobile agent.
/fill in the MAs with the identifiers of the NSs/
Begin
for i :=1 to k do / k: number of neighboring nodes at the Sink /
for j :=1 to N do / N : number of SNs in D[i] /
 MA[i]@List_Src[j] := T[i,j]@id; / fill in the identifiers of the SNs which are in table T in MA /
end for;
end for;
/send each MA to the SN furthest in its list/
for i :=1 to k do / k: number of neighboring nodes at the Sink or number of MAs /
Pass the MA[i] at MA[i]@List_Src [1];
MA[i]@Data :=Ri1 ; / Put the data from the furthest SN to the MA packet /
end for;
for i :=1 to k do
for j :=2 to N do
 Pass the MA[i] at MA[i]@List_Src[j];
  if the SN data is already existing in the MA[i]@data packet then
  break; / ignore data and move on to next (go back to loop) /
  else
  MA[i]@Data = MA[i]@Data + ρ . Rij ; / add data to MA packet /
  end if;
end for;
 Pass the MA at Sink;
end for;
End.