Skip to main content
. 2019 Feb 28;19(5):1037. doi: 10.3390/s19051037
Algorithm 2. Cautious Adversary Algorithm
1: Adversary_location = Sink_location
2: Adversary stores information of all the Visited_immediate_sender_nodes in its memory
3: When adversary overhears a packet
Adversary_location = Immediate_sender_node_location
4: At the Adversary_location, wait for a fixed amount of time as set on the timer
5: while (Adversary_location ! = Source_node_location) do
6:     if (packet arrives at Adversary_location from Immediate_sender_node before timer expires) then
7:       if (Immediate_sender_node ! = Visited_immediate_sender_nodes) then
8:        Adversary_location = Immediate_sender_node
9:        Update Visited_immediate_sender_nodes with Adversary_location
10:       else
11:        discard the packet
12:       end if
    else
13:       move to the last Visited_immediate_sender node.
14:     end if
15: end while
// Source_node _location found