The contention window provides a buffer to prevent multiple 802.11 stations from transmitting at the same time which may lead to collisions. To prevent collisions on air – the Contention window for back-off is selected as an exponentially growing back-off counter. The contention window has a minimum and a maximum value given by CWmin and CWmax.
The contention window for back-off will start at CWmin value and proceed to the next value for setting back-off time – when there is a transmission failure
As per the 802.11-2012TM standard – the following is stated
“The CW shall take the next value in the series every time an unsuccessful attempt to transmit an MPDU causes either STA retry counter to increment, until the CW reaches the value of aCWmax.”
The Contention window is shown pictorially below
The value of time which the 802.11 station will back-off is based on the formula
Backoff Time = Random() x aSlotTime
Hence, if the current value of contention window is 31 – then a random generator picks a value between 7 (CWmin) < CW < 31 (Current CWmax) and that value is multiplied with slot-time to give the back-off time for an 802.11 station to wait before attempting transmission
At the successful transmission of a frame – the Contention window is brought back to CWmin value
Virtual Carrier Sense
In addition to the Physical Carrier sense – all stations maintain a virtual timer value. This timer is termed as Network Allocation Vector (NAV) timer. The NAV timer holds the duration value in terms of time of an on-going transmission by another 802.11 station