1 Introduction

Cognitive radio (CR) has been recently proposed as a candidate solution to alleviate spectrum shortages by allowing unlicensed users (secondary users, SUs) to opportunistically access or share the frequency bands allocated to the licensed users (primary users, PUs) when they are detected to be idle [1]. In order to avoid causing harmful interference to the PU, the CRs need to monitor the PU’s activities periodically to find a suitable spectrum band for possible utilization. Thus, effective and efficient spectrum sensing is an essential component for CR systems. The spectrum sensing process can be performed via several methods, but energy detection is still the common method among them, as it can be simply implemented and requires no a priori information of PU’s signal. However, the performance of energy detection in face of multipath fading, shadowing, and unknown noise power profiles significantly degrades [2]. Cooperative spectrum sensing scheme is an effective approach to overcome these problems by sharing and combining the sensing results of SUs to make the more accurate decision about the presence of the PU [3]. There are two metrics to evaluate the performance of a sensing algorithm: detection probability (pd) that indicate the probability of a SU correctly detecting the presence of the primary signal and false alarm probability (pf) which is the probability of a SU mistakenly declaring the presence of PU when the spectrum is actually free. Keeping the probability of false alarm below a certain value enables the SU to higher opportunity to use the available spectrum in order to maximize the achievable secondary network throughput. The higher probability of detection reduces the amount of harmful interference introduced to the PUs. The probability of detection is related to the sensing time, the longer sensing time leads to more accurate sensing and higher probability of detection. However, for a given frame duration, by inceasing the sensing time, the available data transmission time of the SUs decreases, and consequently SUs throughput reduces. Thus, there exists a fundamental tradeoff between the sensing accuracy and the achievable throughput for SUs to find the optimal sensing time that maximizes the SUs’ throughput while provides adequate protection to the PU.

Some researchers have investigated sensing-throughput tradeoff in several papers. Other researchers have focused on maximizing the SUs’ throughput through the optimization of different parameters such as sensing time, detection threshold and transmission power.

A sensing-throughput tradeoff was presented in [4, 5] for maximization of the opportunistic throughput of the CR by optimization of the sensing time under the constraint that the PUs are sufficiently protected. In [6], a sensing-throughput tradeoff model was proposed, in which the optimal sensing time varies in different primary channel conditions. furthermore, in the paper, the effect of PUs’ traffic on the performance of the secondary network was studied to evaluate the tradeoff between the sensing quality and the achievable throughput. A throughput-sensing tradeoff for a fixed transmission rate was studied in [7]. The joint optimization of sensing time and power allocation for improvement of the throughput of the CR network was addressed in [8]. The joint optimization of the sensing time and the sensing threshold was considered in [9, 10]. In [11], the authors focused on the joint optimization of the sensing time, the detection thresholds and the vector power allocation under the power and (deterministic/probabilistic) interference constraints such that SUs’ throughput was maximized. In [12], a sensing optimization problem for a multiband CR network was proposed to obtain the optimal values for combining weights and decision thresholds of each sub-band. In [13,14,15], the authors optimized the sensing time and power allocation for a wideband cognitive radio network. The throughput-delay tradeoff problem for cooperative spectrum sensing was studied in [16] in order to optimize the sensing bandwidth and the decision threshold jointly such that the throughput of the SUs was maximized while their transmission delay was constrained.

In [17], the joint optimization problem of sensing time, power allocation and sensing-channel selection was considered under the constraints of average transmit power budget and average interference power budget to maximize the achievable throughput of the CR network. In [18], the maximization of throughput for both primary and secondary networks was considered. Ref. [19] was investigated the tradeoff between the transmitted data and the sensing overhead in cooperative CR networks in order to maximize the secondary throughput. In [20], the sensing time, detection threshold, and transmit power of a multi-input multi-output (MIMO) CR network were optimized for maximization of the network throughput in single-band and multi-band systems under transmit power, probability of false alarm, and probability of detection constraints.

The authors in [21] considered the joint optimization of the local sensing time and the number of the cooperative CRs for a periodical single band cooperative spectrum sensing scheme under probabilities of false alarm and detection constrains in order to maximize the CR throughput and minimize the channel search time, respectively. They also considered the joint optimization of the numbers of the sensing time slots and cooperative CRs for a periodical wideband cooperative spectrum sensing scheme in order to obtain the maximal throughput of CR.

A multi-modal cooperative spectrum sensing was presented in [22] to make an accurate decision on the presence of the PU through combing multi-modal sensing data of the PU signal, such as energy, power spectrum and signal waveform from different SUs for getting a global decision. In this paper, the authors also proposed a multi-modal Dempster-Shafer (DS) fusion decision to combine the sensing information according to the basic credibility of each detector, in order to decrease the sensing uncertainty. A weight DS fusion is also proposed to improve the decision performance by resisting the inaccurate detection of malicious SU while increasing the fusion proportion of predominant SU. They showed that the proposed methods improve the sensing performance and detection probability in fading channels. However, the multi-modal cooperative sensing has a high complexity and long detection time.

In [23], the authors presented a spectrum handoff scheme based on recommended channel sensing sequence for minimization of the sensing delay. In [24], the throughput enhancement for SUs is provided through jointly optimizing the number of available channels and total sensing delay including local spectrum sensing and idle channel searching. The aim of authors is to obtain the optimal number of available channels such that the SU always have opportunities to detect out an idle channel while achieving the channel searching time as least as possible. The maximization of SU’s throughput and minimization of the average packet delay encountered by the SU subject to a constraint on the maximum allowable average delay of the PU was studied in [25]. The authors in [26] presented a SUs throughput maximization approach in multi-channel CR network under average power, interference and packet delay constraints. They considered the optimal stopping rule and power control problem. The optimal stopping rule was such that SU senses the channels sequentially to find an occupied channel by PU and stops its search to access a channel if it offers a significantly high throughput. From the above discussion, it becomes obvious that the performance of cooperative spectrum sensing and the throughput of SUs is related to sensing time and the number of cooperative SUs. All the above-mentioned works focused on either throughput or adequate protection to the PU as optimization metric.

