对IEEE 802.15.4中Slotted CSMA-CA的理解

                     **对IEEE 802.15.4中Slotted CSMA-CA的理解**

Part1
IEEE 802.15.4的superframe分为两部分,Active和Inactive;Active又可以分为三部分,Beacon, CAP, CFP,如图1所示。在CFP,每个时隙都被分配好。但在CAP,节点通过CSMA-CA或者slotted CSMA-CA的方式接入信道。下面说说我对IEEE 802.15.4中slotted CSMA-CA的理解。图1为superframe结构。

对IEEE 802.15.4中Slotted CSMA-CA的理解_第1张图片

                                    图1 Superframe structure

Part2
关于slotted CSMA-CA,我最初读的是国际标准IEEE_802.15.4_2011的5.1.1.4章节 “CSMA-CA algorithm”,但由于标准里面细节太多,我没能抓住重点。于是找到解读版的论文“A Survey of Beacon-Enabled IEEE 802.15.4 MAC Protocols in Wireless Sensor Networks”。该论文对slotted CSMA-CA进行了简化阐述,读完它之后再读原标准就容易多了。

论文原文如下
During the CAP, nodes utilize the slotted CSMA-CA mechanism to contend for medium access. The slotted CSMA-CA employs the Binary Exponential Backoff (BEB) algorithm as a means to reduce the probability of collisions over the wireless channel. BEB operates as follows. Before any transmission
attempt three parameters are initialized, namely, the Number of Backoff stages (NB), the Contention Window (CW), and the Backoff Exponent (BE). These parameters are initialized with zero, two, and macMinBE , respectively. After that, the node backs off for a random duration selected from the range [0, 2BE - 1]. Once the backoff period expires, the node proceeds for two Clear Channel Assessments (CCA1 and CCA2). The number of CCAs is controlled by the parameter CW, such that CCAs are conducted as long as CW is not zero. If either CCA reveals that the medium is busy, CW is reset to two. The CCAs are needed to check whether the wireless medium is free from any activity before commencing a transmission. Packet transmission starts only if the medium is found to be clear during the two CCAs (provided that the remaining time slots in the current CAP are sufficient to transmit the packet and its ACK. Otherwise, the node has to postpone the packet transmission to the next superframe). However, if either of the CCAs reveals that the medium is busy, the value of BE will be increased by one (up to a maximum of macMaxBE) and the node backs off again (that is, NB is increased by one and can reach a maximum of macMaxCSMABackoffs). If BE reaches its maximum, it cannot change unless a successful/failed packet transmission occurs or packet retransmission commences. In that case, BE is reset to macMinBE. The packet will be dismissed
这段话描述的是节点A在一次数据传输过程中的所有行为。

关键参数三个:
NB: Number of Backoff stages
NB初始值为0,CCA过程一旦发现信道忙,NB就会加1,直到NB超过最大允许的退避次数macMaxCSMABackoffs后停止
CW: Contention Window
CCA次数,为何要进行多次CCA,一次不行吗?下面会有解释。
注:非时隙CSMA-CA中仅进行一次CCA
BE: Backoff Exponent
每一次退避的时间为多长是由BE值决定的,BE值最初为macMinBE,每次CCA信道忙则BE值加1,一直加到macMaxBE后,BE值保持不变。

对IEEE 802.15.4中Slotted CSMA-CA的理解_第2张图片

                            图2 CSMA-CA mechanism

下面说说为何要不止一次地CCA?论文中这样解释
if a node is performing its CCA1 at the same instant that another node has finished its packet transmission; the first node will sense the medium free. Therefore, in order to give the second node a chance to receive its ACK packet, the first node is required to perform another CCA. This way, 802.15.4 MAC has implicitly employed a priority-based approach in which the ACK packet is favored over other data packets.
也就是说当节点A刚发完数据的时刻,CCA虽然检测到信道空闲,但仍然不能立即抢占信道,因为接下来A要接收ACK。所以要进行两次CCA,以确认信道确实不会有节点再占用。

总结:IEEE 802.15.4中slotted CSMA-CA有以下重点
1, 三个参数。NB,CW,BE
2, CW=2是必须的,因为如果只进行一次CCA依然有冲突隐患。

Part3
以上从论文中的简化版解释中可以大致理解IEEE 802.15.4中slotted CSMA-CA工作方式,下面给出国际标准IEEE_802.15.4_2011的5.1.1.4章节对它的完整表述。图3为国际标准IEEE_802.15.4_2011中slotted CSMA-CA和CSMA-CA的流程图

对IEEE 802.15.4中Slotted CSMA-CA的理解_第3张图片

                         图3 CSMA-CA algorithm

图3和图2有两点不同,其一,增加了非时隙CSMA-CA部分;其二,在Slotted CSMA-CA部分多了一条判断“battery life extension”。本文不关注不同点,只关注相同点。

下面是标准中的原文摘录
Each device shall maintain three variables for each transmission attempt: NB, CW, and BE. NB is the number of times the CSMA-CA algorithm was required to back off while attempting the current transmission; this value shall be initialized to zero before each new transmission attempt. CW is the contention window length, defining the number of backoff periods that need to be clear of channel activity before the transmission can commence. This value shall be initialized to CW0 before each transmission attempt and reset to CW0 each time the channel is assessed to be busy. For operation in the Japanese 950 MHz band, CW0 shall be set to one; otherwise, CW0 shall be set to two. The CW variable is only used for slotted CSMA-CA. BE is the backoff exponent, which is related to how many backoff periods a device shall wait before attempting to assess a channel. In unslotted systems, or slotted systems with the received battery life extension (BLE) field, as defined in Figure 41, set to zero, BE shall be initialized to the value of macMinBE. In slotted systems with the received BLE field set to one, this value shall be initialized to the lesser of two and the value of macMinBE. Note that if macMinBE is set to zero, collision avoidance will be disabled during the first iteration of this algorithm。
如果只读这个标准,很难理解NB,CW,BE分别是什么意思。尤其是NB的定义,更是费解。NB不就等于CCA的次数吗。

总结:IEEE 802.15.4标准虽然内容面面俱到,但很多地方难理解,需要找到合适的论文讲解。

你可能感兴趣的:(网络)