Genetic algorithm-based hybrid spectrum handoff strategy in cognitive radio-based internet of things

In Cognitive radio-based Internet of Things (CR-IoT) systems, the return of the primary user (PU) causes the secondary user (SU) that is communicating to face the spectrum handoff problem. In the process of spectrum handoff, the user terminal cant get the idle channels in time because of the unknown channel usage state.To solve this problem, a hybrid spectrum handoff algorithm based on genetic algorithm is proposed. The algorithm considers the regularity of PU activities in space and time, defines the idle probability of channels from the perspective of week attributes and time periods, obtains the optimal time period length using genetic algorithm,generates a channel idle probability table, and provides the target channel sequence for SUs in combination with the proposed channel ordering scheme. Simulation results show that when the total number of SUs is within 10 ∼\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\sim $$\end{document} 20, the proposed algorithm has a spectrum handoff outage probability of less than 7%, an average delivery time of less than 13s, a total packet error rate of less than 5.5%, a channel utilization of consistently above 70%, and an average detection times of less than 7 times.


Introduction
The Internet of Things(IoT) is a ubiquitous technology that communicates with each other by complexly integrating devices (or things) around us to form a closed network of connections to solve real-life problems intelligently [1].Many IoT devices are mobile, small, and located in decentralized locations [2]. Therefore, wireless networks are considered B Liu Miao lm_jlu@163 [3]. Tens of thousands of devices connected through networks constitute the IoT. All physical objects in the IoT can communicate without human intervention, share information, and coordinate decisions [4]. Through the deep integration of physical and digital worlds, IoT revolutionizes the connection and interaction between all objects, and everything will have the ability to sense the environment [5]. With the development of information technology, IoT will penetrate all aspects of the economy, such as intelligent transportation, environmental sensing, smart homes, smart cities, education, industrial monitoring, food traceability, surveillance, and wise collection [6]. According to Intel China in the Future of Intelligent Edge Computing Forum, global IoT devices will reach 100 billion by 2025.
Communication between IoT devices requires spectrum bandwidth, and the growing number of connected objects in the IoT poses multiple challenges, including a scarcity in the spectrum [7]. IoT devices currently use Bluetooth and ZigBee for data transmission in the unlicensed ISM(Industrial Scientific Medical) bands.With the increase of Internet of Things devices, the frequency band in ISM is almost entirely occupied, and the transmission distance supported by traditional wireless technologies can reach 100 meters [8]. Therefore, these conventional wireless technologies are unsuitable for IoT applications, such as smart grid, intelligent vehicle transmission, and environmental monitoring, where deployed smart IoT devices need to communicate with remote base stations [9]. The spectrum scarcity problem is also related to spectrum utilization and the technology used [10].In the traditional spectrum allocation scheme, the licensed spectrum is not fully used. The spectrum utilization is below 3 GHz at roughly 30% and only 0.5% from 3-6 GHz, leaving upwards of 70% of spectrum resources underutilized and spectrum resources severely wasted [11].The Federal Communications Commission (FCC) proposed cognitive radio technology can effectively address this problem [12]. Cognitive radio technology allows unlicensed SUs to dynamically and opportunistically utilize a portion of the licensed spectrum by adaptively changing their operating parameters (transmit power, carrier frequency, modulation energy, etc.) while providing performance guarantees to the traditional primary user (PU) [13].A promising solution to the spectrum shortage is the use of cognitive radio technology in the IoT, which gave rise to the Cognitive Radio based Internet of Things (CR-IoT) [14]. By applying cognitive radio technology to the IoT, IoT devices can reuse spectrum and avoid collisions. In addition, with cognitive radio capabilities, IoT devices will have easier access to many networks and services and the system will be scalable [15]. In a cognitive IoT system, IoT devices with cognitive capabilities are called secondary users (SUs). In a cognitive IoT system, when a PU returns or the spectrum quality deteriorates, the SU needs to suspend its ongoing transmission, free up the channel, and identify a target channel to resume its transmission. This process is called spectrum handoff [16].

