Spectrum Sharing Based on a Bertrand Game in Cognitive Radio Sensor Networks

In the study of power control and allocation based on pricing, the utility of secondary users is usually studied from the perspective of the signal to noise ratio. The study of secondary user utility from the perspective of communication demand can not only promote the secondary users to meet the maximum communication needs, but also to maximize the utilization of spectrum resources, however, research in this area is lacking, so from the viewpoint of meeting the demand of network communication, this paper designs a two stage model to solve spectrum leasing and allocation problem in cognitive radio sensor networks (CRSNs). In the first stage, the secondary base station collects the secondary network communication requirements, and rents spectrum resources from several primary base stations using the Bertrand game to model the transaction behavior of the primary base station and secondary base station. The second stage, the subcarriers and power allocation problem of secondary base stations is defined as a nonlinear programming problem to be solved based on Nash bargaining. The simulation results show that the proposed model can satisfy the communication requirements of each user in a fair and efficient way compared to other spectrum sharing schemes.


Introduction
In the field of Cyber-Physical Social Sensing, wireless sensor networks (WSNs) [1][2][3] play a very important role. WSNs are organized networks composed of some tiny sensor nodes that can perform information collection, processing and wireless transmission actions. Due to the large number of nodes in WSNs, a large amount of data needs to be collected [4][5][6], and these data also need to be transmitted, which leads to the problem of spectral tension and node limitations. In order to solve these problems, Cognitive Radio Sensor Networks (CRSNs) have become a research hotspot of many scholars at home and abroad. CRSNs make each sensor node have the ability of spectrum sensing and dynamic spectrum access by introducing cognitive radio (CR) [7,8] technology into WSNs, and is considered to be the most promising wireless sensor network of the next generation [9,10]. Dynamic spectrum sharing make cognitive user/secondary users that have CR technology share spectrum resources that can only be used by authorized user/primary users (PUs) by adaptively adjusting the transmission parameters in the CRSNs, which makes the spectrum resource utilization not be high in traditional static management mode and alleviates the shortage of spectrum resources.
According to different wireless network access methods, dynamic spectrum sharing can be divided into underlay mode [11] and overlay mode [12,13]. In underlay mode, the secondary user is able to evaluate the interference temperature threshold of the primary network, by using to reduce the waste of spectrum resources and excess power on the network environment caused by interference. Thus, considered the communication needs of users, this paper proposes a kind of two stage model of spectrum pricing and allocation to study the problem of spectrum sharing. The main work includes the following three aspects: (1) In the first stage, designing a secondary user utility function reflecting the needs facing the secondary network spectrum. (2) A spectrum rental model facing these needs was designed based on Bertrand game theory, and a spectral demand adjustment algorithm of secondary base stations was also designed. This made the optimal spectrum rental quantities of secondary base stations just equal to the secondary network needs when the primary base station used Nash equilibrium pricing. (3) In the second stage, for the communication needs of secondary users, fairly and efficiently allotting secondary base station spectrum resources based on a Nash bargaining scheme considering frequency, power and time dimensions.

Primary and Secondary Network Model
Suppose there is a WSN, that has M primary networks that can lease free spectrum to a secondary network. In order to meet the communication of secondary users, the secondary network need to lease the primary network spectrum on the basis of controlling the transmission power of secondary users. This is shown in Figure 1. Suppose we have a secondary network comprising N secondary users and each secondary user ( = 1,2, … , ) can transmit channel capacity demand to the secondary station to request spectrum resources for communication services. The secondary base station collects user requirements ∑ of all secondary users and decides the spectrum prices ( 1 , 2 , … , M ) of different primary base stations, leasing spectrum ( 1 , 2 , … , M ) from different primary base stations, wherein i refers to the number of subcarriers, assuming that all subcarriers have the same bandwidth w. In primary networks, each primary base station adjusts its pricing k continuously as seller, until they can not further increase their own income, then the spectrum market is in an equilibrium state between the spectrum price for primary base stations and the spectrum requirements for secondary base stations is ( 1 * , 2 * , … , * ) and ( 1 * , 2 * , … , * ). After the secondary station pays for the spectrum resources, it would assign the corresponding spectrum resources and transmission power to each secondary user according to the needs of secondary users ( 1 , 2 , … , ) and the transmission power threshold . Suppose we have a secondary network comprising N secondary users and each secondary user i(i = 1, 2, . . . , N) can transmit channel capacity demand R i to the secondary station to request spectrum resources for communication services. The secondary base station collects user requirements N ∑ i R i of all secondary users and decides the spectrum prices (λ 1 , λ 2 , . . . , λ M ) of different primary base stations, leasing spectrum (q 1 , q 2 , . . . , q M ) from different primary base stations, wherein q i refers to the number of subcarriers, assuming that all subcarriers have the same bandwidth w. In primary networks, each primary base station adjusts its pricing λ k continuously as seller, until they can not further increase their own income, then the spectrum market is in an equilibrium state between the spectrum price for primary base stations and the spectrum requirements for secondary base stations is λ * 1 , λ * 2 , . . . , λ * M and q * 1 , q * 2 , . . . , q * M . After the secondary station pays for the spectrum resources, it would assign the corresponding spectrum resources and transmission power to each secondary user according to the needs of secondary users (R 1 , R 2 , . . . , R N ) and the transmission power threshold p TOTAL .

Oligopoly Market and Bertrand Game
The network model that contains many primary base stations and a single secondary base station can use oligopolistic market theory to understand the interactions of spectrum leasing process for buyers and sellers. The oligopolistic market is between the monopolistic market and the perfectly competitive market, which refers to all the commodities in the market that are controlled by a small number of sellers, each seller is able to influence the spectrum markets that contains other sellers by changing strategies such as adjusting the price or volume of goods, and sellers' decisions are visible to each other. The Bertrand game is a kind of game in the oligopoly market, which is used to model the price competition behavior in the market, so as to analyze and get the equilibrium pricing strategy of each seller. A Bertrand game basically includes the following three elements: (1) The player set N = {1, 2, 3, . . . , n}, which consists of the secondary users or the primary users participating in spectrum sharing; (2) Strategy vector a, player i select a strategy a i from its own strategy set S i in each game, the strategy can be the number of purchased spectrum, or transmission power, strategy vector of all players a = (a 1 , a 2 , . . . , a n ); (3) Utility function u i (a i , a −i ) : S → R , which represents the degree of benefit or satisfaction that player i can obtain in strategy vector a = (a i , a −i ). Usually, a −i = {a 1 , a 2 , . . . , a i−1 , a i+1 , . . . , a n } denotes the strategy vector of other players except i, and u = {u 1 , u 2 , . . . , u n } is called the utility vector.
In a Bertrand game based on an oligopoly market, the primary base stations of the primary network act as oligarchs, making decisions independently, and content of the decision is to change the price of goods. It is usually assumed that the goods of different sellers have their own characteristics, and the goods can't be completely replaced. When the demand function of seller i is q k = D k (λ k , λ −k ), so i's optimal pricing can be obtained by seeking extreme value income function formula (1) in the corresponding cost C k (D k (λ k , λ −k )): The primary and secondary user networks shown in Figure 1 are modeled based on the Bertrand game model. All of the primary base stations as oligarchs control the market spectrum, and each primary base station rationally adjusts the spectrum pricing in the pursuit of maximizing its own income; secondary base stations acts as buyers according to their own needs and the spectrum pricing of each primary base station to determine the amount of spectrum that they should lease from different sellers. In spectrum markets, primary and secondary base stations are competitive in the market by continuously adjusting pricing and spectrum requirements, ultimately stabilizing to a market equilibrium. The primary base stations also stabilize to a Nash equilibrium in the price competition of constantly adjusting prices.
Since the primary base stations holds licensed spectrum, they have higher spectrum access priority, so primary base stations as "leaders" determine the spectrum price λ, while the secondary base station as "followers" determine the rent number q by the spectrum prices and their demand functions. Leaders know followers will react to their policy, thus they can take the followers' reactions into account when determining the price. That is, before the primary base station rents spectrum to a secondary base station, it will forecast the rent amount q i of i when the price is λ i , and then determining the price λ * i that can make their own maximum income, under this pricing, the rental amount of i is q * i . For this transaction process where the primary base station determines the spectrum price and the secondary user decides the number of leases, we can use a reverse induction method to solve the spectrum pricing and spectrum requirements for the equilibrium point where assuming that known the spectrum price λ, the supply of the primary base station is q = S(λ), and the spectrum needs of the secondary base station is q = D(λ). Usually, the supply function is a non-decreasing function with respect to the price, and the demand function is a non-increasing function with respect to the price. As shown in Figure 2, the market equilibrium (λ * , q * ) in the supply and demand curves junction, Equation (2) can be obtained. From Equation (2), we can see that the supply of the primary base station equals the demand of all secondary base stations and D(λ * ) = S(λ * ), that is, λ * = S −1 (q * ) = S −1 (D(λ * )), so market equilibrium pricing and spectrum requirements of secondary users are available: price. As shown in Figure 2, the market equilibrium ( * , * ) in the supply and demand curves junction, Equation (2) can be obtained. From Equation (2), we can see that the supply of the primary base station equals the demand of all secondary base stations and ** ( ) ( )

