# BiPAD: Binomial Point Process Based Energy-Aware Data Dissemination in Opportunistic D2D Networks
## 2 BiPAD: Binomial Point Process-Based Energy-Aware Data Dissemination
### Distributed Relay Selection and BPP-Based D2D Data Dissemination  
We herein propose the furthest-\(k\) relay selection algorithm from the \(n\)-th nearest distance in (4). From (4), the distance from the source to the \(k\)-th furthest device can be described as:  
\[r_{k}=\dfrac{\bar{R}n^{1/2}}{(\bar{N}+1)^{1/2}}, \tag{5}\]  
where \(k=\bar{N}-n+1\) and \(\bar{N}=N\times\dfrac{\pi R^{2}}{\pi R^{2}}\). Furthermore, \(R\) and \(\bar{N}\) indicate the transmission range of the transmitter and the number of receivers within its transmission range, respectively. The overall procedures of the proposed algorithm can be described as follows.  
**Start of data dissemination**:
1. A source device sends a message, including its location information and the desired number of relays, \(k\). Here, \(k\) is determined as the number required to achieve the same message delivery ratio as the epidemic routing algorithm.
**Calculation of \(r_{k}\)**:
2. If a device receives the message from the source, it calculates the \(k\)-th furthest distance from the source device to the furthest \(k\)-th device (\(r_{k}\)) using the received \(k\) value and the total number of devices within the transmission range of the receiver, as estimated by the network user density.
**Distributed forwarding decision and termination**:
3. The receiver calculates the distance from the source device to itself, \(r_{user}\). If \(r_{user}\geq r_{k}\), the receiver prepares to forward the received message including its location information and the \(k\) value to its neighboring devices. Then, the receiver forwards this message to its neighbors. In our proposed BiPAD algorithm, using the \(r_{k}\) value, the source device can select almost exactly the number of relay devices using this distributed forwarding decision based on BPP.
* Repeat Step 1 to Step 3 until the messages are disseminated to the entire network.  
To calculate (5) in the BPP, the source device must know the exact or approximate number of neighbors within its transmission range. To this end, the source device can use the average device density of the network as a whole to estimate the number of neighbor devices within the range.  
Figure 1 shows an example of the furthest-krelay selection of the proposed BiPAD algorithm when \(\bar{N}=5\) and \(k=4\). One example of a D2D data dissemination scenario is that of a D2D-based rescue request. In our proposed algorithm, the source device generates and transmits a message that includes the location information of the source device (i.e., global positioning system (GPS) value) and the \(k\) value to all the devices within its transmission range. Provided that the neighboring devices receive the message from the source device, the devices can calculate the \(k\)-th furthest distance from the source device. Alternatively, instead of the \(k\) value, the source device can directly transmit the \(k\)-th furthest distance from the source device. Each device can check its location through GPS. Devices that receive the message from the source device then know whether to forward the message or not. In other words, devices located beyond the \(k\)-th furthest distance forward the message to neighbor devices within their own transmission ranges. Note that those devices that previously received the same message do not then relay the message. The above procedure is consecutively repeated until there are no more devices that cannot receive the messages within the coverage of all the relays. In summary, in the epidemic routing protocol, all devices must forward the message in the transmission range of every device, while only those devices in the range between \(r_{k}\) and the maximum transmission range are chosen to forward the message in the proposed BiPAD algorithm.