# Power Efficient Random Access for Massive NB-IoT Connectivity
## 3 Collision--CE Level Based RAP (PE-RAP)
It has the following key components:  
```
1:for 1: T trials do
2: Input: \(q_{0}\), \(q_{1}\), \(q_{2}\), \(R_{0}\), \(R_{1}\), \(R_{2}\), \(N\), \(M_{s}\) & \(\rho\)
3: Output: Number of attempts in each CE level and \(P_{avg}\)
4: Devices select either CE0 or CE1 or CE2 with the probability \(q_{0}\) or \(q_{1}\) or \(q_{2}\), respectively
5: Let \(n_{1}\) devices select CE0 out of \(N\) devices
6:\(n_{1t}\) = \(n_{1}\)+ New arrival + Devices that did not attempted for RAP during previous \(t_{i}-1\) slot
7:\(n_{1t}\) Device selects a random number between \([0,1]\)
8:if Selected number is \(>\) Optimal ACB factor \(\rho_{*}\), then
9: Remaining \(m_{k}\) devices out of \(n_{1t}\) devices attempt for RAP during this \(t_{i}\)
10:\(\mathbb{P}_{r}(m_{k}\mid n_{1t})=\binom{n_{1t}}{m_{k}}\rho_{*}^{m_{k}}(1- \rho_{*})^{m_{1t}-m_{k}}\)
11:\(i=i+1\) (Count attempt in CE0)
12:if Two device selects same preamble from \(M_{s}\), then
13: It is considered as collision and collision probability is \(\mathbb{P}_{r}(C)\)
14: The collision results in random access attempt failure
15: Go to step 4
16:else
17: Device is successful
18:endif
19:else
20: Wait for \(t_{i}+1\) and go to step 4
21:endif
22: Similar Process is Repeated for CE1, and CE2 to obtain \(j\) and \(n-i-j\)
23:\(P_{avg}[n]=\sum_{i=0}^{n}\sum_{j=0}^{n-i}\binom{n}{i}\binom{n-i}{j}\big{(}( iR_{0}P_{0}+jR_{1}P_{1}+(n-i-j)R_{2}P_{2})\big{)}q_{0}^{i}(1-q_{0}-q_{2})^{j}(q_{2})^{n -i-j}\)
24:\(P_{avg}=\sum_{n=1}^{\infty}P_{avg}[n]\mathbb{P}_{r}(C)^{n-1}(1-\mathbb{P}_{r}(C))\)
25:endfor
```  
**Algorithm 1** PE-RAP* Inputs \(R_{0},R_{1},R_{2}\), It is clear from the 3 GPP report on random access in NB-IoT that the PRACH configuration includes the parameter \(N_{rep}^{NPRACH}\). It gives number of NPRACH repetitions per RAP attempt [18]. It is not a fixed value and would depend upon the network configurations. For PE-RAP, we consider variables \(R_{0},R_{1}\) and \(R_{2}\), respectively, to express the number of repetitions in CE0, CE1 and CE2. For a reliable transmission at high coupling loss more number of repetitions can be configured [28]. In the succeeding performance analysis section, we give different values to \(R_{0},R_{1}\) and \(R_{2}\), such that (\(R_{0}<R_{1}<R_{2}<128\)) and observe their effect on the power consumption. * Inputs \(q_{0}\), \(q_{1}\) and \(q_{2}\) As there are three CE levels, \(q_{0}\), \(q_{1}\) and \(q_{2}\), respectively, represent the probabilities of channel conditions for CE0, CE1 and CE2 such that \(q_{0}+q_{1}+q_{2}=1\). The device that fails RAP can re-select any of the CE levels for the RAP reattempt based on the probabilities \(q_{0},q_{1}\) and \(q_{2}\). The device measures RSRP to select the CE level. Since in PE-RAP we consider that the CE level is re-selected at failure, it can be accomplished by the RSRP measurements in the real world scenario. Since our proposal is aimed at obtaining the average power consumption, the specific methodology for the measurement of RSRP is not in the scope. Instead, we use probabilities \(q_{0}\), \(q_{1}\) and \(q_{2}\) to emulate that the conditions where the device can be in any of the CE levels after the collision. The probability that the device selects CE0 for an RAP reattempt is \(q_{0}\). Similarly, the device can select CE1 or CE2 with probability \(q_{1}\) or \(q_{2}\) respectively for its RAP reattempt. In the performance analysis we vary \(q_{0}\), \(q_{1}\) and \(q_{2}\) to understand the effect of CE level variations. The channel variation over time is possible since each RAP attempt comprises of several repetitions over which the channel may change. Moreover, the device has to wait for the next PRACH occasion before it can reattempt an RAP. * RAP and preamble selection To initiate an RAP, an active NB-IoT device selects the preamble randomly from amongst the ones that are mapped to its identified CE level. In step 5 of the algorithm, if the device is in CE0, it selects the preambles configured for CE0.