Motivation
In a CR-IoT system, the SUs can use the following methods when performing spectrum handoff: proactive, reactive, and hybrid spectrum handoff schemes [3]. Before establishing a data connection, the proactive spectrum handoff scheme predetermined the target channel sequence based on long-term statistics. This approach saves detection and handshaking time at each handoff but requires dealing with obsolescence when the target channel is no longer available. The reactive spectrum handover scheme detects idle channels at the SU unit at the beginning of each handoff procedure [17]. In this method, the time of detection and handshake must be taken into account. In addition, the order and number of sensing channels must be considered for efficient transmission. Although this scheme can obtain free channels for handoff, it still suffers from handoff delays during spectrum sensing. The hybrid handoff scheme combines the above two handoff schemes (proactive and reactive spectrum handoff schemes) by applying proactive spectrum sensing and reactive handoff actions [18]. In other words, it takes advantage of fast response and accurate target selection in proactive and reactive handoff schemes and can realize fast spectrum handoff with a short waiting time [19].
When the PU returns to the authorized channel, the SU occupying the channel must unconditionally quit immediately to avoid affecting the use of the PU. Only when the PU is free, the authorized channel can be competed by SUs on a "first-come, first-served" basis, and the activity of the PU is the main factor affecting whether the authorized channel is free or not. This paper proposes a hybrid spectrum switching scheme based on genetic algorithm from the perspective of statistical analysis of PU activity on the channel, which can provide an effective spectrum selection strategy for SU spectrum handoff.

Contribution
The contributions made in this paper are as follows: (1) PU activity has the characteristics of regularity in space and time. This paper puts forward the idle probability table according to the week attribute of the spectrum handoff moment and the idle probability of each channel in the time period. (2) Considering the reason why SUs stop using authorized channels near the moment of spectrum handoff, a target channel sequencing scheme is proposed to enable SUs to detect idle channels faster. (3) The genetic algorithm is used to calculate the optimal period length, which makes the obtained channel idle probability table more referential. (4) Ordinary SUs can not perform the complex calculation of channel idle probability and large-capacity data storage, so the solution is proposed by using a central cognitive device. The central cognitive device assigns the target channel sequence to the SU to obtain the channel detection ranking with high idle probability and enable it to detect the idle channel as soon as possible.

Organization
The rest of the paper is organized as follows. In Sect. 2, we summarize the related work. Section 3 describes the system model. In Sect. 4,We discuss the proposed spectrum switching algorithm. In Sect. 5, simulation experiments are performed, and the results are compared and analyzed. Finally, Sect. 6 draws conclusions.

