Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Analysis of Bluetooth Frequency hopping algorithm

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

1. Overview 1.1. Why do you need frequency hopping

WLAN and wireless devices based on the IEEE 802.11 specification, like Bluetooth, operate in the 2.4GHz ISM (industrial, scientific and medical) radio band without a license. In order to improve the communication performance of the same standard equipment in this environment, SIG introduces the adaptive frequency hopping technology AFH (advance frequence hopping) to reduce the influence of this kind of interference. The frequency hopping technology can be realized by various methods, each of which has its inherent advantages and disadvantages.

Bluetooth products developed before the advent of AFH solutions use another form of frequency hopping, which is random in design. These first-generation Bluetooth devices use 79 of the 83.5 available channels in the 2.4GHz band and skip these channels randomly at a rate of 1600 times per second. Once another wireless device is introduced into the environment, this type of jump can lead to occasional conflicts. Bluetooth without AFH lacks the ability to avoid these conflicts and thus adapt to its environment. The result is shown in the following figure, which shows the environment in which both Bluetooth (BT) and Wireless LAN (WLAN) are running.

In contrast, the adaptive frequency hopping AFH allows Bluetooth to adapt to the environment by identifying a fixed source of interference and excluding it from the list of available channels. This remapping process also involves reducing the number of channels used by Bluetooth. The Bluetooth specification requires a minimum set of at least 20 channels. The following figure shows the same environment as the one above, but now uses a Bluetooth communication channel after adaptive frequency hopping.

2.Classic frequency hopping

The classic Bluetooth frequency hopping framework is as follows: there is a Channel map, that is, a frequency hopping table, a frequency hopping step; according to the frequency hopping table, the frequency hopping step and the current communication frequency point, the frequency point of the next data communication between the master and slave can be calculated.

Bluetooth hopping table algorithm is slightly different from each other, but they all need to solve two problems.

1. Channel assessment:

The SIG specification does not specify how to identify bad channels. At present, there are two main methods to perform channel evaluation with adaptive frequency hopping: RSSI (received signal strength indication) and PER (packet error rate).

Both RSSI and PER are well-known techniques for determining which channels may have been occupied. However, when it comes to monitoring the current channel state, the two methods are different. The method used by PER to repeatedly test and re-evaluate bad channels is not as accurate as RSSI and can lead to temporary setbacks. However, there are many other problems when using RSSI, such as RSSI consumes more power than PER. When there is a lack of available time slots, RSSI can also require bandwidth from other functions.

two。 Data communication on the same channel:

Bluetooth AFH stipulates that both master and slave devices communicate through the same channel. This is done to avoid situations in which the master device transmits on the "good" channel and the slave device responds to the "bad" channel (and vice versa), as this will lead to multiple retransmissions (the data transceiver of other protocols AFH is in different channels, resulting in normal sending data, and the receiving channel interference causes multiple retransmissions generated by the master to be unable to respond). Because the master and slave devices send and receive data at the same frequency, the channel hop frequency is reduced by 50% to 800 times per second. Although this can make Bluetooth devices more sensitive to interference from other Bluetooth devices, the benefits so far outweigh this small disadvantage.

The principle of 3.AFH3.1.AFH

AFH technology is an improvement of the original Bluetooth frequency hopping sequence, which allows Bluetooth devices to reduce the number of frequency hopping points. Its basic principle is to divide the channels into unknown and bad or good, so as to avoid using bad channels and reduce the degree of interference. When the Bluetooth piconet enters the AFH state, the number of hopping points N that can be used in its frequency hopping sequence is dynamic, but it is stipulated that there must be a minimum Nmin, that is, Nmin ≤ N ≤ 79. Nmin is defined as 20 in the Bluetooth protocol. AFH is only used in the connection state, but does not change the frequency hopping sequence in the paging, query and other states. The implementation of the adaptive frequency hopping selection mechanism is based on the frequency selection core of the original 79-hop system, on which two parameters AFH_mode and AFH_ channel _ map are added (figure 2.12). AFH_mode indicates whether the current frequency selection core can use adaptive frequency hopping sequences; AFH_channel_map indicates which channels are available and which channels are not available. First, the original frequency selection core generates a channel. If the channel is the available channel defined in AFH_channel _ map, it is directly used as the output of the frequency hopping sequence without any adjustment. If the channel is included in the unavailable channel, it is mapped to an available channel by the relocation function. This mapping relationship is one-to-one, that is, if a Bluetooth address, clock and AFH_channel_map are given, an unavailable RF channel will be uniquely converted into an available channel, which ensures that the master-slave devices using AFH mechanism in the same piconet can keep the synchronization of frequency hopping sequences.

