1 Introduction

Quite recently, considerable attention has been paid to D2D communications, that is considered as one of the technologies that can enhance the user data rate, reduce the power consumption and minimize latency for data transfer [1]. The principle of D2D communication is to allow the nearby user equipments to directly communicate with each others without the need to traverse the base station. The concept of D2D seems tolerable, but it has a lot of confrontations, such as resource allocation, power allocation, interference management, etc. So, this paper concentrate on the resource and power allocation. The resource allocation in a D2D system is divided into two types, namely, inband resource allocation and outband resource allocation [2]. In the inband resource allocation, the cellular resources are utilized for both cellular users and D2D users, where the D2D users are controlled by the cellular system. The inband resource allocation is divided into two types, namely, underlay resource allocation and overlay resource allocation. In the underlay inband resource allocation, the cellular users and D2D users share the same band; and consequently this improves the spectrum efficiency. The major challenge of underlay D2D resource allocation is the mutual interference among the cellular and D2D users. This interference problem should be solved by using improved resources allocation and power control algorithms. In the overlay in-band resource allocation, the resources are divided into two dedicated bands; the first band is used by the cellular users and the second band is used by the D2D users. The merit of the overlay resource allocation is that there is no interference between the cellular users and D2D users, but it may reduce the spectrum efficiency. In the out-band resource allocation, an unlicensed spectrum is utilized for D2D communications, where there is no interference between the cellular users and D2D users. The out-band resource allocation is divided into two types controlled and autonomous. In the controlled out-band resource allocation, the D2D users are controlled by the cellular network. On the contrary, in the autonomous out-band resource allocation, the cellular network does not have such control on the D2D communication.

In the recent past years, great effort has been devoted to study the resource and power allocation in wireless communication systems. The target is to increase the data rate, the spectral efficiency and the energy efficiency. For example, the authors in [3] investigate the joint subcarrier assignment with power allocation problem for a non-orthogonal multiple access (NOMA) system, in the presence of eavesdroppers. The authors of [3] exploit cooperative jamming for enhancing the security of the communication link in order to maximize the total achievable secrecy energy efficiency. In [4], user association and power allocation in mm Wave based ultra dense networks (UDNs) is considered, for increasing both of energy and spectral efficiency.

Moreover, many research works have studied the resource and power allocation for the in-band D2D communication. Some of these research works concentrate on the underlay D2D communications, such as [5]. The authors in [5] tried to mitigate interference between D2D users and cellular users. Therefore, they have presented two schemes to mitigate the mutual interference among the D2D users and the cellular users. In this regard, the transmitting device of a D2D link selects a resource block and adjusts its transmission power in order to constrain the interference within a tolerable threshold. As a result of this, the system throughput can be increased with \(40\%\). In [6], the resource sharing between cellular users and D2D users in an underlay scenario were studied. It has been shown that, the resource sharing problem in an underlay D2D communications can be formulated as a non-linear optimization problem in order to find the optimum resource allocation solution. However, they proved that this optimization problem is NP-hard combinatorial optimization problem, where the complexity of solving the problem increases exponentially with the number of cellular users and D2D users. Thus, they have proposed an interference-aware graph-based resource allocation scheme in order to mitigate the complexity of the original resource sharing problem. However, their graph-based scheme leads to a non-optimal solution. [7] considered an underlay D2D communications network, where the authors presented an algorithm that allocates the power and selects the mode (either cellular mode or D2D mode) for each user in the network so as to maximize the power efficiency. In [8], the authors analysed the system performance of D2D communications underlaying cellular system. Also, they presented a joint mode selection and power allocation scheme for D2D users.