Related work
During spectrum handoff, SU needs to find an idle channel to continue transmission. In the process of finding the inactive channel, it needs to spend its own energy to detect the idle channel until the available channel is obtained or the timeout is interrupted, which will also cause transmission delay. For time-critical transmission requirements, the importance of fast idle channel discovery is even more critical. How to quickly find available channels has been extensively studied by previous authors. [20] proposed an proactive handover scheme based on an artificial neural network to find the best candidate channel. The licensed channel uses the past index of PU activities to train the neural network to obtain a channel list based on the minimum probability of PU occupancy . CR users use the sorted list to obtain the best channel for switching. [21] applies support vector machine (SVM) to CR-IoT network, so that it can learn and adapt to the changing network dynamics, and identify the use of PU spectrum based on the established multi-class (Jx6)d feature set. In [7], the author proposed a predictive spectrum switching scheme for hybrid cognitive radio networks based on deep DQN. In the proposed spectrum switching method, in order to ensure the reliability of spectrum switching, the spectrum switching success rate is introduced into the optimal spectrum resource allocation model, and the closed expression of spectrum switching success rate is obtained based on Poisson distribution.In addition, a transfer learning strategy is adopted to improve the learning process of DQN further. Finally, the priority sequence of available channels of the spectrum switching target is obtained. While meeting the interference constraint between SU and PU, spectrum switching success rate constraint, and SUs performance requirements, the total throughput of HCRNs is maximized. [22] developed an adaptive switching algorithm that allows the SU to detect the arrival of the primary user (through sensing) and adapt to a proactive or reactive switching strategy accord-ingly. The adaptive switching scheme first allows the SU to decide whether to stay on the current channel and wait or to perform handoff. In the case of switching, the SU intelligently switches between proactive or reactive switching modes depending on the PU arrival rate. The paper, in addition, a PU-first Markov method is proposed to model the interaction between the PU and the SU for smooth channel access.A new prediction-based spectrum management strategy is proposed in [23]. The strategy fully considers spectrum prediction and user mobility prediction. Combining the prediction information and cooperative sensing, the cognitive radio base station can obtain the sensing information of each SU's future location and thus pre-set high-quality channels for SUs in advance. The authors also propose a new channel selection scheme when multiple channels are available simultaneously. [24] proposed the M/M/1 queuing model for spectrum switching and the shortest queueing selection model for the backup channel after the switching process occurs. The results show that the model has the smallest queuing delay and total system time compared with random selection, which can improve the service quality of SUs. In [25], a new technique based on particle swarm optimization is proposed to minimize the switching delay and maximize the throughput.Reference. In [26], a new hybrid method based on fuzzy rough set theory (FRST) and support vector machine (SVM) is proposed to deal with spectrum switching.An improved PSO (iPSO) algorithm is proposed in [27] to switch the spectrum. Compared with SpecPSO algorithm, this algorithm has better throughput and data rate efficiency.The paper [28] proposes a handover scheme of cognitive radio network based on hybrid priority queuing model , which is divided into two parts: (1) Prioritize the SUs in the channel, then calculate the waiting time, and propose a mixed priority queuing model with discretionary rules; (2) Improve the learning rate of SUs to other users to reduce waiting time. The analysis table of different spectrum handoff schemes in the related work is shown in Table.1.  Fig. 1, where the PU and SU will use access points (APs) to compete for the use of spectrum channels for uplink and downlink transmissions. The model consists of several independent wireless channels, central cognitive devices and several users. Each wireless channel consists of three priority queues: high priority queue (PU transmission), switching queue (spectrum switching user transmission) and low priority queue (SU transmission). For simplicity of description, it is considered that each queue is infinitely long. Also, the preemptive recovery priority (PRP) M/G/1 queuing model is combined to manage the spectrum switching process.When PU finds that the channel it belongs to is occupied by SU, it will preemptively transmit before the arrival of SU. Since the preemption priority queue gives the spectrum owner the right to interrupt its transmission when the SU arrives, it can represent the inherent traffic structure of CR-IoT. Figure 2 shows the frame structure designed for CR-IoT with periodic spectrum sensing, in which each frame includes a sensing time slot and a data transmission time slot. In the spectrum sensing time slot, the SUs sense the presence state of the PU in the target channel, and only when the PU is idle, it enters the data transmission time slot to transmit data.When each SU starts to transmit in the channel, it is necessary to periodically monitor the usage of the channel PU in each time slot.
Once the current channel is found to be busy, it is necessary to perform spectrum switching and jump to the idle channel for the equipment to continue communication, wherein the idle channel is provided by the central cognitive device. When the waiting time of equipment frequency switching is too long, the transmitting task will be interrupted, and the task will not be sent later.

Channel idle probability and idle probability table
The channel idle probability is the probability that the channel is inactive when the SU is performing channel detection.
The value range of (P f ree ) i,(k,t) is between 0 and 1. The larger the value of (P f ree ) i, (k,t) , the greater the idle probability including the channel ch i .

