# Evaluation of the Effects of Hidden Node Problems in IEEE 802.15.7 Uplink Performance
## 3 IEEE 802.15.7 Overview
### MAC Layer
#### 3.3.2 Random Channel Access  
When transmitting during the CAP of the superframe, the MAC layer uses the slotted version of the random access algorithm defined in the standard. This algorithm is implemented using units of time called backoff periods, where one backoff period is equal to _aUnitBackoffPeriod_ clock cycles:  
\[aUnitBackoffPeriod=20\text{ optical clock cycles} \tag{8}\]  
Figure 6 shows the flow chart of the slotted random access algorithm used in IEEE 802.15.7, which is briefly explained next. During every frame transmission attempt, each device maintains two variables:  
* _NB_ (Number of Backoffs): counts the number of times the medium access algorithm has made a backoff--random delay--during the current transmission attempt. This variable is initialized to zero at the beginning of each new frame transmission attempt.
* _BE_ (Backoff Exponent): related to the number of backoff periods, a device shall wait before attempting to access/assess a channel. This variable is initialized to the value of macMinBE attribute.  
Access procedure begins with the initialization of NB and BE variables. Next, backoff periods in the device are aligned with the beginning of the superframe. Then, the MAC layer shall delay for a random number of complete backoff periods in the range \([0,2^{BE}-1]\). If carrier detection is enabled, the PHY layer is requested to perform the CCA (Clear Channel Assessment) function to check if the channel is idle and available to transmit. If the PHY layer evaluates that the channel is busy, the MAC layer will increase variables _NB_ and _BE_, ensuring that _BE_ does not exceed the value of _macMaxBE_ attribute. If _NB_ is less than or equal to the value of the _macMaxCSMABackoffs_ attribute, a new backoff delay will begin. If _NB_ is greater than _macMaxCSMABackoffs_, the algorithm will terminate with a channel access failure status. If the PHY layer evaluates that the channel is available--or if the CCA is not active--the frame will be transmitted. After transmitting the frame, if enabled the use of acknowledgement (ACK), the MAC layer will wait for at most macAckWaitDuration optical clocks for the corresponding ACK. In case the ACK frame is received, the ACK frame is received, _NB_ and _BE_ variables will be increased to perform a new backoff, provided that NB is not greater than _macMaxCSMABackoffs_.  
In our developed simulation model, we have added the necessary steps to the algorithm in order to verify that the maximum number of frames retransmissions limit is not exceeded, in accordance with clause number 5.1.7.5 of the standard. This clause specifies that when the ACK frame is not received, the data frame should be retransmitted, repeating this sequence up to a maximum of macMaxFrameRetries times. If a data transfer attempt fails a total of \((1+\mathit{macMaxFrameRetries})\) times, the MAC layer will finish the procedure with a frame transmission failure. To fulfill this requirement, we have added the numRetries variable, which accounts for the number of frame retransmissions, adding also the necessary steps to verify that the limit of _macMaxFrameRetries_ retransmissions is not exceeded (marked in blue color in the flow chart).