# Energy-Efficient Check-and-Spray Geocast Routing Protocol for Opportunistic Networks
## 3 Proposed EECSG Routing Protocol
In our proposed EECSG routing protocol, an energy-efficient controlled flooding methodology (referred to as Check-and-Spray) is designed to distribute the geo messages to all the nodes within the geocast region. It consists of two parts. In the first part, the node's energy level is checked against the threshold. The presence of the already existing message in the receiving node cast and the receiving node's current location are checked. In the second part, the message is flooded to only those nodes which have passed all the checks mentioned in the first part. Afterwards, the receivers become the senders and the Check-and-Spray method is re-invoked. This process is continued until it is resumed. Due to the first part, this controlled flooded technique tend to consume less energy. ```
1:Phase 1: Forwarding the message towards the destination cast
2:for each Sender Node(SN) meets the receiver node(RN) do
3: Calculate the Energy Threshold(ET)
4:if RN energy is \(<\) ET then
5: Skip this RN and go to the next node
6:endif
7: Drop Expired Messages from the Buffer
8: Apply Buffer Scheduling Policy
9:for each message m in the buffer do
10:if m already exists in RN then
11: Skip this m and goto the next m in the loop
12:endif
13:if RN is located in geocast area then
14: forward message to RN
15:else if S \(>\) 0 then
16: S = S - 1
17: Forward a copy to RN
```  
**Phase 2: Flooding the message to nodes within the geocast region**  
18:else if S = 0 and m is in geocast region then
19:if RN is inside the destination geocast then
20:if SN energy is greater than threshold then
21:if RN does not have the m already then
22: Forward m to RN
23:endif
24:endif
25:endif
26:endif
27:endforAn illustration of the working of the proposed EECSG routing protocol is shown in Figure 1. where the parent node in blue colour generates a message with the sequence number 3 (this is because here, the message should be able to reach the destination cast in 3 hops, otherwise it will be lost). The node in blue colour meets with its first neighbor node (node in red colour on the right) and finds out that its energy level is lower than the prescribed energy level threshold (ET). In this case, the message is not sent to that node in red and the node in blue looks for its next neighbor (node in green colour) with a good energy level, then delivers the message by decrementing the sequence number S to 2 (i.e., S = S\(-\)1). For each encountered node with a good energy level, the message is delivered by decrementing the sequence number. If S becomes 0 and the node is not in the geocast area, the message will not be forwarded further and will be considered as lost. As soon as the destination node receives the message within the geocast area, it will start implementing a check-and-wait technique for controlled flooding of the message within the geocast area. Afterwards, the nodes in yellow colour, which have shown a good energy level are those that will take part in the dissemination of the message across all neighboring nodes. The nodes in red colour, which have shown an energy level less than that of the threshold level, will only receive the messages, but could not transmit them further.