Optimal length of time period obtained by genetic Algorithm
By counting the usage of all channels in the fixed environment, the idle state attributes of channels several times a week can be obtained. To generate the initial channel idle probability table, it is also necessary to determine the optimal slot length of the division time. According to the time slot length, a day is divided into multiple time slots, and the idle probability of each channel of the time slot is obtained according to the formula of channel idle probability. If the slot length is too large or too small, the performance of the proposed spectrum switching algorithm will be degraded. The selection of the time slot length affects the accuracy of the channel idle probability table. To solve this problem, a scheme based on a genetic algorithm to obtain the optimal time slot length is proposed in this paper. A genetic algorithm (GA) is an optimization algorithm inspired by natural biological evolution. It finds the most suitable gene for the natural environment by selecting, crossing, and mutating the genes in a population and is widely used to search for the optimal solutions to various scientific and engineering problems.
In the scheme of obtaining the best time slot length based on a genetic algorithm, the genetic algorithm tries to find the best time slot length for time-division, so that SU can get the idle channel fastest by querying the channel idle probability table. A genetic algorithm obtains the best value through a series of iterative operations.
The proposed scheme for obtaining that optimal period length base on genetic algorithm consists of the following parts: Step1: Initial population Initially, the initial population is set to consist of N individuals, and the genetic algorithm initializes the population by randomly generating N chromosomes, while binary coding them and transforming them into the space that the genetic algorithm can handle.
Step2: Population fitness The fitness function of population is a key factor to evaluate the fitness of population. Combined with this paper, the set population fitness function is considered in combination with the number of detections required by SU to detect the target channel sequence to obtain the idle channel and the length of the time period.
The fitness function is: where n is the total number of experiments and Duration is the time period length.N um_test j,(k,t) is the number of detection times when SU found the free channel in the j experiment in (k, t).
Step3: Selection, crossover and variation The fitness value of each individual in the initial population is first obtained, and the roulette wheel method is used to determine the proportion of the roulette wheel occupied by each individual based on the fitness value, and then the chromosomes that can be inherited to the next generation are selected from the initial population. The crossover probability is set, and when the randomly generated probability value is greater than the crossover probability, the selected chromosomes are crossed, and the selection of the crossover rate determines the frequency of the crossover. When the crossover rate is larger, the generations can be crossed adequately, but the crossover does not necessarily produce offspring with high fitness, which can lead to a greater possibility of destruction of the selected good genes in the population, thus producing a larger generation gap, which will make the search tend to be randomized; when the crossover rate is set lower, the generation gap produced will be smaller, which will make more of the selected current good individuals replicate directly to the next generation. Similarly, the selected mutation rate also affects whether chromosomal gene mutation is performed, and the mutation operation will be triggered when the probability of random generation is greater than the mutation rate.
Step4: Stop conditions The iteration is stopped when the children generated by the above steps have the required fitness value or when the maximum number of iterations is reached, otherwise the above steps are repeated.

Target channel sorting scheme
The channels are sorted according to the corresponding probabilities in the idle probability table from largest to smallest to generate the initial target channel sequence. the SU uses the idle channel for transmission encounters two situations:(1) the SU uses the idle channel for transmission in the process, the PU returns, and the SU is forced to stop transmission and perform spectrum switching. (2) The SU completes the data transmission using the idle channel without any problem. After the transmission is completed, the SU stops channel occupation. To reduce the time and energy consumed by the SU to detect the idle channel, this paper makes the following improvements to the initial target channel sequencing scheme: for case(1), the SU shall actively report the interruption of the used channel to the central cognitive device. When the central cognitive device needs to generate the target channel sequence within a short period of time, it is always placed at the bottom of the target channel sequence to be generated, regardless of the idle probability of this channel at that moment. For case(2), the SU reports normal usage information to the central cognitive device. In a short time, if the central cognitive device needs to generate a target sequence, it is always placed at the top of the target channel sequence to be generated, regardless of the value of the idle probability of this channel.

Channel idle probability table update
Through the above method, the channel initial idle probability of each channel in different time periods in each week attribute is obtained. The probability is updated every time of subsequent detection. It is updated to get the channel idle probability with a more excellent reference.
Every time the channel ch i is detected, the number of channel detections in the corresponding (k, t) is increased by 1, that is: When the detected channel ch i is idle in (k, t), the channel idle probability of the corresponding period is updated: Similarly, when the detected channel ch i is occupied, Channel idle probability in (k, t) update : where the value of (N f ree ) i,(k,t) remains unchanged.

