802.11 MAC -- What is DCF and how it works

Distributed Coordination Function (DCF)

802.11 Distributed Coordination Function 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.
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 timer has expired, it 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 response with a clear to send (CTS) if it is available to receive data.

802.11 Distributed Coordination Function (DCF) maximizes throughput while preventing packet collisions. When the source receives the CTS, it will transmit its data. Along with both the RTS and CTS, a network allocation vection (NAV) is transmitted. After correct reception of the data, the destination will transmit an acknowledgment (ACK) back to the sender. At this point, if the sender has more data to transmit, it will again begin its backoff and repeat the process. This process is demonstrated in above figure.

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 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 DIFS, this ensure 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.

** Now let us see how a station transmits packets, what is the work flow? **


If a node wants to send a packet:

  1. Sense the channel whether it is idle. If yes, It wait a DIFS
  2. Then wait a random backoff time
  3. If the channel is still free, send the packet
  4. Continue to wait SIFS, after receive the ACK, release the channel.

** What happens if another node wants to send a packet? **

For example, when Mira also wants to send a packet to Arnold:

  1. It senses the channel is busy, so it waits until the transmission is finished
  2. When the channel is idle, it waits a DIFS,
  3. If it is still idle after DIFS, waits a random backoff time within contention window
  4. If it is still idle, send the packet

** What happens when collsion occurs? **

collision
  1. Both Sue and Mira are preparing to send packets to Arnold, they wait a DIFS and a random backoff time.
  2. Unfortunately, they send packets at the same time because of different start time of DIFS and backoff time. Collsion occurs, but they don't know and they still wait a SIFS. Only Arnold senses the collision, so it doesn't response with ACK.
  3. When SIFS times out, both Sue and Mira don't receive the ACK, so they wait a random backoff time and retransit again. This time Mira's backoff time is shorter and get the higher priority to send the packet.

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 knows that they have no need to sensing the channel for the time indicated. Since idle sensing of the channel is the biggest use of the energy in the 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 countdown reaches 0, the node will sense the channel and if the channel is 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 attempt to transmit at the same time. If the window is too large, the nodes may be idle for a long time before transmitting. The window size can increase by a factor of 2 if a transmission fails.

Summary

There are 2 types of carrier sensing as described above: the physical carrier sensing and virtual carrier sensing functions. If either carrier sensing function indicates that the medium is busy, the MAC reports this to higher layers.

Finally, hidden and exposed nodes are a major problem with any carrier sensing based on MAC.

** Hidden note problem **


hidden_node_problem

Station A can communicate with Station B. Station can also communicate with Station B. However, Station A and Station C can't sense each other on the network, because they are out of range of each other. So Station A and Station C may send packets simultaneously to the Station B, then collsion occurs.

** Exposed node problem **

exposed_node_problem

The exposed node problem occurs when a node is prevented from sending packets to other nodes because of a neighboring transmitter. If a transmission between S1 and R1 is taking place, node S2 is prevented from transmitting to R2 as it conculudes after carrier sense that it will interfere with the transmission by its neighbor S1. Howerver node R2 could still receive the transmission of S2 without interference because it is out of range of S1

802.11 CTS/RTS mechanism helps to solve these problems. More details refer to <<How NAV works>>
NOTE: exposed node problem is more difficult, CTS/RTS only solve this problem only if the nodes are synchronized and packet size and data rate are the same for both transmitting nodes. When a node S2 hears an RTS from a neighboring node S1, but no the corresponding CTS, that node can deduce that it is an exposed node and is permitted to transmit to other neighboring node R2.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 213,186评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,858评论 3 387
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 158,620评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,888评论 1 285
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,009评论 6 385
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,149评论 1 291
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,204评论 3 412
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,956评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,385评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,698评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,863评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,544评论 4 335
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,185评论 3 317
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,899评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,141评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,684评论 2 362
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,750评论 2 351

推荐阅读更多精彩内容