Research Article

Heuristic Localization Algorithm with a Novel Error Control Mechanism for Wireless Sensor Networks with Few Anchor Nodes

Algorithm 2

Initialization phase for blind nodes.
Input: The unique ID of current node ID_c
Define: HopInfo Packet HIP = {ID, position, hopInfo}
     NeighborInfo Packet NIP = {ID1,⋯, IDn_init}
     Anchor HopInfo List
          AHL = [IDi, positioni, hopInfoi]
     Neighbor Distance List NDL = [IDi, di]
Procedure:
1: if received an HIP:
2: parse the HIP to obtain ID, position, hopInfo
3: ifID in AHL.ID and ID is an anchor:
4:  if hopInfo < AHL [ID].hopInfo
5:   AHL [ID].hopInfo = hopInfo
6: else ifID is an anchor:
7:  append [ID, position, hopInfo] to AHL
8:  send an HIP
9:  if hopInfo==1:
10:   record ID and RSSI
11: if received an NIP:
12: parse the NIP
13: ifID_c in NIP and sizeof (AHL) > 2:
14:  fori from 1 to sizeof (AHL):
15:   estimate di to each anchor based on hopInfo and the RSSI
16:  estimate the position of ID_c based on position in AHL and a series of di
17: change node type to pseudo-anchor