The MAC layer is implemented in every 802.11 station, and enables the station to establish a network or join a pre-existing network and to transmit data passed down by Logical Link Control (LLC). These functions are delivered using two classes of services, station services and distribution system services, which are implemented by the transmission of a variety of management, control and data frames between MAC layers in communicating stations.
Before these MAC services can be invoked, the MAC first needs to gain access to the wireless medium within a BSS, with potentially many other stations also competing for access to the medium. The mechanisms to efficiently share access within a BSS are described in the next section.
Wireless Media Access
Sharing media access among many transmitting stations in a wireless network is more complex to achieve than in a wired network. This is because a wireless network station is not able to detect a collision between its transmission and the transmission from another station, since a radio transceiver is unable both to transmit and to listen for other stations transmitting at the same time.
In a wired network a network interface is able to detect collisions by sensing the carrier, for example the Ethernet cable, during transmission and ceasing transmission if a collision is detected.
This results in a medium access mechanism known as carrier sense multiple access/ collision detection (CSMA/CD). The 802.11 standard defines a number of MAC layer coordination functions to co-ordinate media access among multiple stations.
Media access can either be contention-based, as in the mandatory 802.11 distributed coordination function (DCF), when all stations essentially compete for access to the media, or contention free, as in the optional 802.11 point coordination function (PCF), when stations can be allocated specific periods during which they will have sole use of the media.
The media access method used by the distributed coordination function is carrier sense multiple access/collision avoidance (CSMA/CA), illustrated in Figure below.
In this mode a station that is waiting to transmit will sense the medium on the channel being used and wait until the medium is free of other transmissions. Once the medium is free, the station waits a predetermined period (the distributed inter-frame spacing or DIFS).
If the station senses no other transmission before the end of the DIFS period, it computes a random backoff time, between parameter values Cwmin and Cwmax, and commences its transmission if the medium remains free after this time has elapsed.
The contention window parameter Cw is specified in terms of a multiple of a slot time that is 20 μs for 802.11b or 9 μs for 802.11a/g networks. The backoff time is randomised so that, if many stations are waiting, they will not all try again at the same time — one will have a shorter backoff and will succeed in starting its transmission.
If a station has to make repeated attempts to transmit a packet, the computed backoff period is doubled with each new attempt, up to a maximum value Cwmax defined for each station. This ensures that, when many stations are competing for access, individual attempts are spaced out more widely to minimise repeated collisions.
If another station is sensed transmitting before the end of the DIFS period, this is because a short IFS (SIFS) can be used by a station that is waiting either to transmit certain control frames (CTS or ACK — see Figure below) or to continue the transmission of parts of a data packet that has been fragmented to improve transmission reliability.
CSMA/CA is a simple media access protocol that works efficiently if there is no interference and if the data being transmitted across the network is not time critical. In the presence of interference, network throughput can be dramatically reduced as stations continually backoff to avoid collisions or wait for the medium to become idle.
CSMA/CA is a contention-based protocol, since all stations have to compete for access. With the exception of the SIFS mechanism noted above, no priorities are given and, as a result, no quality of service guarantees can be made.
The 802.11 standard also specifies an optional priority based media access mechanism, the point coordination function (PCF) which is able to provide contention free media access to stations with time critical requirements. This is achieved by allowing a station implementing PCF to use an interframe spacing (PIFS) intermediate between SIFS and DIFS, effectively giving these stations higher priority access to the medium.
Once the point coordinator has control, it informs all stations of the length of the contention free period, to ensure that stations do not try to take control of the medium during this period. The coordinator then sequentially polls stations, giving any pollable station the opportunity to transmit a data frame.
Although it provides some limited capability for assuring quality of service, the PCF function has not been widely implemented in 802.11 hardware and it is only with the 802.11e enhancements, that quality of service (QoS) and prioritised access are more comprehensively incorporated into the 802.11 standard.
Discovering and Joining a Network
The first step for a newly activated station is to determine what other stations are within range and available for association. This can be achieved by either passive or active scanning. In passive scanning the new station listens to each channel for a predetermined period and detects beacon frames transmitted by other stations.
The beacon frame will provide a time synchronisation mark and other PHY layer parameters, such as frequency hopping pattern, to allow the two stations to communicate. If the new station has been set up with a preferred SSID name for association, it can use active scanning by transmitting a Probe frame containing this SSID and waiting for a Probe Response frame to be returned by the preferred access point.
A broadcast Probe frame can also be sent, requesting all access points within range to respond with a Probe Response. This will provide the new station with a full list of access points available. The process of authentication and association can then start — either with the preferred access point or with another access point selected by the new station or by the user from the response list.
MAC layer station services provide functions to send and receive data units passed down by the LLC and to implement authentication and security between stations, as described in list below.
- Authentication - This service enables a receiving station to authenticate another station prior to association. An access point can be configured for either open system or shared key authentication.
Open system authentication offers minimal security and does not validate the identity of other stations — any station that attempts to authenticate will receive authentication. Shared key authentication requires both stations to have received a secret key (e.g. a passphrase) via another secure channel such as direct user input.
- Deauthentication - Prior to disassociation, a station will deauthenticate from the station that it intends to stop communication with. Both deauthentication and authentication are achieved by the exchange of management frames between the MAC layers of the two communicating stations.
- Privacy - This service enables data frames and shared key authentication frames to be optionally encrypted before transmission, for example using wired equivalent privacy (WEP) or Wi-Fi protected access (WPA).
- MAC service data unit delivery - A MAC service data unit (MSDU) is a unit of data passed to the MAC layer by the logical link controller. The point at which the LLC accesses MAC services (at the “top” of the MAC layer) is termed the MAC service access point or SAP.
This service ensures the delivery of MSDUs between these service access points. Control frames such as RTS, CTS and ACK may be used to control the flow of frames between stations, for example in 802.11b/g mixed-mode operation.
Distribution System Services
The functionality provided by MAC distribution system services is distinct from station services in that these services extend across the distribution system rather than just between sending and receiving stations at either end of the air interface. The 802.11 distribution system services are described in list below.
- Association - This service enables a logical connection to be made between a station and an access point. An access point cannot receive or deliver any data until a station has associated, since association provides the distribution system with the information necessary for delivery of data.
- Disassociation - A station disassociates before leaving a network, for example when a wireless link is disabled, the network interface controller is manually disconnected or its host PC is powered down.
- Reassociation - The reassociation service allows a station to change the attributes (such as supported data rates) of an existing association or to change its association from one BSS to another within an extended BSS. For example, a roaming station may change its association when it senses another access point transmitting a stronger beacon frame.
- Distribution - The distribution service is used by a station to send frames to another station within the same BSS, or across the distribution system to a station in another BSS.
- Integration - Integration is an extension of distribution when the access point is a portal to a non-802.11 network and the MSDU has to be transmitted across this network to its destination. The integration service provides the necessary address and media specific translation so that an 802.11 MSDU can be transmitted across the new medium and successfully received by the destination device’s non-802.11 MAC.