{'fraction_non_alphanumeric': 0.0224642614023145, 'fraction_numerical': 0.008934649421375085, 'mean_word_length': 5.108627858627859, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Dynamic Selection of D2D Communication for Internet of Vehicles

Vehicle communication technology, as the core technology of intelligent transportation system, is expected to pass various communication connection means, combined with artificial intelligence, situational awareness, monitoring device, and precise positioning system, to solve the demand of the intelligent transportation system in the car safety, transportation efficiency, and the information service, etc. And it has the potential to serve driverless system. Device-to-device(D2D) communication is suitable for short distance vehicle communication because of its related characteristics and advantages. D2D users multiplexing cellular network spectrum will bring the same frequency interference problems. In order to avoid interference, improve system performance, this paper proposes a vehicle networking D2D communication mode based on spectrum sensing dynamic selection method. Simulation results show that the system capacity can be maximized by changing the sensing time of spectrum. Dynamic selection model is verified through the comparison superiority, and provides the intelligent transportation system a better vehicle-to-vehicle communication method.


Introduction
In recent years, the national economy continues to develop, and the transportation industry, as an important part of it, also develops rapidly. The increasing vehicle ownership and traffic participants have brought great pressure to traffic management and traffic infrastructure and formed many traffic problems, such as traffic congestion and traffic accidents. The traffic jam brings the serious waste of time and energy, which affects the city economy and people's travel quality and life experience. Traffic accidents bring a series of safety problems, which seriously affect people's personal and property safety. However, the development of information technology has brought various opportunities for the transportation industry, and intelligent transportation systems emerge at the historic moment. Internet of vehicles is an important bridge for information acquisition and interaction of intelligent transportation system and a core component of intelligent transportation system [1] .
All kinds of complex information need to be transmitted between vehicles and roads, and effective communication means are needed to solve the problems that may exist in network load, congestion and delay. As for traffic collision information which needs to be transmitted in real time, a reliable communication mode with low delay is needed for real-time and reliable transmission to warn and avoid the occurrence of serial collision. As one of the key technologies of 5G, D2D communication has the potential to improve system performance, improve user experience and expand the capability of cellular communication [2][3][4] . D2D communication is a communication technology for information exchange between adjacent devices without passing through the base station. D2D communication can achieve high data rate, low delay and low power consumption, which is very suitable for vehicle-tovehicle communication [5][6] . When a traffic event occurs, a large amount of relevant traffic status information needs to be transmitted in a short time and within a short distance. D2D communication is a reliable short-distance direct communication technology, which can effectively reduce the load of the core network and is suitable for short-distance traffic information transmission in the Internet of vehicles. In the communication system, when a D2D communication link is established, the data transmission between the two sides can be carried out without the participation of the base station, which can reduce the data pressure of the core network, increase the system capacity and improve the spectrum utilization [7] .
D2D users can communicate in private and multiplexed modes. In the special mode, D2D users use the special resources allocated for them by the base station in advance to communicate. At this time, the resources occupied by D2D users are orthogonal with those of cellular users, and there will be no interference. In the multiplexing mode, under the control of the base station, D2D users reuse the resources of cellular users for direct communication, and the resource utilization rate is higher, but the same frequency interference will occur [8][9] . Therefore, it is necessary to allocate spectrum, power and other resources reasonably, control interference, and select the appropriate mode. Reference [10] proposed a method of avoiding interference in wireless resource allocation based on D2D link to reduce the same frequency interference, but only considered the reduction of uplink interference, which could not guarantee the system throughput. Reference [11] proposed a distributed power control and pattern selection algorithm to ensure the minimum SINR acceptable to D2D users and cellular users in the system and optimize the system throughput, but did not consider the problem of spectrum utilization. Cognitive Radio (CR) has cognitive ability and reconstruction ability, which can effectively improve the spectrum utilization rate. Spectrum sensing technology, the key technology of cognitive radio, is used to detect the state of spectrum and allocate spectrum resources dynamically. In this paper, a dynamic selection method of D2D communication for Internet of vehicles based on spectrum sensing is presented. And we deduce the mathematical expressions of system capacity, make the maximum system capacity and verify the existence of the optimal time perception.

System Model
The system model is shown in figure 1, In this system, it is assumed that there is a cellular user ( cell U ), a base station (BS) and a pair of D2D communication pairs, including a transmitter (DT) and a receiver (DR). In this system, channel gain between cellular user and base station, channel gain between D2D user, channel gain between transmitter and base station of D2D user, and channel gain between cellular user and receiver of D2D user are represented by ub h , dd h , db h , and ud h , respectively.
Where 0 H is the case when the spectrum is idle and 1 H is the case when the spectrum is not idle. The cell user's transmitting signal is represented by ( ) p t ,the mean and the variance are zero. ( ) t  is additive white gaussian noise (AWGN), its mean value is zero and its variance is 2 2 n    . And, ( ) p t and ( ) t  independent of each other.

Dynamic Selection of D2D Communication Mode Based on Spectrum Sensing
By using spectrum sensing to detect the current spectrum state, when the spectrum is detected to be idle, D2D users can fully occupy the spectrum for communication without considering power control and other issues, without generating interference and avoiding interference problems. When it is detected that the cell user is communicating, the D2D user will reuse the uplink resources of the cell user for data transmission, and the simultaneous interference between the cell user and D2D user needs to be considered. Dynamic selection of D2D communication mode based on spectrum perception is shown in figure 2.
Figure 2 .dynamic model The spectrum sensing method of energy detection is adopted, and fs is used to represent the sampling frequency. in order to simplify, assume N=τfs, then the test result can be expressed by equation 2,where  represents the spectrum sensing time, and T   represents the time of communication between the two devices. D2D communication between vehicles dynamically selects the communication mode according to the spectrum detection results. In other words, when it is detected that the cellular user does not occupy the spectrum resources, that is, the spectrum is idle, the D2D user can choose the dedicated mode and fully own the spectrum resources for communication without considering the interference to the cellular user. When it is detected that the spectrum is not idle, the D2D user chooses the multiplexing mode to use the uplink resources of the cellular user. The spectrum sensing of cellular users can be divided into four cases for analysis, namely, the first case is that the communication of cellular users is detected when it does exist; The second is when the cellular user's communication is detected but the result is not found. The third is when the cellular user's communication does not exist but is judged to exist by the detection result. The last case is when the cellular user's communication does not exist and the detection result does not exist. Let's use 11 Pr ,  10 Pr , and 00 Pr to represent the probabilities of these four scenarios. Accordingly, 11 C , 01 C , 10 C and 00 C represent the system capacity of these four scenarios. Then the system capacity can be expressed as follows 11 11 01 01 10 10 00 00 The expression of system capacity is obtained here, which can be compared with the general reuse mode. This part will be reflected in the next simulation.

Simulation Analysis
MATLAB software is used to verify the proposed dynamic mode selection theory based on spectrum sensing. Figure 3 shows the relationship between sensing time and system capacity. The "o" in the figure indicates the sensing time when the system capacity is maximum, so the optimal sensing time slot exists and is unique to maximize the system capacity. In figure 3, the corresponding conditions are shown when the detection probability is 0.8, 0.85, 0.9 and 0.95 respectively. It can be seen that in the case of different detection probabilities, the perception time that maximizes the system capacity is different. With the improvement of detection probability, the optimal sensing time gap will increase, and the system capacity will decrease accordingly. This indicates that the higher the detection probability is, the longer the optimal sensing time gap is, and the smaller the system capacity is. This is because a higher detection probability requires a longer perception time to ensure its accuracy, and the result is that the user has a shorter access time and a smaller effective capacity. As shown in figure  3, for the proposed dynamic selection method of D2D mode, it is indeed that system capacity can be optimized.  Figure 4. connection time v.s capacity Figure 4 shows the relationship between D2D connectivity time and system capacity in both multiplexing mode and dynamic selection mode. It can be seen that with the increase of D2D connectivity time, system capacity shows an upward trend. With the increase of D2D communication connection time, the system capacity of D2D multiplexing mode is better than that of D2D multiplexing mode. This is because the dynamic selection of D2D communication mode using spectrum sensing can effectively avoid the same frequency interference, thus improving the system performance.

Conclusion
The Internet of vehicles is an important part of the intelligent transportation system and a carrier for carrying and transmitting traffic information. Efficient vehicle-to-vehicle communication is the cornerstone of intelligent transportation systems. D2D communication is a reliable short-distance direct communication technology, which is suitable for short-distance traffic information transmission in the Internet of vehicles. Aimed at the selection of D2D communication mode in the Internet of vehicles, this paper proposes a dynamic selection method of D2D communication mode based on spectrum perception. The expression of system capacity is derived, and the simulation results show that the proposed method can optimize the system capacity, reduce the influence of the same frequency interference on the system and improve the system performance.