Set of anchor positions:
Set of untrustworthy anchor to node RSSs:
Set of trustworthy anchor to anchor RSSs:
Detection threshold:
 Define a grid G of L points in the plane, covering the WSN deployment region and an array V of L counters.
for every anchor   do
  Obtain a ring of the form (2) that should ideally contain the node position, using (3)
   for every point of the grid   do
   if     then
    Increment counter of votes for point g:
   end if
  end for
end for
 Obtain the intersection region as the set of grid points with maximum number of “votes”:
 Estimate the position of the node as the centroid of the intersection area:
 Compute the sample mean of the number of votes:
if   then
  set  wormhole_flag true
  set  wormhole_flag false
end if
return  wormhole_flag and estimated position
Algorithm 3: Simultaneous localization and wormhole detection. Nonparametric approach: DWARFLoc.