Under this implementation mechanism, the frequency hopping sequence of the non-adaptive 79-hop system is equal to the frequency sequence generated by the available AFH frequency selection core, which makes it easy to maintain compatibility with the original non-AFH devices. Another change of AFH technology is that in the original frequency hopping system, the master-slave equipment sends data at different frequencies; when in the AFH state, during a master-slave conversation, Slave uses the same radio frequency channel as Master to respond to data packets to Master, which is called the same channel mechanism of AFH. The use of the same channel mechanism is mainly due to the fact that in the case of interference in the network, reducing frequency hopping can prevent Slave from jumping to the possible collision channel when sending response packets, ensuring that the data is not easy to be interfered during at least one master-slave conversation, thus achieving the purpose of improving throughput.

Control of 3.2.AFH state

Because the frequency hopping sequence in a piconet is completely determined by the master device, the master device is also responsible for controlling the enabling and stopping of the adaptive state of the piconet frequency hopping sequence, and needs to update the available channel information regularly. When the system wants to enter the AFH state, the master device must first identify and initialize the device, which is mainly carried out in the LMP (Link Management Protocol) layer. The master device first sends a query message to all its slave devices and checks whether it has the ability to support the AFH mechanism by looking at the properties of the slave device. If both the master and slave devices support AFH, the master device sends a PDU data packet of LMP_set _ AFH, which includes parameters such as AFH_mode and AFH_channel_map, and advertises available and unavailable channels to the slave device. The master device uses this PDU type for the entry, exit, and update of AFH status. After sending the AFH command, the master device will wait for the confirmation message to return. If the confirmation message is received before a specified time (AFH_instant), the whole piconet can smoothly change the AFH state.

If the update channel information operation is carried out, if the confirmation information is not received before the AFH_instant, the master device will resume the frequency hopping sequence using all channels as available channels, and continue to send AFH commands to the slave device until a response is received before the updated adaptive frequency hopping sequence can be used.

3.3. Determination of available channels

The available channels in the AFH_channel_map parameters are determined by the following:

(1) the measurement of interference by the main equipment itself. It is mainly based on packet loss rate (PLR), received signal strength (RSSI), cyclic redundancy error correction (CRC), hybrid error correction (HEC), forward error correction (FEC) and so on.

(2) the Host side can declare channel state information to the Bluetooth device through the HCI command HCI_set_AFH_Channel_Classification.

(3) the slave device can also report the channel information it holds to the master device through the PDU of the LMP layer.

The master equipment will analyze and calculate these information resources and finally generate a reliable AFH_channel_map, but the number of available channels must be greater than the minimum number of channels Nmin (20). Assuming that the number of available good channels is NG, if NG ≥ Nmin, all good channels can be used; if Nmin > NG, some unknown/bad channels must be used.

4.CSA#1 (BLE 4.x) 4.1. Algorithm flow

CAS#1 frequency hopping algorithm is used in data connection. There are 37 data channels. The frequency hopping formula is as follows: unmappedChannel = (lastUnmappedChannel + hopIncrement) mod 37.

Fn+1= (fn+hop) mod 37, hop is a random value of 5 to 16 and is fixed after each link is established. The protocol specifies the fn=0,fn+1= (0+hop) mod 37, that is, the hop channel number, in the first connection event

4.2. Give an example

Suppose the host ChanelMap = 00011110 00000000 11100000 00000110 000000b, the rightmost channel is channel 1, and the leftmost channel is channel 40. Then the channels used are 9, 10, 21, 22, 23, 33, 34, 35, 36.

UsedChannel [] = {9, 10, 21, 22, 23, 33, 34, 35, 36, that is, numUsedChannel (N) = 9

The initial value of Last Unmapped Channel is 0 (followed by the unmappedChannel calculated each time)

Suppose you enter hopIncrement = 7, then

UnmappedChannel = (0,7) mod37 = 7, and channel 7 is not an available channel, so it needs to be remapped.

RemappingIndex = 7mod N = 7

UsedChannel [7] = 35 again

So data channel index = 35.

4.3.usedChannel

In the above discussion, we assume that ChanelMap, but how to get it in the actual process.

1. After startup, the system sets all data channels (37) to be available.

two。 The channel state is evaluated in the subsequent use process, which is very similar to the channel evaluation of the AFH mechanism (which can be regarded as a simplified version of AFH).

3. There are two input parameters for evaluation, 1) the evaluation result of the device itself, and 2) the evaluation result from host. Finally, through a series of algorithms to determine the exception of usedChannel map.

