Keywords

1 Introduction

With the popularity of 5G technology, the IoT paradigm and a variety of emerging applications (such as smart home, industrial IoT, etc.) are developing rapidly. During this period, the number of connections between smart devices and terminals increased explosively. In any case, the rapid growth in the number of connections in the IoT is bound to take up all the 5G spectrum. Therefore, both now and in the future, it is an important challenge for the network to improve spectrum efficiency. In this regard, cognitive radio is regarded as a potential solution [1,2,3]. Cognitive radio technology can monitor the spectrum utilization in real-time and dynamically adjust the devices accessing the spectrum [4, 5].

Before spectrum allocation, it is necessary to determine whether the target spectrum is available or not. Recently, machine learning has been used in spectrum sensing [6]. Sarikhani et al. [7] have proposed Deep Reinforcement Learning based cooperative spectrum sensing algorithm. Zheng et al. [8] have proposed a sensing method based on deep learning classification.

However, in these methods combined with machine learning, it is troublesome to build a centralized dataset containing a large number of samples. At present, some people have proposed methods to expand the data set [9, 10]. However, if the data sets in the IoT devices are required to be transmitted to the cloud to build a large data set, which is then used to train machine learning models, it may lead to serious network security or user privacy problems [11]. FL [12] solved this problem. In FL, IoT devices train the model independently, and then the central node aggregates the local model to get the global model. Google proposed a FederatedAveraging algorithm [13], which averages the neural network parameters of each edge device to improve the global model. However, the average aggregation method can not resist poisoning attacks. Therefore, this paper proposes a value evaluation mechanism, which can accurately evaluate the effectiveness of IoT devices and resist poisoning attacks.

This paper is organized as follows. Section 2 introduces the framework of FL and the system model. In Sect. 3, the workflow of the model and the value evaluation mechanism of IoT devices are introduced. The simulation and analysis are conducted in Sect. 4. Finally, conclusions are drawn in Sect. 5.

2 System Work

In this paper, the OFDM signal is used as the signal of the primary user (PU). Different Internet of things devices will correspond to different signal acquisition devices, so they will produce their own local data sets that are different from other devices. The device \({D}_{i}\) regards the spectrum sensing problem as a binary classification problem and uses local data sets to train the local model. The system model is shown in Fig. 1.

Fig. 1.
figure 1

System model

The essence of FL a distributed machine learning. FL mainly includes IoT devices and cloud servers. IoT devices jointly train the model under the coordination of the cloud server (CS). Each of these IoT devices has a copy of the global model, which is called the local model. IoT devices use their local data to update the local model, and the cloud server aggregates all the local models to get a global model \(\omega \), which is similar to the result of centralized machine learning after many iterations. In this way, problems such as data leakage can be effectively avoided.

However, if there is a device \({D}_{j}\) that maliciously uses the wrong dataset to update the model, the effectiveness of the global model may be seriously affected.

In FL, the collection of devices can be defined as \(D=\left\{{D}_{1},{D}_{2},\dots , {D}_{{N}_{D}}\right\}\), where \({D}_{i}(i=\mathrm{1,2},\dots ,{N}_{D})\) represents the \(i\)-th device, \({N}_{D}=|D|\) indicates the total number of devices. Each device stores its own local dataset. The local dataset of the device \({D}_{i}\) is represented as \({S}_{i}\), where \(\left|{S}_{i}\right|={N}_{i}\).

The model of device \({D}_{i}\) utilizes an \({M}_{i}\)-element antenna system to receive signals based on \({N}_{i}\) observation vectors, then get the dataset by the method in [14]. Then we use mathematical methods to calculate the covariance matrix and finally get true color pictures as dataset \({S}_{i}\) [9].

3 Spectrum Sensing Based on FL

3.1 Work Flow