DS
, that is, , so market equilibrium pricing and spectrum requirements of secondary users are available:

The First Stage: Pricing Model Based on a Bertrand Game
Firstly, in order to quantify whether the leased spectrum satisfies the communication needs of secondary users, we need to design the utility function of the secondary base station. Secondary base stations can determine the demand function ( , ) of subcarriers in specific communication needs and spectrum prices by this utility function. Subsequently, modeling the pricing game of primary base stations based on the Bertrand game, it is proved that the non-cooperative game can converge to a Nash equilibrium, and the pricing method of the Nash equilibrium is used for the primary base stations.

The Utility Function and Demand Function of Secondary Base Stations
In order to meet the channel capacity requirements ( 1 , 2 , … , ) of all secondary users, the number of subcarriers that a secondary base station needs to hire from a primary base station is C when the primary network interference power threshold is and the average subcarrier channel gain is h, assuming that all secondary users use equal power ⁄ in different subcarriers. According to Shannon's theorem, satisfies Equation (3), because the secondary users use M-quadrature amplitude modulation [24], so, η = −1.5/(δz 2 ·ln(5BERij)). By solving Equation (3), we can obtain the total available subcarriers that a secondary base station needs, indicated by Equation (4), where δ = p TOTAL ·|h| 2 ·η, W(·) is the Lambert-W function.
So, the utility function of secondary base station is designed as follows:

The First Stage: Pricing Model Based on a Bertrand Game
Firstly, in order to quantify whether the leased spectrum satisfies the communication needs of secondary users, we need to design the utility function of the secondary base station. Secondary base stations can determine the demand function D(R, λ) of subcarriers in specific communication needs and spectrum prices by this utility function. Subsequently, modeling the pricing game of primary base stations based on the Bertrand game, it is proved that the non-cooperative game can converge to a Nash equilibrium, and the pricing method of the Nash equilibrium is used for the primary base stations.

The Utility Function and Demand Function of Secondary Base Stations
In order to meet the channel capacity requirements (R 1 , R 2 , . . . , R N ) of all secondary users, the number of subcarriers that a secondary base station needs to hire from a primary base station is C when the primary network interference power threshold is p TOTAL and the average subcarrier channel gain is h, assuming that all secondary users use equal power p TOTAL /C in different subcarriers. According to Shannon's theorem, C satisfies Equation (3), because the secondary users use M-quadrature amplitude modulation [24], so, η = −1.5/(δ z 2 ·ln(5BER ij )). By solving Equation (3), we can obtain the total available subcarriers that a secondary base station needs, indicated by Equation (4), where δ = p TOTAL ·|h| 2 ·η, W(·) is the Lambert-W function. So, the utility function of secondary base station is designed as follows: . . , q M } represents the number of subcarriers that rent from different primary base stations. The utility function consists of three parts: (1) u 1 represents the utility that leased spectrum can provide. When the rented spectrum is just equal to the spectrum requirements, u 1 can obtain the maximum benefit. If the leased spectrum is less than the spectrum requirements, the quality that the communication of secondary networks needs can't be guaranteed. If the leased spectrum is more than the spectrum requirements, this would result in excess spectrum and reduced resource utilization. The preference coefficient α reflects the desirability that a secondary base station meets its demand. In addition, to ensure that the utility value of this part is positive, setting µ(µ > 0) is the upper limit of its utility value. (2) u 2 describes the mutual substitutability of the spectrum sold by different primary base stations.
The Bertrand game assumes the rental spectrum of different primary base stations can't be completely replaced, therefore, a spectrum replacement rate v is introduced to consider the spectrum substitutability of different primary base stations. The meaning of replacement rate v ∈ [−1.0, 1.0], that is, when v = 0.0, the secondary user can't switch between different primary base station spectra; when v = 1.0, the secondary user can switch between different spectra; when v < 0, the user spectrum sharing needa to use complementary spectrum, that is, when a secondary user uses a spectrum of the primary base station, it needs to lease one or more other spectra of primary base stations together. (3) u 3 represents the cost that must be paid for the subcarriers {q 1 , q 2 , . . . , q M } of the primary base station.
When given the price of spectrum λ = (λ 1 , λ 2 , . . . , λ M ), the following conclusions are established: When the utility function of the secondary base station is given by Equation (5), the corresponding demand function that the subcarriers share is: Proof. Since the utility function (5) is a concave function, namely, ∂ 2 u SBS (q) ∂q i 2 < 0, we just need to get the maximum value of the function to get q k = D 1 λ k + D 2 (λ −k ), (k = 1, 2, ..., k), which proves the theorem.

The Utility of the Primary Base Station and the Bertrand Game
For the network model which has several or more primary networks and only one secondary network, we know that the supply of the primary base station k is equal to the market demand which we called D k (λ) when the market is proportionate, so the corresponding utility is: The loss coefficient of β k stands for the loss caused by the primary base station k in the process of renting. In the market of this spectrum, spectrum pricing of the primary base station k is called λ k ; it will not only be influenced by other primary base stations' pricing, but it also affects the pricing of other primary base stations. To deal with this problem, we can build a Bertrand competition to study the price competition among different primary base stations. For the corresponding Bertrand competition Γ = M, S, u , let: (1) M represents the set of game players. This set is composed of primary base stations, such as {1, 2, . . . , M}.
(2) λ k ∈ S k represents a player's strategy. The primary base station sets the renting price S k = λ k |λ k > β k , λ k ∈ R + , k ∈ M of subcarriers of per unit. (3) µ k (λ k , λ −k ) represents a payoff function. The primary base station k determines the available utility that spectrum pricing λ k could acquire, calculated by the formula µ PBS k (λ k , λ −k ).
The primary base station k, as a player in the Bertrand games constantly adjusts its pricing, in satisfying certain conditions, it can eventually be stable in a state of equilibrium, which is called a Nash equilibrium (NE).
Definition 1 (Nash Equilibrium). The Nash equilibrium of the strategic form game is a strategy vector This definition shows that no player can unilaterally change its own strategy to obtain a greater incentive in a Nash equilibrium, so, when other players choose a Nash equilibrium strategy, the best strategy of the player can choose is the Nash equilibrium strategy, that is: Herein the function B k (·) is called the optimal response function. However, a Nash equilibrium doesn't always exist in any form of strategy. The existence condition of a Nash equilibrium is given in [25]. Lemma 1. For any player k ∈ M in the strategic form of game Γ = M, S, u , if the policy set S k is a convex compact subset of the Euclidean space, the utility function u k is to be concave and continuous on the policy set S k then the Nash equilibrium of this game exists.