4. When the link is established, the initiating side sends a CONNECT_REQ, populates the channel_map with the ChM field, and sets a timer (device_channel_map_update_timer) to update the channel_map periodically later (using LL_CHANNEL_MAP_IND)

5. Secondly, when host sends the channel evaluation result of host through hci cmd, channel_map also needs to be updated.

How to evaluate the channel locally?

In fact, similar to classic, it is mainly based on packet loss rate (PLR) and cyclic redundancy error correction (CRC). So it can be regarded as a simplified version of AFH.

5.CSA#2 (BLE 5.0)

CSA#2 is a more complex and difficult algorithm to track the channel index used to obtain the next connection event. Especially in the case of high-throughput use, to avoid interference and multipath fading effects, Bluetooth can obtain radio certification from different countries around the world when the transmission power exceeds the 10dBm. (single point transmission power is too high must be sad for European and American radio certification. We must use frequency hopping to make the product average lower than the local government requirements, under the CSA # 2 algorithm. The average power of Bluetooth products in the entire operating band is lower than that of CSA # 1).

5.1. Input parameters

1.ChannelIdentifier = (Access Address31-16) XOR (Access Address15-0)

2.The 16-bit input counter changes for each event.

For data connections it is the connection event counter connEventCounter defined in Section 4.5.1.

For M & S, every CE,connEventCounter+=1

For periodic advertising it is the event counter paEventCounter defined in

Section 4.4.3.4. (The initial value of this counter is implementation specific. The counter shall be incremented by one for each AUX_SYNC_IND PDU; the paEventCounter shall wrap from 0xFFFF to 0x0000. AUX_SYNC_IND PDUs shall use the Channel Selection Algorithm # 2 (see Section 4.5.8.3) with this event counter.)

5.2. The generating process of random number prn_e

5.2.1.PERM

5.2.2.MAM

Output = (17 x a + b) mod

5.3. Remapping

5.4. Give an example

Let's assume that the channel used by the host is 9, 10, 21, 22, 23, 33, 34, 35, 36.

UsedChannel [] = {9, 10, 21, 22, 23, 33, 34, 35, 36]

Access Address is assumed to be 0x364F10C1, Access Address [31: 0] = {0011 0110 0100 1111 0001 0000 1100 0001}

Step one:

ChannelIdentifier = {0011 0110 0100 1111} XOR {0001 0000 1100 0001} = {0010 0110 1000 1110} (decimal 9870)

Step 2:

Point A: ChannelIdentifier XOR counter, initial moment counter=0

A = {0010 0110 1000 1110} XOR {0000 0000 0000} = {0010 0110 1000 1110}

Point B PERM, exchanging bits

B = {0110 0100 0111 0001} (decimal 25713)

Point C MAM, Multiply, Add, and Modulo

C = (257131709870) MOD (2 ^ 16) = 53775 {1101 0010 0000 1111}

By the same token:

D = {0100 1011 1111 0000} (decimal 19440)

E = (194401709870) MOD (2 ^ 16) = 12670 {0011 0001 0111 1110}

F = {1000 1100 0111 1110} (35966)

G = (359661709870) MOD (2 ^ 16) = 31468 {0111 1010 1110 1100}

Prn_e = G XOR ChannelIdentifier = {0101 1100 0110 0010} (23650)

Step 3:

UnmappedChannel = prn_e MOD 37 = 7

Step 4:

It is judged that channel 7 is not an available channel, so it is necessary to remap.

RemappingIndex = floor (923650 / 2 ^ 16) = 3

UsedChannel [3] = 22 again

So data channel index = 22.

5.5. Summary

Like CSA # 1, CSA # 2 has an agreed frequency hopping table; the difference is the value of frequency hopping step. The frequency hopping step value of CSA # 1 is fixed, and the frequency hopping step of CSA # 2 is calculated by algorithm.

Another difference is that CSA # 2 can be used in broadcast and connection channels, while CSA # 1 only applies to connection channels.

6. Summary

The classical Bluetooth frequency hopping AFH algorithm is the most complex, which requires real-time monitoring of bad channels, updating the frequency hopping table, and high requirements for MCU resources. BLE 4.x is the simplified version of AFH. The frequency hopping table is random and the frequency hopping step is fixed. The BLE part of Bluetooth 5 uses the new CSA # 2 algorithm, and the frequency hopping step is calculated by the algorithm to avoid interference and multipath fading.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report