As shown in Fig. 2, the operation at the \(l\)-th epoch consists of the following five moves:

  1. a.

    Get and store datasets. Follow the method in Sect. 2 to create a dataset \({S}_{i}\) for device \({D}_{i}\);

  2. b.

    Global model distribution. The CS sends the global model \({\omega }^{l-1}\) to each device;

  3. c.

    Edge model update. The device \({D}_{i}\) updates the edge model based on the global model \({\omega }^{l-1}\). Then the parameter \({\omega }_{i}^{\left(m,l\right)}\) of the \(m\)-th iteration of the local model at the \(l\)-th epoch can be expressed as

    $${\omega }_{i}^{\left(m,l\right)}={\omega }_{i}^{\left(m-1,l\right)}-\gamma \nabla {F}_{i}\left({\omega }_{i}^{\left(m,l\right)}\right)$$
    (1)

    where \(\gamma \) represents the learning rate, \({F}_{i}\left({\omega }_{i}^{\left(m,l\right)}\right)\) is the loss function. The final parameter is taken as the local model parameter \({\omega }_{i}^{l}\) of the \(l\)-th epoch.

  4. d.

    Local model upload. the device \({D}_{i}\) upload the parameter \({\omega }_{i}^{l}\) of the updated edge model to the CS.

  5. e.

    Global model aggregation. In FL, the aggregation at the \(l\)-th epoch can be expressed as

    $$ \omega^{l} = \sum\nolimits_{i = 1}^{{N_{D} }} {\alpha_{i} \omega_{i}^{l} .} $$
    (2)

    where \({\alpha }_{i}=\frac{{ST}_{i}}{ST}\) is the weight of the device \({D}_{i}\), \({ST}_{i}\) indicates the score of the device \({D}_{i}\), \(ST\) represents the total score of all devices.

Repeat these steps until the global model converges or the model reaches the required accuracy.

3.2 Value Evaluation Mechanism of Parameters

Because of the long distance between edge devices, there are many difficulties in the correct dissemination of information. There are even some devices that tamper with an edge or global model during move e. Therefore, it is very significant to make a complete effectiveness evaluation of the parameters uploaded by the equipment. At present, many objective weighting methods are widely used to determine the weight [15, 16].

The CRITIC weight method is an objective weighting method. It is based on the contrast intensity of indicators and the conflict between the indicators to comprehensively measure the objective weight of indicators.

In this paper, we use several indicators to evaluate the score of the parameter, such as the size of the dataset, the correlation with the global model, and the accuracy of the local model. The CRITIC weight method is utilized to evaluate the weight of the indicators. The score for the edge device is generated during the global model aggregation. The score affects the weight of the parameters of the local model in FL. Due to the complexity of deep learning, it is difficult to assess the validity of parameters by simply comparing the accuracy of local models. Therefore, we determine the local training performance by calculating the correlation between the parameters of the edge model and the global model.

Suppose \({\omega }_{i}=\left\{{\omega }_{i1},{\omega }_{i2},\dots ,{\omega }_{iP}\right\},(i=\mathrm{1,2},\dots ,{N}_{D})\) are all the parameters of the local model uploaded by the device \({D}_{i}\), \(\omega^{\prime} = \left\{ {\omega^{\prime}_{1} ,\omega^{\prime}_{2} , \ldots ,\omega^{\prime}_{P} } \right\}\) are all parameters of the global model. We use Pearson product-moment correlation coefficient (PPMCC) to represent the degree of correlation between the edge model and the global model:

$$ r_{i} = \frac{{\mathop \sum \nolimits_{j = 1}^{P} \left( {\omega_{ij} - \overline{{\omega_{i} }} } \right)\left( {\omega^{\prime}_{j} - \overline{\omega }^{\prime}} \right)}}{{\sqrt {\mathop \sum \nolimits_{j = 1}^{P} \left( {\omega_{ij} - \overline{{\omega_{i} }} } \right)^{2} } \sqrt {\mathop \sum \nolimits_{j = 1}^{P} \left( {\omega^{\prime}_{j} - \overline{\omega }^{\prime}} \right)^{2} } }} $$
(3)

The larger the \({r}_{i}\), the greater the correlation between the edge model and the global model. In addition, we can make further improvements to \({r}_{i}\),

