# Can not understand why wifi doesn't work "sometimes"

## diablo465

It is been like this for many months. Basically I am using the same gentoo connecting with my hub. The hub didn't switched off or has anything changed in between. However, my gentoo "sometimes" can get wifi connected, while sometimes it simply can not. 

here are some basic informations:

lspci -k

```
03:00.0 Network controller: Qualcomm Atheros AR5416 Wireless Network Adapter [AR5008 802.11(a)bgn] (rev 01)

        Subsystem: Qualcomm Atheros Device 3071

        Kernel driver in use: ath9k

        Kernel modules: ath9k
```

lsmod

```
Module                  Size  Used by

fuse                   72589  3 

ath9k                 156064  0 

ath9k_common            1839  1 ath9k

ath9k_hw              412646  2 ath9k_common,ath9k

ath                    15638  3 ath9k_common,ath9k,ath9k_hw

vboxnetflt             15634  0 

vboxnetadp             17702  0 

vboxdrv              1809437  2 vboxnetadp,vboxnetflt
```

cat /etc/NetworkManager/system-connections/itsmeagain

```

 [connection]

id=itsmeagain

uuid=0b29611e-f501-49c5-a84d-c72ed78f491d

type=802-11-wireless

#timestamp=1401980710

[802-11-wireless]

ssid=itsmeagain

mode=infrastructure

mac-address=F8:D1:11:89:57:7D

#seen-bssids=08:86:3B:DD:4A:FE;

security=802-11-wireless-security

#system-ca-certs=False

[802-11-wireless-security]

key-mgmt=wpa-psk

psk=abcde

[ipv4]

method=auto

[ipv6]

method=ignore
```

 uname -r

```
3.10.25-gentoo
```

The abovementioned information didn't change for the working case and non-working case. Once the connection succeed, I will get:

demsg

```

[    7.229242] ath: EEPROM regdomain: 0x809c

[    7.229245] ath: EEPROM indicates we should expect a country code

[    7.229246] ath: doing EEPROM country->regdmn map search

[    7.229247] ath: country maps to regdmn code: 0x52

[    7.229249] ath: Country alpha2 being used: CN

[    7.229250] ath: Regpair used: 0x52

[    7.232823] ieee80211 phy0: Selected rate control algorithm 'minstrel_ht'

[    7.233372] ieee80211 phy0: Atheros AR5416 MAC/BB Rev:2 AR2133 RF Rev:81 mem=0xffffc90011260000, irq=16

[    7.347086] systemd-udevd[1579]: renamed network interface wlan0 to wlp3s0

[    8.078470] Adding 2105340k swap on /dev/sda6.  Priority:-1 extents:1 across:2105340k 

[    8.623049] EXT4-fs (sda7): mounted filesystem with ordered data mode. Opts: (null)

[    8.867126] EXT4-fs (sda8): mounted filesystem with ordered data mode. Opts: (null)

[    8.925397] EXT4-fs (sda5): mounted filesystem with ordered data mode. Opts: (null)

[    8.984899] EXT4-fs (sda2): mounted filesystem with ordered data mode. Opts: (null)

[    9.053998] systemd-journald[982]: Received request to flush runtime journal from PID 1

[   17.752440] warning: `VBoxHeadless' uses 32-bit capabilities (legacy support in use)

[   22.348872] IPv6: ADDRCONF(NETDEV_UP): wlp3s0: link is not ready

[   23.397806] uhci_hcd 0000:00:1a.0: reserve dev 2 ep81-INT, period 8, phase 4, 93 us

[   24.294760] wlp3s0: authenticate with 08:86:3b:dd:4a:fe

[   24.301063] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 1/3)

[   24.325472] wlp3s0: authenticated

[   24.326013] wlp3s0: associate with 08:86:3b:dd:4a:fe (try 1/3)

[   24.329855] wlp3s0: RX AssocResp from 08:86:3b:dd:4a:fe (capab=0x411 status=0 aid=3)

[   24.329903] wlp3s0: associated

[   24.329913] IPv6: ADDRCONF(NETDEV_CHANGE): wlp3s0: link becomes ready

[   46.724874] gnome-shell (1915) used greatest stack depth: 4376 bytes left

[   53.862011] fuse init (API version 7.22)

```

while if the system didn't work, I will get 

dmesg

```

[  210.705009] wlp3s0: authentication with 08:86:3b:dd:4a:fe timed out

[  337.933432] wlp3s0: authenticate with 08:86:3b:dd:4a:fe

[  337.938788] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 1/3)

[  338.706014] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 2/3)

[  338.941915] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 3/3)

[  339.702015] wlp3s0: authentication with 08:86:3b:dd:4a:fe timed out

[  350.378396] wlp3s0: authenticate with 08:86:3b:dd:4a:fe

[  350.384250] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 1/3)

[  351.387895] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 2/3)

[  352.389904] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 3/3)

[  353.393894] wlp3s0: authentication with 08:86:3b:dd:4a:fe timed out

[  378.075667] wlp3s0: authenticate with 08:86:3b:dd:4a:fe

[  378.080976] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 1/3)

[  378.702014] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 2/3)

[  379.085909] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 3/3)

[  379.705008] wlp3s0: authentication with 08:86:3b:dd:4a:fe timed out

[  390.382738] wlp3s0: authenticate with 08:86:3b:dd:4a:fe