Proof.
A Bertrand competition in normal form is a structure Γ = M, S, u , where a player's strategy is a nonempty convex subset λ k |λ k β k , λ k ∈ R + . We can prove that µ PBS k is a concave function by Equations (6) and (7). By Theorem 2 and Equation (9), we can find that there is a Nash equilibrium λ * 1 , λ * 2 , . . . , λ * M in this game, and λ * k = argmax λ k ∈S k u PBS k (λ k , λ * −k ), ∀k ∈ M, which proves the theorem.
This means that when all parameters are known in the network, we can get a Nash equilibrium pricing strategy (Equation (11)) of a primary base station by Equation (6) and linear Equation (10) and the amount of subcarrier that each secondary base station rents from the primary base station could be solved by its demand function (Equation (6)): For example, in the situation of two primary base stations, the corresponding linear equation is:

Dynamic Bertrand Game
Different primary base stations in different primary networks can't monitor the earnings that each other has acquired and also know nothing about the current strategies of others, so they need to obtain optimal pricing by designing a corresponding distributed program. We provide a distributed program based on dynamic Bertrand competition, which iterates the Bertrand competition process repeatedly to reach optimal pricing. For every iteration named t and each primary base station named i, when the spectrum pricing of i is λ k [t], other primary base stations' pricing will be λ k [t]. When we enter the next t + 1 iteration, the primary base station k adjusts the spectrum pricing of this iteration with a different update strategy to approach Nash equilibrium closer and closer using the different information acquired, where: (1) The update strategy of pricing can use the following formula if the primary base station can obtain other players' historical strategy during the last iteration: (2) The following learning strategy will be used when the primary base station can only study local information, where σ k means the step size of each update: The marginal revenue ∂u PBS ∂λ of Equation (14) can be calculated by Equation (15). When setting a suitable threshold τ and Equation (16) is established, with the increase of the number of iterations and when the utility value of the primary user is close to stable, we can argue that the dynamic Bertrand game can reach the equilibrium state. Moreover, it also can use Equation (17) to calculate the marginal revenue by observing the margin of their utility's change when a minute pricing adjustment occurs. Let ε represent the margin of each minute adjustment, it will stop updating when the conditions of Equation (18) are satisfied:

Stability and Complexity Analysis of Dynamic Game
By analysis of the stability and complexity of a dynamic game, we can definite whether this dynamic game could reach a Nash equilibrium when it converges to a stable state gradually and how to converge to stable state quickly. We can see the two update strategies in Equations (13) and (14) as two different self-mapping functions, so we can learn from the Routh-Hurwitz criterion that this self-mapping function is stable if and only if all its eigenvalues ξ i are located in the unit circle of a complex plane, that means |ξ i |<1. We define a Jacobian matrix shown in (19) in order to obtain the solution set of eigenvalues of the self-mapping function: At first, the dynamic game is based on Equation (13) and its Jacobian matrix is Equation (20). By calculating the steps described above, we can get its eigenvalues: Since the replacement rate ν ∈ [−1.0, 1.0], we can know that the molecule of all eigenvalues is less than the denominator, that is |ξ k | < 1, (k = 1, 2, . . . , M), so the dynamic game of the self-mapping function (13) is stable.
The matrix shown in (21) is the Jacobian matrix of the dynamic game presented in (14). Let σ 1 = σ 2 = σ M = σ, we can obtain its relevant eigenvalues: so by finding the solution of inequality |ξ k | < 1, (k = 1, 2, . . . , M), we can come to a conclusion that the sufficient condition for a dynamic game to be stable is obtained by updating the step size σ of dynamic game that must satisfy constraint: It can be seen from the above stability analysis that the dynamic game update strategy of (13) can converge to the Nash equilibrium according to the optimal response value. The convergence rate of the dynamic game update strategy in (14) is highly dependent on the update step, and the complexity of the model depends on the convergence rate and number of iterations of the dynamic game, so the update step is the key to the complexity of the model. In the later simulation experiments, we will further discuss the effect of the update step on the convergence speed of the dynamic game to ensure the lowest model complexity.

Spectrum Requirement Adjustment and System Scheduling
In the model of spectrum pricing and spectrum allocation which are both based on Bertrand competition, when the subcarrier rent in the state of market equilibrium is lower than the demand of subcarriers in secondary networks, rental subcarriers will not satisfy the spectrum requirements of the secondary network.
From Figure 3, we can learn that when we have set preference factor, replacement rate and loss coefficient, then both the real spectrum requirements and the optimal rent total amount q * = ∑ M k=1 D k (λ * ) will linearly increase, so we can do the next two steps. Firstly, secondary base stations could present their actual spectrum requirements to the primary base station in advance and then by the optimal pricing that the primary network has formulated, we could define the relationship between the actual spectrum requirements and the amount of rental subcarriers. Secondly, in order to acquire spectrum resources that could fulfill the demands of the secondary networks, we can adjust the spectrum requirements again based on the first step. That means, the secondary base stations send actual requirements C + ε and C − ε , which have undergone a minute adjustment to each primary base station, and then calculate the corresponding total amount of rental subcarriers q * total (C + ε ) and q * total (C − ε ) by the requirement function (6) after each base station has returned the optimal pricing λ * (C + ε ) and λ * (C − ε ) under Nash Equilibrium conditions. Secondary base stations find the solution set of slopes which indicate the linear relationship between their requirements and the amount of rent subcarriers by Equation (22), and then determine which virtual spectrum requirement C to send to the primary base station using Equation (23). Through lots of experiments, we can know that the amount of spectrum rental subcarriers based on the subcarrier requirements could satisfy the spectrum requirements of the secondary networks: of the dynamic game update strategy in (14) is highly dependent on the update step, and the complexity of the model depends on the convergence rate and number of iterations of the dynamic game, so the update step is the key to the complexity of the model, In the later simulation experiments, we will further discuss the effect of the update step on the convergence speed of the dynamic game to ensure the lowest model complexity.

Spectrum Requirement Adjustment and System Scheduling
In the model of spectrum pricing and spectrum allocation which are both based on Bertrand competition, when the subcarrier rent in the state of market equilibrium is lower than the demand of subcarriers in secondary networks, rental subcarriers will not satisfy the spectrum requirements of the secondary network.
From Figure 3, we can learn that when we have set preference factor, replacement rate and loss coefficient, then both the real spectrum requirements and the optimal rent total amount will linearly increase, so we can do the next two steps. Firstly, secondary base stations could present their actual spectrum requirements to the primary base station in advance and then by the optimal pricing that the primary network has formulated, we could define the relationship between the actual spectrum requirements and the amount of rental subcarriers. Secondly, in order to acquire spectrum resources that could fulfill the demands of the secondary networks, we can adjust the spectrum requirements again based on the first step. That means, the secondary base stations send actual requirements + ′ and − ′ , which have undergone a minute adjustment to each primary base station, and then calculate the corresponding total amount of rental subcarriers * ( + ′ ) and * ( − ′ ) by the requirement function (6) after each base station has returned the optimal pricing * ( + ′ ) and * ( − ′ ) under Nash Equilibrium conditions. Secondary base stations find the solution set of slopes which indicate the linear relationship between their requirements and the amount of rent subcarriers by Equation (22), and then determine which virtual spectrum requirement ' to send to the primary base station using Equation (23). Through lots of experiments, we can know that the amount of spectrum rental subcarriers based on the subcarrier requirements could satisfy the spectrum requirements of the secondary networks: Figure 3. The relationship between spectrum demand and optimal rent number. Figure 3. The relationship between spectrum demand and optimal rent number.
In summary, when the primary base station is based on the local information of dynamic spectrum pricing, the scheduling process of first stage is as shown in Figure 4. In summary, when the primary base station is based on the local information of dynamic spectrum pricing, the scheduling process of first stage is as shown in Figure 4. Adjust pricing according to (14) * ' Figure 4. Spectrum pricing and allocation scheduling.

