# Enhanced Integrated Satellite-Terrestrial NOMA with Cooperative Device-to-Device Communication
## 3 Satellite-Aided NOMA with Cooperative D2D Communication
### SANOCO-D2D Operation
In the next step, the algorithm calculates the rate \(R_{weak}^{D2D_{(i,j)}}\) that the weak satellite user is able to achieve via the corresponding D2D link if this pair is used, through (10), and the rate \(R_{weak}^{DECODED_{(i,j)}}\) that the weak user is able to achieve in case that the strong user forwards the received signal from the satellite to the weak user using (13). Next, considering the rate \(R_{weak}^{D2D_{(i,j)}}\) that the D2D link is able to offer to the weak user, and the rate \(R_{weak}^{DECODED_{(i,j)}}\) that the weak user is able to achieve when the strong user forwards the weak user signal, the algorithm calculates the achievable rate of the weak user by calculating the minimum of these two rates through (14), and practically uses this information to identify whether or not the D2D link is preferable compared to the directly received coded satellite signal at the weak user. Here note that the algorithm must calculate the minimum of \(R_{weak}^{D2D_{(i,j)}}\) and \(R_{weak}^{DECODED_{(i,j)}}\), because if the D2D rate surpasses the achieved rate of the weak user's signal at the strong user, then the strong user is able to send the weak user's signal through the D2D channel without errors. On the contrary, if the achievable rate regarding the D2D link is less than the rate of the weak users signal that received from the satellite at the strong user, then the D2D rate is a bottleneck that will result in reduced rate. In other words, the minimum of the two rates represents the total profit or loss of D2D cooperation. As a final step, for the weight update procedure of \(e_{i,j}\), the algorithm calculates the total sum rate that this pair of users is able to achieve through (15). The first term on the right hand side of (15) represents the achievable rate of the strong satellite user using the NOMA optimal user pairing scheme, while the second term is the achievable rate of the weak user. The achievable rate of the weak satellite user is calculated by applying the maximum function between the achievable rate \(R_{weak}^{OMA}\) of the weak user using the NOMA optimal user pairing scheme at the satellite and the achievable rate of the weak user \(R_{weak}^{NOMA-D2D_{(i,j)}}\) through the D2D link. In this way, it is ensured that if a D2D link failure occurs; then the weak channel satellite user will be served only through NOMA. Next, the weight \(w_{i,j}\) of the edge \(e_{i,j}\) is updated to the value that was calculated in the previous step through (15). The weight \(w_{i,j}\) of the edge \(e_{i,j}\) indicates the sum rate that this possible pair of users \(\text{UE}_{i}\) and \(\text{UE}_{j}\) is able to achieve and contributes to the total sum rate of the system. Finally, when the procedure of weight updating terminates, the Edmonds algorithm is executed, giving as an output the optimal user pairing policy \(\mathbf{u}_{\mathbf{i},\mathbf{j}}^{*}\) and the maximum sum rate \(R_{\text{max}}\) of the system. The proposed scheme considers the possibility where in some cases, the D2D link between two users may not be feasible because of power or propagation issues, and thus the weak user is only served through the satellite. Thus, if no profitable D2D link exists, then the optimal user pairing policy and the maximum sum rate coincide with the optimal downlink user pairing NOMA scheme [6].