Furthermore, several publications have appeared in recent years focusing on the overlaying D2D communications. For instance, the authors of [9] present a resource allocation and mode selection scheme for overlay D2D using carrier sensing threshold. Their objective is to maximize the rate of the D2D users provided that the target rate of the cellular users are not affected. However, the authors of [9] did not consider power control for both the cellular users and D2D users. In [10], the authors propose a resource allocation approach for D2D communications overlaying two-way cellular networks. Their approach allows the D2D users to communicate bi-directionally with each other, and at the same time, utilizes the D2D users as relays to assist the two-way communications of the cellular users with the base station. Furthermore, they considered power control for both D2D links and cellular links. In [11], a Minimum Rate Proportional Fairness (MRPF) algorithm was proposed for the overlay D2D communication that maximize the total rate of the system using the proportional fairness between the D2D and cellular devices. A key limitation of the work presented in [11] is that the authors assume a fixed power allocation. [12] investigates a joint spectrum and power resource allocation in the overlay OFDMA D2D communications to enhance the system throughput with low complexity, however fairness among the D2D pairs is not taken into account.

This article introduces a novel algorithm for both resource and power allocation considering fairness of resource allocation among D2D pairs. Simulation results show that the fairness of the proposed algorithm outperforms the fairness of best subcarrier channel state information resource allocation (BSCR) and subcarrier achievable data rate (SAD) algorithms, which are proposed in [12]. The BSCR is a greedy algorithm, where a certain subcarrier is allocated to the D2D pair that has the best channel condition over this subcarrier. Then, local water-filling is performed in order to allocate the power for the allocated subcarriers of every D2D pair. The SAD algorithm assumes that the power is equally allocated for all subcarriers for each D2D pair. The achievable data rate is calculated before and after allocating a new subcarrier to all D2D links. The differences between the new and the old achievable rates should be calculated. Then, SAD allocates the subcarrier to the D2D link that achieves the maximum increase in data rate using this subcarrier. Finally, SAD performs local water-filling power allocation for each D2D pair based on subcarriers allocated to this pair.

The remainder of this paper is organized as follows. Section 2 describes the resource allocation system model of the OFDMA D2D communication overlaying cellular networks. The problem formulation of the proposed algorithm with fair resource allocation depending on the Jain’s fairness index [13] and power allocation using water-filling algorithm is introduced in Sect. 3. The simulation results and the performance effectiveness of the proposed algorithm is presented in Sect. 4. In Sect. 5, the conclusions are drawn.

2 System model

We consider D2D communications in an interference limited area overlaying a cellular network as depicted in Fig. 1. A typical cell in cellular network has a single base station at its center. We assume that M D2D pairs are located in the considered interference limited area within the cell. Furthermore, it is assumed that E OFDMA subcarriers are dedicated to the D2D users. The frequency selective fading is assumed where the different subcarriers do not encounter the same fading. The fading on every subcarrier is assumed to be fixed during the resource allocation period. Furthermore, it is assumed that every subcarrier encounters a Rayleigh flat fading for all D2D users, i.e., the fading is constant in the entire bandwidth of every individual subcarrier. An additive white Gaussian noise (AWGN) is introduced at the receiver of the D2D link. This paper concentrates on the scenario where the application is sensitive to any source of interference such as factory automation, autonomous driving, remote surgery, etc. These applications require immediate connection and low latency. So an interference-limited area, where the resources are not reused, is considered in this paper. Although reusing the resources among different D2D pairs can improve the spectral efficiency, it is not preferred for interference-sensitive applications because the introduced interference can impact these applications dramatically. So this paper assumes no spectrum reuse between different D2D pairs, i.e., each subcarrier can be allocated to a single D2D link only [14].

Fig. 1
figure 1

An illustration of dedicated resource allocation for D2D communication

Here, we define \(\varOmega _{e,m}\) as the subcarrier allocation indicators, which indicates whether the e-th subcarrier is allocated to the m-th D2D link or not. In this sense, \(\varOmega _{e,m}= 1\) when the e-th subcarrier is allocated to the \(D2D_m\) link, otherwise \(\varOmega _{e,m}= 0\), where \(m \in \{1,\ldots ,M\}\) and \(e \in \{1,\ldots ,E\}\). If the e-th subcarrier is allocated to \( D2D_m\) link, the received signal at the receiver of the \( D2D_m\) link on the e-th subcarrier, \(X_{e,m}\), is calculated as

