# [SOLVED] wpa_supplicant deauthenticating every 300 seconds

## Rutberg

Hello,

I need some assistance on setting up the wifi. I'm getting deauthenticated nearly every 300 seconds.

```

dmesg | grep -i deauth

[  546.673672] wlan0: deauthenticated from 90:f6:52:ea:18:da (Reason: 2)

[  846.155517] wlan0: deauthenticated from 90:f6:52:ea:18:da (Reason: 2)

[ 1145.637266] wlan0: deauthenticated from 90:f6:52:ea:18:da (Reason: 2)

[ 1445.120683] wlan0: deauthenticated from 90:f6:52:ea:18:da (Reason: 2)

[ 1744.603323] wlan0: deauthenticated from 90:f6:52:ea:18:da (Reason: 2)

[ 2044.084766] wlan0: deauthenticated from 90:f6:52:ea:18:da (Reason: 2)

.

.

.

```

Here are the details of one deauthentication:

```

dmesg | grep '\[ 20'

[ 2044.084766] wlan0: deauthenticated from 90:f6:52:ea:18:da (Reason: 2)

[ 2044.112857] cfg80211: Calling CRDA to update world regulatory domain

[ 2045.263262] wlan0: authenticate with 90:f6:52:ea:18:da

[ 2045.282983] wlan0: send auth to 90:f6:52:ea:18:da (try 1/3)

[ 2045.284535] wlan0: authenticated

[ 2045.294741] wlan0: associate with 90:f6:52:ea:18:da (try 1/3)

[ 2045.301274] wlan0: RX AssocResp from 90:f6:52:ea:18:da (capab=0x431 status=0 aid=1)

[ 2045.302294] wlan0: associated

```

The poblem doesn't have to do with the hardware, since I don't have this problem with a 64-bit Ubuntu from a live-CD.

When looking at the output of dmesg | grep -i 'crda' I made a strange observation: CRDA is only called once for Germany, although it is in the wpa_supplicant.conf file.

```

[    5.198305] cfg80211: Calling CRDA to update world regulatory domain

[  546.704938] cfg80211: Calling CRDA for country: EC

[  846.187708] cfg80211: Calling CRDA to update world regulatory domain

[ 1145.668474] cfg80211: Calling CRDA to update world regulatory domain

[ 1445.149283] cfg80211: Calling CRDA to update world regulatory domain

[ 1744.636034] cfg80211: Calling CRDA to update world regulatory domain

[ 2044.112857] cfg80211: Calling CRDA to update world regulatory domain

```

I'm using Gentoo AM64 Kernel 3.5.9 on a Lenovo L412 laptop.

I'have configure the wireless interferface manually by:

[*] symlinking net.wlan0 to net.lo

[*] adding net.wlan0 to default runlevel

[*] setting up /etc/conf.d/net

```

#Generated by NetworkManager

###### Global Configuration ######

modules="wpa_supplicant"

# To use dhcp

# ** Regardless of your dhcp client **, it's "dhcp", not "dhcpcd".

config_wlan0="dhcp"

wpa_supplicant_wlan0="-Dwext -d -c /etc/wpa_supplicant/wpa_supplicant.conf"

preup() {

  if [[ ${IFACE} == "wlan0" ]]; then

    if ifplugstatus | grep -q 'eth0: link beat detected'; then

      ewarn "Wired connection on eth0 detected, aborting configuration on ${IFACE}"

      return 1

    fi

  fi

  return 0

}

```

[*] setting up /etc/wpa_supplicant/wpa_supplicant.conf:

```

#Generated by NetworkManager

###### Global Configuration ######

# Die folgende Zeile nicht ändern, sonst wird nichts funktionieren

ctrl_interface=/var/run/wpa_supplicant

# Sicherstellen, dass nur root die WPA Konfiguration lesen kann

ctrl_interface_group=0

# wpa_supplicant soll sich um scannen und AP Auswahl  kümmern

ap_scan=1

country=DE

###### Security Configuration ######

network={

   priority=5

   ssid="..."

   mode=0

   proto=RSN

   key_mgmt=WPA-PSK

   psk=...

}

```

Here is the output of lspci -v for the network controller:

```

03:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8191SEvB Wireless LAN Controller (rev 10)

   Subsystem: Realtek Semiconductor Co., Ltd. Device e020

   Flags: bus master, fast devsel, latency 0, IRQ 17

   I/O ports at 2000 [size=256]

   Memory at f0600000 (32-bit, non-prefetchable) [size=16K]

   Capabilities: [40] Power Management version 3

   Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+

   Capabilities: [70] Express Legacy Endpoint, MSI 00

   Capabilities: [100] Advanced Error Reporting

   Capabilities: [140] Virtual Channel

   Capabilities: [160] Device Serial Number 88-55-22-fe-ff-4c-e0-00

   Kernel driver in use: rtl8192se

   Kernel modules: rtl8192se

```

