macos 为什么要在发送 ACK 之前等待 SIFS 时间?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2030606/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why wait SIFS time before sending ACK?
提问by Omega
Question about the MAC-protocol of 802.11 Wifi.
关于 802.11 Wifi 的 MAC 协议的问题。
We have learned that when a station has received the data it waits for SIFS time. Then it sends the packet. When searching online the reason that is always mentioned is to give ACK packets a higher priority. This is understandable since a station first has to wait DIFS time when it wants to send normal data (and DIFS is larger than SIFS).
我们已经了解到,当一个站收到数据时,它会等待 SIFS 时间。然后它发送数据包。在网上搜索时,总是提到的原因是给 ACK 数据包更高的优先级。这是可以理解的,因为当一个站点想要发送正常数据时,它首先必须等待 DIFS 时间(并且 DIFS 大于 SIFS)。
But why wait at all? Why not immediately send the ACK? The station knows the data has arrived and the CRC is correct, so why wait?
但为什么要等呢?为什么不立即发送ACK?站知道数据已经到达并且CRC是正确的,那么为什么要等待呢?
采纳答案by Aidan Cully
It is theoretically possible to know that the CRC is correct at the exact end of the received data from the wire, but in practice, you need to accumulate all the samples in the last block in order to run the IFFT, deconvolution, FEC, and then, finally, at the very end, after finally getting the input data out of the waveform, do you know that the CRC is correct. Also, you sometimes need to turn on transmit circuitry to send the ACK, which can hamper receive performance. If each step in the processing chain were instantaneous, and if the transmit circuitry definitely didn't interfere with the receive circuitry, and if there were no lead-time necessary for building the waveform for the ACK, it'd be possible to send the ACK immediately after getting the last bit of the wave-form. But, while each element in this chain takes some deterministic time, it is not instantaneous. SIFS gives the receiver time to get the data from the PHY, verify it, and send the response.
理论上可以知道 CRC 在从线路接收到的数据的确切末尾是正确的,但实际上,您需要累加最后一个块中的所有样本,以便运行 IFFT、解卷积、FEC 和然后,最后,最后,在最终从波形中取出输入数据后,您知道CRC是否正确。此外,您有时需要打开发送电路来发送 ACK,这可能会影响接收性能。如果处理链中的每个步骤都是瞬时的,并且如果发送电路绝对不会干扰接收电路,并且如果没有为 ACK 构建波形所需的提前时间,则可以发送获得波形的最后一位后立即确认。但,虽然这个链中的每个元素都需要一些确定的时间,但它不是即时的。SIFS 为接收器提供了从 PHY 获取数据、验证数据并发送响应的时间。
Disclaimer: I'm more familiar with Homeplug than 802.11.
免责声明:与 802.11 相比,我更熟悉 Homeplug。
回答by Christian V
It is like that because Distributed Coordination Function (DCF) and Point Coordination Function (PCF) mode can coexistwithin one cell. That is a base station may use polling while at the same time the cell can use disitributed coordination using CSMA/CA.
之所以这样,是因为分布式协调功能(DCF)和点协调功能(PCF)模式可以在一个小区内共存。即基站可以使用轮询,同时小区可以使用使用 CSMA/CA 的分布式协调。
So during SIFS, control frames or next fragment may be sent. During PIFS, PCF frames may be sent and during DIFS DCF frames may be sent. During SIFS and PIFS, PCF can work its magic.
因此在 SIFS 期间,可能会发送控制帧或下一个片段。在 PIFS 期间,可以发送 PCF 帧,在 DIFS 期间可以发送 DCF 帧。在 SIFS 和 PIFS 期间,PCF 可以发挥其魔力。
Even though not all base stations support PCF all stations must wait since some may support it.
尽管并非所有基站都支持 PCF,但所有基站都必须等待,因为有些基站可能支持它。
Update:
更新:
The way I understand this now is that during SIFS the station may send RTS,CTS or ACK and have enough time to switch back to receiving mode before the sender starts to transmit. If that's correct, it will send ACK during SIFS. Then it will change to receive mode and wait until SIFS elapses. When SIFS has elapsed the transmitter will start sending.
我现在理解的方式是,在 SIFS 期间,站点可能会发送 RTS、CTS 或 ACK,并且有足够的时间在发送方开始传输之前切换回接收模式。如果这是正确的,它将在 SIFS 期间发送 ACK。然后它将更改为接收模式并等待 SIFS 过去。当 SIFS 过去后,发送器将开始发送。
Also, PCF is controlled by PIFS which comes after SIFS and before DIFS and is therefor not relevant for this discussion (my mistake). That is, SIFS < PIFS < DIFS < EIFS.
此外,PCF 由 SIFS 之后和 DIFS 之前的 PIFS 控制,因此与本次讨论无关(我的错误)。也就是说,SIFS < PIFS < DIFS < EIFS。
Sources: This PDF (page 8)and Computer Networks by Andrew S. Tanenbaum
回答by Venki
SIFS = RTT (based on PHY Transmission rate) + FRAME PROCESSING DELAY AT RECEIVER (PHY PROCESSING DELAY + MAC PROCESSING DELAY) + FRAME PROCESSING DELAY (FOR COMPOSING RESPONSE CTS/ACK)+ RF TUNER DELAY (CHANGE FROM RX to TX)
SIFS = RTT(基于 PHY 传输速率)+ 接收器处的帧处理延迟(PHY 处理延迟 + MAC 处理延迟)+ 帧处理延迟(用于组合响应 CTS/ACK)+ RF 调谐器延迟(从 RX 到 TX)
A the Transmitter side, after last PHY Symbol (of RTS, e.g), the time required to change to RX mode (at RF). So, I would see SIFS as a RX side calculation than a TX side.
A 发送端,在最后一个 PHY 符号(例如 RTS)之后,更改为 RX 模式(在 RF 处)所需的时间。因此,我会将 SIFS 视为 RX 端计算而不是 TX 端计算。
回答by paxdiablo
I can't say for sure but it sounds like an optimization strategy similar to IP. If you don't require an ACK for everydata packet, it makes sense to hold off for a bit so that, if more data packets arrive, you can acknowledge them all with a single ACK.
我不能肯定,但这听起来像是一种类似于 IP 的优化策略。如果您不需要对每个数据包都使用 ACK ,那么推迟一点是有意义的,这样,如果有更多数据包到达,您可以使用单个 ACK 确认所有这些数据包。
Example: client sends 400 packets reallyfast to the server. Rather than the server sending back 400 ACKs, it can simply wait until the client takes a breather before sending a single ACK back. Combined with the likelihood that the client willtake a breather even under heavy load (it has to as its unacknowledged-packets buffer fills up), this would be workable.
示例:客户端非常快速地向服务器发送 400 个数据包。不是服务器发回 400 个 ACK,它可以简单地等待客户端喘口气,然后再发回单个 ACK。结合客户端即使在重负载下也会喘口气的可能性(它必须在其未确认的数据包缓冲区填满时),这将是可行的。
This is possible in systems where the ACK(n)
means "I've received everything up to and including packet # n
.
这在系统中是可能的,其中的ACK(n)
意思是“我已经收到了包括数据包 # 在内的所有内容n
。
You'll get better performance and less traffic by using such a strategy. As long as the wait-before-sending-ack time on the receiver is less than the retransmit-if-no-ack-before time on the sender (taking transmission delays into account), there should be no problem.
通过使用这样的策略,您将获得更好的性能和更少的流量。只要接收端的wait-before-sending-ack时间小于发送端的retransmit-if-no-ack-before时间(考虑传输延迟),应该没有问题。
回答by Enginnerd
Quick crash-course on 802.11:
802.11 快速速成课程:
802.11 is a essentially a giant system of timers. The most common implementations of 802.11 utilize the distributed coordination function, DCF. The DCF allows for nodes to come in and out of the range of a radio channel being used for 802.11 and coordinate in a distributed fashion who should be sending and receiving data (ignoring hidden and exposed node problems for this discussion). Before any node can begin sending data on the channel they all must wait a period of DIFS, in which the channel is determined to be idle, if it is idle during a DIFS period the first node to grab the channel begins transmitting. In standard 802.11, i.e. non-802.11e implementations and non 802.11n, every single data packet that gets transmitted needs to be acknowledged by a physical layer, PHY, acknowledgment packet, irregardless of the upper layer protocol being used. After a data packet gets sent a SIFS time period needs to expire, after SIFS expires control frames destined for the node that has "taken" control of the channel may be sent, in this instance and acknowledgment frame is transmitted. SIFS allows the node that sent the data packet to switch from transmitting to receiving mode. If a packet does get lost and no ACK is received after SIFS/ACK timeout occurs, then exponential back-off is invoked. Exponential back-off, a.k.a contention window (CW), begins at a value CWmin, in some linux implementation this is 15 slot times, where a slot time varies depending on the 802.11 protocol that is being used. The CW value is then chosen from 1 to whatever the upper limit that has been calculated for CW. If the current packet was lost, then the CW is incremented from 15 to 30, and then a random value is chosen between 1 and 30. Every-time there is a consecutive lose the CW doubles up to 1023, at which point it hits a limit. Once a packet is received successfully the CW is reset back to CWmin.
802.11 本质上是一个巨大的计时器系统。802.11 最常见的实现利用分布式协调功能 DCF。DCF 允许节点进出用于 802.11 的无线电信道的范围,并以分布式方式协调谁应该发送和接收数据(在本讨论中忽略隐藏和暴露的节点问题)。在任何节点可以开始在信道上发送数据之前,它们都必须等待一段 DIFS 时间,在此期间确定信道空闲,如果在 DIFS 时间段内空闲,则第一个抢占信道的节点开始传输。在标准 802.11 中,即非 802.11e 实现和非 802.11n,传输的每个数据包都需要通过物理层、PHY、确认包进行确认,不管使用的上层协议如何。在发送数据包后,SIFS 时间段需要到期,在 SIFS 到期后,可以发送发往“取得”信道控制权的节点的控制帧,在这种情况下,发送确认帧。SIFS 允许发送数据包的节点从发送模式切换到接收模式。如果数据包确实丢失并且在 SIFS/ACK 超时发生后没有收到 ACK,则调用指数退避。指数退避,又名争用窗口 (CW),从值 CWmin 开始,在某些 linux 实现中,这是 15 个时隙,其中时隙根据所使用的 802.11 协议而变化。然后从 1 到为 CW 计算的任何上限选择 CW 值。如果当前数据包丢失,然后 CW 从 15 增加到 30,然后在 1 到 30 之间选择一个随机值。每次连续丢失时,CW 都会加倍增加到 1023,此时它会达到一个限制。一旦成功接收到数据包,CW 将重置回 CWmin。
In regards to 802.11n / 802.11e: Every data packet still needs to be acknowledged, but when using 802.11e (implemented into 802.11n) multiple data packets can be aggregated together in two different ways A-MSDU or A-MPDU. A-MSDU is a jumbo-frame that has one checksum for the entire aggregated packet being sent, within it are many sub-frames that contain each of the data frames that needed to be sent. If there is any error in the A-MSDU frame and it needs to be retransmitted, then every sub-frame is required to be resent. However, when using A-MPDU, each sub-frame has a small header and checksum that allow for any sub-frame that has an error in it to be retransmitted by itself/within another aggregated frame the next time the sending nodes gains the channel. With these aggregated packet sending schemes there is the notion of the block-ack. The block-ack contains a bitmap of the frames from a starting sequence number that were just sent in the aggregated packet and received correctly or incorrectly. Usage of aggregated frame sending greatly improves throughput performance as more data can be sent per channel acquisition by a sending node, also allowing out-of-order packet sending. However, out-order packet sending greatly complicates the 802.11 MAC layer.
关于 802.11n / 802.11e:每个数据包仍然需要被确认,但是当使用 802.11e(在 802.11n 中实现)时,可以以两种不同的方式将多个数据包聚合在一起 A-MSDU 或 A-MPDU。A-MSDU 是一个巨型帧,它对正在发送的整个聚合数据包有一个校验和,其中有许多子帧,其中包含需要发送的每个数据帧。如果A-MSDU帧有错误需要重发,则每个子帧都需要重发。然而,当使用 A-MPDU 时,每个子帧都有一个小的报头和校验和,允许任何有错误的子帧在下次发送节点获得信道时由它自己/在另一个聚合帧内重传. 在这些聚合的数据包发送方案中,存在块确认的概念。块确认包含来自起始序列号的帧的位图,这些帧刚刚在聚合数据包中发送并正确或不正确地接收。使用聚合帧发送极大地提高了吞吐量性能,因为发送节点可以在每个通道采集中发送更多数据,还允许无序发送数据包。然而,乱序发送使 802.11 MAC 层变得非常复杂。
回答by Amar Shekhar
SIFS=D+M+Rx/Tx
SIFS=D+M+Rx/Tx
Where,
在哪里,
D=(Receiver delay (RF delay) and decoding of physical layer convergence procedure (PLCP) preamble/header)
D=(接收器延迟(RF 延迟)和物理层收敛程序(PLCP)前导码/报头的解码)
M=(MAC processing delay)
M=(MAC处理延迟)
Rx/Tx=(transceiver turnaround time)
Rx/Tx=(收发器周转时间)
Above all the delays can not be avoided so It has to wait SIFS time before sending acknowledgement
最重要的是,延迟是无法避免的,因此在发送确认之前必须等待 SIFS 时间