# Cross-Cycled Uplink Resource Allocation over NB-IoT
## 3 Cross-NP Uplink Resource Allocation
### Algorithm Description  
In this section, we propose a cross-NP uplink resource-allocation algorithm. This algorithm allocates the subframes of the current NP and uses the following NP's uplink resources without affecting the uplink resources available to the next NP. Furthermore, this algorithm allocates UEs using the subframes that cannot be used in the next NP because of scheduling delays to increase resource utilization and use the as few subframes as possible to satisfy the needs of all UEs. This algorithm first determines the allocation order of UEs based on the transmission spectrum efficiency. The UE with the highest spectrum efficiency is selected first. Moreover, because NPRACHs may use some subframes, this algorithm considers the number of remaining subcarriers in each subframe to select the used modulation and unit type for the UE. In addition, because the NB-IoT resource allocation protocol for the uplink should meet Equation (1), an NPUSCH start subframe is a substantial subframe. This NPUSCH start subframe occupied by a UE without efficiently using the following NPUSCH subframes will cause some subframes to never be used. Therefore, this algorithm checks whether vacating an occupied NPUSCH start subframe of a UE can release more usable subframes to serve other UEs. The pseudo-code of the cross-NP uplink resource allocation is presented in Algorithm 1. In the first line, the number of \(P\) NPs to meet the data requirements of all UEs is set to 0. In line 3, we call the Transmission-Performance() function to calculate the transmission performance (bits) of each UE \(d\) with each unit type \(u\) and modulation strategy \(m\) in a subframe and store it in table \(v(d,u,m)\). The Transmission-Performance() function is revised from the UPLOAD-SIZE() function proposed in [12]. In Line 4, we sort the UE index in descending order according to the data requirement \(\psi_{d}\) of each UE \(d\). That is, we give a higher priority to the UE with a higher data requirement. In lines 5-25, we try to schedule \(D\) UEs in an NP and search for a combination of the four parameters, the unit type, modulation, available DCI, and scheduling delay value, for a UE. For a selected UE \(d^{\prime}\), we should select one combination of unit type \(u\) with modulation \(m\) from the \(UM\) selections (Line 6). According to table \(v(d^{\prime},u,m)\), this algorithm chooses the \(j\)-th combination of \(u^{\prime}\) and \(m^{\prime}\) with the highest spectrum efficiency for UE \(d^{\prime}\) (Line 7). Then, in Lines 8-16, we find a DCI \(c\) with a scheduling delay value \(k_{0}^{i}\) for UE \(d^{\prime}\). If NPUSCH start subframe \(t_{i}^{i}\) is farther than the farthest unusable subframe of the next NP (i.e., \(t_{i}^{i}\geq L+R_{max}/R+k_{0}^{0}+1\)) or has no empty subcarriers (i.e., \(S_{P}^{\ell_{i}}+r_{p}^{i}\geq F\)), DCI \(c\) using scheduling delay \(k_{0}^{i}\) is unavailable. Therefore, we try the next one (Lines 8-11). Otherwise, it indicates that the cell currently has sufficient radio resources using the four parameters for the UE. Used DCI \(c^{\prime}\) and scheduling delay value index \(i^{\prime}\) are set as \(c\) and \(i\), respectively (Lines 13-14). The \(j\)-th combination of \(u^{\prime}\) and \(m^{\prime}\) can be used for the UE, and indicator \(X_{P,d^{\prime}}^{u^{\prime},m^{\prime}}\) is set as 1. Because this algorithm finds four available parameters for the UE, we break the three for loops (Lines 15-16). If this algorithm cannot find a combination of the four parameters for UE \(d^{\prime}\), it goes to Line 5 to serve the next UE. In Line 17, we call the Subframe-Allocation() function to allocate subcarriers and subframes for UE \(d^{\prime}\) using the four parameters. This function returns the number of allocated units for UE \(d^{\prime}\) (i.e., \(l_{d^{\prime}}^{h}\)) and the last allocated subframe index \(\tau_{d^{\prime}}\), which is designed for the NSF-Adjustment() function.