Here is the output of modinfo rtl8192se:

```

filename:       /lib/modules/3.5.7-gentoo/kernel/drivers/net/wireless/rtlwifi/rtl8192se/rtl8192se.ko

firmware:       rtlwifi/rtl8192sefw.bin

description:    Realtek 8192S/8191S 802.11n PCI wireless

license:        GPL

author:         Larry Finger   <Larry.Finger@lwfinger.net>

author:         Realtek WlanFAE   <wlanfae@realtek.com>

author:         lizhaoming   <chaoming_li@realsil.com.cn>

alias:          pci:v000010ECd00008174sv*sd*bc*sc*i*

alias:          pci:v000010ECd00008173sv*sd*bc*sc*i*

alias:          pci:v000010ECd00008172sv*sd*bc*sc*i*

alias:          pci:v000010ECd00008171sv*sd*bc*sc*i*

alias:          pci:v000010ECd00008192sv*sd*bc*sc*i*

depends:        rtlwifi,mac80211

intree:         Y

vermagic:       3.5.7-gentoo SMP mod_unload 

parm:           swenc:Set to 1 for software crypto (default 0)

 (bool)

parm:           ips:Set to 0 to not use link power save (default 1)

 (bool)

parm:           swlps:Set to 1 to use SW control power save (default 0)

 (bool)

parm:           fwlps:Set to 1 to use FW control power save (default 1)

 (bool)

parm:           debug:Set debug level (0-5) (default 0) (int)

```

I'm having this problem now for weeks and could find a solution. Any help would be appreciated.Last edited by Rutberg on Wed Nov 28, 2012 6:36 pm; edited 3 times in total

----------

## Logicien

Hello,

I think you should compare the way the modules rtl8192se, cfg80211, mac80211 and Wpa_supplicant are set in Ubuntu and try to use this configuration in Gentoo.

The module rtl8192se have some options about powersave. You can have a look on how those options are set by default or by a .conf file in /etc/modprobe.d/ with the command

```
more /sys/module/rtl8192se/parameters/*
```

If needed, you can disable powersave by adding in a .conf file in /etc/modprobe.d/ the line

```
options rtl8192se ips=0 fwlps=0 swlps=0
```

Because powersave can break a network link this might help. In the same ideas order, you can disable the powersaving in the device itself by the command

```
iwconfig wlan0 power off
```

The powersaving can be disable at least on the bus itself.

The country set in /etc/wpa_supplicant/wpa_supplicant.conf is related to Wpa_supplicant itself. The country use in the dmesg output is related to the cfg80211 module. You can force the country that cfg80211 ask to the crda command in a .conf file option in /etc/modprobe.d/

```
options cfg80211 ieee80211_regdom=DE
```

I had those deauthentications before. You have to check on the net the meaning of reason 2. What I do to try to advoid deauthentication is to set a long delay to some options of the mac80211 module before it give up

```
options mac80211 max_nullfunc_tries=60 max_probe_tries=60 probe_wait_ms=3600000
```

You can use -Dnl80211 instead of -Dwext as Wpa_supplicant driver. It should be supported. You can ping a network site to simulate data transfert to see if the  deauthentications come from network idle.Your problem can come from kernel configuration too.

All this might help or not. Check Welcome - Linux Wireless for more usefull informations.

----------

## Rutberg

Hello Logicien,

Thank you very much for your reply.

I have created two files in /etc/modprobe.de:

```

# cat /etc/modprobe.d/rtl8192se.conf 

options rtl8192se swlps=0 fwlps=0 ips=0

```

and

```

# cat /etc/modprobe.d/cfg80211.conf

options cfg80211 ieee80211_regdom=DE

```

but they have no effect on the modules.

What am I doing wrong?

Regards

  Rutberg

----------

## Rutberg

Hello,

in my previous post I wrote that the .conf files have no effect on the modules. This refers to the output of modinfo, only.

When I check the module option in the sysfs e.g. by 'more /sys/module/rtl8192se/parameters/*" everything is set up as requested by the .conf-files. Is this normal? (Please excuse me, if this is a newbie question.)

Regards

 Rutberg

----------

## Rutberg

Hello,

Although having tried the solutions propose by Logicien, I still have not solved the problem.

I have prepared a log of the wpa_supplicant with the -d option. It seems, that the deauthentification sequence starts with

"BSS: Expire BSS 0 due to age".

Here is an example snippet of the log.

