When using FreeBSD on a new laptop you sometimes find out that the WiFi chip that it came with is not supported … or not yet supported in RELEASE version and support exists in CURRENT development version that you do not want to use.
This is where Realtek RTL8188CUS chip comes hand.
Its used in many appliances and products but we are interested in its small USB WiFi version that is really small.
The Realtek company even got Taiwan Green Classics Award 2011 for their 802.11b/g/n 2.4GHz 1T1R WLAN Single Chip Controller (RTL8188CE/RTL8188CUS) on 2011 year when it was introduced.
Its not very powerful as it comes with 1×1 antennas and 802.11n support – yes only single antenna. 150Mbps at most.
Its also very small and almost does not stick out of the laptop.
When connected it also gives subtle little dim light.
I will now show you how it works on FreeBSD. This is for 12.2-RELEASE version but it worked the same for 11.1-RELEASE 3 years ago.
My ThinkPad W520 laptop already has Intel 6300 with 3×3 antennas and 802.11n standard WiFi card supported by iwn(4) driver.
# sysctl net.wlan.devices net.wlan.devices: iwn0
We will now attach Realtek RTL8188CUS chip and will check whats coming in dmesg(8) command.
# dmesg (...) ugen2.3: at usbus2 rtwn0 on uhub4 rtwn0: on usbus2 rtwn0: MAC/BB RTL8188CUS, RF 6052 1T1R
… and some more information from usbconfig(8) command.
# usbconfig (...) ugen2.3: at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA) # usbconfig -d 2.3 show_ifdrv ugen2.3: at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA) ugen2.3.0: rtwn0:
Its now listed as rtwn0 as its supported by the rtwn(4) driver on FreeBSD.
# sysctl net.wlan.devices net.wlan.devices: rtwn0 iwn0
Lets connect to some wireless network with this Realtek chip. I will create wlan1 device as wlan0 is already taken by the other Intel 6300 card.
# ifconfig wlan1 create wlandev rtwn0 # ifconfig wlan1 wlan1: flags=8802<broadcast,simplex,multicast> metric 0 mtu 1500 ether 00:1d:43:21:2d:1c groups: wlan ssid "" channel 1 (2412 MHz 11b) regdomain FCC country US authmode OPEN privacy OFF txpower 30 bmiss 7 scanvalid 60 wme bintval 0 parent interface: rtwn0 media: IEEE 802.11 Wireless Ethernet autoselect (autoselect) status: no carrier nd6 options=21<performnud,auto_linklocal> # wpa_supplicant -i wlan1 -c /etc/wpa_supplicant.conf Successfully initialized wpa_supplicant wlan1: Trying to associate with d8:07:b8:b8:f4:81 (SSID='wireless' freq=2442 MHz) wlan1: Associated with d8:07:b6:b8:f4:81 wlan1: WPA: Key negotiation completed with d8:07:b6:b8:f4:81 [PTK=CCMP GTK=CCMP] wlan1: CTRL-EVENT-CONNECTED - Connection to d8:07:b6:b8:f4:81 completed [id=40 id_str=] ^Z // HIT THE [CTRL]+[Z] KEYS HERE zsh: suspended wpa_supplicant -i wlan1 -c /etc/wpa_supplicant.conf # bg  + continued wpa_supplicant -i wlan1 -c /etc/wpa_supplicant.conf #
We should now have network LAYER 2 connected and wpa_supplicant(8) should be running in a background and wlan1 interface should have associated status.
# ps ax | grep wpa_supplicant 48693 4 S 0:00.43 wpa_supplicant -i wlan1 -c /etc/wpa_supplicant.conf 50687 4 S+ 0:00.00 grep --color wpa_supplicant # ifconfig wlan1 wlan1: flags=8843<up,broadcast,running,simplex,multicast> metric 0 mtu 1500 ether 00:1d:43:21:2d:1c groups: wlan ssid wireless channel 7 (2442 MHz 11g ht/20) bssid d8:07:b6:b8:f4:81 regdomain FCC country US authmode WPA2/802.11i privacy ON deftxkey UNDEF AES-CCM 2:128-bit txpower 30 bmiss 7 scanvalid 60 protmode CTS ht20 ampdulimit 64k ampdudensity 4 shortgi -stbc -ldpc -uapsd wme roaming MANUAL parent interface: rtwn0 media: IEEE 802.11 Wireless Ethernet MCS mode 11ng status: associated nd6 options=29<performnud,ifdisabled,auto_linklocal> </performnud,ifdisabled,auto_linklocal></up,broadcast,running,simplex,multicast>
Lets add LAYER 3 with IP address using dhclient(8) command.
# dhclient wlan1 DHCPDISCOVER on wlan1 to 255.255.255.255 port 67 interval 3 DHCPOFFER from 10.0.0.1 DHCPREQUEST on wlan1 to 255.255.255.255 port 67 DHCPACK from 10.0.0.1 bound to 10.0.0.9 -- renewal in 3600 seconds.
We just got the 10.0.0.9 IP address.
One last step with DNS and we will test the connection with ping(8) command.
# echo nameserver 22.214.171.124 > /etc/resolv.conf # ping -c 3 freebsd.org PING freebsd.org (126.96.36.199): 56 data bytes 64 bytes from 188.8.131.52: icmp_seq=0 ttl=50 time=119.870 ms 64 bytes from 184.108.40.206: icmp_seq=1 ttl=50 time=119.371 ms 64 bytes from 220.127.116.11: icmp_seq=2 ttl=50 time=119.128 ms --- freebsd.org ping statistics --- 3 packets transmitted, 3 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 119.128/119.456/119.870/0.309 ms
I next tested the performance of this simple single antenna Realtek chip using NFS large file transfer in thunar(1) file manager.
The results are not that bad but not great either.
The file copy from LAN server attached directly to WiFi router to my laptop was about 2.9 MB/s fast. I was 5 meters away from the router.
server ==LAN==> router ==WiFi==> laptop @ 2.9 MB/s
The file copy from laptop using WiFi to LAN server attached directly to WiFi router was about 2.6 MB/s fast. Still about 5 meters away from the router.
laptop ==WiFi==> router ==LAN==> server @ 2.6 MB/s
That is 23.2 Mbps and 20.8 Mbps respectively. Really far from theoretical single antenna 802.11n 150 Mbps transfer … its probably fault of the FreeBSD wireless stack.
I would say that its sufficient for Internet browsing but using local LAN resources over NFS can be painful.
On the contrary my Intel 6300 WiFi card does 5.5 MB/s on the laptop-to-router-to-server copy and 10.5 MB/s on the server-to-router-to-laptop road. That is 44 Mbps and 84 Mbps respectively instead of 450 Mbps theoretical maximum. Both the Intel 6300 and my router have 3×3 antennas.
Would love to see these number closer to 30 MB/s …
One of the other benefit of the Realtek RTL8188CUS chip is that it works very well on small Raspberry Pi boxes. Personally I have tested it on the Raspberry Pi 2B and it worked like a charm.
This chip is also great when it comes to price. Products based on this chip are available everywhere. They are on EBAY. They are on ALIEXPRESS. And it costs as low as $2.50 in many cases.
Sometimes the delivery costs more then the product itself 🙂
UPDATE 1 – Middle Ages
Reddit user Yaazkal user from Reddit just reminded me that rtwn(4) driver on FreeBSD still does not support 802.11n protocol.
It’s still in the middle ages of 802.11g transfers.