## 3 Flood and Contain (F&C)  
The main goal of F&C is to stop further propagation of a flooding search once the target node is found, guaranteeing that the generated overhead is always less than or equal to the one generated by the original flooding. To achieve this, F&C uses two flooding events with different propagation speeds. During the initial flooding, a source node seeking a route to a node having a particular resource or feature floods the network with RQ packets. Upon receiving a RQ packet, a target node initiates a fast chase flooding to eat up the initial slow flooding packets to avoid unnecessary resource consumption in the rest of the network. For this operation to occur, it is necessary for the initial flooding to propagate more slowly than the chase flooding. To slow down the propagation of search packets during the initial flooding, nodes receiving an RQ packet do not retransmit it immediately, but keep it in their buffer for a short predetermined period (\(\Delta_{t}\)) before forwarding it. What sets F&C apart from any other repeal-based protocol is that nodes only launch a chase flooding if the reported hop-count to the source node is smaller than the node's estimated repeal-flooding boundary. This condition guarantees that the aggregate overheard, considering the initial and chase flooding, never surpasses traditional flooding overhead. In case the reported hop-count to the source node is within the repeal-flooding boundary, the target node launches the chase flooding of RP packets. In this case, nodes attempt to retransmit RP packets as soon as they receive them. In case a node receives an RP packet before it has forwarded the previously received RQ packet, further propagation of both RQ and RP packets stops. This operation contains the area flooded with control packets during the resource discovery phase to a portion of the network only, as opposed to traditional flooding in which typically the entire network is flooded with signaling packets. Algorithm 1 defines the operation of the F&C protocol. ```
/*S: source node*/ /*D: Resource node set*/ /*N: node*/
1:\(S\) initiates a slow flooding of RQ packets
2:\(N_{i}\) receives an RQ
3:if\(N_{i}\
otin D\)then
4:\(N_{i}\) reads delay flooding parameter \(\Delta_{t}\)
5:\(N_{i}\) waits \(\Delta_{t}\) seconds
6:\(N_{i}\) forwards the RQ packet
7:elseif\(N_{i}\in D\)then
8:if\(N_{i}\) is reached after \(N_{i}\)'s repeal-flooding boundary then
9:\(N_{i}\) replies to S (unicast) using the reverse route
10:elseif\(N_{i}\) is located before \(N_{i}\)'s repeal-flooding boundary then
11:\(N_{i}\) initiates a chase flooding of RP packets
12:endif
13:endif
14:\(N_{i}\) receives an RP packet
15:if\(N_{i}\) has previously received an RP then
16:\(N_{i}\) does not forward the RP packet
17:endif
18:if\(N_{i}\) has already received and forwarded the RQ packet then
19:\(N_{i}\) forwards the RP packet
20:elseif\(N_{i}\) has the RQ packet in its buffer then
21:\(N_{i}\) does not forward the RQ and RP packets
22:endif
```  
**Algorithm 1** F&C (S, N, D)  
Figure 2 graphically illustrates the behavior of the F&C protocol. Figure 2a shows source node \(S\) initiating flooding of RQ packets in search of a target node in \(D\); blue diamonds illustrate nodes propagating RQ packets. Every time a node receives an RQ packet, it keeps the packet in its buffer for a predefined time interval (\(\Delta_{t}\)) before forwarding the packet again. Figure 2b,c show further propagation of RQ packets over time. Upon receiving the first RQ packet (see Figure 2c), a target node replies immediately with an RP packet (see Figure 2d) (this example assumed that the source node is within the target node's maximum repeal-flooding boundary). The RP originates a chase flooding that propagates faster since nodes receiving an RP packet attempt to retransmit it as soon as possible. Figures 2d-f illustrate further propagation of RP packets, represented by red stars.