Strategy summary
This system uses the central cognitive device, and uses it to allocate the target channel sequence required for spectrum switching to SU.The central cognitive device combines the channel idle probability and the target channel ordering scheme to generate the sequence and send it to the SU for sensing. System operation process: When the SU needs to switch the spectrum, it must send a request to the central cognitive device to obtain the target channel sequence. After receiving the request, the central cognitive device first determines the week attribute and the detection time period.
According to this information, it learns the idle probability corresponding to each channel from the channel idle probability table. At the same time, it refers to the proposed channel sorting scheme to generate the target channel sequence to be detected, and sends the sequence to the SU.After receiving the sequence information, SU detects the channels in the sequence in order. When the channel with the highest ranking is in the occupied state, it sequentially detects the channels slightly lower than its position. It continues this way until the idle channel is seen.When the SU stops using the found idle channel, it reports the channel detection and the reason for stopping using this channel to the central cognitive device. The central cognitive device updates the idle probability of the corresponding channel and records the reasons for channel deactivation. In this way, the obtained data are constantly updated, resulting in a channel idle probability with more excellent predictive reference. The proposed spectrum handoff process is shown in Fig. 3.

Algorithm complexity analysis
The complexity of the proposed hybrid spectrum handoff algorithm based on genetic algorithm depends mainly on the genetic algorithm and the fitness function. The complexity of the genetic algorithm is mainly related to the comparison between the individuals in the population and the rest of the individuals to obtain the optimal solution, and the complexity is O (N ). The complexity of the fitness function is measured to be independent of the length of the selected time period, and only related to the total number of channels in the system,

Example of hybrid spectrum handoff algorithm based on genetic algorithm
It is assumed that there are 5 authorized channels in a fixed environment and an initial channel idle probability table has been obtained. As shown in Fig. 4, an example is given to illustrate the four spectrum handoff processes for SUs in the hybrid spectrum handoff algorithm based on channel idle probability.
(1) At the beginning, theSU 1 transmits data on the target channel Ch1, and the PU returns in the process, resulting in the first interruption. The SU 1 reports the interruption of transmission on the authorized channel Ch1 to the central cognitive device, and the central cognitive device inquires the channel idle probability corresponding to the week attribute and time period in the channel idle probability table. At this time, the channels are in the order of Ch2, Ch5, Ch1, Ch4 and Ch3 according to the idle probability from large to small. Ch1 is the channel returned by PU at this time, which causes transmission interruption, so the target channel sequence (Ch2,Ch5,Ch4,Ch3,Ch1) for spectrum handoff is obtained. The SU 1 finds the first channel Ch2 from the sequence, and after detecting that Ch2 is idle at the moment, SU 1 accesses the channel Ch2. (2) In the second interruption, SU 1 reports the interruption of transmission and obtains that the channels are sorted by idle probability: Ch5, Ch2, Ch1, Ch3, Ch4 by referring to the channel idle probability table at this moment. The target channel sequence is (Ch5,Ch4,Ch1,Ch3,Ch2), and SU 1 finds the target channel as Ch5 from the sequence, but it is detected that the channel Ch5 is occupied at the moment. Therefore, continues to select the channel Ch4 from the target channel sequence, and it is detected that the channel Ch4 is idle at the moment, and SU 1 accesses the channel Ch4. And update the idle probabilities of channels Ch5 and Ch4 at this moment. (3) In the third interruption and same cluster, a short time before spectrum handoff occurs in SU 1 ,SU 1 normally uses up channel Ch3 and releases it, and at this moment, the channels are sorted as Ch5, Ch3, Ch2, Ch4 and Ch1 according to idle probability. Combined with SU 2 , the target channel sequence of SU 1 at this time is (Ch3, Ch5, Ch2, Ch1, Ch4) because channel Ch3 is normally used up. The SU 1 obtains the primary idle detection channel Ch3 from the target channel sequence, and after detecting that Ch3 is idle at the moment, SU 1 accesses Ch3 to continue transmission and updates the idle probability of Ch3 in the channel idle probability table. (4) Not long after SU 3 in the same cluster stopped using channel Ch5 because PU returned, SU 1 was interrupted for the fourth time. At this moment, the order of channel idle probability is Ch5, Ch2, Ch4, Ch3 and Ch1. Because SU 3 stops using channel Ch5 due to PU return, the target channel sequence of SU 1 at this time is (Ch2, Ch4, Ch3, Ch1, Ch5). The SU 1 obtains the primary channel Ch2 to be idle from the target channel sequence. After detecting that Ch2 is idle at the moment, accesses Ch2 to continue transmission and updates the idle probability of Ch2 in the channel idle probability table.

