A multi-access method and device
The data transmission strategy is determined by the state machine, and the problem of high hardware costs in low-rate IoT scenarios is solved, and low-cost and high-reliability wireless communication is achieved.
Patent Information
- Application Number
- CN202410379864.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-29
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2044-03-29
AI Technical Summary
The prior art uses high-performance hardware to implement the CSMA/CA protocol in low-rate IoT scenarios, resulting in high economic costs and waste of resources.
Provides a multi-access method, determines the target execution strategy of data through state changes of the state machine, selects a competition-free strategy or a competition strategy to send data, reduces hardware overhead, and is suitable for low bandwidth scenarios.
It realizes rapid deployment, low-cost and high-reliability wireless communication in low-bandwidth scenarios, avoids waiting time, and is suitable for Internet of Things and vehicle-side component communication.
Smart Images

Figure CN118301782B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the technical field of wireless communications, and in particular, to a multiple access method and device. Background Art
[0002] In the field of WIFI (Wireless Fidelity), when transmitting wireless data, each wireless device undergoes a channel competition process. In order to prevent multiple wireless devices from sending wireless frames at the same time on the same busy frequency band, a Carrier Sense Multiple Access Collision Avoidance (CSMA / CA) protocol is introduced to avoid this situation.
[0003] In the prior art, in order to enable WIFI to achieve high-bandwidth transmission, such as 80211n, 80211ac and other data frame transmissions of up to several hundred megabytes, the chip implements the CSMA / CA part through hardware or FPGA programming.
[0004] However, for some low-speed IoT scenarios or low-bandwidth scenarios, the application of such high-performance hardware increases economic costs and wastes resources. Summary of the invention
[0005] In order to solve the above problems, the embodiments of the present application provide a multi-access method and device.
[0006] In a first aspect, an embodiment of the present application provides a multi-access method, applied to a wireless device, the method comprising:
[0007] Acquire the data to be sent and configure the to-be-sent flag as the first to-be-sent flag;
[0008] According to the first to-be-sent flag, a wireless channel contention phase interface is called, and the first state machine is in an idle state;
[0009] When the first state machine is in an idle state and the channel is idle, determining a target execution strategy for the data to be sent, the target execution strategy including a contention-free strategy and a contention strategy; wherein the contention-free strategy is used to call a data sending phase interface when the channel is idle to send the data to be sent; and the contention strategy is used to send the data to be sent after channel contention;
[0010] When the first state machine is in an idle state and the channel is busy, the first state machine enters a channel busy state, wherein when the first state machine is in the channel busy state after a timeout and the channel is idle, the contention strategy is executed.
[0011] Optionally, when the first state machine is in an idle state and the channel is idle, determining a target execution strategy for the data to be sent includes:
[0012] When the first state machine is in an idle state, if the channel is idle and the data to be sent is not retransmission data, the target execution strategy of the data to be sent is a contention-free strategy;
[0013] The competition-free strategy includes:
[0014] Set a preset backoff time for the timer interrupt;
[0015] When the preset backoff time is reached, the first state machine enters a contention-free waiting state and queries the idle or busy state of the channel;
[0016] If the channel is idle, calling the data sending phase interface to send the data to be sent, and the first state machine enters the channel occupied state;
[0017] If the channel is busy, a channel idle interrupt is enabled and the first state machine enters a channel busy state.
[0018] Optionally, when the first state machine is in an idle state and the channel is idle, determining a target execution strategy for the data to be sent includes:
[0019] When the first state machine is in an idle state, if the channel is idle and the data to be sent is retransmission data, the target execution strategy of the data to be sent is a competition strategy;
[0020] The competition strategy includes:
[0021] Set a preset backoff time for the timer interrupt;
[0022] When the preset backoff time is reached, the first state machine enters a contention waiting state.
[0023] Optionally, when the preset backoff time is reached, after the first state machine enters the contention waiting state, the method further includes:
[0024] Query the idle and busy status of the channel;
[0025] When the channel is idle, a channel busy interrupt is enabled, and a random backoff time is set for the timer interrupt, and if the random backoff time is reached or the channel busy interrupt is triggered, the first state machine enters a competition state;
[0026] When the channel is busy, a channel idle interrupt is enabled, and the first state machine enters a channel busy state.
[0027] Optionally, if the random backoff time is reached or the channel busy interrupt is triggered, after the first state machine enters a contention state, the method further includes:
[0028] If the first state machine enters a contention state after the random backoff time is reached, querying the idle or busy state of the channel;
[0029] When the channel is idle, the data sending phase interface is called to send the data to be sent, and the first state machine enters the channel occupied state;
[0030] When the channel is busy, a channel idle interrupt is enabled, and the first state machine enters a channel busy state;
[0031] If the first state machine enters a contention state after the channel busy interrupt is triggered, indicating that the random backoff time of the timer interrupt has not arrived, the channel idle interrupt is enabled, a first timeout time is set for the timer interrupt, and the first state machine enters a contention suspension state.
[0032] Optionally, after the first state machine enters the contention suspension state, the method further includes:
[0033] Query the idle and busy status of the channel;
[0034] When the channel is idle, restart the random backoff time of the timer interrupt, and after the random backoff time is reached, the first state machine enters a competition state;
[0035] When the channel is busy, a channel idle interrupt is enabled, and the first state machine enters a channel busy state.
[0036] Optionally, the method comprises:
[0037] When the first state machine enters a channel busy state, setting a first timeout period for a timer interrupt;
[0038] When the first timeout period is reached and the channel is busy, re-updating the first timeout period for the timer interrupt;
[0039] When the first timeout period is not reached, triggering a channel idle interrupt, setting a preset backoff time for the timer interrupt, and when the preset backoff time is reached, the first state machine enters a contention waiting state;
[0040] The first timeout period is calculated based on the product of the number of times the first state machine is currently in a channel busy state and a calibrated time value.
[0041] Optionally, the calculation formula of the random backoff time is:
[0042] Random backoff time = random_number*slot_time
[0043] random_number=n 2
[0044] Wherein, n is the number of times that the first state machine is currently in the channel busy state continuously; slot_time is the time slot time corresponding to the current transmission protocol.
[0045] Optionally, after the first state machine enters a channel occupied state, the method includes:
[0046] When the data sending phase interface is called and the data to be sent is sent, the first state machine enters an idle state and clears the first to-be-sent flag;
[0047] When the data sending phase interface is called and the sending of the data to be sent times out, detecting whether the data to be sent exceeds a maximum retransmission number threshold for a single packet;
[0048] If the data to be sent does not exceed the maximum retransmission number threshold of a single packet, the data to be sent is used as retransmission data, and the first state machine enters an idle state to resend the data to be sent;
[0049] If the data to be sent exceeds the maximum retransmission number threshold of a single packet, the first to-be-sent flag is cleared and the first state machine enters an idle state.
[0050] In a second aspect, this embodiment further provides a multi-access device, applied to a wireless device, the device comprising:
[0051] An acquisition module, used for acquiring data to be sent and configuring a to-be-sent flag as a first to-be-sent flag;
[0052] A wireless channel contention phase interface calling module, used to call the wireless channel contention phase interface according to the first to-be-sent flag, and the first state machine is in an idle state;
[0053] A target strategy execution module is used to determine the target execution strategy of the data to be sent when the first state machine is in an idle state and the channel is idle, and the target execution strategy includes a non-contention strategy and a competition strategy; wherein the non-contention strategy is used to call the data sending phase interface when the channel is idle to send the data to be sent; the competition strategy is used to send the data to be sent after channel competition; when the first state machine is in an idle state and the channel is busy, the first state machine enters a channel busy state, wherein when the first state machine is in the channel busy state after timeout and the channel is idle, the competition strategy is executed.
[0054] Beneficial effects:
[0055] Acquire the data to be sent and configure the to-be-sent flag with a first to-be-sent flag; according to the first to-be-sent flag, call the wireless channel competition phase interface, and the first state machine is in an idle state; when the first state machine is in an idle state and the channel is idle, determine the target execution strategy of the data to be sent, and the target execution strategy includes a non-competition strategy and a competition strategy; wherein the non-competition strategy is used to call the data sending phase interface when the channel is idle to send the data to be sent; the competition strategy is used to make the data to be sent be sent after channel competition; when the first state machine is in an idle state and the channel is busy, the first state machine enters a channel busy state, wherein when the first state machine is in a channel busy state after a timeout and the channel is idle, the competition strategy is executed.
[0056] When sending the data to be sent, the method can determine the target execution strategy of the data to be sent through the state change of the first state machine, determine whether the data to be sent is sent through a contention-free channel or needs to compete for a channel before sending, and after the state machine is in a channel busy state, if the timeout period is reached, the channel is competed for to send the data to be sent, thereby avoiding the waiting time of the data to be sent. The method can send data based on the state change of the first state machine, and can be applied in scenarios such as the Internet of Things / vehicle-side component communication with low bandwidth requirements, and has the effects of fast deployment speed, low cost and high reliability. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0058] Figure 1 is a flowchart of the steps of a multiple access method proposed in one embodiment of the present application;
[0059] Figure 2 is a state diagram of a first state machine provided in an embodiment of the present application;
[0060] Figure 3 is a state diagram of a second state machine proposed in an embodiment of the present application;
[0061] Figure 4 It is a functional module diagram of a multi-access device proposed in an embodiment of the present application. DETAILED DESCRIPTION
[0062] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0063] The Carrier Sense Multiple Access with Collision Avoid (CSMA / CA) protocol can prevent multiple wireless devices from sending wireless frames at the same time on the same frequency band. The principle is that before each wireless device sends a wireless frame, it first detects whether the channel is in use. If it detects that the channel is idle, it waits for a random period of time before sending data. If the channel is busy, it waits for a random period of time and then detects the busy or idle status of the channel. When the receiving end receives the correct data, it responds with ACK (Acknowledge character) after a short frame interval. After receiving the ACK frame, the sending end considers that the transmission is successful; and repeats sending subsequent frame data in sequence.
[0064] In the prior art, in order to enable WIFI to achieve high-bandwidth transmission, such as 80211n, 80211ac and other data frame transmissions of up to several hundred megabytes, chip manufacturers choose to implement the CSMA / CA working process through hardware or FPGA (Field Programmable Gate Array) programming. However, for some low-speed IoT scenarios or low-bandwidth scenarios (such as 80211b and other low-bandwidth requirements), this method of implementing CSMA / CA is particularly costly and wastes resources.
[0065] To this end, the method provides a multi-access method, which is mainly based on the communication protocol of the carrier sense multiple access collision avoidance (CSMA / CA) wireless local area network, and uses software to implement the process control of wireless channel competition during frame transmission in WiFi communication to meet the 80211 protocol specification standard, thereby realizing process control of wireless channel competition, reducing the hardware overhead cost of wireless devices, and can be quickly deployed in low-speed transmission scenarios such as the Internet of Things and vehicle-side controllers.
[0066] The 80211 protocol defines DCF (Distributed Coordination Function), which is a working mode in wireless communication. It standardizes the negotiation between multiple devices. The DCF mode includes the CSMA / CA sub-mode. The working principle of CSMA / CA consists of two steps:
[0067] 1) Channel monitoring and conflict avoidance: Before sending data, wireless devices will first monitor the channel busy or idle status. If the channel is idle, it will enter a DIFS (Distributed Inter-frame Spacing) waiting time. If it is idle, it will wait for a random period of time (called backoff time) and then detect whether the channel is idle again. If it is idle, the device will enter the data transmission state. If it is busy, it will repeat the above actions.
[0068] DIFS is defined in the 802.11 protocol as the time interval during which each wireless device must wait before sending a data packet. The value of DIFS varies depending on the protocol used, such as 802.11b / g / n.
[0069] 2) Data transmission: When the channel is idle, the device sends data. After the data transmission is successful, the receiving end will use ACK as a data reception response.
[0070] Reference Figure 1 , shows a flowchart of a multi-access method in an embodiment of the present application, the method is applied to a wireless device, and the method may specifically include the following steps:
[0071] S101: Acquire data to be sent and configure a to-be-sent flag as a first to-be-sent flag.
[0072] Before receiving the data to be sent, the CCA (Carrier Detection, Clear Channel Assessment) interrupt I1 is initialized first, the RF frame transmission completion interrupt I2 is initialized and set to high priority, and the timer interrupt I3 is initialized, where the timer interrupt I3 is a 1us granularity timer interrupt.
[0073] CCA interrupt I1 is based on the working principle of CCA. It detects the wireless signal strength on the 2.4G (5G) frequency band through the hardware RF module and performs matching. When the air medium signal strength is less than the capability detection threshold, the signal busy interrupt is triggered; when the air medium signal strength is greater than the capability detection threshold, the signal idle interrupt is triggered. At the same time, when CCA interrupt I1 is triggered, the channel idle and busy status flag idle_flag will be set. idle_flag = 0 indicates that the signal is busy, and idle_flag = 1 indicates that the signal is idle.
[0074] Specifically, this embodiment also sets a to-be-sent flag tx_flag. When the upper-layer 80211 protocol stack sends the data to be sent to the underlying software, or when the data to be sent is retransmission data, the to-be-sent flag tx_flag is configured as the first to-be-sent flag, that is, tx_flag=1, otherwise tx_flag=0; the retransmission flag can also be set to indicate whether the data to be sent is retransmission data. When the data to be sent is retransmission data, repeat_flag=1, otherwise repeat_flag=0.
[0075] S102: According to the first to-be-sent flag, a wireless channel contention phase interface is called, and the first state machine is in an idle state.
[0076] In this embodiment, according to the two stages of channel listening and conflict avoidance and data transmission in the CSMA / CA working principle, the data transmission process of the wireless device is also divided into a wireless channel competition stage and a data transmission stage.
[0077] In the wireless channel competition phase, a first state machine is set, and the first state machine includes 7 states, which are: idle state S1,
[0078] When the to-be-sent flag tx_flag=1, the wireless channel contention phase interface is called, and the first state machine first enters the idle state S1, the contention-free waiting state S2, the contention waiting state S3, the channel busy state S4, the contention state S5, the contention suspension state S6 and the channel occupied state S7.
[0079] When the to-be-sent flag tx_flag is configured as the first to-be-sent flag, ie, tx_flag=1, it indicates that the wireless device has data to be sent. At this time, the first state machine first enters the idle state S1.
[0080] S103: When the first state machine is in an idle state and the channel is idle, determining a target execution strategy for the data to be sent, wherein the target execution strategy includes a contention-free strategy and a contention strategy.
[0081] When the first state machine enters the idle state S1, it queries the idle and busy state of the channel, and then determines the target execution strategy of the data to be sent based on the idle and busy state of the channel and whether the data to be sent is retransmission data, that is, by judging the channel idle and busy state flag idle_flag and the retransmission flag repeat_flag.
[0082] The target execution strategy includes a non-competition strategy and a competition strategy. The non-competition strategy is used to call the data sending phase interface when the channel is idle to send the data to be sent; the competition strategy is used to send the data to be sent after channel competition.
[0083] Specifically, when the first state machine is in the idle state S1, if the channel is idle and the data to be sent is not retransmission data, that is, idle_flag=1 and repeat_flag=0, the target execution strategy of the data to be sent is the contention-free strategy.
[0084] The competition-free strategy includes: setting a backoff time backoff_wait for the timer interrupt I3, where backoff_wait is a preset backoff time, i.e., DIFS corresponding to different protocol types, wherein the preset backoff time depends on the protocol type selected by the upper layer protocol stack, and the calculation formula is preset backoff time DIFS=SIFS+(2*Slot time).
[0085] The preset backoff times corresponding to different protocol types are shown in Table 1 below:
[0086] Table 1 Preset backoff time corresponding to different protocol types
[0087] Protocol Type SIFS(μs) Slot Time(μs) DIFS(μs) IEEE 802.11b 10 20 50 IEEE 802.11a 16 9 34 IEEE 802.11g 10 9 / 20 28 / 50 IEEE 802.11n 16 9 34
[0088] When the backoff time backoff_wait of the timer interrupt I3 is reached, the timer interrupt I3 is triggered, and the first state machine enters the contention-free waiting state S2.
[0089] The first state machine in the contention-free waiting state S2 queries the idle or busy state of the channel again. If the channel is idle, that is, idle_flag=1, the data sending phase interface is called to send the data to be sent, and the first state machine enters the channel occupation state S7; that is, for the data to be sent that is not retransmitted, it can be sent without channel competition when the channel is idle.
[0090] When the first state machine is in the contention-free waiting state S2, if the channel is busy, that is, idle_flag=0, the channel idle interrupt is enabled, and the first state machine enters the channel busy state S4.
[0091] Specifically, when the first state machine is in the idle state S1, if the channel is idle and the data to be sent is retransmission data, that is, idle_flag=1 and repeat_flag=1, the target execution strategy of the data to be sent is a contention strategy.
[0092] The competition strategy includes: setting the backoff time backoff_wait for the timer interrupt I3 as a preset backoff time. When the backoff time backoff_wait of the timer interrupt I3 is reached, the timer interrupt I3 is triggered, and the first state machine enters the competition waiting state S3; that is, for the retransmitted data to be sent, channel competition is still required before it can be sent when the channel is idle.
[0093] In addition, when the first state machine is in the idle state S1, if the channel is busy, that is, idle_flag=0, the backoff time backoff_wait of the timer interrupt I3 is cleared; the next state of the first state machine is the channel busy state S4, and the I1 channel idle interrupt is turned on. In the channel busy state S4, the timeout time of the timer interrupt I3 is set to the first timeout time T1, and the first timeout time T1 is calculated based on the number of times the first state machine is currently in the channel busy state S4 continuously and the product of the calibrated time value:
[0094] T1=n*Ti
[0095] Wherein, n represents the number of times that the first state machine is currently in the channel busy state S4 continuously, and the calibration time value Ti is a maximum of 10ms and can be 50us by default.
[0096] The T1 timeout mechanism is designed to ensure that when the wireless device is frequently in a busy channel, it will actively detect the busy or idle state of the channel once the timeout occurs, to avoid software protection processing when the hardware status detection is abnormal. At the same time, it ensures that the channel is queried once in a short time when the channel is busy, occupying CPU resources.
[0097] The first state machine is in the channel busy state S4, when the first timeout time T1 is reached and the channel busy idle_flag=0, the first timeout time T1 is re-updated for the timer interrupt I3; but if the first timeout time T1 has not been reached, the I1 channel idle interrupt has been triggered, and the backoff time backoff_wait is set for the timer interrupt I3 as the preset backoff time. When the backoff time backoff_wait of the timer interrupt I3 is reached, the timer interrupt I3 is triggered, and the first state machine enters the contention waiting state S3.
[0098] When the first state machine is in the contention waiting state S3, the idle or busy state of the channel is queried.
[0099] When the channel is idle, that is, idle_flag=1, the I1 channel busy interrupt is enabled, and the backoff time backoff_wait is set as a random backoff time for the timer interrupt I3.
[0100] In this embodiment, in order to give wireless devices that send data to be sent a higher priority in channel competition, within the scope allowed by the protocol, the calculation formula for the random backoff time is:
[0101] Random backoff time = random_number*slot_time
[0102] random_number=n 2
[0103] Wherein, n is the number of times that the first state machine is currently in the channel busy state S4 continuously; slot_time is the time slot time corresponding to the current transmission protocol.
[0104] In the existing 80211 protocol definition, the random value random_number is generated in the following way: when entering random avoidance for the first time, a random number is generated within 1-31; after one repetition, a random number is generated within 1-63; after two repetitions, a random number is generated within 1-127, and the numbers are accumulated in sequence until the range reaches 1-1023.
[0105] In this embodiment, when entering random avoidance for the first time, a random value of random_number is used as 1 to try to compete once. If it fails, it is repeated once, and the random number random_number is 2. After repeating twice, the random number random_number is 4. After repeating three times, the random number random_number is 8. ... After repeating six times, the random number random_number is fixed to 64, and then the calculated random backoff time is smaller, thereby increasing the number of times the wireless device with data to be sent competes in the channel.
[0106] If the backoff time backoff_wait of the timer interrupt I3 is reached, that is, when the random backoff time is reached, or when the I1 channel busy interrupt is triggered, the first state machine enters the competition state S5.
[0107] When the channel is busy, that is, idle_flag=0, the I1 channel idle interrupt is turned on, and the first state machine enters the channel busy state S4.
[0108] When the first state machine is in the contention state S5, if the backoff time backoff_wait of the timer interrupt I3 is reached, that is, the random backoff time is reached, the first state machine enters the contention state S5, and queries the idle and busy states of the channel.
[0109] When the channel is idle, that is, idle_flag=1, the data sending phase interface is called to send the data to be sent, and the first state machine enters the channel occupied state S7; when the channel is busy, that is, idle_flag=0, the I1 channel idle interrupt is turned on, and the first state machine enters the channel busy state S4;
[0110] If the first state machine enters the competition state S5 due to triggering the I1 channel busy interrupt, it indicates that the random backoff of the timer interrupt I3 has failed, the backoff time backoff_wait of the timer interrupt I3 has not been reached, the I1 channel idle interrupt is turned on, and the timeout time of the timer interrupt I3 is set to the first timeout time T1, and the first state machine enters the competition suspension state S6.
[0111] After the first state machine enters the contention suspension state S6, the idle or busy state of the channel is queried.
[0112] When the channel is idle, that is, idle_flag=1, the backoff_wait of the timer interrupt I3 is restarted and continues to be limited by the random backoff time; until the backoff_wait time of the timer interrupt I3 is reached, that is, when the random backoff time is reached, the first state machine enters the competition state S5;
[0113] When the channel is busy, that is, idle_flag=0, the I1 channel idle interrupt is turned on, and the first state machine enters the channel busy state S4.
[0114] After the first state machine enters the channel occupied state S7, the data sending phase interface is called to send data.
[0115] After calling the data sending phase interface and sending the data to be sent, in this embodiment, a data sending completion flag tx_ok_flag is set. When the data sending phase completes data sending, tx_ok_flag=1, the first state machine enters the idle state S1, and clears the first to-be-sent flag, that is, tx_flag=0.
[0116] When the data transmission phase interface is called and the sending of the data to be sent times out, tx_ok_flag=0. At this time, it is detected whether the data to be sent exceeds the maximum retransmission number threshold of a single packet.
[0117] If the data to be sent does not exceed the maximum retransmission number threshold for a single packet, the data to be sent is used as retransmission data, and repeat_flag=1 is set, and the first state machine enters the idle state S1; if the data to be sent exceeds the maximum retransmission number threshold for a single packet, the first to-be-sent flag is cleared, that is, tx_flag=0 is set, and the first state machine returns to the idle state S1, which indicates packet loss; just wait for the next data to be sent.
[0118] Reference Figure 2 , shows a state diagram of the first state machine provided by the implementation of the present application. In a feasible implementation, the execution process of the wireless channel contention phase of the present method is as follows:
[0119] First, initialize the CCA interrupt (I1), initialize the RF frame transmission completion interrupt (I2) and set it to high priority, and initialize the 1us granularity timer interrupt (I3);
[0120] When the upper layer 80211 protocol stack sends wireless data to the underlying software or the data is retransmitted (repeat_flag=1), tx_flag=1, the wireless channel competition phase interface is called, and the following process is performed:
[0121] 1. The first state machine is in the idle state S1, and determines the channel idle or busy state;
[0122] (1) When idle_flag=1 and repeat_flag=0, determine the preset backoff time, and set the backoff_wait of the timer interrupt I3 to the preset backoff time; when the preset backoff time is reached, that is, backoff_wait=0, the timer interrupt I3 is triggered, and the first state machine enters the contention-free waiting state S2 from the idle state S1;
[0123] (2) When idle_flag=1 and repeat_flag=1, the preset backoff time is determined, and the backoff_wait of the timer interrupt I3 is set to the preset backoff time. When the preset backoff time is reached, that is, backoff_wait=0, the timer interrupt I3 is triggered, and the first state machine enters the contention waiting state S3 from the idle state S1;
[0124] (3) When idle_flag=0, clear the backoff_wait of the timer interrupt, set the next state to the channel busy state S4, and enable the I1 channel idle interrupt. In the channel busy state S4, set the timeout time of the timer interrupt I3 to the first timeout time T1:
[0125] (31) Before the first timeout time T1 is reached, the I1 channel idle interrupt is triggered first, and the backoff_wait of the timer interrupt I3 is set to the preset backoff time, and the competition state is activated at the same time. When the preset backoff time is reached, that is, backoff_wait = 0, the timer interrupt I3 is triggered, and the first state machine enters the competition waiting state S3 from the channel busy state S4;
[0126] (32) When the first timeout time T1 is reached and idle_flag=0, the first timeout time T1 is updated for the timeout time of the timer interrupt I3, that is, step (3) is repeated until any time does not time out and triggers the I1 channel idle interrupt, and then the contention waiting state S3 is entered after the preset backoff time is reached;
[0127] 2. The first state machine enters the contention-free waiting state S2 and determines the channel busy or idle state:
[0128] (1) When idle_flag=1, the data transmission phase interface is called to send the data to be sent, and the first state machine enters the channel occupation state S7;
[0129] (2) When idle_flag=0, the next state is set to the channel busy state S4, the I1 channel idle interrupt is enabled, and the first state machine enters the channel busy state S4, and the steps are the same as those shown in 1 and (3);
[0130] 3. When the first state machine enters the contention waiting state S3, it determines the channel busy or idle state:
[0131] (1) When idle_flag = 1, the I1 channel busy interrupt is turned on, and the backoff_wait of the timer interrupt I3 is set to a random backoff time. When the random backoff time is reached, that is, backoff_wait = 0, the timer interrupt I3 is triggered or the I1 channel busy interrupt is triggered, and the first state machine enters the competition state S5;
[0132] (2) When idle_flag=0, the next state is set to the channel busy state S4, the I1 channel idle interrupt is enabled, and the first state machine enters the channel busy state S4, and the steps are the same as those shown in 1 and (3);
[0133] 4. When the first state machine enters the competition state S5:
[0134] (1) If backoff_wait of timer interrupt I3 is 0, that is, after the random backoff time is reached, the first state machine enters the competition state S5, and then queries the channel busy and idle state again:
[0135] (11) When idle_flag=1, the data transmission phase interface is called to send the data to be sent, and the first state machine enters the channel occupation state S7;
[0136] (12) When idle_flag=0, the next state is set to the channel busy state S4, the I1 channel idle interrupt is enabled, and the first state machine enters the channel busy state S4, and the steps are the same as those shown in 1 and (3);
[0137] (2) If the I1 channel busy interrupt is triggered and the contention state S5 is entered, it indicates that the random backoff fails, backoff_wait≠0, the I1 channel idle interrupt is enabled, the timeout time of the timer interrupt I3 is set to the first timeout time T1, and the first state machine enters the contention suspension state S6;
[0138] 5. When the first state machine enters the contention suspension state S6, it queries the channel idle and busy states:
[0139] (1) When idle_flag=1, the random backoff time of the timer interrupt I3 is restarted. When the random backoff time is reached, that is, backoff_wait=0, the timer interrupt I3 is triggered, and the first state machine enters the competition state S5;
[0140] (2) When idle_flag=0, the next state is set to the channel busy state S4, the I1 channel idle interrupt is enabled, and the first state machine enters the channel busy state S4, and the steps are the same as those shown in 1 and (3);
[0141] 6. When the first state machine enters the channel occupation state S7,
[0142] (1) When the data transmission completion flag tx_ok_flag = 1, it indicates that the wireless data transmission is completed, the first state machine enters the idle state S1, and the waiting flag tx_flag = 0, and feeds back the upper layer protocol to run and send the next data;
[0143] (2) When the data transmission completion flag tx_ok_flag=0, it indicates that the data transmission fails. Check whether the data to be sent exceeds the maximum retransmission number threshold of a single packet. If not, retransmission can be performed, and the retransmission flag repeat_flag=1 is filled, and then tx_flag=1, then the first state machine enters the idle state S1 from the channel occupation state S7, and actively calls the wireless channel competition phase interface to retransmit data; if exceeded, it indicates packet loss, clear all flag bits, tx_flag=0, and the channel occupation state S7 of the first state machine enters the idle state S1, waiting for the next wireless data to be sent.
[0144] In this embodiment, the data sending stage is a PPDU (Physical Layer Protocol Data Unit) sending stage, and a second state machine is provided in the PPDU sending stage.
[0145] Reference Figure 3 , shows a state diagram of the second state machine provided in an embodiment of the present application, the second state machine includes 4 states: idle state S_0, sending state S_1, waiting for completion state S_2 and waiting for receiving ACK state S_3.
[0146] Among them, the idle state S_0 indicates that the current channel is idle and can be written; the sending state S_1 indicates the data sending process; the waiting completion state S_2 indicates that the data sending is completed, which is triggered by the RF frame sending completion interrupt I2 or the sending timeout interrupt; the waiting to receive ACK state S_3 indicates waiting for the ACK response from the receiving end.
[0147] The PPDU sending phase specifically includes:
[0148] (1) After competing for the channel, the PPDU sending process is called to prepare to send the data to be sent;
[0149] (2) The second state machine enters the sending state S_1 from the idle state S_0, and calls the hardware interface to send the data to be sent, and calculates the sending timeout T2 in combination with the sending length of the data to be sent, the protocol type and the hardware performance of the wireless device, and the timeout time of starting the timer interrupt I3 is the sending timeout T2; when the RF frame sending completion interrupt I2 is triggered or the start timer interrupt I3 is triggered after the sending timeout T2 is reached, the second state machine enters the waiting completion state S_2 from the sending state S_1.
[0150] (3) When the second state machine is in the waiting completion state S_2:
[0151] (31) If the radio frame transmission completion interrupt I2 is triggered to enter the waiting completion state S_2, check whether the data to be sent requires an ACK response from the destination (indicated by the 80211 protocol stack);
[0152] A. If an ACK response is required, the timeout time of the timer interrupt I3 is set to the preset timeout time T3, wherein the preset timeout time T3 is calculated according to the definition in the 80211 protocol; if the preset timeout time T3 is reached, the second state machine enters the waiting for receiving ACK state S_3 from the waiting completion state S_2, and queries again whether the ACK response has been received.
[0153] B. If an ACK response is not required, it indicates that the data to be sent has been sent. The second state machine enters the idle state S_0 from the waiting completion state S_2, sets the data sending completion flag tx_ok_flag=1, and actively calls the wireless channel competition phase interface.
[0154] (32) If the timer interrupt I3 is triggered to enter the waiting completion state S_2 after the transmission timeout period T2 is reached, the second state machine enters the idle state S_0 from the waiting completion state S_2, and sets the data transmission completion flag tx_ok_flag = 0, indicating that the transmission fails due to the transmission timeout, and actively calls the wireless channel competition phase interface.
[0155] (4) When the second state machine is in the waiting to receive ACK state S_3:
[0156] (41) If an ACK response is received, it indicates that the transmission is successful. The second state machine enters the idle state S_0 from the waiting for receiving ACK state S_3, sets the data transmission completion flag tx_ok_flag = 1, and actively calls the wireless channel competition phase interface.
[0157] (42) If no ACK is received, it indicates that the response sending process has timed out. The second state machine enters the idle state S_0 from the waiting ACK receiving state S_3, sets the data sending completion flag tx_ok_flag = 0, actively calls the wireless channel competition phase interface, the first state machine is in the S7 state, and sets the retransmission flag repeat_flag = 1.
[0158] During the application of the method, the WLAN (Wireless Local Area Network) carrier sense multiple access conflict avoidance process can be realized through the wireless channel competition stage and the data transmission stage. When implementing the method, the hardware only needs to support 4 hardware interrupt functions: 1) CCA (carrier detection) interrupt; 2) RF frame transmission completion interrupt; 3) 1us granularity timer interrupt; 4) hardware support interrupt priority (setting the above 3 interrupts to high priority) to realize the method. The process of sending data without conflict can be achieved through the state change based on the first state machine and the second state machine. It can be applied in scenarios such as the Internet of Things / vehicle-side component communication with low bandwidth requirements, and has the effects of fast deployment speed, low cost and high reliability.
[0159] Reference Figure 4 , shows a functional module diagram of a multi-access device in an embodiment of the present application, the device comprising:
[0160] An acquisition module 100 is used to acquire data to be sent and configure a to-be-sent flag as a first to-be-sent flag;
[0161] A wireless channel contention phase interface calling module 200, configured to call a wireless channel contention phase interface according to the first to-be-sent flag, wherein the first state machine is in an idle state;
[0162] The target strategy execution module 300 is used to determine the target execution strategy of the data to be sent when the first state machine is in an idle state and the channel is idle, and the target execution strategy includes a non-contention strategy and a competition strategy; wherein the non-contention strategy is used to call the data sending phase interface when the channel is idle to send the data to be sent; the competition strategy is used to send the data to be sent after channel competition; when the first state machine is in an idle state and the channel is busy, the first state machine enters a channel busy state, wherein when the first state machine is in the channel busy state after timeout and the channel is idle, the competition strategy is executed.
[0163] An embodiment of the present application further provides a non-volatile readable storage medium, wherein the non-volatile readable storage medium stores a computer program, wherein the computer program, when executed by a processor, performs the multiple access method described in the embodiment.
[0164] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0165] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, devices or computer program products. Therefore, the present application can be implemented in the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present application can be implemented in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0166] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems) and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0167] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0168] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0169] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.
[0170] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0171] Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A multiple access method, characterized in that: Applied to a wireless device, the method comprises: Acquire the data to be sent and configure the to-be-sent flag as the first to-be-sent flag; According to the first to-be-sent flag, a wireless channel contention phase interface is called, and the first state machine is in an idle state; When the first state machine is in an idle state and the channel is idle, determining a target execution strategy for the data to be sent, the target execution strategy including a contention-free strategy and a contention strategy; wherein the contention-free strategy is used to call a data sending phase interface when the channel is idle to send the data to be sent; and the contention strategy is used to send the data to be sent after channel contention; When the first state machine is in an idle state and the channel is busy, the first state machine enters a channel busy state, wherein when the first state machine is in the channel busy state after a timeout and the channel is idle, the contention strategy is executed; When the first state machine is in an idle state and the channel is idle, determining a target execution strategy for the data to be sent includes: When the first state machine is in an idle state, if the channel is idle and the data to be sent is not retransmission data, the target execution strategy of the data to be sent is a contention-free strategy; The competition-free strategy includes: Set a preset backoff time for the timer interrupt; When the preset backoff time is reached, the first state machine enters a contention-free waiting state and queries the idle or busy state of the channel; If the channel is idle, calling the data sending phase interface to send the data to be sent, and the first state machine enters the channel occupied state; If the channel is busy, a channel idle interrupt is enabled, and the first state machine enters a channel busy state.
2. The method according to claim 1, characterized in that When the first state machine is in an idle state and the channel is idle, determining a target execution strategy for the data to be sent includes: When the first state machine is in an idle state, if the channel is idle and the data to be sent is retransmission data, the target execution strategy of the data to be sent is a competition strategy; The competition strategy includes: Set a preset backoff time for the timer interrupt; When the preset backoff time is reached, the first state machine enters a contention waiting state.
3. The method according to claim 2, characterized in that When the preset backoff time is reached, after the first state machine enters the contention waiting state, the method further includes: Query the idle and busy status of the channel; When the channel is idle, a channel busy interrupt is enabled, and a random backoff time is set for the timer interrupt, and if the random backoff time is reached or the channel busy interrupt is triggered, the first state machine enters a competition state; When the channel is busy, a channel idle interrupt is enabled, and the first state machine enters a channel busy state.
4. The method according to claim 3, characterized in that If the random backoff time reaches or triggers the channel busy interrupt, after the first state machine enters the contention state, the method further includes: If the first state machine enters a contention state after the random backoff time is reached, querying the idle or busy state of the channel; When the channel is idle, the data sending phase interface is called to send the data to be sent, and the first state machine enters the channel occupied state; When the channel is busy, a channel idle interrupt is enabled, and the first state machine enters a channel busy state; If the first state machine enters a contention state after the channel busy interrupt is triggered, indicating that the random backoff time of the timer interrupt has not arrived, the channel idle interrupt is enabled, a first timeout time is set for the timer interrupt, and the first state machine enters a contention suspension state.
5. The method according to claim 4, characterized in that After the first state machine enters the contention suspension state, the method further includes: Query the idle and busy status of the channel; When the channel is idle, restart the random backoff time of the timer interrupt, and after the random backoff time is reached, the first state machine enters a competition state; When the channel is busy, a channel idle interrupt is enabled, and the first state machine enters a channel busy state.
6. The method according to any one of claims 1 to 5, characterized in that: The method comprises: When the first state machine enters a channel busy state, setting a first timeout period for a timer interrupt; When the first timeout period is reached and the channel is busy, re-updating the first timeout period for the timer interrupt; When the first timeout period is not reached, triggering a channel idle interrupt, setting a preset backoff time for the timer interrupt, and when the preset backoff time is reached, the first state machine enters a contention waiting state; The first timeout period is calculated based on the product of the number of times the first state machine is currently in a channel busy state and a calibrated time value.
7. The method according to any one of claims 3 to 5, characterized in that: The calculation formula of the random backoff time is: Random backoff time = random_number*slot_time random_number=n 2 Wherein, n is the number of times that the first state machine is currently in the channel busy state continuously; slot_time is the time slot time corresponding to the current transmission protocol.
8. The method according to claim 1 or 4, characterized in that: After the first state machine enters the channel occupied state, the method includes: When the data sending phase interface is called and the data to be sent is sent, the first state machine enters an idle state and clears the first to-be-sent flag; When the data sending phase interface is called and the sending of the data to be sent times out, detecting whether the data to be sent exceeds a maximum retransmission number threshold for a single packet; If the data to be sent does not exceed the maximum retransmission number threshold of a single packet, the data to be sent is used as retransmission data, and the first state machine enters an idle state to resend the data to be sent; If the data to be sent exceeds the maximum retransmission number threshold of a single packet, the first to-be-sent flag is cleared and the first state machine enters an idle state.
9. A multi-access device, characterized in that: The device comprises: An acquisition module, used for acquiring data to be sent and configuring a to-be-sent flag as a first to-be-sent flag; A wireless channel contention phase interface calling module, used to call the wireless channel contention phase interface according to the first to-be-sent flag, and the first state machine is in an idle state; A target strategy execution module is used to determine the target execution strategy of the data to be sent when the first state machine is in an idle state and the channel is idle, and the target execution strategy includes a non-contention strategy and a contention strategy; wherein the non-contention strategy is used to call the data sending phase interface when the channel is idle to send the data to be sent; the contention strategy is used to send the data to be sent after channel contention; when the first state machine is in an idle state and the channel is busy, the first state machine enters a channel busy state, wherein when the first state machine is in the channel busy state after a timeout and the channel is idle, the contention strategy is executed; When the first state machine is in an idle state and the channel is idle, determining a target execution strategy for the data to be sent includes: When the first state machine is in an idle state, if the channel is idle and the data to be sent is not retransmission data, the target execution strategy of the data to be sent is a contention-free strategy; The competition-free strategy includes: Set a preset backoff time for the timer interrupt; When the preset backoff time is reached, the first state machine enters a contention-free waiting state and queries the idle or busy state of the channel; If the channel is idle, calling the data sending phase interface to send the data to be sent, and the first state machine enters the channel occupied state; If the channel is busy, a channel idle interrupt is enabled, and the first state machine enters a channel busy state.