# UAV Charging Station Placement in Opportunistic Networks
## 7 Routing Protocols
### State-Based Campus Routing (SCR) Protocol  
In SCR [40], nodes can serve either as a sender or a receiver. When two nodes come within a certain proximity to each other, they open a session. First, the sender node sends the message vector to the receiver node while keeping in mind that each message has an expiration date. The receiver node replies by sending another message vector that holds the message IDs that the receiver node does not have. The sender then sends the required messages whose IDs are listed in the previous transmission. Following this, the two nodes switch sender and receiver roles and open a new session. In this routing method, each node can be either in an idle or active state. A node is considered to be in an idle state if the node encounters many nodes within a short period of time compared to its past encounter frequencies, at which point we presume that the node is in a standby area, such as a waiting place or a hot spot. If the node is in an active state, it means that the node is either walking or at someplace where encounter frequency is lower. The pseudo-code for an SCR session is shown in Algorithm 5. ```
Input: Hosts \(u\) and \(v\)  boolean Session \(SV(u)\) and \(SV(v)\) Output: booleanmessagesExchange
```
Drop messages with expired lift-time from \(u\) and \(v\);  
ifSessionthen  Host \(u\) sends \(SV(u)\) to \(v\); \(\overline{msg_{S}^{s}}\gets SV(u)+(\
eg SV(v))\);  Host \(v\) requests \(\overline{msg_{S}^{s}}\) from \(u\);  Host \(u\) sends \(\overline{msg_{S}^{s}}\) to \(v\); foreach\(m\in\overline{msg_{S}^{s}}\)do if\(\mathit{lsDestination}(v)\)then \(\mathit{consume}(v,m)\); else \(\mathit{store}(v,m)\);  end if  end for  Host \(v\) sends \(SV(v)\) to \(u\); \(\overline{msg_{S}^{s}}\gets SV(v)+(\
eg SV(u))\);  Host \(u\) requests \(\overline{msg_{S}^{s}}\) from \(v\);  Host \(v\) sends \(\overline{msg_{S}^{s}}\) to \(u\); foreach\(m\in\overline{msg_{S}^{s}}\)do if\(\mathit{lsDestination}(u)\)then \(\mathit{consume}(u,m)\); else \(\mathit{store}(u,m)\);  end if  end fore \(\mathit{messagesExchange}\leftarrow\mathit{true}\)  end fore
```

**Algorithm 5** State-based Campus routing (SCR) protocol

## 8 Simulation Study

In this section, we explain our simulation environment, the datasets, and the metrics used to evaluate the simulation scenario. ### Simulation Environment

The simulation study for the application scenario was carried out using Java. The in-house simulator by [PERSON] and [PERSON] [11] is further developed for this application. The opportunistic wireless environment includes a 10% error rate for wireless communication. We assume that the encounter duration between the nodes is long enough for packet exchange. Based on the nature of the opportunistic network, if the receiver does not receive a protocol message, the sender does not send the packet again. The reason being the message may be received from another node again when encountering takes place. ### Dataset

Two datasets have been used in our simulation (Table 1), North Carolina State University (NCSU) and the Korea Advanced Institute of Science and Technology (KAIST) dataset by [PERSON] et al. [56]. The datasets contain the traces of the nodes every 10 s. The locations in the datasets are relative to an origin location. We have used the data points of all the nodes on the map at 300 s time intervals while applying the clustering techniques. Below is the description of each dataset:

**NCSU Dataset**: NCSU dataset contains 35 movement traces of students in the NSCU campus for 78,090 s which equates to more than 21 h. The width of the simulation environment is 14,629 m by 9714 m. We have removed the third movement trace. The removed movement trace goes to the corner of the map where no node movement activity takes place after around.