From owner-freebsd-wireless@freebsd.org Wed Sep 16 22:43:21 2020 Return-Path: Delivered-To: freebsd-wireless@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EB4443F3E35 for ; Wed, 16 Sep 2020 22:43:21 +0000 (UTC) (envelope-from james.wright@digital-chaos.com) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.24]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mout.kundenserver.de", Issuer "TeleSec ServerPass Class 2 CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BsFVw5qZcz4PNc for ; Wed, 16 Sep 2020 22:43:20 +0000 (UTC) (envelope-from james.wright@digital-chaos.com) Received: from [192.168.0.12] ([82.29.153.121]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.179]) with ESMTPSA (Nemesis) id 1M4sD3-1kJV5e3itT-0022W2; Thu, 17 Sep 2020 00:43:18 +0200 Subject: Re: Edimax EW-7811Un (rtwn): Slow speeds / rate control To: Adrian Chadd Cc: "freebsd-wireless@freebsd.org" References: From: James Wright Message-ID: <31c36c34-f1aa-3d4d-ccd3-3d76dc9bf69e@digital-chaos.com> Date: Wed, 16 Sep 2020 23:43:18 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:FUB1m2dcUNPgmhmjnUYhg4YGqf/Fu0YpjTTCccaGh/vsvE30gel PZWZvy+geEzHEKc1RPNpHeZBCzxHvuoBFNnju2+rlWnqhmp5cAo0gzXMO5QXAgsjexcL9IV KYa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Queue-Id: 4BsFVw5qZcz4PNc X-Spamd-Bar: + Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of james.wright@digital-chaos.com has no SPF policy when checking 212.227.17.24) smtp.mailfrom=james.wright@digital-chaos.com X-Spamd-Result: default: False [1.32 / 15.00]; TO_DN_EQ_ADDR_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; FREEMAIL_TO(0.00)[gmail.com]; RECEIVED_SPAMHAUS_PBL(0.00)[82.29.153.121:received]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:8560, ipnet:212.227.0.0/16, country:DE]; MID_RHS_MATCH_FROM(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; NEURAL_SPAM_SHORT(0.16)[0.161]; NEURAL_HAM_LONG(-0.11)[-0.111]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[digital-chaos.com]; AUTH_NA(1.00)[]; NEURAL_SPAM_MEDIUM(0.37)[0.368]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[212.227.17.24:from]; R_SPF_NA(0.00)[no SPF record]; RWL_MAILSPIKE_POSSIBLE(0.00)[212.227.17.24:from]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-wireless] X-BeenThere: freebsd-wireless@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "Discussions of 802.11 stack, tools device driver development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2020 22:43:22 -0000 On 16/09/2020 22:36, Adrian Chadd wrote: > > > On Wed, 16 Sep 2020 at 13:41, James Wright > wrote: > > Hi wireless gurus, > >     I'm trying to understand why this USB wifi dongle is so slow under FreeBSD. > The max real-world download rate seems to be capped at ~900KB/sec (see wget below), > but with exactly the same hardware and conditions under Win10 I reach ~3MB/sec. > > > OS:       FreeBSD 12.2-PRERELEASE (r365055) > Router:   Virgin Media SuperHub 3 (802.11a/b/g/n/ac) > Hardware: Edimax EW-7811Un (RTL8188CUS) > Driver:   rtwn > > % grep wlan /etc/rc.conf > wlans_rtwn0="wlan0" > ifconfig_wlan0="WPA SYNCDHCP" > create_args_wlan0="country GB > > % dmesg | grep rtwn > rtwn0 on uhub0 > rtwn0: on usbus0 > rtwn0: MAC/BB RTL8188CUS, RF 6052 1T1R > > % sysctl dev.rtwn > dev.rtwn.0.rx_buf_size: 24 > dev.rtwn.0.ratectl_selected: 1 > dev.rtwn.0.ratectl: 1 > dev.rtwn.0.hwcrypto: 1 > dev.rtwn.0.debug: 0 > dev.rtwn.0.ht40: 0 > dev.rtwn.0.%parent: uhub0 > dev.rtwn.0.%pnpinfo: vendor=0x7392 product=0x7811 devclass=0x00 devsubclass=0x00 devproto=0x00 sernum="00e04c000001" > release=0x0200 mode=host intclass=0xff intsubclass=0xff intprotocol=0xff > dev.rtwn.0.%location: bus=0 hubaddr=1 port=1 devaddr=2 interface=0 ugen=ugen0.2 > dev.rtwn.0.%driver: rtwn > dev.rtwn.0.%desc: Realtek 802.11n WLAN Adapter, class 0/0, rev 2.00/2.00, addr 1 > dev.rtwn.%parent: > > % ifconfig wlan0 > wlan0: flags=8843 metric 0 mtu 1500 >          ether 74:da:38:8b:e1:10 >          inet 192.168.0.12 netmask 0xffffff00 broadcast 192.168.0.255 >          groups: wlan >          ssid VM5909357 channel 6 (2437 MHz 11g ht/20) bssid c0:05:c2:57:8d:69 >          regdomain ETSI country GB authmode WPA2/802.11i privacy ON >          deftxkey UNDEF AES-CCM 2:128-bit AES-CCM 3:128-bit txpower 30 bmiss 7 >          scanvalid 60 protmode CTS ht20 ampdulimit 64k ampdudensity 8 shortgi >          -stbc -ldpc wme roaming MANUAL >          media: IEEE 802.11 Wireless Ethernet MCS mode 11ng >          status: associated >          nd6 options=29 > > % ifconfig wlan0 scan > SSID/MESH ID                      BSSID              CHAN RATE    S:N     INT CAPS > VM5909357                         c0:05:c2:57:8d:69    6   54M  -78:-95   100 EPS  HTCAP WME ATH RSN > > % ifconfig wlan0 list sta > ADDR               AID CHAN RATE RSSI IDLE  TXSEQ  RXSEQ CAPS FLAG > c0:05:c2:57:8d:69    1    6  65M 21.5    0  28562   4816 EPS  AQEHTRs HTCAP WME ATH RSN (rssi 0.0:0.0:0.0:0.0 nf > 0:0:0:0) > > % wget https://download.freebsd.org/ftp/releases/amd64/amd64/ISO-IMAGES/12.1/FreeBSD-12.1-RELEASE-amd64-dvd1.iso > FreeBSD-12.1-RELEASE-amd64-dvd1.iso > > 0%[                                       ]  19.05M   947KB/s    eta 79m 18s > > > % wlandebug +rate > $ dmesg > wlan0: [c0:05:c2:57:8d:69] AMRR: current rate 6, txcnt=11, retrycnt=6 > wlan0: [c0:05:c2:57:8d:69] AMRR decreasing rate 5 (txcnt=11 retrycnt=6) > wlan0: [c0:05:c2:57:8d:69] AMRR: current rate 5, txcnt=36, retrycnt=1 > wlan0: [c0:05:c2:57:8d:69] AMRR increasing rate 6 (txcnt=36 retrycnt=1) > wlan0: [c0:05:c2:57:8d:69] AMRR: current rate 6, txcnt=37, retrycnt=7 > wlan0: [c0:05:c2:57:8d:69] AMRR: current rate 6, txcnt=36, retrycnt=9 > wlan0: [c0:05:c2:57:8d:69] AMRR: current rate 6, txcnt=36, retrycnt=2 > wlan0: [c0:05:c2:57:8d:69] AMRR increasing rate 7 (txcnt=36 retrycnt=2) > wlan0: [c0:05:c2:57:8d:69] AMRR: current rate 7, txcnt=36, retrycnt=5 > wlan0: [c0:05:c2:57:8d:69] AMRR: current rate 7, txcnt=36, retrycnt=5 > wlan0: [c0:05:c2:57:8d:69] AMRR: current rate 7, txcnt=37, retrycnt=12 > wlan0: [c0:05:c2:57:8d:69] AMRR: current rate 7, txcnt=36, retrycnt=7 > wlan0: [c0:05:c2:57:8d:69] AMRR: current rate 7, txcnt=36, retrycnt=10 > > As you can see the MCS rate is being set by wlan_amrr to MCS 6 and 7, but the actual real-world download rate > remains firmly stuck at around ~900KB/sec (!) > > Please could someone with knowledge of the FreebSD wifi stack help diagnose this problem with me? > > > hi! > > You can experiment with limiting the unicast rate - eg ifconfig wlan0 ucastrate 3 for MCS3 when it's in 11n mode. > > AMRR isn't the best at all at 802.11n rate selection. It may just be over-estimating how great the channel is behaving. > > However, that's just the transmit rate control. The remote end (ie the sender) is making choices on what rate to use > when transmitting to you. So let's see if we can first limit bad choices (and thus taking up too much airtime) > transmitting data BACK, and then we can figure out what's up with download speeds. > > > > -adrian > Hi Adrian, thanks for your time and the explanation, much appreciated! I tried setting ucastrate 3 and it made no difference to the download rate; % ifconfig wlan0 wlan0: flags=8843 metric 0 mtu 1500 ether 74:da:38:8b:e1:10 inet 192.168.0.12 netmask 0xffffff00 broadcast 192.168.0.255 groups: wlan ssid VM5909357 channel 6 (2437 MHz 11g ht/20) bssid c0:05:c2:57:8d:69 regdomain ETSI country GB authmode WPA2/802.11i privacy ON deftxkey UNDEF AES-CCM 2:128-bit AES-CCM 3:128-bit txpower 30 bmiss 7 ucastrate 3 scanvalid 60 protmode CTS ht20 ampdulimit 64k ampdudensity 8 shortgi -stbc -ldpc wme roaming MANUAL media: IEEE 802.11 Wireless Ethernet MCS mode 11ng status: associated nd6 options=29 % wget https://download.freebsd.org/ftp/releases/amd64/amd64/ISO-IMAGES/12.1/FreeBSD-12.1-RELEASE-amd64-dvd1.iso FreeBSD-12.1-RELEASE-amd64-dvd1.iso. 0%[ ] 8.87M 806KB/s eta 81m 35s