The 802.11a/g wifi router is marked as 54Mbps, divided by 8, at least 6MB/s. Why is the actual speed only over 2M? Most of the explanations on the Internet are vague, so I had to take a stab at it myself, corrections are welcome.

Wifi communication takes place on a given carrier frequency band (channel), just like everyone talking in a hall, everyone’s speech interferes with others.

Why not create more channels? On the one hand, the ISM band that can be used without a license is very limited in the 2.4GHz area suitable for wireless communication; on the other hand, to ensure communication speed, the channel cannot be too narrow. In 802.11a/g (wifi protocol), the channel width is 22MHz, and 14 channels are divided (some of which are not in the ISM band in some countries). Each channel also interferes with the surrounding channels (see the figure below), which is why wireless routers have a dozen channels, but only the distant 1, 6, 11 channels can be used at the same time.

wifi-7wifi-7

Smart readers must have thought that since everyone can hear each other, then speak when you hear that no one else is speaking. This is Carrier Sense Multiple Access (CSMA) technology. But the problem is not that simple.

The first problem is, as shown in the figure below, 1, 2, 3 are lined up, 1 wants to talk to 2, at this time 3 is talking to 2, but 1 does not know this fact, 2 hears 1 and 3 at the same time, it’s all messed up. In the real world, we may have encountered such embarrassment.

wifi-2wifi-2

The second problem is that human ears and mouths are “full duplex”, that is, they can receive and send at the same time; but wireless communication has not yet achieved full duplex, that is, it can only switch between receiving and sending, and cannot hear the surrounding sound when speaking. Therefore, it is unrealistic to monitor the carrier in real time during the transmission process.

To avoid conflicts, 802.11 introduced Request to Send (RTS) and Clear to Send (CTS). In the figure below, node 1 wants to send a frame to 2, first sends an RTS frame. The nodes around 1 will be silent after hearing RTS. The target node 2 will reply with a CTS frame after receiving RTS, asking the nodes around 2 to shut up. After 1 receives CTS, it can start sending data. In order to ensure that the data can be accurately received, 2 also needs to reply with an ACK for confirmation.

wifi-1wifi-1

The switching of wireless antenna transmission and reception modes takes time, and the protocol needs to ensure that the antenna has switched from the transmission state to the reception state when the reply frame starts to be transmitted, so some frame intervals are added.

wifi-3wifi-3

Among them, SIFS (Short Interframe Space) is the interval between RTS and CTS, the interval between CTS and data frames, and the interval between data frames and ACK. To avoid conflicts, there must be a longer DIFS (Distributed Interframe Space) from the end of ACK to the start of the next frame transmission. In 802.11a OFDM PHY (Orthogonal Frequency Division Multiplexing Physical Layer), these intervals are:

  • SIFS = 16 µs
  • Slot time = 9 µs
  • DIFS = 2 x Slot time + SIFS = 34 µs
    The maximum frame length of 802.11a is 1536 bytes, which is 12288 bits, plus 6 extra bits indicating the end of error correction coding, a total of 12294 bits. According to the table below, 57 symbols are needed at a transmission speed of 54Mbps. TCP ACK has 76 bytes, plus 6 extra bits, a total of 614 bits are needed, according to the table below, 3 symbols are needed. 802.11 ACK only needs 1 symbol.

wifi-4wifi-4

Before sending real data, a Preamble must also be sent. The Preamble is used to train the receiver, letting the receiver know what kind of signal corresponds to what kind of data, which antenna to use for reception, etc. These Preambles take 20 µs to transmit. Each symbol carrying data takes 4 µs to transmit.

wifi-5wifi-5

wifi-6wifi-6

The transmission process of TCP is to first send TCP data, then reply with TCP ACK. The process of transmitting TCP data and TCP ACK respectively needs to go through DIFS, 802.11 Data, SIFS, 802.11 ACK. The following table (excerpted from [1]) calculates the time required for a TCP packet transmission.

TCP data TCP ACK
DIFS 34 µs 34 µs
802.11 Data 20 µs + 57 * 4 µs/symbol = 20 µs + 228 µs = 248 µs 20 µs + 3 * 4 µs/symbol = 20 + 12 µs = 32 µs
SIFS 16 µs 16 µs
802.11 ACK 20 µs + 1 * 4 µs/symbol = 20 µs + 4 µs = 24 µs = 24 µs
Frame exchange total 322 µs 106 µs
**Transaction Total** 428 µs
Therefore, 1000000/428 = 2336 TCP packet transmissions can be performed per second. Subtracting the 20-byte IP header and the 40-byte TCP header from 1536 bytes leaves 1476 bytes of TCP payload. This means that the data transmission rate can reach 3.45 MB/s (decimal system) or 3.29 MB/s (binary system). Considering that the TCP sliding window protocol allows sending new packets before receiving TCP ACK, the actual transmission speed may be faster.

The above rate is the theoretical rate under ideal conditions. In a real network environment,

  • The frame length of wireless networks is generally set to 1500 bytes instead of 1536 bytes;
  • The TCP sender and receiver have to compete for the use of the channel, which will increase additional control overhead;
  • If multiple devices access the same access point (AP), they have to compete for the use of the channel, not only to give up part of the channel to others, but also to increase the additional overhead of control signaling;
  • Wireless network transmission is not as stable as wired, channel interference and source movement may cause transmission errors, requiring retransmission;
  • TCP itself also has a congestion control mechanism, it is impossible to always send at the theoretical maximum rate.
    These factors combined, the measured data transmission rate is only about 2.3 MB/s (binary system). There is a big gap from 3.29M to 2.3M, which factor is more important, or what factors I have not considered, I still can’t figure it out. Welcome friends to discuss together.

References:

  1. http://www.oreillynet.com/pub/a/wireless/2003/08/08/wireless_throughput.html
  2. 802.11 Wireless Networks: The Definitive Guide

Comments

2013-08-03