The performance of spectrum sensing will increase by increasing the number of cooperative SUs in the environment but at the cost of increase in the energy consumption of the SUs and the communication overhead while the energy consumption should be minimized for the CR networks due to resource limitations. Ref. [27] proved that cooperating all SUs in spectrum sensing does not necessary to get the optimum performance, instead, selecting SUs with the highest PU’s signal-to-noise (SNR) ratio can be enough. The authors in [28] presented an energy efficient spectrum sensing approach for cognitive sensor networks based on the combination of censoring and sleeping schemes in order to reduce the energy consumed under constraints on the detection performance. They considered a same SNR for all sensing nodes which is not a practical assumption. Furthermore, only the number of sensing nodes was determined without specifying which nodes could sense the spectrum. In [29], an energy efficient cooperative spectrum sensing was proposed under the constraints on the detection performance by determining the best sensing nodes. They considered a different SNR for each sensor due to their different distances from the PU and channel status. An energy-efficient spectrum sensing scheme has been proposed in [30] to minimize the energy consumption and the spectrum sensing duration by employing the diversity of SUs in their received SNR of the PU’s signal. In fact, the objective of authors was to determine the sensing duration for each channel and the SUs which sense it such that the energy consumed was minimized. However, they didn’t consider the energy constraints of SUs. The authors in [31] proposed an energy-based sensor selection algorithm considering their energy constraints to achieve the energy efficient cooperative spectrum sensing. They presented an algorithm to obtain the maximum acceptable error probability on the reporting channels. Then, an algorithm was proposed to dynamically select proper sensors for cooperative spectrum sensing. In [32], a combination of sleeping and censoring methods was used for energy-efficient cooperative spectrum sensing. The aim was to minimize the energy consumption of each sensor, including the sensing and transmission energies under the constraints on the global probability of detection and the global probability of false alarm by optimally choosing the sleeping rate and two thresholds. A number of sensors sleep during the sensing phase with a specific sleeping rate. When the sensor is on, will transmit the sensing results compared with two thresholds to the fusion center (FC) if they are conclued to be informative.

The problem of joint optimal selection of the sensing nodes, decision node (DN) and the detection threshold was considered in [33] for minimization of the energy consumed in distributed sensing under the constraints on the probability of detection and the probability of false alarm. The priority of each node for spectrum sensing was determined by a cost function such that the node with higher detection probability and lower energy consumption was selected. In [34], an optimal relay selection scheme called EAORS was presented for tradeoff between detection accuracy and energy efficiency. The number of optimal relays was obtained by a weighted objective function considering energy consumption in both spectrum sensing and the cooperative transmission phases subject to the constraints of the probability of detection and the secondary cooperative transmission bit error rate (BER). However, the researchers considered the same missed detection probabilities for all relays which was not a real assumption. In [35], the minimization of the average energy consumption was provided by two algorithms. At first, a clustering algorithm was presented to determine all the subsets of sensors having desired detection and false alarm probabilities. Then, an algorithm called MECEC was presented to dynamically select appropriate sensors for spectrum sensing considering energy constraints of its members. In [36], the problem of optimal selection of the multi-antenna sensors was considered to minimize the energy consumption such that the constrains on the global probability of detection and the probability of false alarm were satisfied. In [37], the joint optimization of the sensing time, the detection threshold and the length of the modulated symbol sequence was addressed to maximize the energy efficiency (EE) defined as the ratio of the average throughput to the average energy consumption of CSNs.

The main contributions of this paper are as follows.

  • First, different from the most previous cooperative spectrum sensing, which consider either throughput or energy consumption as optimization metric, we consider both metrics simultaneously. We formulate a problem of joint throughput improvement of the network and minimizing energy consumption in cooperative spectrum sensing under the constraints on the detection performance when all SUs have different SNRs.

  • The proposed scheme called JSTDTSS solves the Joint optimization problem of the Sensing Time, the Detection Threshold and the Selection of the sensing and data transmitting SUs for improvement of the throughput of SUs and minimization of the energy consumption of the network under the constrains on the global probability of detection and global probability of false alarm.

  • In this work, two algorithms are used. The first algorithm achieves the optimum sensing time and the sensing threshold. Then, an iterative algorithm is employed to select the appropriate sensing and data transmitting SUs. In second algorithm, two cost functions are defined in order to determine the priority of each SU for spectrum sensing as well as data transmitting such that the SUs with higher detection probability and lower energy consumption are selected.

Simulation results reveal that optimizing the detection threshold, sensing time and the selection of the sensing and data transmitting SUs together increases the throughput and significantly decreases the energy consumption of the CR network in comparison to other schemes. In addition, the influence of the detection threshold and sensing time on the probability of detection, average throughput and energy consumption of the CR network is shown.

The rest of the paper is organized as follows. In Sect. 2, the system model and the assumptions are presented in details. Expressions of the total average throughput and the user selection problem is also formulated in this section. In addition, the joint optimization algorithm of the sensing threshold, the sensing time and the selection of the sensing and data transmitting users is developed in Sect. 2. The simulation result and discussion are presented in Sect. 3. Finally, we conclude the paper in Sect. 4.

2 System model and assumptions

Consider a CR including one FC and M SUs that monitor a frequency band allocated to one PU. The network model is indicated in Fig. 1.

Fig. 1
figure 1

The network model

The sensing problem is formulated as a binary hypothesis testing. H0 and H1 represent the absence and presence of the PU in the channel, respectively.

The SUs use an energy detector and measure their received powers during the sensing slot. Therefore, the received sampling signal by jth SU is defined as:

$$\varvec{y}_{\varvec{j}} \left( l \right) = \left\{ {\begin{array}{*{20}l} { w_{j} \left( l \right)} \hfill & {H_{0} :PU\,is\, absent} \hfill \\ {h _{j} \left( l \right)s_{ } \left( l \right) + w_{j} \left( l \right)} \hfill & {H_{1} :PU\, is \,present} \hfill \\ \end{array} \;l \, = \, 1,2, \ldots ,\tau f_{s} } \right.$$
(1)

where \(s_{ } \left( l \right)\) and \(w_{j} \left( l \right)\) represent the received primary lth sample and the independent identically distributed (i.i.d.) Gaussian random process with zero mean and the variance \(\sigma_{w}^{2}\), respectively.

\(h _{j} \left( l \right)\) is the channel coefficient between jth SU and PU and is modeled as follows [36]:

$$h_{j} = 10^{{ - \frac{{L_{j} }}{20}}} \cdot g_{j}$$
(2)

where gj denotes a complex Gaussian random process with zero mean and unit variance considering for Raleigh fading. Lj is consist of two parts: the first part expresses the path loss based on free-space path loss model and the second part denotes a real Gaussian random variable with zero mean and standard deviation of 3 according to large scale log-normal shadowing and is expressed as follows:

$$L_{j} = 20\log \left( {\frac{{d_{{PS_{j} }} 4\pi f_{c} }}{C}} \right) + n_{j}$$
(3)

where \(f_{c}\) and C are the carrier frequency and the speed of light, respectively. \(d_{{PS_{j} }}\) denotes the distance of jth SU from PU. The test statistic for the jth SU is expressed as follows:

$$V_{j} = \frac{1}{{\tau f_{s} }}\mathop \sum \limits_{l = 1}^{{\tau f_{s} }} \left| {y_{j} \left( l \right)} \right|^{2}$$
(4)

\(\tau f_{s}\) is the number of samples. τ and \(f_{s}\) denoting the sensing time and the sampling frequency, respectively. Each SU at the beginning of each frame, having duration T, senses the status of the spectrum for τ units of time, whereas it transmits the data during the remaining time, T-\(\tau\).The test decision is considered as follows:

$$Decide = \left\{ {\begin{array}{*{20}c} {H_{0} } & {if\; V_{j} < \epsilon } \\ {H_{1} } & { if\; V_{j} > \epsilon } \\ \end{array} } \right.$$
(5)

where ϵ is a specified threshold value. Two probabilities of interest in the jth SU are [28]:

$${\text{P}}_{{{\text{f}}j}} = {\text{P}}\left( {V_{j} \ge \epsilon | {\text{H}}_{0} } \right) = \frac{{\Gamma \left( {\uptau {\text{f}}_{\text{s}} ,\frac{\epsilon }{2}} \right)}}{{\Gamma \left( {\uptau {\text{f}}_{\text{s}} } \right)}}$$
(6)
$${\text{P}}_{{{\text{d}}j}} = {\text{P}}\left( {V_{j} \ge \epsilon | {\text{H}}_{1} } \right) = Q_{{\uptau {\text{f}}_{\text{s}} }} \left( {\sqrt {2 \gamma_{j} } ,\sqrt \epsilon } \right)$$
(7)

where \(Q_{m}\)(a,b) and \(\Gamma \left( {{\text{a}} \cdot b} \right)\) denote the generalized Marcum Q-function and the incomplete gamma function, respectively and \(\Gamma \left( {\text{a}} \right)\) is the gamma function. \(\gamma_{j}\) is the received signal to noise ratio in jth SU. Under the logical-OR fusion rule at the FC, the probability of false alarm,\(Q_{f}\), and the global detection probability, \(Q_{d}\), will be as:

$$Q_{f} = 1 - \mathop \prod \limits_{j = 1}^{M} \left( {1 - P_{{f_{j} }} } \right)$$
(8)
$$Q_{d} = 1 - \mathop \prod \limits_{j = 1}^{M} \left( {1 - P_{{d_{j} }} } \right)$$
(9)

As mentioned in the introduction, we can choose some SUs having better probabilities of detection for spectrum sensing while some others are selected to send their data to the FC and the rest will be idle in order to improve the energy consumption and throughput. Therefore, the Eqs. (88) and (99) can be modified as follows:

$$Q_{f} = 1 - \mathop \prod \limits_{j = 1}^{M} \left( {1 - \rho_{j} P_{{f_{j} }} } \right)$$
(10)
$$Q_{d} = 1 - \mathop \prod \limits_{j = 1}^{M} \left( {1 - \rho_{j} P_{{d_{j} }} } \right)$$
(11)

where \(\rho_{j} \in \left\{ {0,1} \right\}\) is the assignment index. The value ‘1’ indicates that the SU participates for sensing the spectrum while ‘0’ indicates that the SU is not a sensing user. We consider \(\alpha\) and \(\beta\) as the thresholds for \(Q_{f}\) and \(Q_{d}\) such that \(Q_{f} \le \alpha\) and \(Q_{d} \ge \beta\) in order to protect the PU from the interference and for enhancing the throughput of the SUs.

According to Eqs. (6), (8) and (10), since,\(Q_{f}\) is an increasing function of \(\rho_{j}\) and it is not dependent on the received signal to noise ratio in jth SU,\(\gamma_{j}\). Furthermore, according to Eq. (66), the local probability of false alarm is the same for all SUs. Therefore, using (10) and \(Q_{f} \le \alpha\), the maximum number of SUs for sensing is determined as:

$$n \le \frac{{\ln \left( {1 - \alpha } \right)}}{{\ln \left( {1 - \frac{{\Gamma \left( {\uptau {\text{f}}_{\text{s}} ,\frac{\epsilon }{2}} \right)}}{{\Gamma \left( {\uptau {\text{f}}_{\text{s}} } \right)}}} \right)}} = K$$
(12)

where K is the maximum number of SUs which can be selected for spectrum sensing and \(n = \sum\nolimits_{j = 1}^{M} {\rho_{j} }\) is the number of the SUs participating in sensing.

We employ the considered model in [36] to calculate the total energy consumption of CR network. In this model, the total energy consumption of CR network consists of the two main components where the first component is the energy consumption denoted by \(E_{{S_{j} }}\) for sensing the channel, decision about the channel and signal processing like modulation type, signal shaping, etc. The second component is the energy consumption for sending one decision bit or data from each SU to the FC denoted by \(E_{{t_{j} }}\) and \(E_{{td_{j} }}\). Therefore, the total energy consumption is expressed as follows:

$$E_{T} = \mathop \sum \limits_{j = 1}^{M} \rho_{j} \left( {E_{{S_{j} }} + E_{{t_{j} }} } \right) + \vartheta_{j} E_{{td_{j} }}$$
(13)

where \(\vartheta_{j} \in \left\{ {0,1} \right\}\) is the assignment index to specify the SUs is sending their data to FC and \(E_{{t_{j} }}\) is used to derive the radio electronics and the power amplification and it is given by:

$$E_{{t_{j} }} = E_{t{\text{-}}elec} + e_{amp} d_{{FS_{j} }}^{2}$$
(14)

where \(E_{t{\text{-}}elec}\) is the transmitter electronics energy. \(e_{amp}\) denotes the required amplification to satisfy a given receiver sensitivity level. \(d_{{FS_{j} }}\) is the distance of jth SU from FC. \(E_{T}\) can be rewritten as:

$$E_{T} = \mathop \sum \limits_{j = 1}^{M} \rho_{j} \left( {P_{{s_{j} }} \tau_{j} + E_{{t_{j} }} } \right) + \vartheta_{j} (T_{f} - \tau_{j} )P_{{t_{j} }}$$
(15)

where \(P_{{s_{j} }}\) and \(\tau_{j}\) are sensing power and sensing time of jth SU, respectively. We assume \(\tau_{j}\) and \(E_{{S_{j} }}\) are the same for all SUs and are denoted by \(\tau_{ }\) and \(E_{{S_{ } }}\), respectively. \(T_{f}\) is the frame duration and \(P_{{t_{j} }}\) denotes the data transmitting power of jth SU. In this work, the IEEE 802.15.4/ZigBee radios are employed as the communication technology between SUs for cooperating with each other to sense the spectrum. Therefore, the communication parameters to satisfy a receiver sensitivity of − 90 dBm are considered as \(E_{s} = 190\,{\text{nJ}}.\,\, E_{t{\text{-}}elec} = 80\,{\text{nJ}}\) and \(e_{amp} =\) 40.4 \({\raise0.7ex\hbox{${pJ}$} \!\mathord{\left/ {\vphantom {{{\rm pJ}} {{\rm m}^{2} }}}\right.\kern-0pt} \!\lower0.7ex\hbox{${m^{2} }$}}\) [28, 29].

The average throughput of the jth SU when the PU is absence and the CR network succeeds in detecting the absence of the PU, \(c_{j}^{0}\), and for the case of the PU is active but the CR network fails to detect the active state of PU, \(c_{j}^{1}\), are given by:

$$c_{j}^{0} = P\left( {H_{0} } \right){ \log }\left( {1 + \frac{{p_{{S_{j} }} h_{{FS_{j} }}^{2} }}{{\sigma_{w}^{2} }}} \right)$$
(16)
$$c_{j}^{1} = P\left( {H_{1} } \right) { \log }\left( {1 + \frac{{p_{{S_{j} }} h_{{FS_{j} }}^{2} }}{{p_{P} h_{FP}^{2} + \sigma_{w}^{2} }}} \right)$$
(17)

where \(p_{P}\) and \(p_{{S_{j} }}\) denote the PU and jth SU transmit power, respectively. \(h_{{FS_{j} }}^{ }\) is the channel gain between the jth SU and the FC while \(h_{FP}^{ }\) is the channel gain between the PU and the FC. P(H0) and P(H1) express the probability of state that the PU is absent, and the probability for which the PU is present, respectively. Therefore, the total average throughput of CR is:

$$C = \mathop \sum \limits_{j = 1}^{M} \vartheta_{j} \left( {\frac{{T_{f} - \tau_{j} }}{{T_{f} }}} \right)\left( {\left( {1 - Q_{f} } \right)c_{j}^{0} + \left( {1 - Q_{d} } \right)c_{j}^{1} } \right)$$
(18)

Therefore, we formulate the optimization problem as follows:

$$\mathop {\hbox{min} }\limits_{{\rho_{j} ,\vartheta_{j} ,\tau ,\epsilon }} E_{T}$$
$$\varvec{s}.\varvec{t}.\;Q_{d} \ge \beta$$
(19-1)
$$Q_{f} \le \alpha$$
(19-2)
$$C \ge C_{th}$$
(19-3)
$$\rho_{j} \in \left\{ {0,1} \right\}\forall j$$
(19-4)
$$\vartheta_{j} \in \left\{ {0,1} \right\}\forall j$$
(19-5)
$$\rho_{j} \vartheta_{j} = 0$$
(19-6)

where \(C_{th}\) is the minimum required total throughput of the CR. The last constraint indicates that one SU cannot be selected for sensing and transmitting, simultaneously. Since the parameters \(\rho_{j}\) and \(\vartheta_{j}\) have the discrete nature, the problem is NP-complete.

The optimum solution for problem (19) is gained through the exhaustive search algorithm, in which, all possible n candidates for sensing and Mn candidates for data transmitting are examined and the state that leads to minimum energy consumption while satisfies the constraints is selected as the optimum solution. Therefore, we should examine all \(\sum\nolimits_{j = 1}^{K} {\left( {\begin{array}{*{20}c} M \\ j \\ \end{array} } \right)}\) states to find the best answer. However, for large values of M, this approach has a high complexity with the order of O(M!), which has an exponential complexity of M and is not practical and usable. Therefore, we search for the solutions with less complexity. It can be said, the complexity of the problem (19) comes from the integer nature of the assignment indices, \(\rho_{j}\) and \(\vartheta_{j}\). In order to simplify the problem (19), we assume \(\rho_{j}\) and \(\vartheta_{j}\) are continuous parameters so that \(\rho_{j} \epsilon \left[ {0,1} \right]\) and \(\vartheta_{j} \epsilon \left[ {0,1} \right]\). After solving our problem,\(\rho_{j}\) and \(\vartheta_{j}\) is mapped to discrete space again.

Before to solve the optimization problem, we evaluate the effect of detection threshold and sensing time on Qd, Qf, throughput and energy consumption. Thus, we consider an environment with M = 10 SUs and τ = 6.25 μs sensing time. Figures 2 and 3 show the probability of detection and the probability of false alarm versus the different detection threshold for 20,000 runs. It is clear that the probability of detection and the probability of false alarm are reduced with the increasing of the detection threshold. For small values of detection threshold, it is possible to achieve the better probability of detection but the desired probability of false alarm is not acheived.

Fig. 2
figure 2

Probability of detection versus the detection threshold

Fig. 3
figure 3

Probability of false alarm versus the detection threshold

Figures 4 and 5 show the average throughput and the energy consumption of the CR network as the detection threshold increases. It can be seen that when the threshold is less than 9e−15 the average throughput can attain almost the maximum and constant value while the more threshold leads to less throughput. Figure 6 shows that as the threshold increases, the energy consumption increases.That’s due to the fact that as the threshold increases, the probability of detection for each SU,\(P_{{d_{j} }}\), decreases and the selection of more SUs is required to satisfy detection performances. It can be concluded that the best threshold level for this case is approximately 8e−15 to 9e−15 because these values leads to less energy consumption and more average throughput while the desired detection performance is satisfied. On the other hand, the longer sensing time leads to shorter available data transmission time and reducing the throughput. Figures 6, 7 and 8 show the influence of the sensing time on the probability of detection, the average throughput and energy consumption, respectively, where the number of SU is set to M = 10 and the detection threshold is fixed to 8.62e−15. The results have been achieved in 30,000 runs. We can see, the probability of detection increases with the increasing of the sensing time until it reaches to 1.

Fig. 4
figure 4

The average throughput versus the detection threshold

Fig. 5
figure 5

The energy consumption versus the detection threshold

Fig. 6
figure 6

The probability of detection versus sensing time

Fig. 7
figure 7

The impact of the sensing time on the average throughput of the CR network

Fig. 8
figure 8

The impact of the sensing time on the energy consumption

In Fig. 7, the average achievable throughput is less at a small or large sensing time, that’s due to the fact that the small sensing time decreases the detection performance, whereas large sensing time reduces the data transmitting time and therefore, we see the tradeoff between the sensing time and achievable throughput of the CR network. It can be seen, in sensing time of almost 6.5 μs, the maximum throughput is obtained.

Form Fig. 8, we can clearly see that there exist an optimal sensing time for minimizing the energy consumption. It can be seen that at the sensing time of about 6.5 μs, the energy consumption can attain almost the minimum value while the more or less sensing times leads to more energy consumption because it gets more times for sensing and data transmitting, respectively.

Therefore, according to Figs. 2, 3, 4, 5, 6, 7 and 8, the minimum threshold and sensing time should be achieved in feasible set, the set of all feasible points [38], such that the throughput of the secondary network is maximized and the total energy consumption is minimized while detection constraints can be satisfied. Thus, We can see that \(P_{{d_{j} }}\) and \(P_{{f_{j} }}\) increase by the increasing the sensing time and by the decreasing the threshold. In result, the fewer number of SUs participating in the spectrum sensing is required to satisfy the detection constrains and reduce the total energy consumption. Now, in the first step to solve the problem, an algroithm is proposed to find the optimum values of sensing time and detection threshold. Based on the proposed algorithm, first, for any pair of time sensing and threshold, the probability of detection for all SUs is calcluated and sorted in descending order. Then, the SUs having the higher probability of detection are selected such thatthe maximum number of sensing SUs and \(Q_{d} \ge \beta\) constraints can be maintained. Finally,The following rule by using Bisection search method [38] is employed to update the values τ and ϵ: If the global probability of detection becomes greater than \(\beta\), ϵ will decrease; otherwise, will increase. In result, the optimum ϵ is achieved. The same algorithm is used simultaneously to find the optimum τ. The algorithm 1 shows the pseodo code to find the minimum detection threshold and sensing time. The complexity of proposed approach is in the order of O(M) because in each iteration, cost functions for all SUs are computed.

figure e

In the second step, the obtained values of minimum ϵ and τ are employed in the problem of the sensing SUs selection and the data transmiting SUs selection. In result, for obtained ϵ and \(\tau\) in the previous step, the problem can be reformulated as follows:

$$\mathop {\hbox{min} }\limits_{{\rho_{j} , \vartheta_{j} }} E_{T}$$
$$s.t.\;Q_{d} \ge \beta$$
(20-1)
$$Q_{f} \le \alpha$$
(20-2)
$$C \ge C_{th}$$
(20-3)
$$\rho_{j} \in \left[ {0,1} \right]\forall j$$
(20-4)
$$\vartheta_{j} \in \left[ {0,1} \right]\forall j$$
(20-5)
$$\rho_{j} \vartheta_{j} = 0$$
(20-6)

The problem (20) is not a standard convex optimization problem. The priority of SUs for sensing and transmitting can be determined by the Lagrangian function and Karush–Kuhn–Tucker (KKT) conditions. Therefore, the Lagrangian function is written as:

$$\begin{aligned} L & = \mathop \sum \limits_{j = 1}^{M} \rho_{j} \left( {E_{S} + E_{{t_{j} }} } \right) + \vartheta_{j} E_{{t_{j} }} - \mu \left( {C - C_{th} } \right) \\ & \quad - \,\lambda \left( {Q_{d} - \beta } \right) + \eta \left( {\mathop \sum \limits_{J = 1}^{M} \rho_{j} - K} \right) \\ \end{aligned}$$
(21)

Where \(\mu\), \(\lambda\) and \(\eta\) are the Lagrangian multipliers. By using KKT condition, we have:

$$\frac{\partial L}{{\partial \rho_{j} }} = \left( {E_{S} + E_{{t_{j} }} } \right) - \lambda P_{{d_{j} }} \mathop \prod \limits_{k \ne j}^{ } \left( {1 - \rho_{k} P_{{d_{k} }} } \right) + \eta = 0 \;\forall j\epsilon \left\{ {0,1,2, \ldots ,M} \right\}$$
(22)
$$\frac{\partial L}{{\partial \vartheta_{j} }} = - \mu \left( {\frac{{T_{f} - \tau_{ } }}{{T_{f} }}} \right)\left( { \left( {1 - Q_{f} } \right)c_{j}^{0} + \left( {1 - Q_{d} } \right)c_{j}^{1} } \right) + E_{{t_{j} }} = 0\; \forall j\epsilon \left\{ {0,1,2, \ldots ,M} \right\}$$
(23)

The objective is to determine the priority of the SUs for sensing and transmitting. Therefore, the quantity of \(\vartheta_{j} s\) and \(\rho_{j} s\) is not very important. Thus, the ratios of \(\rho_{j}\) / \(\rho_{i}\) and \(\vartheta_{j}\) / \(\vartheta_{i}\) for any pair of SUs should be computed and the SUs having the higher priority are selected. Hence,

$$\frac{\partial L}{{\partial \rho_{i} }} = \left( {E_{S} + E_{{t_{i} }} } \right) - \lambda P_{{d_{i} }} \mathop \prod \limits_{k \ne i}^{ } \left( {1 - \rho_{k} P_{{d_{k} }} } \right) + \eta = 0 \forall i\epsilon \left\{ {0,1,2, \ldots ,M} \right\}$$
(24)
$$\frac{\partial L}{{\partial \vartheta_{i} }} = - \mu \left( {\frac{{T_{f} - \tau_{ } }}{{T_{f} }}} \right)\left( { \left( {1 - Q_{f} } \right)c_{i}^{0} + \left( {1 - Q_{d} } \right)c_{i}^{1} } \right) + E_{{t_{i} }} = 0\; \forall i\epsilon \left\{ {0,1,2, \ldots ,M} \right\}$$
(25)

By using (22) and (24), we have

$$\frac{{\left( {E_{S} + E_{{t_{i} }} } \right) + \eta }}{{ \mathop \prod \nolimits_{k \ne i,j}^{ } \left( {1 - \rho_{k} P_{{d_{k} }} } \right)}} - \lambda P_{{d_{i} }} \left( {1 - \rho_{j} P_{{d_{j} }} } \right) = 0$$
(26)
$$\frac{{\left( {E_{S} + E_{{t_{j} }} } \right) + \eta }}{{ \mathop \prod \nolimits_{k \ne i,j}^{ } \left( {1 - \rho_{k} P_{{d_{k} }} } \right)}} - \lambda P_{{d_{j} }} \left( {1 - \rho_{i} P_{{d_{i} }} } \right) = 0$$
(27)

Then, we obtain

$$\frac{{\left( {E_{S} + E_{{t_{i} }} } \right) + \eta }}{{ \mathop \prod \nolimits_{k \ne i,j}^{ } \left( {1 - \rho_{k} P_{{d_{k} }} } \right)}} - \lambda P_{{d_{i} }} = - \lambda P_{{d_{i} }} \rho_{j} P_{{d_{j} }}$$
(28)
$$\frac{{\left( {E_{S} + E_{{t_{j} }} } \right) + \eta }}{{ \mathop \prod \nolimits_{k \ne i,j}^{ } \left( {1 - \rho_{k} P_{{d_{k} }} } \right)}} - \lambda P_{{d_{j} }} = - \lambda P_{{d_{j} }} \rho_{i} P_{{d_{i} }}$$
(29)

In result, the ratio of \(\rho_{j}\)/\(\rho_{i}\) is calcluated as:

$${{\rho_{j} } \mathord{\left/ {\vphantom {{\rho_{j} } {\rho_{i} }}} \right. \kern-0pt} {\rho_{i} }} = \frac{{\left( {E_{S} + E_{{t_{i} }} } \right) + \eta - \lambda P_{{d_{i} }} \mathop \prod \nolimits_{k \ne i,j}^{ M} \left( {1 - \rho_{k} P_{{d_{k} }} } \right)}}{{\left( {E_{S} + E_{{t_{j} }} } \right) + \eta - \lambda P_{{d_{j} }} \mathop \prod \nolimits_{k \ne i,j}^{ M} \left( {1 - \rho_{k} P_{{d_{k} }} } \right)}} = \frac{cost\left( i \right)}{cost\left( j \right)}$$
(30)

Therefore, the priority of SUs for being selected as the sensing SUs is related to the inverse ratio of the following cost function.

$$cost\left( i \right) = \left( {E_{S} + E_{{t_{i} }} } \right) + \eta - \lambda P_{{d_{i} }} \mathop \prod \limits_{k \ne i,j}^{ M} \left( {1 - \rho_{k} P_{{d_{k} }} } \right)$$
(31)

The cost function (31) is calculated for all SUs and sorted in ascending order. Then, the first K SUs with the highest priority are selected as spectrum sensing candidates. We assume that η is the same for all SUs and it can be omitted from the cost function. Also, we consider ρj/ρi for only two SUs (i.e., the other SUs are not selected yet). Therefore (31) is simplified as follows:

$$cost\left( i \right) = \left( {E_{S} + E_{{t_{i} }} } \right) - \lambda P_{{d_{i} }}$$
(32)

By same way, the priority of SUs for transmitting is determined. By using (23) and (25), we have

$$\begin{aligned} & \vartheta_{i} \left( { - \mu \left( {\frac{{T_{f} - \tau_{ } }}{{T_{f} }}} \right)\left( { \left( {1 - Q_{f} } \right)c_{i}^{0} + \left( {1 - Q_{d} } \right)c_{i}^{1} } \right) + E_{{t_{i} }} } \right) \\ & = \vartheta_{j} \left( { - \mu \left( {\frac{{T_{f} - \tau_{ } }}{{T_{f} }}} \right)\left( { \left( {1 - Q_{f} } \right)c_{j}^{0} + \left( {1 - Q_{d} } \right)c_{j}^{1} } \right) + E_{{t_{j} }} } \right) \\ \end{aligned}$$
(33)

Therefore, the priority of SUs for data transmitting is determined as follows:

$$\frac{{\vartheta_{j} }}{{\vartheta_{i} }} = \frac{{\left( { - \mu \left( {\frac{{T_{f} - \tau }}{{T_{f} }}} \right)\left( { \left( {1 - Q_{f} } \right)c_{i}^{0} + \left( {1 - Q_{d} } \right)c_{i}^{1} } \right) + E_{{t_{i} }} } \right)}}{{\left( { - \mu \left( {\frac{{T_{f} - \tau }}{{T_{f} }}} \right)\left( { \left( {1 - Q_{f} } \right)c_{j}^{0} + \left( {1 - Q_{d} } \right)c_{j}^{1} } \right) + E_{{t_{j} }} } \right)}} = \frac{cost\left( i \right)}{cost\left( j \right)}$$
(34)

Therefore, the ratio \(\frac{{\vartheta_{j} }}{{\vartheta_{i} }}\) is related to the inverse ratio of the following cost function.

In result, the cost function for each SU is defined as:

$$cost\left( i \right) = \left( { - \mu \left( {\frac{{T_{f} - \tau_{ } }}{{T_{f} }}} \right)\left( { \left( {1 - Q_{f} } \right)c_{i}^{0} + \left( {1 - Q_{d} } \right)c_{i}^{1} } \right) + E_{{t_{i} }} } \right)$$
(35)

As a result, SUs having the smaller cost function are selected for transmitting its data to the FC. -Now, the complimentary slackness conditions are analyzed to determine the optimum \(\lambda\) and \(\mu\).

We have:

$$\left\{ {\begin{array}{*{20}l} {\lambda \left( {Q_{d} - \beta } \right) = 0 \to \left\{ {\begin{array}{*{20}l} {\lambda = 0 , Q_{d} > \beta \quad \quad\,\,\left( {36{\text{-}}1} \right)} \hfill \\ {\lambda \ne 0 , Q_{d} = \beta \quad \quad\,\,\left( {36{\text{-}}2} \right)} \hfill \\ \end{array} } \right.} \hfill \\ {\eta (\sum \rho_{j} - K) = 0 \to \left\{ {\begin{array}{*{20}l} {\eta = 0 ,\sum \rho_{j} < K\quad \left( {36{\text{-}}3} \right)} \hfill \\ {\eta \ne 0 ,\sum \rho_{j} = K\quad \left( {36{\text{-}}4} \right)} \hfill \\ \end{array} } \right.} \hfill \\ {\mu \left( {C - C_{th} } \right) = 0 \to \left\{ {\begin{array}{*{20}l} {\mu = 0 , C > C_{th} \quad \quad\left( {36{\text{-}}5} \right) } \hfill \\ {\mu \ne 0 , C = C_{th} \quad \quad\left( {36{\text{-}}6} \right)} \hfill \\ \end{array} } \right.} \hfill \\ \end{array} } \right.$$

We know \(Q_{d}\), \(Q_{f}\) and \(E_{T}\) are the increasing functions of \(\rho_{j}\) s. If (36-1) is considered as the optimum condition, \(\rho_{j}\) s can be reduced so that \(Q_{d} = \beta\) is satisfied. Also \(Q_{f}\) and \(E_{T}\) will decrease which the more desirable answer is achieved. Therefore, \(\lambda \ne 0\) is considered as the true condition in (36-2). If the number of selected sensing SUs satisfying the detection performance becomes fewer than K then (36-3) is considered, otherwise, (36-4) is desirable. In addition, \(C = C_{th}\) is considered as the optimal condition because ET is an increasing function of \(\vartheta_{j}\) s. Therefore, By reducing \(\vartheta_{j}\), the energy consumption is minimized while the minimum required throughput constraint is satisfied.

In final step, the sensing SUs and data transmitting SUs are determined with helping ellipsoid search method. The ellipsoid search method [38] is used in order to update the values \(\lambda\) and \(\mu\). This method is a simple iterative algorithm to find query points in multi-dimensional search. The complexity order of this method is proportional to O(M).

Therefore, according to the considered algorithm for selecting the sensing and transmitting SUs, in each iteration which \(\lambda\) and \(\mu\) are updated, the cost function in (32) is computed for each SU and sorted in ascending order and then the SUs with the lower cost function are selected for sensing so that the maximum number of sensing SUs and \(Q_{d} \ge \beta\) constraints can be maintained. Then, the cost function (35) is computed for remaining SUs and sorted in ascending order. The SUs with higher priority are selected for data transmitting so that the constraint on throughput is satisfied.

The algorithm 2 shows the pseodo code to select the sensing and data transmitting SUs.

It should be noted that, Lagrangian function (21) is convex and convergence to the global optimum can be guaranteed by using a gradient search. However, L(\(\mu ,\lambda ,\eta )\) is not necessarily differentiable. Thus, it does not always have a gradient and it is possible to search based on subgradient. The vector g is the subgradient of L(\(\mu ,\lambda ,\eta )\), if the following condition is provided.

figure f
$$\left[ {L(\mu ,\lambda^{\prime},\eta } \right],L\left( {\mu^{\prime},\lambda ,\eta } \right)\left] { \ge \left[ {L(\mu ,\lambda ,\eta } \right),L\left( {\mu ,\lambda ,\eta } \right)} \right] + g^{T} \left[ {\left( {\lambda^{\prime} - \lambda } \right),\left( {\mu^{\prime} - \mu } \right)} \right] \forall \lambda^{\prime},\mu^{\prime}$$
(37)

3 Simulations and discussion

To evaluate the performance of the proposed approach, numerical results are presented and compared with several other schemes. The simulations have been executed via MATLAB 2015a and the results are obtaned through the average of 10,000–30,000 independent simulation runs. We consider a CR network in which the number of the SUs varies from 10 to 100. The SUs and PU are uniformly and randomly distributed in a square field with the determined length for each experiment. FC is located in the center of the field. The channel model between every SU and FC as well as between PU and FC is considered as (22). The list of the simulation parameters is presented in Table 1.

Table 1 Parameters used in simulations

In order to indicate the superiority of the proposed approach, we compare it with the following four schemes.

  1. 1.

    SS: In first scheme, only the problem of the Selection of the sensing SUs and data transmitting SUs selection (SS) is considered. In SS method, the SUs are sorted in descending order based on their probability of detection. Then, SUs with the higher \(P_{{d_{j} }}\) s are selected for sensing so that the maximum number of sensing SUs and \(Q_{d} \ge \beta\) constraints can be satisfied. In next step, the remaining SUs are sorted in ascending order according to their distances from FC and then, SUs with minimum distances are selected for data transmitting so that the constraint on throughput is satisfied.

  2. 2.

    RS: Random Selection (RS) is the algorithm in which, SUs are randomly selected for spectrum sensing and transmitting data. In this method, none of the sensing time and detection threshold are optimized.

  3. 3.

    JSTSS: This method considers the Joint optimization problem of the Sensing Time and the Selection of the sensing and the transmitting SUs (JSTSS). Optimization of the detection threshold is not considered in JSTSS. The sensing and transmitting SUs are determined similar to JSTDTSS method.

  4. 4.

    JDTSS: The Joint optimization problem of the Detection Threshold and sensing SUs Selection and the data transmitting SUs (JDTSS) is addressed in this scheme. The selection of the sensing and data transmitting SUs is similar to JSTDTSS method.

Figure 9 shows the influence of dimensions of the network on average throughput, where the number of SU is equal to 10 and the simulations are executed in 10,000 iterations. As can be observed, all schemes maintain the throughput threshold constraint for all dimensions. In addition, for dimensions less than 6700 m2, the average achievable throughput of the SS is superior in comparision with other schemes. By the increase of the dimensions of the network, the difference between the average throughput of JSTDTSS and other methods increases and the average throughput of the JSTDTSS is maximized. We can also see that RS has the minimum throughput due to the random selection of the SUs.

Fig. 9
figure 9

The average throughput versus different dimensions

Figure 10 shows the influence of different dimensions on energy consumption. The energy consumption for all schemes increases by increasing the dimensions of the network. This can be explained by the fact that as the dimensions of the network increases, the more SUs must sense the spectrum and more SUs need for transmitting their data to the FC to satisfy the constraint (20-3). Moreover, as the dimensions of the network increases, distance between SUs and PU as well as between SUs and FC increases so that more energy must be consumed to satisfy of the minimum sensitivity of the receivers. We can also see that JSTDTSS achieves the less energy consumption compared to other methods. The difference between the energy consumption of JSTDTSS and other schemes increases when the dimensions of the network increases.

Fig. 10
figure 10

The energy consumption versus different dimensions

The influence of changing the dimensions of the network on the probability of detection using all expressed methods is shown in Fig. 11. It can be observed that the probability of detection decreases with the increase of the dimensions for RS, SS and JSTSS methods while it is fixed for JDTSS and JSTDTSS methods. In addition, JDTSTSS achieves the maximum probability of detection. It can be seen that RS and SS have the same results and are matched with each other.

Fig. 11
figure 11

The probability of detection versus different dimension

Figure 12 compares the average throughput under different quantities of SUs. The dimensions of the environment 100 m × 100 m and the number of iteration 10,000 are assumed in simulation. Observations in Fig. 13 show that the average throughput increases with the increase of number of SU until in almost 40 SUs is fixed and maximum its value is obtained. We also see that for the less number than 20 SUs, JSTDTSS has the maximum average throughput.

Fig. 12
figure 12

The average throughput versus different number of SUs

Fig. 13
figure 13

Energy Consumption versus different number of SUs

The influence of the number of SUs on energy consumption for 10,000 iterations is shown in Fig. 13. The dimensions of the environment are considered 100 m × 100 m. It can be seen that by increasing the number of the SUs in the CR system, the energy consumption decreases. It should be noted that when the number of SUs increases, it is possible that more SUs are located near the PU and FC and therefore the global probability of detection and the total throughput are improved, respectively. The located SUs near to FC also lead to less energy consumption. By considering the Figs. 11 and 12, it can be concluded that JSTDTSS can lead to a minimum energy consumption for CR network while satisfying the throughput of the network and the probability of detection constraints. Because of the random selection of the SUs, RS consumes more energy to satisfy the probability of detection constraint. JDTSS and JSTSS consume less energy than SS due to the optimization of the detection threshold and sensing time, respectively. It should be noted that by increasing the number of the SUs for data transmitting in the CR network, the energy consumption and the total throughput are increased. However, our optimization problem is to minimize the energy consumption of the CR network such that the minimum required total throughput of the CR is satisfied. In other words, our goal is to find the number of nodes and specify the nodes that minimizes the energy consumption according to Eq. (33), and also satisfies the minimum required total throughput of the CR. Therefore, all SUs do not need to cooperate for data transmitting. Thus, the selection of the data transmitting SUs is considered for minimization of the energy consumption of the network and satisfaction of the required throughput of SUs.

For the final analysis, the probability of detection of all schemes versus different number of SUs in an environment with dimensions 100 m × 100 m is compared as shown in Fig. 14. The probability of detection increases with the increase of number of SU for JSTSS, JDTSS and JSTDTSS methods until in almost 40 SUs is fixed and maximum its value is achieved.

Fig. 14
figure 14

The probability of detection versus different number of SUs

We can see that, for less than 40 SUs, the best probability of detection is obtained by JSTDTSS method. By increasing the number of SUs, the probabilities of detection of JSTSS and JSTDTSS are equal. The Fig. 14 shows that, SS and RS methods have approximately the same probability of detection. We also see that the constraint on the probability of detection can be satisfied for all schemes. In all simulations, the schemes are compared when all of them have an answer in feasible set.

4 Conclusion

Cooperative spectrum sensing schemes mitigate the multi-path fading and shadowing effects, which improve the probability of detection in heavily shadowed environments. While cooperative approaches provide more accurate sensing performance, they also cause adverse effects on the energy consumption of the CR network due to the additional operations and communication overhead. Cooperating all SUs in spectrum sensing does not necessary to get the optimum performance. In this paper, we proposed a new scheme to solve the joint optimization problem of the sensing time, the detection threshold and the selection of the sensing and data transmitting SUs for improvement of the throughput of CR network and minimization of the energy consumption of the network under the constrains on the global probability of detection and global probability of false alarm. We obtained the optimal values of detection threshold and sensing time such that the detection constraints are satisfied. We used the convex optimization methods to determine the priority of SU for sensing and data transmitting. Furthermore, we have provided simulation results, which revealed that the proposed sensing approach can achieve higher average throughput and less energy consumption compared to the others schemes.