[  390.388370] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 1/3)

[  391.391909] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 2/3)

[  392.393920] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 3/3)

[  393.397912] wlp3s0: authentication with 08:86:3b:dd:4a:fe timed out

[  504.484474] wlp3s0: authenticate with 08:86:3b:dd:4a:fe

[  504.489772] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 1/3)

[  505.493894] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 2/3)

[  506.497901] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 3/3)

[  507.501896] wlp3s0: authentication with 08:86:3b:dd:4a:fe timed out

[  518.176482] wlp3s0: authenticate with 08:86:3b:dd:4a:fe

[  518.181973] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 1/3)

[  518.702015] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 2/3)

[  519.185909] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 3/3)

[  519.705008] wlp3s0: authentication with 08:86:3b:dd:4a:fe timed out

[  565.671455] wlp3s0: authenticate with 08:86:3b:dd:4a:fe

[  565.676766] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 1/3)

[  566.679944] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 2/3)

[  567.681921] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 3/3)

[  568.685931] wlp3s0: authentication with 08:86:3b:dd:4a:fe timed out

[  579.361522] wlp3s0: authenticate with 08:86:3b:dd:4a:fe

[  579.367204] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 1/3)

[  580.369899] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 2/3)

[  581.373906] wlp3s0: send auth to 08:86:3b:dd:4a:fe (try 3/3)

[  582.377906] wlp3s0: authentication with 08:86:3b:dd:4a:fe timed out

```

More experience about the situation:

1.The same problem also exists to debian system installed in the same machine. it is sure that if gentoo didn't work, debian would not be working, either.

2. There is no problem to a scientific linux (installed in the same machine), even when both gentoo and debian is not working. The scientific linux installed arth9k from public driver, not from kernel. 

3. There is no particular time period in a day where the problem may possiblely occur. So I always need to pray before the GUI comes out. 

4. Reboot the hub will definately not help fixing this problem.

5. usually if the problem persists, I may try to reboot the pc AFTER 2 hours and try again. However, it is not guaranteed that it will be working in the next 2 hours. If I reboot my PC immediate, it may not be working either. 

Can anyone please shed some light on this issue? your reply is appreciated.

----------

## VinzC

Wireless is by nature unstable and very polluted. The frequency range, it's also that of microwaves and bluetooth, is a complete mess with more various devices every day. Only 3 Wifi channels are designed to not overlap in frequency. When radio frequencies overlap, it can become impossible to distinguish between emitting devices and collisions abound. Only the strongest signal is the winner.

Other factors include buggy wireless firmware, poor impedance adaptation on the emitting devices (being hot might be an indication), high frequency shadows and echoes, parasitic high frequency reverberation due to the presence of metallic surfaces... It might be what you're experiencing. But without a radio-frequency audit it's still hard to tell.

----------

## steveL

You might try a simpler network management regime.

 *UberLord wrote:*   

> Of note re wpa_supplicant, dhcpcd-6 will start (and stop) wpa_supplicant if /etc/wpa_supplicant.conf exists by itself. This is handy because I can now plug and unplug a USB wifi card and It Just Works.
> 
> No need for udev, ifplugd, NM or anything else.

 

I don't use WIFI, but it seems to me that if there's less to worry about, it reduces the likelihood of bad interaction.

----------

## zsitvaij

 *Quote:*   

> [    7.229249] ath: Country alpha2 being used: CN 

 

Are you in China? I had this problem come up before, when wifi stopped working in Gentoo but Ubuntu and Windows still worked.

You need to have net-wireless/crda and net-wireless/iw installed. If you call "iw reg set HU" (with your own country code in place of HU) as root, it might start working.

Used to be that having the COUNTRY environment variable set would be enough, but the crda binary stopped working properly for me a while back.

----------

## diablo465

 *zsitvaij wrote:*   

>  *Quote:*   [    7.229249] ath: Country alpha2 being used: CN  
> 
> Are you in China? I had this problem come up before, when wifi stopped working in Gentoo but Ubuntu and Windows still worked.
> 
> You need to have net-wireless/crda and net-wireless/iw installed. If you call "iw reg set HU" (with your own country code in place of HU) as root, it might start working.
> ...

 

Thanks for the reply, zsitvaij, I have tried and it seems to be working. I will have a close watch on its performance in the next few days..

----------

## diablo465

@zsitvaij

I have tried to run "iw reg set AU" to change the contry code however, the message in dmesg didn't chage, even if the system has been reboot.

----------

## khayyam

 *diablo465 wrote:*   

> I have tried to run "iw reg set AU" to change the contry code however, the message in dmesg didn't chage, even if the system has been reboot.

 

diablo465 ... Atheros will take the regdomain from EEPROM (see: Q: Why can't i use channel X, i did iw reg set NN but it is still unavailable). There is a patch (from openwrt) out there that allows you to set ATH_USER_REGD and so override this (not used it so can't comment). Anyhow, the standard method of solving this is to customise crda's regulatory.bin.

best ... khay

----------

## zsitvaij

diablo465: khayyam is probably right on this, I only have a ralink and a broadcom card at hand, and they accept the crda change.

----------

## cwr

I've had problems resetting the CRDA domain in the past, which were only fixed by moving the wireless

driver into a module;  recent CRDA / driver setups don't seem to have this problem, but I haven't

looked closely.

Will

----------