$$X_{e,m}=\sqrt{P_{e,m}.D_m^{-\alpha }} . h_{e,m} . S_{e,m} + N_{e,m}, $$
(1)

where \(S_{e,m}\) is the signal transmitted by the transmitter of the m-th D2D link on the e-th subcarrier, and \( N_{e,m}\) is the AWGN at the receiver which is distributed as \({\mathcal {C}}{\mathcal {N}}(0,\sigma ^2)\). Also, \(D_m\) is the distance between the transmitter and the receiver of the m-th D2D link, and \(P_{e,m}\) is the power transmitted by the transmitter of the m-th D2D link on the e-th subcarrier. Furthermore, \(\alpha \) is the path loss exponent and \(h_{e,m}\) is the small scale fading coefficient of the channel for \(D2D_m\) pair on the e-th subcarrier. The signal to noise ratio (SNR) for \(D2D_{m}\) on the e-th subcarrier, \(SNR_{e,m}\), is given by

$$ {\mathrm {SNR}}_{{\mathrm {e}},{\mathrm {m}}} = \frac{P_{e,m}.h_{e,m}^{2}.D_{m}^{-\alpha }}{B.N_A}, $$
(2)

where B is the subcarrier bandwidth and \(N_A\) is the AWGN power spectral density. The instantaneous data rate that can be achieved on the e-th subcarrier for \(D2D_m\) link, \(\varGamma _{e,m}\), is given by

$$ \varGamma _{e,m} =B.\log _2\left( 1+\frac{P_{e,m}.h_{e,m}^2.D_{e,m}^{-\alpha }}{\sigma ^2}\right) ,$$
(3)

When the network is at state, t, every \( D2D_m \) link will be allocated a subset of the available subcarriers according to the subcarrier allocation indicators of the \( D2D_m \) link, \(\varOmega _{e,m}(t)\). At this state, t, the total data rate for \(D2D_m\) link, \(R_m(t)\), is given by

$$ R_m(t) = \sum \limits _{e=1}^{E} \varOmega _{e,m}(t).\varGamma _{e,m},$$
(4)

Furthermore, at state, t, the total system throughput, R(t), is given by

$$ R(t)=\sum \limits _{m=1}^{M} R_m(t), $$
(5)

The fairness index of the network at state, t, is denoted by FI(t) and is given by

$$ FI(t) =\frac{\left( \sum \nolimits _{m=1}^{M} R_{m}(t)\right) ^2}{M.\sum \nolimits _{m=1}^{M}\Big (R_{m}(t)\Big )^2} $$
(6)

3 Proposed scheme

In this section, the resource allocation for D2D communications overlaying cellular system is represented as an optimization problem. Furthermore, the proposed algorithm is introduced to solve the optimization problem in order to improve the fairness of resources allocation while not degrading the individual users’ performance. We utilized the local water-filling algorithm for allocating the power budget of each D2D pair over the subcarriers allocated to this D2D pair.

3.1 Problem formulation

The target of this paper is to maximize the fairness index in the considered interference-limited area. At the same time, we should ensure that every individual D2D link achieves the maximum possible data rate by efficiently distributing its available power, \(P_M\), among the subcarriers allocated to it. We performed this in two consecutive stages. In the first stage, we assume equal power allocation over subcarriers that may be used by each D2D link. Correspondingly, we seek subcarriers allocation scheme that maximizes the fairness index of the network. In the second stage, we will apply the local water-filling algorithm for each D2D link. This ensures that every individual D2D link can achieve the maximum achievable data rate using the subcarriers allocated to it in the first stage.

Regarding the first stage, our target is to allocate the available subcarriers so as to maximize the data rate fairness among the existing D2D pairs. This can be achieved by solving the following optimization problem