$$ r_{j} = \left\{ {\begin{array}{*{20}l} {r_{j} } \hfill & {if\;\;r_{j} > 0} \hfill \\ 0 \hfill & {if\;\;r_{j} \le 0} \hfill \\ \end{array} } \right. $$
(4)

CRITIC Weight Method

The number of dataset in the device \({D}_{j}\) is \({N}_{j}\), the accuracy of edge model \({\omega }_{j}\) is \({A}_{j}\), and the correlation between the local parameter \({\omega }_{j}\) and the global parameter \(\omega^{\prime}\) is \({r}_{j}\). In the following sections, we use \(x_{ij} \left( {i = 1,2,3,\;\;j = 1,2, \ldots ,N_{T} } \right)\) to denote \({N}_{j}\), \({A}_{j}\) and \({r}_{j}\), that is, \({x}_{1j}={N}_{j},{x}_{2j}={A}_{j},{x}_{3j}={r}_{j}\).

Then the proportion of \({x}_{ij}\) can be expressed as

$${P}_{ij}=\frac{{x}_{ij}}{\sum_{j=1}^{{N}_{T}}{x}_{ij}}$$
(5)

First of all, we use the standard deviation \(S{D}_{i}\) to express the contrast intensity of the \(i\)-th indicator. First calculate the mean value \(\overline{{x }_{i}}=\frac{1}{n}\sum_{j=1}^{{N}_{T}}{x}_{ij}\), and then the standard deviation of the \(i\)-th indicator is obtained,

$$S{D}_{i}=\sqrt{\frac{\sum_{j=1}^{{N}_{T}}{\left({x}_{ij}-\overline{{x }_{i}}\right)}^{2}}{n-1}}$$
(6)

Secondly, the correlation coefficient \({R}_{i}\) is used to express the conflict of the indicators. First of all, we need to calculate the correlation degree \({r}_{ik}\) between different indicators. According to PPMCC,

$${r}_{ik}=\frac{\sum_{j=1}^{{N}_{D}}({x}_{ij}-\overline{{x }_{i}})({x}_{kj}-\overline{{x }_{k}})}{\sqrt{\sum_{j=1}^{{N}_{D}}{({x}_{ij}-\overline{{x }_{i}})}^{2}}\sqrt{\sum_{j=1}^{{N}_{D}}{({x}_{kj}-\overline{{x }_{k}})}^{2}}}$$
(7)

Then

$$ R_{i} = \sum\nolimits_{k = 1}^{3} {\left( {1 - r_{ik} } \right)} $$
(8)

Then the amount of information \({C}_{i}\) of the \(i\)-th indicator is calculated according to the standard deviation \(S{D}_{i}\) and the correlation coefficient \({R}_{i}\).

$$ C_{i} = SD_{i} \times \sum\nolimits_{k = 1}^{3} {\left( {1 - r_{ik} } \right) = SD_{i} \times R_{i} } . $$
(9)

So the objective weight of the \(i\)-th indicator is

$${W}_{i}=\frac{{C}_{i}}{\sum_{1}^{3}{C}_{i}}$$
(10)

Therefore, the score of the device \({D}_{i}\) can be expressed as

$$ ST_{j} = \sum\nolimits_{i = 1}^{3} {W_{i} \times P_{ij} } . $$
(11)

After the above steps, we adjust the weight of each edge device in the model aggregation to prevent the bad model uploaded by malicious nodes from affecting the accuracy of the global model. This method significantly improves the accuracy, convergence and anti-interference of the global model.

4 Numerical Result

In this paper, we set up 10 nodes in FL and establish local datasets for each node under different signal-to-noise ratios (SNR). At the same time, two cases are set, one is that there is no malicious node in 10 nodes, and the other is that there are two malicious nodes in 10 nodes, which is called a poisoning attack. The dataset of the malicious node is wrong, and the distribution of the wrong dataset is opposite to that of the normal dataset. As a result, the local model of the malicious node has the opposite effect on the aggregation of FL. At the same time, we compare the performance of average aggregation, called FLavg, and weighted aggregation with value evaluation mechanism, called FLvem, under different SNR. The probability of detection (PD) and probability of false alarm (PFA) are shown in Fig. 2.

When there are no malicious nodes, the performance of FLavg is almost the same as that of FLvem. with the increase of SNR, PD increases and PFA decreases. However, when subjected to poisoning attacks, the performance of FLvem is almost unchanged under most SNR, while the performance of FLavg degrades sharply.

At the same time, we can also see the advantages of FLvem from loss function. Figure 3 shows the loss function of FLavg and FLvem when subjected to poisoning attacks under SNR = −2 dB, respectively. It can be seen that the loss function of FLavg can not always decrease steadily, but will increase when it decreases to a certain extent, which shows that the malicious nodes have a serious impact on the global model, and the loss function of the global model is difficult to converge to the lowest value. However, the loss function of FLvem can maintain a steady and continuous decline, and its global model can gradually converge to the lowest value, which indicates that malicious nodes have almost no effect on the global model.

Fig. 2.
figure 2

The probability of detection and the probability of false alarm

In fact, not only in the case of poisoning attack, the performance of FLvem is superior, but also the loss function of FLvem converges faster when there is no poisoning attack.

Fig. 3.
figure 3

The loss function of FLavg and FLvem

5 Conclusion

In summary, we design a spectrum sensing framework based on federated learning in IoT. At the same time, in federated learning, we propose a value evaluation mechanism for IoT devices, which can effectively strengthen the positive role of beneficial nodes and weaken the impact of malicious nodes. In federation learning, this mechanism not only plays a significant role in making the model converge more quickly and stably but also can effectively resist poisoning attacks.