The Second Stage: Cooperation Spectrum Sharing
Secondary base station can obtain the set SC of subcarriers in a total number paying for a number of primary base stations. This is used in the communication services of secondary users in the secondary network, so secondary base stations need to solve how to assign a set of subcarriers for each secondary user based on the channel capacity requirements ( 1 , 2 , … , ) and the transmission power of each subcarrier j, and ensure not causing interference for the primary network communication. According to the characteristics of the problem, we can model and solve the problem by using the bargaining game model of cooperative game theory.

Spectrum Sharing Based on a Bargaining Game
Secondary users in a secondary network can fairly and efficiently share available spectrum resources through cooperative games. Bargaining games, as a kind of a cooperative game, can offer game players a win-win and fair solution: According to the bargaining game definition, we can regard secondary users in secondary networks as game players that reach a cooperative agreement, and we can use a bargaining game to set up a module for the secondary base station spectrum resource allocation problem. The corresponding bargaining game formula is Γ = (N, , , 0 ): (1) The set of game players: secondary user set {1, 2,…, i,…, N};

The Second Stage: Cooperation Spectrum Sharing
Secondary base station can obtain the set SC of subcarriers in a total number ∑ M k=1 D k (λ) by paying for a number of primary base stations. This is used in the communication services of secondary users in the secondary network, so secondary base stations need to solve how to assign a set of subcarriers for each secondary user based on the channel capacity requirements (R 1 , R 2 , . . . , R N ) and the transmission power p ij of each subcarrier j, and ensure not causing interference for the primary network communication. According to the characteristics of the problem, we can model and solve the problem by using the bargaining game model of cooperative game theory.

Spectrum Sharing Based on a Bargaining Game
Secondary users in a secondary network can fairly and efficiently share available spectrum resources through cooperative games. Bargaining games, as a kind of a cooperative game, can offer game players a win-win and fair solution: Definition 2 (Bargaining game and bargaining solution). The game Γ = N, S, U, u 0 is called the bargaining game, if U is a closed convex subset of R N , and there is at least one feasible payoff vector, for any I, u i ≥ u 0 i that exists. A bargaining scheme is a function that maps the bargaining problem to the only feasible payoff vector: f U, u 0 : U → u * .
According to the bargaining game definition, we can regard secondary users in secondary networks as game players that reach a cooperative agreement, and we can use a bargaining game to set up a module for the secondary base station spectrum resource allocation problem. The corresponding bargaining game formula is Γ = N, S, U, u 0 : (1) The set of game players: secondary user set {1, 2, . . . , i, . . . , N}; (2) Player strategy a i = (SC i , p i ) ∈ S i : the secondary user i asks the secondary base station for communication subcarrier set SC i . The power transmission of every subcarrier is p i = p ij , (j ∈ SC i ); (3) Payoff function u k (a k , a −k ): The user i uses power p ij to transport information in the corresponding subcarrier of the subcarrier set SC i . It can obtain channel capacity (4) Payoff vector is u 0 when it doesn't reach a cooperation agreement: The demand of channel capacity of the secondary user is (R 1 , R 2 , . . . , R N ); Thus, the problem of subcarriers and power allocation of secondary base station can be transformed into a feasible payoff vector problem in cooperative spectrum communion based on a bargaining game. The bargaining solution is considered a kind of selection criteria of the optimal feasible payoff vector. The Nash bargaining solution (NBS) is a kind of general resource sharing bargaining solution.
Not only can it satisfy the secondary user's needs, but also it can ensure the fairness of resource allocation to the greatest extent. Therefore, according to the Nash bargaining solution, we can define the allocation problem of subcarrier set SC i and power transmission p ij as the nonlinear programming problem shown in Equation (24) in order to fairly and efficiently assign spectrum resources in the secondary network. In the equation, r ij = w·log 2 1 + p ij h ij 2 ·η represents the fact that secondary user i can obtain channel capacity by using subcarrier j to transfer. The constraint (1) makes it possible for every the secondary user to get higher channel capacity than demanded. In order to avoid affecting the primary network communication, the condition (2) controls that the power transmission of the secondary user network is less than the interference power threshold p TOTAL . The condition (3) ensures that subcarriers assigned for all the secondary users will be in the subcarrier set rented by the secondary base station:

The Optimal Allocation of Subcarriers, Power and Time
For nonlinear programming Equation (24), the general solution is to list all subcarrier sets and transmission power levels. However, for communication systems that allow a time sharing strategy, the exhaustive method will lead to inestimable computing resource consumption because the full range extends from the finite set to the infinite set. We can reduce the complexity of solving the problem through introducing time allocation scheduling. Namely, the secondary base station used all subcarriers for a communication service for a certain user. Therefore, the allocation problem of subcarrier set and transmission power (24) can be translated into the allocation problem of transmission time and transmission power (25). In the equation, t i represents that the time which all subcarriers are assigned by the secondary base station is used for the secondary user i is the proportion accounting for the entire scheduling cycle. Consequently, the actual transmission time of the secondary user i is t i ·T, and T is the total time of scheduling period: Theorem 3. A feasible solution for the nonlinear programming problem (25) exists only when ∑ N i=1 R i /r * i ≤ 1 In the formula, the optimal power allocation strategy and time allocation strategy are: where [x] + represents max{x,0}, and Proof. The optimal power allocation is considered firstly. For the feasible time allocation strategy t * i given p = (p * ij ) (i = 1, 2, .., N, j ∈ SC) is the optimal power allocation strategy for (25) only when p * ij is also the optimal solution for programming problem (28): So, the optimal power allocation problem for (25) can be obtained by the Lagrange Multiplier Approach solving programming problem (27). The corresponding Lagrange function is: In the equation, µ = (µ 1 , µ 2 , . . . , µ N ) is Lagrange multiplier, so: We can apply the KKT condition to get Equations (32) and (33). The optimal power allocation strategy (26) can be achieved by substituting Equation (33) into Equation (32): Then, the existence of the feasible solution should be considered. The existence of the optimal power allocation strategy doesn't mean that the feasible solution for the programming problem (25) exists. Based on the optimal allocation strategy (26), the feasible solution for (25) exists when the constraint conditions (1) and (3) of (25) are satisfied. Therefore, through putting the optimal power allocation strategy into (1) and (3), we can get the necessary and sufficient condition for the existence Lastly, based on the optimal allocation, we consider the optimal time allocation.
Let r * i = ∑ j∈SC w · log 2 1 + p * ij · h ij 2 · η , and we can achieve the programming problem (34) by putting p = (p * ij ) into Equation (25). We can solve the programming problem (35) through logarithmic transformation of Equation (34) because f (x) = ln(x) is a monotonically increasing concave function in domain. Meanwhile, the Lagrange Multiplier Approach is used for solving the problem. The corresponding Lagrange function is: Here ϕ is the Lagrange multiplier. By applying the KKT condition, we can get the equations: The optimal time allocation can be achieved through solving Equations (37) and (38). Therefore, the corresponding subcarriers and power optimal allocation process can be expressed as shown in Figure 5.
For each subcarrier, the secondary base station carry out the optimal power allocation for each user according to (26),and obtain *

