路由器RTS参数实验

年前在家,发现所有的设备都会时不时地遇到网速极慢的情况。一番排查后发现,问题来自华硕的黑科技——Smart Connect 三频合一功能。每当路由器觉得某个客户端的信号不好时,就会主动把它踢到 2.4G 频道上面去;而由于邻居的路由器信号过强,我家中的无线电环境——尤其是 2.4G 频道——十分的错综复杂。过强的干扰往往会降低信噪比,增加冲突的可能性。在网上一番搜查后,我发现了一种看似很高深的说法——降低路由器的 RTS 值即可提升路由器在强干扰环境中的性能。我首先搜索了一番什么是 RTS。Wikipedia 是这么说的:

This protocol was designed under the assumption that all nodes have the same transmission ranges, and does not solve the hidden terminal problem. The RTS/CTS frames can cause a new problem called the exposed terminal problem in which a wireless node that is nearby, but is associated with another access point, overhears the exchange and then is signaled to back off and cease transmitting for the time specified in the RTS.

RTS/CTS is an additional method to implement virtual carrier sensing in carrier sense multiple access with collision avoidance (CSMA/CA). By default, 802.11 relies on physical carrier sensing only, which is known to suffer from the hidden node problem.

The RTS/CTS packet size threshold is 0–2347 octets. Typically, sending RTS/CTS frames does not occur unless the packet size exceeds this threshold. If the packet size that the node wants to transmit is larger than the threshold, the RTS/CTS handshake gets triggered. Otherwise, the data frame gets sent immediately.

IEEE 802.11 RTS/CTS mechanism could help solve exposed node problem as well, only if the nodes are synchronized and packet sizes and data rates are the same for both the transmitting nodes. When a node hears an RTS from a neighboring node, but not the corresponding CTS, that node can deduce that it is an exposed node and is permitted to transmit to other neighboring nodes.[1] If the nodes are not synchronized (or if the packet sizes are different or the data rates are different) the problem may occur that the exposed node will not hear the CTS or the ACK during the transmission of data of its neighbor.

——摘自Wikipedia

简单的来说,RTS/CTS 机制是用来减少无线信道中的冲突的。在经典的“隐藏终端”问题中,基站A向基站B发送了数据,而基站C并未侦测到基站A的存在(这可能是基站的位置分布导致的),也向基站B发送了数据,最后基站A和基站C的数据同时到达基站B,导致所有的数据都丢失了。RTS/CTS 机制则相当于要求所有基站在发送数据前先要说一声“我要发数 据了”,也就是 Request To Send (RTS);而接受数据的基站会在信道变空闲后回复“你可以发数据了”,也就是 Clear To Send (CTS)。这样就多了一步握手的协议,确保了之前那样的冲突不会发生。

路由器中的 RTS 门槛说的是同一个东西。RTS 门槛是一个位于 0-2347 之间的整数。它的意思是,发送大小大于这个值的封包前需要进行 RTS/CTS 机制。如果设置成 0,就意味着总是进行 RTS/CTS 机制;如果设置成 2347,那么就意味着从不进行 RTS/CTS 机制,因为以太网的最大封包大小是 1518 字节(参考文章)。我的路由器中的默认值便是 2347,如图:

那么改变 RTS 门槛的值,到底会不会提升 2.4G WiFi 的性能呢?我决定实际测试一下。为了测试的科学性,我关闭了两个 5G 频道、断开了无关设备的连接、仅将两台测试电脑连接到了 2.4G 频道上。接着,我在不同的 RTS 门槛下,运行相同的网络性能测试。我设置的测试含有 3 条 1M 封包的线程和 3 条 500K 封包的线程,每个线程发送 100M 数据。

RTS 门槛=2347:

RTS 门槛=2200:

RTS 门槛=2000:

RTS 门槛=1800:

RTS 门槛=1600:

RTS 门槛=1400:

RTS 门槛=1200:

RTS 门槛=1000:

RTS 门槛=800:

RTS 门槛=600:

RTS 门槛=0:

分析一下这些数据点,做了个简单的统计:

横轴是 RTS 门槛值,纵轴是带宽和响应时间。我发现,不同的 RTS 门槛值对于无线网络的性能几乎没有影响。当然由于我没有进一步地去测试 0-600 这个值域,可能在这个值域中,网络性能会表现出某种规律。但是,至少基于现有的测试结果,我可以认为降低 RTS 门槛的值无法提升网络性能。关闭 Smart Connect,或许是一个更为有效的办法。