## 2 IEEE 802.15.4  
The IEEE 802.15.4 [1] is a standard that specifies the physical (PHY) and medium access control (MAC) layers for low-rate wireless personal area networks (LR-WPANs). This standard targets typical requirements of wireless sensor networks such as low power consumption, low data rate and low cost. The physical layer specifies three operating frequency bands, providing a single channel in the 868 MHz band, 10 channels in the 915 MHz band and 16 channels in the 2.4 GHz band. Available data rates vary from 20 kbps to 250 kbps depending on the frequency band. The MAC layer provides two different modes of operation: non beacon-enabled mode and beacon-enabled mode. The non beacon-enabled mode relies on an unslotted CSMA/CA mechanism, while the beacon-enabled mode provides a slotted CSMA/CA mechanism and an optional reservation-based mechanism called guaranteed time slot (GTS). The unslotted CSMA/CA algorithm [1] is represented in Figure 1. Before accessing the channel, the device must wait for a random backoff interval defined in the range from 0 to (2\({}^{BE}\)-1) backoff periods. The backoff exponent (\(BE\)) initially takes the value _macMinBE_ and one backoff period is equal to _aUnitBackoffPeriod_ symbols. After waiting for a random interval, if the clear channel assessment (CCA) function indicates that the channel is idle, the device starts its transmission after a turnaround time delay, which is the time necessary for the radio transceiver to switch from receive state to the transmit state. If the channel is busy, the device defers its transmission and increments the number of transmission attempts for the current packet (\(NB\)). \(BE\) is also incremented if it has not reached its maximum value, _aMaxBE_. If the maximum number of transmission attempts, _macMaxCSMAbackoffs_,was not reached, a new backoff interval is determined; otherwise, the algorithm declares a channel access failure. The unslotted CSMA/CA parameters are specified in Table 1.  
The beacon-enabled mode imposes the use of a superframe structure delimited by two consecutive beacons, being composed by an active and an inactive portion. An example of the superframe structure is presented in Figure 2. The attribute _macSuperframeOrder_ (_SO_) defines the duration of the active period, which is called Superframe Duration (_SD_), while the attribute _macBeaconOrder_ (_BO_) defines the Beacon Interval (_BI_). The minimum length of the superframe (_aBaseSuperframeDuration_) corresponds to 960 symbols and \(0\leq SO\leq BO\leq 14\). The active portion of the superframe is composed by a beacon frame, a Contention Access Period (CAP) and a Contention Free Period (CFP). The slotted CSMA/CA scheme is used during the CAP and the GTS scheme is used during the CFP. The minimum length of the CAP is given by _aMinCAPLength_ = 440 symbols. \begin{table}
\begin{tabular}{|l|l|c|} \hline
**Parameter** & **Description** & **Value** \\ \hline _macMinBE_ & The minimum value of the & [0–3], default = 3 \\  & backoff exponent & [0–3], default = 3 \\ \hline _aUnitBackoffPeriod_ & The length of the backoff & \\  & period. & 20 symbols \\ \hline _aMaxBE_ & The maximum value of the & \\  & backoff exponent & 5 \\ \hline _macMaxCSMAbackoffs_ & The maximum number of & \\  & backoff periods & [0–5], default = 4 \\ \hline \end{tabular}
\end{table} 
Table 1: Unslotted CSMA/CA parameters. Figure 1: Unslotted CSMA/CA algorithm. The GTS scheme aims to provide some level of quality of service (QoS) support for applications requiring bounded delay or bandwidth guarantees. However, only a maximum of seven GTS allocations are allowed. The active portion of the superframe is divided into 16 slots and a GTS allocation can take an integer number of these slots. In the example of Figure 2, a GTS allocation of three slots and another of two slots are shown. The process of slot allocation in the CFP starts with the transmission of a GTS request command, from the device to the PAN coordinator.