$$\max _{\{\varOmega _{e,m}\forall e,m\}} \quad FI $$
(7a)
$${\text {subject to}} \quad \sum _{m=1}^{M} \varOmega _{e,m} = 1, \quad \forall e$$
(7b)
$$P_{e_m,m} = \frac{P_M}{E_m}, \quad \forall m, e_m \in {\mathbb {E}}_m$$
(7c)
$$\varOmega _{e,m} \in \{0,1\}, \quad \forall m, e$$
(7d)

The objective (7a) of the optimization model (7) is to find the set of the optimum subcarrier allocation indicators, \(\varOmega _{e,m}\), that maximizes the network fairness index. The first constraint (7b guarantees that a subcarrier is allocated only to a single D2D link. The second constraint (7c) declares that equal power allocation among subcarriers of each D2D link is used at this first stage. Here, \(P_{e_m,m}\) is the power allocated to subcarrier \(e_m\) of user m, \(E_m\) is the number of subcarriers allocated to the \(D2D_m\) link and \({\mathbb {E}}_m\) is the set of subcarriers allocated to \(D2D_m\) link. The third constraints ensure that the subcarrier allocation indicators \(\varOmega _{e,m}\) are binary variables. It should be noted that solving the optimization model (7) is not trivial as its complexity increases with increasing the numbers of both subcarriers and D2D links. So we will adopt an iterative approach where we allocate a single subcarrier at a time such that the fairness index after allocating this subcarrier is maximized.

3.2 Proposed iterative FORA algorithm

The proposed algorithm for solving the optimization problem (10) is called the iterative fairness optimization resource allocation algorithm which is presented in Algorithm 1. In what follows we explain our iterative fairness optimization resource allocation (FORA) approach.

Consider that the D2D network in the considered area is at state t, and we have a new subcarrier i that should be allocated to a certain D2D pair. If this subcarrier i is allocated to the \(D2D_k\) pair, the new corresponding rate, \(R_k(t+1)\), of this \(D2D_k\) pair becomes

$$ R_k(t+1) = \sum \limits _{e=1}^{E} \varOmega _{e,k}(t+1).\varGamma _{e,k} = R_k(t)+\varGamma _{i,k},$$
(8)

Consequently, when the subcarrier i is allocated to the \(D2D_k\) link, the corresponding network fairness index at this new state \(t+1\) is given by

$$ FI_{i,k}(t+1) =\frac{\left( \sum \nolimits _{m=1}^{M} R_{m}(t+1)\right) ^2}{M.\sum \nolimits _{m=1}^{M}\Big (R_{m}(t+1)\Big )^2},$$
(9)

It should be noted that all D2D pairs in the new state \(t+1\) will have the same rate as the old state t, except only the \(D2D_k\) pair that utilized the new subcarrier i, which will have new data rate as presented in Eq. (8). Our aim is to allocate this new subcarrier i to the \(D2D_{k^*}\) such that the fairness index is maximized at state \(t+1\). This can be achieved by solving the following optimization problem

$$ k^*=\mathop {{\hbox {arg max}}}\limits _{k} \ \ {FI_{i,k}(t+1)}$$
(10)

If only one D2D pair \(k^{*}\) leads to the same maximum fairness when assigning the subcarrier i to it, the algorithm allocates the subcarrier i to this pair \(k^{*}\). If more than one D2D pairs can achieve the maximum fairness when the subcarrier i is allocated to any of them, the algorithm calculates the increase in the rate, \(\delta _{i,k}\), for all these D2D pairs

$$ \delta _{i,k} = {R}_{k}(t+1) - {R}_{k}(t) = \varGamma _{i,k},$$
(11)

Thus, the algorithm allocates the subcarrier i to the D2D pair \(k^{*}\) that has the highest increase in data rate according to the following equation

$$ k^*=\mathop {{\hbox {arg max}}}\limits _{k\in {\mathbb {M}}} \ \delta _{i,k},$$
(12)

where \({\mathbb {M}}\) is the set of all D2D pairs that achieve the same maximum fairness when the subcarrier i is allocated to any of them.

This should be repeated for all available free subcarriers i. By doing so, we can allocate all the subcarriers in the network. After that, in the second stage, the water-filling power allocation is adopted to allocate the available power of every D2D link for the subcarriers allocated based on solving the iterative FORA (10). In local water-filling method, the maximum transmit power for each D2D link is distributed among the allocated subcarrier for this D2D link. The distributed power among the subcarriers for a single D2D pair depends on the CSI of each subcarrier, such that, subcarriers with low channel gain will be allocated low amount of power, while subcarriers with high channel gain will be allocated high amount of power, proportionally. The concept of local water-filling algorithm aims to increase the data rate for each individual D2D pair using its allocated subcarrier. In a cellular system, the usage of the global water-filling is suitable for the cellular system as the base station is only responsible for allocating the power to all subcarrier [15, 16], but in a D2D system each device has its own maximum power. Therefore, the local water-filling algorithm is used in this paper.

The complexity of iterative FORA algorithm is analyzed using big \({\mathcal {O}}\) notation. In Algorithm 1, there are three major parts that contributes the most in the complexity of the proposed algorithm for allocating each subcarrier \(i \in \{1,2,\ldots ,E\}\). First, calculating the fairness index if the subcarrier i is allocated to each D2D pair, \(k\in \{1,2,\ldots ,M\}\). This part is represented by the lines from line 5 to line 9 in Algorithm 1 and the complexity of calculating it is \({\mathcal {O}}\) (M). Second, finding the D2D pair that, if the subcarrier i is allocated to this D2D pair, will lead to the maximum fairness index. This part is in line 11 and requires \({\mathcal {O}}\, (M)\) operations. Third, in case of more than D2D pairs lead to the same maximum fairness index, identifying which D2D pair will achieve the maximum increase in data rate is required. This part is executed in the lines from line 12 to line 17 of Algorithm 1. In the worst case, when all D2D pairs have the same fairness index, this part will necessitate \({\mathcal {O}}\, (M)\) operations. All these steps are performed for a number of E subcarriers. Thus, the total complexity of the proposed iterative FORA algorithm is \({\mathcal {O}}\, (E*3M)\).

figure a

4 Simulation results

In this section, a comparison has been made between the proposed iterative FORA algorithm, and both of SAD and BSCR algorithms for a single cell where OFDMA is utilized. The subcarrier bandwidth is 15 kHz. The variance of fading coefficient of the channel for each D2D pair is \(E[h_{e,m}^2] = 1\). We assumed a fixed distance between the transmitter and the receiver of every D2D pair is 1 meter. The noise spectral density at the receiver is − 111 dB/Hz. This section is divided into three subsections to show the performance effectiveness of the iterative FORA algorithm with the variation of different system parameters. Here, we define \( R_{min}\), \(R_{max}\) and \( R_{mean}\) as the minimum data rate achieved by a D2D link in the network, the maximum data rate achieved by a D2D link in the network and the average of the data rates of all D2D links in the network, respectively.

4.1 Performance evaluation with different number of users

This part seeks to discover the performance of iterative FORA algorithm with increasing the number of D2D pairs, as the change in the number of the D2D pairs can affects the achieved data rate and the fairness of allocation. The number of subcarrier is assumed to be 64. The fixed coherence bandwidth of the channels is taken by 15 kHz. The ratio of maximum total transmit power per device to the noise power per subcarrier \((\frac{P_M}{N_A . B})\) is 30 dB. The number of D2D pairs is varied from 2 to 20.

Fig. 2
figure 2

Relationship between the \( \frac{R_{min}}{R_{max}} \) and \( \frac{R_{min}}{R_{mean}}\) versus the number of D2D pairs for 15 kHz fixed coherence bandwidth and \((\frac{P_M}{N_A . B})=30 \) dB

Fig. 3
figure 3

Jain’s fairness index versus various number of D2D pairs for 15 kHz fixed coherence bandwidth and fixed \((\frac{P_M}{N_A . B})\) 30 dB

Figure 2 presents the ratio of minimum to maximum and minimum to mean link’s data rate versus various number of D2D pairs. It is shown that \( \frac{R_{min}}{R_{max}}\) and \(\frac{R_{min}}{R_{mean}}\) decrease with increasing the number of D2D pair for all algorithms. This is because, as the number of D2D pairs increases, the number of allocated subcarriers to the single D2D link decrease. So, bad links get less chance to get subcarrier and their data rates become very small, and the \( \frac{R_{min}}{R_{max}}\) and \(\frac{R_{min}}{R_{mean}}\) decrease. Also, it can be seen that Fig. 2, the iterative FORA algorithm significantly outperforms both of the BSCR and SAD algorithms because the iterative FORA algorithm is based on improving the fairness regardless of the channel conditions, but the subcarriers allocation of both SAD and BSCR algorithms depend only on the quality of channels. Figure 3 shows that the iterative FORA algorithm gets approximately optimal fairness index compared with BSCR and SAD algorithms. The probability that many links has a very good channel quality while others has a very bad channel (deep fading) increases, if the number of D2D pair increases. So, it is clear that the fairness index of both SAD and BSCR algorithms decreases as the number of D2D pairs increase because both SAD and BSCR algorithms depend only on the quality of channels and they allocate large number of subcarriers to the links with good quality channels and less number of subcarriers to the links with bad quality channels. On the other hand, the iterative FORA algorithm has an approximately fixed fairness index with increasing the number of D2D pairs since its subcarrier allocation depends on the maximization of the fairness index.

4.2 Performance evaluation with different coherence bandwidth

This subsection discusses the effect of different coherence bandwidth on the system performance. The number of D2D pairs is 4, the number of subcarriers is 40 subcarrier and the \((\frac{P_M}{N_A . B})\) is 30 dB at various coherence bandwidth. As in Fig. 4, the probability of assigning the same number of subcarriers for each D2D pair of the iterative FORA algorithm is higher than that of SAD and BSCR algorithms. The probability of assigning higher and lower number of subcarriers for single D2D pair increases with increasing the coherence bandwidth. This is because when the coherence bandwidth increases the probability of getting subcarriers with high correlated fading across it increases. So, if any subcarrier has bad CSI, the probability that the adjacent subcarriers also have bad CSI increases. Therefore, the probability of allocating these adjacent subcarrier to the D2D pair decreases and the probability of allocating them to another D2D pair increase.

Fig. 4
figure 4

The probability of number of allocated subcarrier to a single D2D pair at different coherence bandwidth, with fixed \((\frac{P_M}{N_A . B})\) 30 dB

Fig. 5
figure 5

Jain’s fairness index against the coherence bandwidth, which vary from (1.5 to 52.5 kHz), with \((\frac{P_M}{N_A . B})\) 30 dB

Figure 5 shows that the Jain’s fairness index of the Iterative FORA algorithm is optimal and constant compared to SAD and BSCR algorithms, where the fairness index of SAD and BSCR algorithms decreases with increasing the coherence bandwidth. Since as the coherence bandwidth increase, the probability of adjacent subcarriers to become more correlated increases for the single D2D link. In this case, the D2D links with good channels will get many correlated good subcarriers while other D2D links will not get sufficient subcarriers. Therefore, the fairness indices of SAD and BSCR algorithms decrease as the coherence bandwidth increases. On the other side, the iterative FORA algorithm is independent on the channel quality, so the correlated carriers doesn’t affect the fairness.

4.3 Performance evaluation with various signal to noise ratio

This part aims to show the effect of the SNR on the proposed algorithm compared to the other algorithms. The number of D2D pairs is 4, the number of subcarriers are 8 subcarriers and fixed coherence bandwidth 15 kHz at different values of maximum total transmit power per device to the noise power per subcarrier \((\frac{P_M}{N_A . B})\).

Fig. 6
figure 6

The ratio of the minimum to maximum link data rates \((\frac{R_{min}}{R_{max}})\) and minimum to mean link data rates \((\frac{R_{min}}{R_{mean}})\) versus \((\frac{P_M}{N_A . B})\), with fixed coherence bandwidth 15 kHz

As shown in Fig. 6 the ratio of \((\frac{R_{min}}{R_{max}})\) and \((\frac{R_{min}}{R_{mean}}) \) for SAD and BSCR are approximately fixed with increasing the \((\frac{P_M}{N_A . B})\). On the other hand, these ratios increase for the iterative FORA algorithm with increasing the \((\frac{P_M}{N_A . B})\). This can be explained using the probability of allocating number of subcarriers for single D2D pair with various \((\frac{P_M}{N_A . B})\), defined by SNR in Fig. 7.

Specifically, Fig. 7 illustrates that the probability of assigning subcarriers using SAD and BSCR algorithms doesn’t change significantly with different SNR values. For the iterative FORA algorithm, at low SNR value (0 dB), the probability of allocating subcarriers to each D2D pair has it’s peak at 1 allocated subcarrier. At high SNR (30 dB), the probability of allocating subcarriers to each D2D pair get its peak at 2 allocated subcarriers for every D2D pair. In other words, the change in SNR affects the number of allocated subcarriers using the iterative FORA algorithm, but there are no effect in case of both SAD and BSCR algorithms.

To declare the behavior of FORA, SAD and BSCR algorithms in Fig. 6, we emphasis that increasing the SNR can increase the link data rate for all algorithms. In SAD and BSCR, the SNR doesn’t play a significant role in ratio of \((\frac{R_{min}}{R_{max}})\) and \((\frac{R_{min}}{R_{mean}})\) because they have fixed number of allocated subcarrier as the maximum and minimum link data rate have been increased more or less approximately with the same percentage. In the iterative FORA algorithm, increasing the SNR can increase the number of subcarriers allocated to D2D pairs. It should be noted that the FORA algorithm is based on maximizing the fairness. Hence, it allocates subcarriers to the D2D links with minimum data rate. This helps in improving the data rate of D2D links with minimum data rate. Consequently, the difference between the minimum and maximum data rate will be reduced. Thus, the ratio of \((\frac{R_{min}}{R_{max}})\) and \((\frac{R_{min}}{R_{mean}}) \) will increase.

Fig. 7
figure 7

Probability of allocating various number of subcarriers for single D2D pair, with fixed coherence bandwidth 15 kHz

Fig. 8
figure 8

Relationship between spectral efficiency (bit/s/Hz) versus \((\frac{P_M}{N_A . B})\), with fixed coherence bandwidth 15 kHz

As in Fig. 8, it is clear that SAD and BSCR algorithms have slightly higher spectral efficiency than the iterative FORA algorithm. This small enhancement in the spectral efficiency is at the price of the fairness. In other words, the iterative FORA algorithm has relatively close spectral efficiency, to both of the SAD and the BSCR algorithms, with a significant improvement in fairness.

5 Conclusion

This paper proposes a new resource and power allocation algorithm for D2D communications overlaying cellular networks. The objective of the proposed algorithm is to maximize the fairness index among D2D users. The simulation results show that the proposed algorithm outperforms existing schemes, such as SAD and BSCR, in terms of fairness index. Furthermore, the proposed algorithm achieves acceptable data rate. It has been demonstrated that increasing the coherence bandwidth doesn’t affect the performance of the proposed algorithm. Furthermore, increasing the SNR per subcarrier improves the fairness index of the proposed FORA algorithm.