# Extremely slow fetch through WiFi



## lazan (Feb 22, 2019)

Hi, folks.

Since recently, I have a new DELL Optiplex 3050 SFF (Intel i5, 8GB RAM, 256GB SDD, two low profile PCIe slots) with preinstalled MS Windows 10.
As I need a wireless connection to my home hotspot, the machine is equipped with an USB WiFi adapter - Netis WF2119S (chipset RealTek RTL8188EUS) that works perfectly under Windows.
It took me several weeks to setup Win10 (remove different "Apps" that change the computer to a funfair) and customize the Windows GUI to what I am used to. That is why I had to be very careful in all following steps.

Next I enhanced the machine by an additional 2.5" hard disk using an internal SATA PCIe card, partitioned the new HDD for UEFI booting (using gpart(8)) and installed FreeBSD 11.2 RELEASE from a USB stick. After many attempts and failures I am able to dual boot either Windows or FreeBSD.

Now the problem:
Relevant part of my /etc/rc.conf is

```
rc_info="YES"            # Enables display of informational messages at boot.

hostname="FreeBSD-MY.my-net.tld"
ipv6_activate_all_interfaces="NO"
ifconfig_lo0="inet 127.0.0.1 up"
ifconfig_re0="NOAUTO"

wlans_urtwn0="wlan0"
ifconfig_wlan0="SYNCDHCP WPA ssid my-ssid mode 11g -powersave"
```

Now I can
`# ping 8.8.8.8` successfully - ICMP works - round-trip time around 20ms.
`# ping google-public-dns-a.google.com` works - DNS is functional.

However,
`# fetch -o /dev/null --no-verify-peer https://ME:MY-PWD@well-working-webserver/files/100MB-file.bin`
shows download speed 1kBps or less.

I'm unable to download and install any additional tools for doing some more sophisticated tests.

An interesting observation was done when I removed and reinserted the USB WiFi adapter while running FreeBSD. Then
`# service netif restart`
Suddenly the previous `fetch` command provided satisfactory speed around 1MBps.
Unfortunatelly after rebooting the speed is again low.

So I suspect some startup timing problem since the `rc` scripts probably finish before the USB devices are fully discovered (as can be seen on the console).
Any hints and/or ideas are highly appreciated.


----------



## SirDice (Feb 22, 2019)

Probably not related but remove the `ifconfig_lo0="inet 127.0.0.1 ifdisabled up"`.


----------



## lazan (Feb 22, 2019)

SirDice said:


> Probably not related but remove the `ifconfig_lo0="inet 127.0.0.1 ifdisabled up"`.



Sorry, really not related. No change.


----------



## lazan (Feb 25, 2019)

*For all dual-boot users*:
Very interesting observation was done. When I do a cold boot of FreeBSD (it is when the computer was powered down), everything is working fine.
However, when instructing Windows to reboot and then I choose to boot to FreeBSD, the above described situation occurs. It means that the USB WiFi adapter is NOT fully reset to the "factory default" state by the FreeBSD urtwn(4) driver.


----------



## tingo (Mar 3, 2019)

Maybe the Windows driver use a firmware that isn't compatible with the urtwn driver?


----------



## lazan (Mar 3, 2019)

tingo said:


> Maybe the Windows driver use a firmware that isn't compatible with the urtwn driver?


This is very likely. But I would expect that the FreeBSD urtwn driver overwrites the firmware left by Windows during the boot process and make the device to work properly under FreeBSD.
This might be a bug or omission in the urtwn initialization stage.


----------



## tingo (Mar 22, 2019)

perhaps it only loads the firmware if the device isn't initialized already?


----------



## lazan (Mar 26, 2019)

tingo said:


> perhaps it only loads the firmware if the device isn't initialized already?


This is what I suspect. I will try FreeBSD Bugzilla.


----------