Performance analysis
In this section, we use Matlab experimental platform for communication simulation. MATLAB is a powerful mathematical software, which has the functions such as matrix operations, plotting functions and data, and implementing algorithms. It is mainly used in the fields of engineering calculation, signal processing and communication. The performance of the proposed spectrum handoff scheme is evaluated by comparing it with other spectrum switching schemes in terms of transmission performance.

Simulation parameter setting
In the simulation, the SNR of the PU signal is -20 dB, the sampling frequency fs is 6 MHz, and the noise spectral density is -174 dBm/Hz. We consider that the whole spectrum is evenly divided into 5 sub-channels for data communication, and the channel bandwidth is 320kbps. There is a common control channel for coordination between central cognitive device and SU. It should be noted that common control channel and data channel are separate. The preemptive recovery priority (PRP)M/G/1 queuing network model is used to model the spectrum handover, where the arrival rates of both PU and SU obey Poisson distribution with initial arrival rates of 0.25 and 0.2, respectively.The service duration distributions of both PU and SU obey exponential distribution with mean service times of 6s and 4s, respectively. In the network, the transmission rate of SU is 64kbps, the spectrum sensing time is 40ms, the longest waiting time for spectrum switching is 320ms and the packet size is 200bytes. In order to evaluate the performance of hybrid spectrum switching algorithm based on genetic algorithm in networks with different SUs, we change the total number of SUs in the system from 10 to 20. Simulation parameters are shown in Table 2.