Simulation
The simulation uses two primary networks, setting the primary network interference power threshold as p TOTAL = 50 mW. The bandwidth of each subcarrier w = 25 kHz, thermal noise level δZ 2 = 10 −11 W, Desired BER = 10 −2 , and the simulation channel is modeled by Rayleigh fading and the loss factor is 3, Suppose that two secondary users are located at a distance of 200 m within the range of the base station in the secondary network, and their respective channel capacity requirements are R1 = 2 Mb/s, R2 = 3 Mb/s. Considering the path loss of the channel at the boundary (when the distance from the base station is 200 m), when the subcarrier demand is 144 by Equation (4) or enumeration, a channel capacity of 5.0 Mb/s can be provided.

Preference Coefficient and Rate of Substitution
After setting the spectrum pricing of two primary base station as p1 = 460, p2 = 440, the effects of different preference coefficients α and substitution rates v on the rent number of subcarriers in the secondary networks are studied. As shown in Figure 6, the secondary base station rents the number of subcarriers whose price is significantly lower than the higher price. If the degree of preference of the secondary base station to satisfy the demand is greater, it will tend to hire more subcarriers to meet the needs of secondary networks. However, when the number of subcarriers meets the demand, the preference coefficient increase that influences the number of subcarriers rented becomes gradually smaller. In addition, Figure 6 shows that substitution rate is smaller, and the switching difficulty that secondary users in the spectrum of different primary base stations experience will be bigger, thus they have to rent more expensive subcarriers; when the substitution rate is higher, secondary users are more likely to rent relatively cheap subcarriers.

Simulation
The simulation uses two primary networks, setting the primary network interference power threshold as p TOTAL = 50 mW. The bandwidth of each subcarrier w = 25 kHz, thermal noise level

Preference Coefficient and Rate of Substitution
After setting the spectrum pricing of two primary base station as p 1 = 460, p 2 = 440, the effects of different preference coefficients α and substitution rates v on the rent number of subcarriers in the secondary networks are studied. As shown in Figure 6, the secondary base station rents the number of subcarriers whose price is significantly lower than the higher price. If the degree of preference of the secondary base station to satisfy the demand is greater, it will tend to hire more subcarriers to meet the needs of secondary networks. However, when the number of subcarriers meets the demand, the preference coefficient increase that influences the number of subcarriers rented becomes gradually smaller. In addition, Figure 6 shows that substitution rate is smaller, and the switching difficulty that secondary users in the spectrum of different primary base stations experience will be bigger, thus they have to rent more expensive subcarriers; when the substitution rate is higher, secondary users are more likely to rent relatively cheap subcarriers.

The Influence of other Primary Base Stations on Spectrum Pricing
According to the results in Section 5.1.2, we set the preference coefficient α = 12, and the replacement rate of v = 0.4 and set different spectrum pricing values of the primary base station 2: λ2 = 460, 480, 520, 550, and then we examine the relationship between the spectrum pricing and revenue of the primary base station 1, As shown in Figure 7, when the spectrum pricing of the primary base station 1 gradually increases in a certain range, because a high price can obtain more revenue, the income also increases; however, when the profit value exceeds a peak point, because the secondary network will choose a cheaper primary station to rent subcarriers, it resulting in a reduced subcarrier requirement for the primary base station 1, so the revenue of the primary base station 1 will be reduced. In addition, with the increase in the price of another primary base station 2, the demand of the secondary network for the base station 1 also increases, therefore, the primary base station 1 can set a higher price to get greater benefits.

The Influence of other Primary Base Stations on Spectrum Pricing
According to the results in Section 5.1.2, we set the preference coefficient α = 12, and the replacement rate of v = 0.4 and set different spectrum pricing values of the primary base station 2: λ 2 = 460, 480, 520, 550, and then we examine the relationship between the spectrum pricing and revenue of the primary base station 1. As shown in Figure 7, when the spectrum pricing of the primary base station 1 gradually increases in a certain range, because a high price can obtain more revenue, the income also increases; however, when the profit value exceeds a peak point, because the secondary network will choose a cheaper primary station to rent subcarriers, it resulting in a reduced subcarrier requirement for the primary base station 1, so the revenue of the primary base station 1 will be reduced. In addition, with the increase in the price of another primary base station 2, the demand of the secondary network for the base station 1 also increases, therefore, the primary base station 1 can set a higher price to get greater benefits.

The Influence of other Primary Base Stations on Spectrum Pricing
According to the results in Section 5.1.2, we set the preference coefficient α = 12, and the replacement rate of v = 0.4 and set different spectrum pricing values of the primary base station 2: λ2 = 460, 480, 520, 550, and then we examine the relationship between the spectrum pricing and revenue of the primary base station 1, As shown in Figure 7, when the spectrum pricing of the primary base station 1 gradually increases in a certain range, because a high price can obtain more revenue, the income also increases; however, when the profit value exceeds a peak point, because the secondary network will choose a cheaper primary station to rent subcarriers, it resulting in a reduced subcarrier requirement for the primary base station 1, so the revenue of the primary base station 1 will be reduced. In addition, with the increase in the price of another primary base station 2, the demand of the secondary network for the base station 1 also increases, therefore, the primary base station 1 can set a higher price to get greater benefits.

Optimal Response Function and Nash Equilibrium
Setting different substitution rates v 1 = 0.4, v 2 = 0.6 and different primary base station loss coefficients β 1,2 = 420, β 1,2 = 400 (β 1,2 represents β 1 = β 2 ), according to the optimal response function, Figure 8 can be drawn. The Nash equilibrium is located at the junction of the optimal response function of the different primary base stations, namely, the equation set (12). The less the loss coefficient of a primary base station, the smaller the rental per unit bandwidth caused by loss, and the primary base station is more willing to lower the price of spectrum resources, therefore, the Nash equilibrium price is lower. In addition, the substitution rate also affects the location of the primary base station pricing and the Nash equilibrium. The greater the replacement rate, the more difficult it is for the secondary network to switch from the spectrum of different primary base stations, and secondary base stations are more inclined to lower the price of rental spectrum resources, therefore, the price of the primary base station is lower when a Nash equilibrium exists.

Optimal Response Function and Nash Equilibrium
Setting different substitution rates v1 = 0.4, v2 = 0.6 and different primary base station loss coefficients β1,2 = 420, β1,2 = 400 (β1,2 represents β1 = β2), according to the optimal response function, that is * * arg max ( , ),( ) Figure 8 can be drawn. The Nash equilibrium is located at the junction of the optimal response function of the different primary base stations, namely, the equation set (12). The less the loss coefficient of a primary base station, the smaller the rental per unit bandwidth caused by loss, and the primary base station is more willing to lower the price of spectrum resources, therefore, the Nash equilibrium price is lower. In addition, the substitution rate also affects the location of the primary base station pricing and the Nash equilibrium, The greater the replacement rate, the more difficult it is for the secondary network to switch from the spectrum of different primary base stations, and secondary base stations are more inclined to lower the price of rental spectrum resources, therefore, the price of the primary base station is lower when a Nash equilibrium exists.

