802.11 Distributed Coordination Function (DCF) is a protocol which uses carrier sensing along with a four way handshake to maximize the throughput while preventing packet collisions. A packet collision is defined as any case where a node is receiving more than one packet at a time, resulting in neither packet being correctly received. The 802.11 protocol is the most well known and widely used wireless networking protocol in real applications. Essentially, 802.11 is a carrier sensing multiple access with collision avoidance (CSMA/CA) medium access control (MAC) protocol using a direct sequence spread spectrum (DSSS) physical interface.
802.11 DCF Algorithm
The basic functionality of 802.11 is as follows. Assume that a node has data that it needs to transmit. First it will wait a random backoff time. This is a random number of time slots which is within a contention window. If at any time the node senses that another node is using the channel, it will pause its timer until the other node has finished transmitting. When the backoff time has expired, the node will “sense” the channel to determine if there is another node transmitting. If the channel is clear, it will then wait for a short time and sense the channel again. If the channel is still free, it will transmit a request to send (RTS) to the destination. The destination will respond with a clear to send (CTS) if it is available to receive data (i.e. if it is not receiving data from another node).
802.11 Carrier Sensing
In 802.11, carrier sensing is the primary method used to avoid collision. Carrier sensing is accomplished by simply measure the amount of energy received on the channel. If that energy is above a threshold, the sensing node determines that another node is currently transmitting and that it must remain silent.
Along with carrier sensing, interframe spacing is primarily used to ensure that the channel is truly free. When a node is sensing the channel, it must be free for the length of the DCF interframe spacing (DIFS) period. The short interframe spacing (SIFS) is used as the wait time between the RTS, CTS, DATA and ACK frames. Since the SIFS is always shorter than the DIFS, this ensures that another node does not incorrectly determine that the channel is idle during the handshake and that priority is given to the transmission in progress.
802.11 Network Allocation Vector
As an alternative to carrier sensing, the network allocation vector (NAV) is used to inform other nodes how long the current node will need the channel. Any nodes overhearing the NAV know that they have no need of sensing the channel for the time indicated. Since idle sensing of the channel is one of the biggest uses of energy in a network, the NAV reduces the amount of idle sensing required at any nodes which can overhear it, thus saving energy at all nodes in the network.
To provide fairness, each node which is transmitting first performs a random countdown, where the length of the countdown is within the length of the contention window. During the countdown, if the node senses that another node is transmitting, it will pause its countdown and continue at that same number after the other transmission is finished. When the countdown reaches zero, the node will sense the channel and, if the channel is still free, transmit the RTS. The range of values which can be chosen for the random backoff time is referred to as the contention window. The size of the window is very important and can change based on network conditions. If the window is too small, there is an increased chance that two nodes will attempt to transmit at the same time. If the window is too large, the nodes may be idly waiting for a long time before transmitting. The window size can increase by a factor of 2 if a transmission fails (i.e. a collision or a node which doesn’t respond to an RTS).
Finally, hidden and exposed terminals are a major problem with any carrier sensing based MAC. Briefly, a hidden terminal is a terminal which is within range of the receiving node, but not within range of the transmitting node. Even though this node’s transmissions would interfere with the communication between the sender and receiver, it can not hear the transmission from the source and therefore may transmit, causing collisions. The exposed terminal problem is where a node is within range of the sending node, but not the receiving node. This node will think that any transmission it creates will interfere with the transmission it overhears. In reality, since it is not in range of the receiver, it should be free to transmit.
802.11 uses the RTS and CTS packets described above to resolve both of these issues. If a node hears a CTS, it knows that it is in range of the receiver and therefore can not transmit without causing a collision. If a node hears an RTS but does not hear a CTS, it knows that it is an exposed terminal and is free to transmit.