Performance comparison and analysis of spectrum switching algorithms
The proposed algorithm is compared with the spectrum handoff scheme based on fuzzy rough set theory (FRST) and support vector machine (SVM)(FRST-SVM) [26], improved PSO (iPSO) (PSO) [27] and hybrid priority queuing model (HPQ) [28]. The results show that the proposed hybrid genetic algorithm based spectrum switching scheme has better results.
When the PU is returned in the authorized channel, the transmitting SU must quit immediately and find an idle channel to continue the transmission. The time that the SU waits for a free channel is limited, and if the SU has not found a free channel for transmission within the specified time, the SU terminates transmission, i.e., the spectrum handoff outage. Figure 5 shows the analysis of spectrum switching outage probability analysis relative to the total SU. It shows that with the increase of the number of SUs , the spectrum switching failure rate of various hybrid switching schemes is increasing, and all of them are within 10%. The probability of spectrum switching outage of PSO is always higher than the other three schemes.With the increase of SU number, the increase range of interrupt probability of FRST-SVM tends to be smooth, and the probability of the proposed algorithm increases rapidly, but both of them gradually approach 5.3%. Among these schemes, the increase of spectrum switching outage probability is mainly due to the high competition of channel access. The proposed model has the minimum handover failure rate, because in this case, the target channel ranking scheme in the proposed algorithm can provide the real-time usage of channels for SU in time, so that SU can realize fast access to channels.
The average delivery time is the time from the beginning of sending data to the completion of transmission by SU in the system. The smaller the average delivery time, the higher the real-time performance of the spectrum switching scheme, and the faster the data transmission task can be realized. Figure 6 describes the change of average delivery time, and the time of four spectrum switching schemes rises as the SU increases. In the process of increasing the SU number, PSO and HPQ perform similarly and gradually approach each other, and the average transmission time of FRST-SVM and the proposed algorithm also has the same changing nature, but only when the number of SUs is 16, the gap of them become smaller and converges to 12%. These models show that as the number of SUs increases, the channel availability in the system decreases, resulting in the need for extensive spectrum switching and longer user transmission times.
When the SU performs spectrum switching, the remaining packets are partially lost due to exceeding the cut-off time, i.e., packet errors, resulting in wasted resources and ineffective transmission. The smaller the value of the total packet error rate, the better. Figure 7shows the variation of the total packet error rate with the number of SUs.From the figure, it can be seen that the proposed algorithm has the lowest total packet error rate, but it gradually approaches FRST-SVM during the increasing SUs.The total packet error rate of the proposed algorithm and FRST-SVM always remains between 2% and 5.3%, which has a better performance. Among the four algorithms compared, the proposed algorithm has the best transmission effect, because it provides alternative channels for SUs in time according to the PU usage, which can achieve spectrum switching more quickly compared to other algorithms, avoiding the loss caused by packet transmission delay and improving transmission efficiency.
In the system, the PU and SU share the channel for transmission, and when PU is free, SU can access the channel. For SU, it is easy to encounter the problem that when there are transmission tasks and idle channels, SU can't find the idle channels and use them.Channel utilization rate is a suitable indicator to reflect the channel utilization status, and the higher the indicator, the better. Figure 8 clearly shows that when the total number of SU is between 10 and 13, the channel utilization corresponding to PSO algorithm is the lowest, and the remaining three algorithms are similar. Since the total number of SUs is greater than 13, the channel utilization rates of the four algorithms are generally similar, which indicates that they are all good at using idle channels. At the same time, another important factor is that the number of SUs is large, and the tasks to be sent are heavy, while the number of channels is limited, which leads to the increase of channel utilization rate. In conclusion, in the comparison of four algorithms, the proposed algorithm can effectively use the channel and reduce the waste of spectrum resources.
When the SU performs spectrum switching, it needs to detect the target channel. When the channel is busy, it needs to visit the next channel to find an idle channel to continue transmission. The average detection times can fully reflect the channel prediction ability of the algorithm, and the algorithm with lower average detection times has better prediction performance. Figure 9 depicts the variation of the average detection times of the algorithms.It can be seen from the figure that the average detection times of PSO, HPQ and FRST-SVM are relatively close, and the times of the pro- Average detection times posed algorithm are lower, which is always below them. This is because the proposed algorithm combines the access characteristics of PU to the authorized channel and the real-time channel usage condition, which can provide the SU with a more reliable sequence of using the target channel and thus achieve fast frequency handoff.
The above simulations show that the proposed algorithm is suitable for situations where there is long-term authorized channel access information in a fixed environment, and the richer the information, the better the guidance effect of spectrum switching channel detection.. Meanwhile, the proposed algorithm is smaller in size, simpler in operation, and requires less computing power from the central cognitive device, which is more suitable for use in large-scale application scenarios. The implementation of FRST-SVM [26] and HPQ [28] can also achieve good results, but the algorithm execution is more computationally intensive and requires higher computing power of the equipment, which also aggravates the shortage of equipment supply and has limited application scenarios. The algorithm complexity of PSO [27] is lower and the requirements of the equipment are consequently reduced, but according to the actual simulation results, it is known that its spectrum switching performance is not yet satisfactory and needs to be improved.

Conclusion
In this paper, a hybrid spectrum handoff algorithm based on genetic algorithm is proposed to help devices in CR-IoT find idle channels to continue transmission. The target channel sequence is generated by using the channel idle probability table and the proposed target channel sorting scheme, so as to reduce the waiting time of spectrum handoff of CR-IoT devices and find idle channels faster. Simulation studies show that the hybrid spectrum handoff algorithm based on genetic algorithm can obviously improve other performances such as total transmission time consumption, total transmission energy consumption, and Maximum number of sensing times for spectrum handoff.
In the future work, we will study how to make the CR-IoT devices get idle channels to continue transmission more quickly when several devices need to switch spectrum in a short time. In addition, the proposed hybrid spectrum handoff algorithm will be optimized by combining the Markov model to make the target channel sequence more effective. Data Availibility Data can be shared and is available on request. Data can be requested by sending an email to the main author.

Declarations
Xu Di received the B.S. degree from the Taiyuan University, China, in 2020. From 2016 to 2020, she was an undergraduate with College of Computer Science and Technology.Since 2020, she is currently pursuing M.S degree in Northeast Petroleum University, Heilongjiang, China. Her current research interests include the performance optimization of Internet of Things and Internet of Things based Cognitive Radio security.