Dynamic Game
We set a secondary network spectrum substitution rate v = 0.4 and the loss coefficients of the two primary base stations are β1 = 420, β2 = 380. According to whether the primary base station can be observed in the history of the policy of other players, we study the process of the primary base station pricing through a dynamic game. For these two cases, the primary base station is respectively based on the optimal response strategy (Equation (13)) and learning strategy (Equation (14)) to dynamically update its spectrum pricing. Wherein, the sufficient conditions of a dynamic game for stability is σ ∈ (0, , we select the learning strategy updating steps σ1 = σ2 = 0.25 and σ1 = σ2 = 0.35, we set the stability threshold τ = 0.01 and the initial pricing of the two primary base stations as λ1(0) = β1, λ2(0) = β2, then the dynamic game process is shown in Figure 9. As the primary base station is able to observe the historical policies of the other primary base station, a dynamic game can quickly converge to a Nash equilibrium based on an optimal response, but when a primary base station can only be based on the demand information fed back locally by secondary networks to update its pricing strategy, the rate of convergence of the dynamic game is largely dependent on the update step size, and as shown in Figure 10, when the replacement rate is lower, the dynamic game with larger update step has a faster convergence speed. When the replacement rate is higher, a smaller update step should be set to ensure the convergence rate. In addition, because of the high

Dynamic Game
We set a secondary network spectrum substitution rate v = 0.4 and the loss coefficients of the two primary base stations are β 1 = 420, β 2 = 380. According to whether the primary base station can be observed in the history of the policy of other players, we study the process of the primary base station pricing through a dynamic game. For these two cases, the primary base station is respectively based on the optimal response strategy (Equation (13)) and learning strategy (Equation (14)) to dynamically update its spectrum pricing. Wherein, the sufficient conditions of a dynamic game for stability is σ ∈ (0, (1−v)(2M−2) 2M−1 ), we select the learning strategy updating steps σ 1 = σ 2 = 0.25 and σ 1 = σ 2 = 0.35, we set the stability threshold τ = 0.01 and the initial pricing of the two primary base stations as λ 1 (0) = β 1 , λ 2 (0) = β 2 , then the dynamic game process is shown in Figure 9. As the primary base station is able to observe the historical policies of the other primary base station, a dynamic game can quickly converge to a Nash equilibrium based on an optimal response, but when a primary base station can only be based on the demand information fed back locally by secondary networks to update its pricing strategy, the rate of convergence of the dynamic game is largely dependent on the update step size, and as shown in Figure 10, when the replacement rate is lower, the dynamic game with larger update step has a faster convergence speed. When the replacement rate is higher, a smaller update step should be set to ensure the convergence rate. In addition, because of the high cost of the primary base loss coefficient of high rental per unit bandwidth, the optimal pricing of the equilibrium is higher than the primary base station of low loss coefficient. cost of the primary base loss coefficient of high rental per unit bandwidth, the optimal pricing of the equilibrium is higher than the primary base station of low loss coefficient.   Figure 11 shows the main effect of the loss coefficient of the primary base station 2 for its own and the revenue of the primary base station 1 for different replacement rates. When the loss coefficient of β2 gradually increases, the price of the primary base station 2 will be increased at a smaller rate than that of the β2, due to the fact the spectrum can be replaced between different base stations, so the corresponding spectrum rental also decreases, and the revenue of base stations is gradually reduced by u2 PBS (λ) = (λ2 − β2)· 2(λ), On the other hand, the increase of β2 will increase the price of the base station 1, the rent amount is also increased, so the revenue increases. Not only that, but the replacement rate will also affect the primary base station revenue. For the same loss coefficient, increasing the replacement rate will decrease the optimal pricing of all primary base stations in the system, resulting in a decline in revenue.  cost of the primary base loss coefficient of high rental per unit bandwidth, the optimal pricing of the equilibrium is higher than the primary base station of low loss coefficient.   Figure 11 shows the main effect of the loss coefficient of the primary base station 2 for its own and the revenue of the primary base station 1 for different replacement rates. When the loss coefficient of β2 gradually increases, the price of the primary base station 2 will be increased at a smaller rate than that of the β2, due to the fact the spectrum can be replaced between different base stations, so the corresponding spectrum rental also decreases, and the revenue of base stations is gradually reduced by u2 PBS (λ) = (λ2 − β2)· 2(λ), On the other hand, the increase of β2 will increase the price of the base station 1, the rent amount is also increased, so the revenue increases. Not only that, but the replacement rate will also affect the primary base station revenue. For the same loss coefficient, increasing the replacement rate will decrease the optimal pricing of all primary base stations in the system, resulting in a decline in revenue.  Figure 11 shows the main effect of the loss coefficient of the primary base station 2 for its own and the revenue of the primary base station 1 for different replacement rates. When the loss coefficient of β 2 gradually increases, the price of the primary base station 2 will be increased at a smaller rate than that of the β 2 , due to the fact the spectrum can be replaced between different base stations, so the corresponding spectrum rental also decreases, and the revenue of base stations is gradually reduced by u 2 PBS (λ) = (λ 2 − β 2 )· D 2 (λ). On the other hand, the increase of β 2 will increase the price of the base station 1, the rent amount is also increased, so the revenue increases. Not only that, but the replacement rate will also affect the primary base station revenue. For the same loss coefficient, increasing the replacement rate will decrease the optimal pricing of all primary base stations in the system, resulting in a decline in revenue.

Spectrum Requirement Adjustment
Setting the loss coefficient of two primary base stations as β1 = 420, β2 = 380 and replacement rate v = 0.4, we search for a particular preference factor, the relationship of the real needs of the subcarriers of secondary base stations and the final amount of the rental spectrum. As shown in Figure 12, when the spectrum need is the same, as the preference coefficient increases, the degree of preference of the secondary base station for the need is greater, so they tend to hire more subcarriers, thus increasing the spectrum demand of the secondary network, so the amount of rent subcarriers increases, and linear fitting for with different requirements and its corresponding rental * ( ), so C and * ( ) show an approximately linear correlation. Subsequently, according to the adjustment strategy introduced in Section 3.5, we can determine the virtual demand for subcarrier ′ and calculating the corresponding hire * ( ′ ) based on ′ .

Spectrum Requirement Adjustment
Setting the loss coefficient of two primary base stations as β 1 = 420, β 2 = 380 and replacement rate v = 0.4, we search for a particular preference factor, the relationship of the real needs of the subcarriers of secondary base stations and the final amount of the rental spectrum. As shown in Figure 12, when the spectrum need is the same, as the preference coefficient increases, the degree of preference of the secondary base station for the need is greater, so they tend to hire more subcarriers, thus increasing the spectrum demand of the secondary network, so the amount of rent subcarriers increases, and linear fitting for C with different requirements and its corresponding rental q * (C), so C and q * (C) show an approximately linear correlation.

Spectrum Requirement Adjustment
Setting the loss coefficient of two primary base stations as β1 = 420, β2 = 380 and replacement rate v = 0.4, we search for a particular preference factor, the relationship of the real needs of the subcarriers of secondary base stations and the final amount of the rental spectrum. As shown in Figure 12, when the spectrum need is the same, as the preference coefficient increases, the degree of preference of the secondary base station for the need is greater, so they tend to hire more subcarriers, thus increasing the spectrum demand of the secondary network, so the amount of rent subcarriers increases, and linear fitting for with different requirements and its corresponding rental * ( ), so C and * ( ) show an approximately linear correlation. Subsequently, according to the adjustment strategy introduced in Section 3.5, we can determine the virtual demand for subcarrier ′ and calculating the corresponding hire * ( ′ ) based on ′ . Subsequently, according to the adjustment strategy introduced in Section 3.5, we can determine the virtual demand for subcarrier C and calculating the corresponding hire q * (C ) based on C . Figure 13 describes the relationship between the virtual spectrum requirement C , the real spectrum needs C and the total amount of hiring spectrum q * (C ) when C = 144, ε i = 0.5. It can be seen that the adjustment of the virtual spectrum demand C corresponds to the leased number of just q * (C ) to meet the real needs of the network spectrum C.  Figure 13 describes the relationship between the virtual spectrum requirement ′ , the real spectrum needs and the total amount of hiring spectrum * ( ′ ) when = 144, ε = 0.5. It can be seen that the adjustment of the virtual spectrum demand ′ corresponds to the leased number of just * ( ′ ) to meet the real needs of the network spectrum .

The Degree of Satisfaction for the Secondary Network Communication Demand
When calculating the spectrum demand in the secondary network, if the secondary base station is based on the path loss of the secondary network boundary, we calculate the channel gain (case I). iIf the channel capacity requirement of the network is 5 Mb/s, the secondary base station needs to hire 144 subcarriers. Suppose secondary user 1 is located 100 m from the secondary base position, and the distance between 2 and secondary base stations changes between 110 m and 200 m, through a cooperative spectrum sharing scheme, each secondary the user can obtain the channel capacity as shown in Figure 14, where the horizontal dotted line in the graph is the secondary user channel capacity requirement, when the distance 2 between the user 2 and the base station increases, the channel gain ℎ 2 and 2 3 is a negative correlation, resulting in a decrease of 2 channel capacity.

The Degree of Satisfaction for the Secondary Network Communication Demand
When calculating the spectrum demand in the secondary network, if the secondary base station is based on the path loss of the secondary network boundary, we calculate the channel gain (case I).
If the channel capacity requirement of the network is 5 Mb/s, the secondary base station needs to hire 144 subcarriers. Suppose secondary user SU 1 is located 100 m from the secondary base position, and the distance between SU 2 and secondary base stations changes between 110 m and 200 m, through a cooperative spectrum sharing scheme, each secondary the user can obtain the channel capacity as shown in Figure 14, where the horizontal dotted line in the graph is the secondary user channel capacity requirement, when the distance D 2 between the user SU 2 and the base station increases, the channel gain h ij 2 and D 3 2 is a negative correlation, resulting in a decrease of SU 2 channel capacity.  Figure 13 describes the relationship between the virtual spectrum requirement ′ , the real spectrum needs and the total amount of hiring spectrum * ( ′ ) when = 144, ε = 0.5. It can be seen that the adjustment of the virtual spectrum demand ′ corresponds to the leased number of just * ( ′ ) to meet the real needs of the network spectrum . Figure 13. Spectrum demand and spectrum rent.

The Degree of Satisfaction for the Secondary Network Communication Demand
When calculating the spectrum demand in the secondary network, if the secondary base station is based on the path loss of the secondary network boundary, we calculate the channel gain (case I). iIf the channel capacity requirement of the network is 5 Mb/s, the secondary base station needs to hire 144 subcarriers. Suppose secondary user 1 is located 100 m from the secondary base position, and the distance between 2 and secondary base stations changes between 110 m and 200 m, through a cooperative spectrum sharing scheme, each secondary the user can obtain the channel capacity as shown in Figure 14, where the horizontal dotted line in the graph is the secondary user channel capacity requirement, when the distance 2 between the user 2 and the base station increases, the channel gain ℎ 2 and 2 3 is a negative correlation, resulting in a decrease of 2 channel capacity. Figure 14. Each secondary user channel capacity. Figure 14. Each secondary user channel capacity.
To obtain sufficient channel capacity for the secondary user SU 2 , the spectrum sharing scheme can be used to reduce the time SU 1 is using subcarrier to increase the occupancy time of SU 2 , so as to meet the channel capacity needs of SU 2 , as shown in Figure 15. Thus, the cooperative spectrum sharing strategy based on the Nash bargaining scheme can allocate spectrum resources more equitably. In addition, when the distance of the SU 2 distance is more than 20 m, the total channel capacity is higher than the demand, when D 2 > 180 m, the path loss is increased, and the simulation channel can't meet the increase of the number of ∑ To obtain sufficient channel capacity for the secondary user 2 , the spectrum sharing scheme can be used to reduce the time 1 is using subcarrier to increase the occupancy time of 2 , so as to meet the channel capacity needs of 2 , as shown in Figure 15. Thus, the cooperative spectrum sharing strategy based on the Nash bargaining scheme can allocate spectrum resources more equitably. In addition, when the distance of the SU2 distance is more than 20 m, the total channel capacity is higher than the demand, when 2 > 180 m, the path loss is increased, and the simulation channel can't meet the increase of the number of ∑ * =1 ≤ 1. When the secondary base station calculates the network spectrum demand, it considers the secondary user's path loss of the secondary base station at the farthest distance (case II), so with the increase of the distance between the 2 and secondary base station, the spectrum leasing number that the channel capacity of 5 MB/s needs increases, as shown in Figure 16. Through cooperative spectrum sharing algorithms, two secondary users were able to get the channel capacity shown in Figure 17. As can be seen from the figure, 1 and 2 can get on average 13% and 5% higher demand for channel capacity, respectively, and with 2 away from the base station, the amount of spectrum that secondary base stations rent increases, to the transmission time that 1 uses for all the subcarriers to communicate is reduced, and the transmission time of 2 increases (Figure 18), but 2 is still able to maintain a higher demand for channel capacity. Moreover, from Figure 17 we can know that when the distance between the 2 and boundary is greater than 20 m, the probability of the secondary base station through the When the secondary base station calculates the network spectrum demand, it considers the secondary user's path loss of the secondary base station at the farthest distance (case II), so with the increase of the distance between the SU 2 and secondary base station, the spectrum leasing number that the channel capacity of 5 MB/s needs increases, as shown in Figure 16. To obtain sufficient channel capacity for the secondary user 2 , the spectrum sharing scheme can be used to reduce the time 1 is using subcarrier to increase the occupancy time of 2 , so as to meet the channel capacity needs of 2 , as shown in Figure 15. Thus, the cooperative spectrum sharing strategy based on the Nash bargaining scheme can allocate spectrum resources more equitably. In addition, when the distance of the SU2 distance is more than 20 m, the total channel capacity is higher than the demand, when 2 > 180 m, the path loss is increased, and the simulation channel can't meet the increase of the number of ∑ * =1 ≤ 1. When the secondary base station calculates the network spectrum demand, it considers the secondary user's path loss of the secondary base station at the farthest distance (case II), so with the increase of the distance between the 2 and secondary base station, the spectrum leasing number that the channel capacity of 5 MB/s needs increases, as shown in Figure 16. Through cooperative spectrum sharing algorithms, two secondary users were able to get the channel capacity shown in Figure 17. As can be seen from the figure, 1 and 2 can get on average 13% and 5% higher demand for channel capacity, respectively, and with 2 away from the base station, the amount of spectrum that secondary base stations rent increases, to the transmission time that 1 uses for all the subcarriers to communicate is reduced, and the transmission time of 2 increases (Figure 18), but 2 is still able to maintain a higher demand for channel capacity. Moreover, from Figure 17 we can know that when the distance between the 2 and boundary is greater than 20 m, the probability of the secondary base station through the Through cooperative spectrum sharing algorithms, two secondary users were able to get the channel capacity shown in Figure 17. As can be seen from the figure, SU 1 and SU 2 can get on average 13% and 5% higher demand for channel capacity, respectively, and with SU 2 away from the base station, the amount of spectrum that secondary base stations rent increases, to the transmission time that SU 1 uses for all the subcarriers to communicate is reduced, and the transmission time of SU 2 increases (Figure 18), but SU 2 is still able to maintain a higher demand for channel capacity. Moreover,  Figure 17 we can know that when the distance between the SU 2 and boundary is greater than 20 m, the probability of the secondary base station through the cooperative spectrum sharing algorithm is about 80%. Compared to the case I, the probability of the case II probability of the situation has declined, but the cost of the secondary base station is able to save 60%, as shown in Figure 19. cooperative spectrum sharing algorithm is about 80%, Compared to the case I, the probability of the case II probability of the situation has declined, but the cost of the secondary base station is able to save 60%, as shown in Figure 19.    cooperative spectrum sharing algorithm is about 80%, Compared to the case I, the probability of the case II probability of the situation has declined, but the cost of the secondary base station is able to save 60%, as shown in Figure 19.    cooperative spectrum sharing algorithm is about 80%, Compared to the case I, the probability of the case II probability of the situation has declined, but the cost of the secondary base station is able to save 60%, as shown in Figure 19.     Assuming two secondary user's spectrum needs are equal, both are 2.5 Mb/s, the distance of SU 1 and the secondary base station is 100 m, and the distance of SU 2 and the secondary base station is between 110 m and 200 m. Under the same constraint ((1) to (4) in Equation (25)), the cooperative spectrum sharing scheme is compared with the spectrum allocation scheme based on the maximum global rate [26] and the spectrum allocation scheme [27] based on the maximum degree of flatness. The objective function of the two kinds of spectrum sharing schemes are: where r i = ∑ j∈SC i w · log 2 (1 + p ij h ij 2 · η) . For two cases I and II (that is, a secondary base station based on the maximum coverage of the network, or based on the distance between the most remote users and the base station, to calculate the channel gain to determine the secondary network spectrum requirements), for these three spectrum allocation schemes, the secondary user SU 1 , SU 2 channel capacity can be obtained as shown in Figures (4) in Equation (25)), the cooperative spectrum sharing scheme is compared with the spectrum allocation scheme based on the maximum global rate [26] and the spectrum allocation scheme [27] based on the maximum degree of flatness, The objective function of the two kinds of spectrum sharing schemes are: For two cases I and II (that is, a secondary base station based on the maximum coverage of the network, or based on the distance between the most remote users and the base station, to calculate the channel gain to determine the secondary network spectrum requirements), for these three spectrum allocation schemes, the secondary user 1 , 2 channel capacity can be obtained as shown in Figures 20 and 21.    1) to (4) in Equation (25)), the cooperative spectrum sharing scheme is compared with the spectrum allocation scheme based on the maximum global rate [26] and the spectrum allocation scheme [27] based on the maximum degree of flatness, The objective function of the two kinds of spectrum sharing schemes are: For two cases I and II (that is, a secondary base station based on the maximum coverage of the network, or based on the distance between the most remote users and the base station, to calculate the channel gain to determine the secondary network spectrum requirements), for these three spectrum allocation schemes, the secondary user 1 , 2 channel capacity can be obtained as shown in Figures 20 and 21.   The corresponding total throughput is compared with Figures 22 and 23. Defining the fair coefficient is the ratio of the secondary user channel capacity, that is r 1 /r 2 , so the fairness of the three kinds of spectrum allocation scheme is obtained as shown in Figures 24 and 25. The corresponding total throughput is compared with Figures 22 and 23. Defining the fair coefficient is the ratio of the secondary user channel capacity, that is r1/r2, so the fairness of the three kinds of spectrum allocation scheme is obtained as shown in Figures 24 and 25.    The corresponding total throughput is compared with Figures 22 and 23. Defining the fair coefficient is the ratio of the secondary user channel capacity, that is r1/r2, so the fairness of the three kinds of spectrum allocation scheme is obtained as shown in Figures 24 and 25.    The corresponding total throughput is compared with Figures 22 and 23. Defining the fair coefficient is the ratio of the secondary user channel capacity, that is r1/r2, so the fairness of the three kinds of spectrum allocation scheme is obtained as shown in Figures 24 and 25.    In case I and case II, for the program based on the maximum global rate, the spectrum will allocated as much as possible to the secondary base station that is close to 1 while ensuring 2 just satisfy the constraints, that is, the secondary users whose channel gain is larger will obtain the maximum possible secondary network total throughput; the aim of the maximum fair spectrum allocation scheme is to reduce the total throughput of the secondary network, using the maximum fairness to ensure that the channel capacity obtained by 1 and 2 is the least. Relatively speaking, the NBS spectrum sharing scheme is able to compromise between the fair and spectrum efficiency, it can not only ensure the fair allocation of spectrum resources, but also enhance the spectrum utilization rate, finally obtaining a larger total network throughput.

Conclusions
With the popularity of the Internet of Things technology [28,29], the improvement of the communication efficiency and spectrum utilization of CRSNs has become a hot research topic, and dynamic spectrum sharing is the main countermeasure to improve spectrum utilization and alleviate the shortage of spectrum resources. However, due to the complexity of the application and the spectrum environment, most of current research on spectrum sharing is based on a large number of assumptions or lacks consideration of actual application scenarios. This paper presents a spectrum pricing and allocation model based on the Bertrand game theory. Spectrum pricing, subcarrier allocation, power control, and allocation issues are studied by synthesizing practical scenarios such as the frequency, power and time dimensions. It provides a practical and effective solution for spectrum sharing, and theory and experiments prove that the scheme can reflect the spectrum requirements of the secondary base stations and the benefit of the primary base station, and realize efficient spectrum sharing. It provides a better foundation and practical basis for the practical application of spectrum sharing, and provides theoretical support for the further development of CRSNs.
The simulation results also show that the model can reflect the demand of the spectrum of the secondary network. Primary base station spectrum pricing through a dynamic game of setting specific parameters, eventually converges to a Nash equilibrium; the adjusted spectrum requirements of secondary base station obtain the spectrum rent amount under market equilibrium, just to meet the needs of the network channel capacity, while in the secondary network, the secondary base stations are based on a cooperative spectrum sharing scheme, which can allocate spectrum resources fairly and efficiently.  In case I and case II, for the program based on the maximum global rate, the spectrum will allocated as much as possible to the secondary base station that is close to SU 1 while ensuring SU 2 just satisfy the constraints, that is, the secondary users whose channel gain is larger will obtain the maximum possible secondary network total throughput; the aim of the maximum fair spectrum allocation scheme is to reduce the total throughput of the secondary network, using the maximum fairness to ensure that the channel capacity obtained by SU 1 and SU 2 is the least. Relatively speaking, the NBS spectrum sharing scheme is able to compromise between the fair and spectrum efficiency, it can not only ensure the fair allocation of spectrum resources, but also enhance the spectrum utilization rate, finally obtaining a larger total network throughput.

Conclusions
With the popularity of the Internet of Things technology [28,29], the improvement of the communication efficiency and spectrum utilization of CRSNs has become a hot research topic, and dynamic spectrum sharing is the main countermeasure to improve spectrum utilization and alleviate the shortage of spectrum resources. However, due to the complexity of the application and the spectrum environment, most of current research on spectrum sharing is based on a large number of assumptions or lacks consideration of actual application scenarios. This paper presents a spectrum pricing and allocation model based on the Bertrand game theory. Spectrum pricing, subcarrier allocation, power control, and allocation issues are studied by synthesizing practical scenarios such as the frequency, power and time dimensions. It provides a practical and effective solution for spectrum sharing, and theory and experiments prove that the scheme can reflect the spectrum requirements of the secondary base stations and the benefit of the primary base station, and realize efficient spectrum sharing. It provides a better foundation and practical basis for the practical application of spectrum sharing, and provides theoretical support for the further development of CRSNs.
The simulation results also show that the model can reflect the demand of the spectrum of the secondary network. Primary base station spectrum pricing through a dynamic game of setting specific parameters, eventually converges to a Nash equilibrium; the adjusted spectrum requirements of secondary base station obtain the spectrum rent amount under market equilibrium, just to meet the needs of the network channel capacity, while in the secondary network, the secondary base stations are based on a cooperative spectrum sharing scheme, which can allocate spectrum resources fairly and efficiently.