```

...

1353876281.061771: EAPOL authentication completed successfully

1353876281.061780: RTM_NEWLINK: operstate=1 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])

1353876281.061782: RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added

1353876281.471236: EAPOL: startWhen --> 0

1353876281.471244: EAPOL: disable timer tick

<-- The deauthentication starts here -->

1353876468.835714: BSS: Expire BSS 0 due to age

1353876468.835722: BSS: Remove id 0 BSSID bc:05:43:95:09:2e SSID 'Alice-WLAN30'

1353876468.835734: BSS: Expire BSS 1 due to age

1353876468.835736: BSS: Remove id 1 BSSID 00:26:5b:b2:c8:58 SSID 'HITRON-C850'

1353876468.835740: BSS: Expire BSS 2 due to age

1353876468.835741: BSS: Remove id 2 BSSID 00:23:08:08:f9:1a SSID 'WLAN-08F907'

1353876468.835745: BSS: Expire BSS 3 due to age

1353876468.835746: BSS: Remove id 3 BSSID 00:1c:28:57:0b:3f SSID 'ALICE-WLAN54'

1353876468.835749: BSS: Expire BSS 5 due to age

1353876468.835750: BSS: Remove id 5 BSSID 00:1c:4a:4d:d2:68 SSID 'WLAN-001C4A4DD268'

1353876838.757452: RTM_NEWLINK: operstate=1 ifi_flags=0x1003 ([UP])

1353876838.757464: RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added

1353876838.793925: RTM_NEWLINK: operstate=1 ifi_flags=0x1003 ([UP])

1353876838.793939: RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added

1353876838.793943: Wireless event: cmd=0x8b15 len=24

1353876838.793945: Wireless event: new AP: 00:00:00:00:00:00

1353876838.793948: Disassociation notification

1353876838.793953: Setting scan request: 0 sec 100000 usec

1353876838.793969: Added BSSID 90:f6:52:ea:18:da into blacklist

1353876838.793974: CTRL-EVENT-DISCONNECTED bssid=90:f6:52:ea:18:da reason=0

1353876838.793976: Disconnect event - remove keys

...

```

Does someone know what the cause of this is?

Thanks in advance for your help.

 Rutberg

----------

## mir3x

Still I dont know if u r using NetworkManager or wpa_supplicant ? >( u have wpa.supplicant.conf configured so it looks like u are using both, or I dont understand how NetworkManager configured your configuration files  - maybe stop wpa and start NetworkManager ? )

Check rc-update, stop and start only one of them by /etc/init.d/*** start or stop ( just to see if disabling one of them works )

To see what wpa_supplicant is doing just start wpa_cli ( isn't it automatically reconnecting after disconnect ?)

Dont bother with those regions, I was setting region to BO ( Bolivia ) to check if there is anything better with 1000mW than 100mW but there is maybe less than 3dB improvement.

----------

## Logicien

According to Linux WiFi: Deauthenticated Reason Codes, reason 2 mean

```
2 Previous authentication no longer valid Client has associated but is not authorised.
```

Can it be some permissions problems? With NetworkManager, the user who initiate the connexion may not have sufficients permissions. Basically, it is preferable to use Wpa_supplicant in command line as root user, with proper wpa_supplicant.conf to see the connexion beahavior for debug purpose. The output of the command iwconfig wlan0 give needed informations to help. 

Did you disable the powersaving on the wireless device has I told you before? Did you try to simulate data transfert by ping or else to see if your deauthentifications are caused by idle time?

It is important to use only one wireless configuration method at a time and not use net.wlan0 startup script if you use NetworkManager and not use NetworkManager if you  use net.wlan0. That's mean only one of the two should be in your startup scripts according to rc-update. If you want to use Wpa_supplicant manually, start none of them.

If you say your are not deauthentificated with Ubuntu, it is possible you have a problem with your kernel configuration. Did you manually configure it or it have been configure by Genkernel?

Check how Ubuntu set the wpa_supplicant.conf file and how Wpa_supplicant is started.

----------

## Rutberg

Hello logicien, hello mir3x,

Thanks for your replies.

Without success I tried out everything logicien recommended - execept the ping test. Since I was the only one in the network having this problem I thought that it is related to my hardware. Today I gave it a try with 'ping -i0.5 -f ...' and voilá no more deauthentications. I assume the problem is related to my AP a TP-Wlan router (Model No. TL-WR1043ND). Ubuntu must be configured somehow to continously access the network. I mark this thread as solved.

So thanks again for your help. I appreciate it very much!

@mir3x:

The networkmanager line is only a leftover from the try with networkmanager. I started with wicd. Then I discovered the problem with the deauthentication, unmerged wicd and gave networkmanager a try. At last I umerged networkmanager and set up the network manually as described in the gentoo handbook.

Regards

 Rutberg

----------

