# RDSP: Rapidly Deployable Wireless Ad Hoc System for Post-Disaster Management
## 3 System Architecture of the RDSP Scheme
Hence, it can be seen from Figure 4 that relays having lower IDs are much closer to the server as compared with relays having higher IDs. Algorithm 3 presents the MMN algorithm. This MMN algorithm is used by client and relay devices to dynamically select their next neighbor relays for the transmission of messages. As shown in step 2, each relay device stores available network IDs in \(Array_{id}\). Then, \(Array_{id}\) is sorted in ascending order. Finally, the relay device finds \(Min_{ID}\) and \(Max_{ID}\) by selecting the first and last index of \(Array_{id}\), respectively. ```
1:procedure
2: Step 1: defining and initializing variables
3:\(Array_{id}\) = Array containing available networks IDs
4:\(F_{index}\) = First index of \(Array_{id}\)
5:\(L_{index}\) = Last index of \(Array_{id}\)
6: Step 2: Finding Minimum and Maximum IDs
7: Store \(AVB_{net}\) in \(Array_{id}\)
8: Sort \(Array_{id}\) in ascending order
9:\(Min_{ID}\) = \(Array_{id}\) [ \(F_{index}\)]
10:\(Max_{ID}\)= \(Array_{id}\) [ \(L_{index}\)]
11:endprocedure
```  
**Algorithm 3** Minimum Maximum Neighbor (MMN)  
**Input:**\(AVB_{net}\) (Available Networks)  
**Output:**\(Min_{ID}\) and \(Max_{ID}\)  
**Algorithm 4** Minimum Maximum Neighbor (MMN)  
**Input:**\(AVB_{net}\) (Available Networks)  
**Output:**\(Min_{ID}\) and \(Max_{ID}\)  
The detailed procedure of the MMN algorithm is explained in Figure 5. Figure 5 shows that all the relays have been assigned IDs after applying the DIA algorithm, as explained earlier in Algorithm 2. Afterwards, each relay will select its next neighbor relay for the transmission of messages. It is shown in Figure 5 that relay X will receive IDs 0 and 2 from server S and relay Y respectively. By applying MMN algorithm, relay A will choose 0 as the minimum ID and 2 as maximum ID. Similarly, in the same fashion, relay Y will receive IDs 1 and 3 from relay X and Z, respectively. After applying the MMN algorithm, relay Y will chose 1 as the minimum ID and 3 as the maximum ID. Algorithm 4 presents the code for the microcontroller in the relay device. The input to the relay device is a request message \(R_{msg}\), an acknowledgment message \(Ack_{msg}\), and available networks \(AVB_{net}\). The output is either a request message or an acknowledgment message. As shown in step 1, the relay device scans for available networks and then it applies the DIA algorithm to select its ID and then the MMN algorithm to select minimum and maximum neighbor IDs. Then in step 2, the relay device continuously waits for the detection of events. If \(R_{msg}\) is detected, then the request message is sent to the next relay node having \(Min_{ID}\). However, if \(Ack_{msg}\) is detected, then acknowledgment is sent back towards the client device via the next relay node having \(Max_{ID}\). ```
1:procedure
2: Step 1: defining and initializing variables
3: Scan \(AVB_{net}\)
4: Apply DIA Algorithm (assigns ID)
5: Apply MMN Algorithm ( returns Min & Max ID)
6: Step 2: detecting events
7:while 1 do
8:if\(R_{msg}=true\)then
9: send \(R_{msg}\) to \(Min_{ID}\)
10:endif
11:if\(Ack_{msg}=true\)then
12: send \(Ack_{msg}\) to \(Max_{ID}\)
13:endif
14:endwhile
15:endprocedure
```  
**Algorithm 4** Relay device  
Figure 5: Minimum Maximum Neighbor selection  
Figure 6 shows the flow chart of client device. The client device includes a GPS system, a microcontroller, WiFi device, and a push button. The GPS device is utilized to receive the latitude and longitude information of the victim. The microcontroller is utilized to transmit the victim's position information to the server via the WiFi module. As shown in the flowchart, after initialization, the client device scans for available networks and applies the MMN algorithm that returns the minimum and maximum IDs (explained earlier). Afterwards, the client device reads the status of push button. If the push button is pressed, it connects with the relay node having a minimum ID.