分类: 嵌入式
2015-09-01 16:05:44
翻译自802.15.4 2006版的7.5.1.4,后面将把7.5.1channel access剩余的几个重要章节翻译放上来
7.5.1.4 CSMA-CA algorithm
The
CSMA-CA algorithm shall be used before the transmission of data or MAC command
frames transmitted within the CAP, unless the frame can be quickly transmitted
following the acknowledgment of a data request command (see 7.5.6.3 for timing
requirements). The CSMA-CA algorithm shall not be used for the transmission of
beacon frames in a beacon-enabled PAN, acknowledgment frames, or data frames transmitted
in the CFP.
CSMA-CA 算法用来在CAP期间传输数据帧或者MAC命令帧,除非该帧是在数据请求命令的确认帧之后马上发送的帧。信标网络里的信标帧、确认帧、CFP期间的数据帧不使用CSMA-CA算法发送。
If periodic beacons are being used in the
PAN, the MAC sublayer shall employ the slotted version of the CSMA-CA algorithm
for transmissions in the CAP of the superframe. Conversely, if periodic beacons
are not being used in the PAN or if a beacon could not be located in a
beacon-enabled PAN, the MAC sublayer shall transmit using
the unslotted version of the CSMA-CA algorithm. In both cases, the algorithm is
implemented using units of time called backoff periods, where one backoff
period shall be equal to aUnitBackoffPeriod symbols.
如果网络采用周期性的信标帧,MAC子层将在超帧的CAP期间引入CSMA-CA算法的slot版本。相反,如果网络没有采用周期性的信标帧,或者在信标网络里信标无法安置,MAC子层在传输时采用CSMA-CA算法的unslotted版本。这两种情况算法都采用了backoff period的时间单元,一个backoff
period等于aUnitBackoffPeriod符号。
In slotted CSMA-CA, the backoff period
boundaries of every device in the PAN shall be aligned with the superframe slot
boundaries of the PAN coordinator, i.e., the start of the first backoff period
of each device is aligned with the start of the beacon transmission. In slotted
CSMA-CA, the MAC sublayer shall ensure that the PHY commences all of its
transmissions on the boundary of a backoff period. In unslotted CSMA-CA, the
backoff periods of one device are not related in
time to the backoff periods of any other device in the PAN.
对于slotted CSMA-CA,网络里每个器件backoff period的边界由协调器分配在超帧的slot边界里,比如:每个期间开始的backoff period分配在信标帧传输的起始。MAC子层确保物理层开始的所有传输凑在backoff period的边界里。对于unslotted CSMA-CA,网络里每个器件的backoff period在时间上是不相关的。
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 backoff 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 two before each
transmission attempt and reset to two each time the channel is assessed to be busy. 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 BLE subfield (see Figure 47) set to zero, BE
shall be initialized to the value of macMinBE. In slotted systems with the
received BLE subfield 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是CSMA-CA算法尝试当前传输时的次数;它的值在每次传输尝试前初始化为0。CW是竞争窗口长度,定义了在传输开始之前清空信道活动的backoff的周期数,它的值在每次传输尝试前初始化为2,当信道接入为忙时重置为2. CW仅仅在slotted CSMA-CA算法里用到。BE是backoff的指数,它和一个设备尝试接入设备前等待的backoff周期数有关。在unslotted系统里,或者slotted系统里BLE域设置为0,BE会被初始化为macMinBE。在slotted系统里收到的BLE域是1,BE会被设置成比2和macMinBE更小的值。注意,如果macMinBE设置成0,碰撞避免机制在算法的第一次迭代中将不起作用。
Although the receiver of the device is
enabled during the CCA analysis portion of this algorithm, the device may
discard any frames received during this time.
Figure 69 illustrates the steps of the
CSMA-CA algorithm. When using slotted CSMA-CA, the MAC sublayer shall first
initialize NB, CW, and BE and then locate the boundary of the next backoff
period [step (1)]. For unslotted CSMA-CA, the MAC sublayer shall initialize NB
and BE and then proceed directly to step (2).
当使用slotted CSMA-CA, MAC子层首先初始化NB,CW和BE,然后确定下一个backoff周期的边界。对于unslotted CSMA-CA, MAC子层将初始化NB和BE,然后直接处理步骤(2)。
In a slotted CSMA-CA system with the BLE
subfield set to zero, the MAC sublayer shall ensure that, after the random
backoff, the remaining CSMA-CA operations can be undertaken and the entire
transaction can be transmitted before the end of the CAP. Note that any bit
padding used by the supported PHY (see 6.7.2.2) must be considered in making
this determination. If the number of backoff periods is greater than the remaining
number of backoff periods in the CAP, the MAC sublayer shall pause the backoff
countdown at the end of the CAP and resume it at the start of the CAP in the
next superframe. If the number of backoff periods is less than or equal to the
remaining number of backoff periods in the CAP, the MAC sublayer shall apply
its backoff delay and then evaluate whether it can proceed. The MAC sublayer
shall proceed if the remaining CSMA-CA algorithm steps (i.e.,
two CCA analyses), the frame transmission, and any acknowledgment can be
completed before the end of the CAP. If the MAC sublayer can proceed, it shall request
that the PHY perform the CCA in the current superframe. If the MAC sublayer
cannot proceed, it shall wait until the start of the CAP in the next superframe
and apply a further random backoff delay [step (2)] before evaluating whether
it can proceed again.
对于一个slotted CSMA-CA系统且BLE设置为0,MAC子层将保证在随机的backoff之后,剩余的CSMA-CA操作能够执行,并且整个过程能够在CAP结束之前发送。注意物理层的任一位的填充必须考虑到这个决定。如果backoff的周期比剩余的backoff周期还要长,那么MAC子层将在CAP结束前停止backoff向下递减,然后再下一次超帧开始时继续。如果backoff的周期小于等于剩余的backoff周期,MAC子层将实施backoff的延迟并评估是否能继续。MAC子层将继续剩余的CSMA-CA算法步骤,帧发送,和任何能在CAP结束前完成的确认信息。如果MAC子层能继续,它将请求物理层在当前超帧执行CCA。如果不能继续,它将等待下一个超帧的CAP,在评估能否继续前用进一步的随机backoff延迟。
In a slotted CSMA-CA system with the BLE
subfield set to one, the MAC sublayer shall ensure that, after the random
backoff, the remaining CSMA-CA operations can be undertaken and the entire
transaction can be transmitted before the end of the CAP. The backoff countdown
shall only occur during the first macBattLifeExtPeriods full backoff
periods after the end of the IFS period following the beacon. The MAC sublayer
shall proceed if the remaining CSMA-CA algorithm steps (two CCA analyses), the
frame transmission, and any acknowledgment can be completed before the end of
the CAP, and the frame transmission will start in one of the first
macBattLifeExtPeriods full backoff periods after the IFS period following the
beacon. If the MAC sublayer can proceed, it shall request that the PHY perform
the CCA in the current superframe. If the MAC sublayer cannot proceed, it shall
wait until the start of the CAP in the next superframe and apply a further
random backoff delay [step (2)] before evaluating whether it can proceed again
对于一个slotted CSMA-CA系统且BLE设置为1,MAC子层将保证在随机的backoff之后,剩余的CSMA-CA操作能够执行,并且整个过程能够在CAP结束之前发送。Backoff仅仅在第一次macBattLifeExtPeriods设置完后向下递减,当信标帧跟随的的IFS结束之后。MAC子层将继续剩余的CSMA-CA算法步骤,帧发送,和任何能在CAP结束前完成的确认信息。帧将在第一次macBattLifeExtPeriods设置完后发送,当信标帧跟随的的IFS结束之后。如果不能继续,它将等待下一个超帧的CAP,在评估能否继续前用进一步的随机backoff延迟。
If the channel is assessed to be busy [step
(4)], the MAC sublayer shall increment both NB and BE by one, ensuring that BE shall be no more than macMaxBE. The MAC sublayer in a
slotted CSMA-CA system shall also reset CW to two. If the value of NB is less
than or equal to macMaxCSMABackoffs, the CSMA-CA algorithm shall return to step
(2). If the value of NB is greater than macMaxCSMABackoffs, the CSMA-CA algorithm
shall terminate with a channel access failure status.
如果信道繁忙,MAC子层将是NB和BE加1,同时保证BE不大于macMacBE。在slotted CSMA-CA系统里MAC子层会将CW重置为2。如果NB的值小于等于macMaxCSMABackoffs, CSMA-CA算法会返回步骤(2)。如果NB大于macMacCSMABackoffs,CSMA-CA算法将以信道接入失败的状态终止。
If the channel is assessed to be idle [step (5)], the MAC sublayer in a slotted CSMA-CA system shall
ensure that the contention window has expired before commencing transmission.
To do this, the MAC sublayer shall first decrement CW by one and then determine
whether it is equal to zero. If it is not equal to zero, the CSMA-CA algorithm
shall return to step (3). If it is equal to zero, the MAC sublayer shall begin transmission
of the frame on the boundary of the next backoff period. If the channel is
assessed to be idle in an unslotted CSMA-CA system, the MAC sublayer shall
begin transmission of the frame immediately.
若果信道接入空闲,在slotted CSMA-CA系统里MAC子层将保证竞争窗口在传输开始前结束。为了做到这点,MAC子层首先将CW减1并比较是否等于0.若果不等于0,CSMA-CA算法将返回步骤3.如果等于0,MAC子层将在下一个backoff周期前传输这一帧。如果在一个unslotted系统里信道空闲,MAC子层立即开始帧传输。