Rtl8187 wireless card drops signal within seconds

7,640

Solution 1

Edit: The previous link to the drivers was broken. It appears it's built into the kernel now according to this I believe the rest of this answer is still valid.

If this fails you could try this. source: http://www.backtrack-linux.org/forums/showthread.php?t=54375

Now open a new terminal and type the following:

ifconfig wlan1 down

or wlan0, whichever your card is on. use "ifconfig -a" to find out

Note the following 2 steps may be illegal in your country, if so skip them and continue. Then type:

iw reg set BO

This sets the country code to boliva so you can use the alfa card in max power.

Then type:

iwconfig wlan1 txpower 30

or wlan0, whichever your card is on.

This sets your card to 30db which is the max power the card can use.

Then type:

iwconfig wlan1 rate 1M

or wlan0, whichever your card is on.

This should fix the connection drop or very slow internet problem [main issue for me]

Now you are almost done, just type the following:

ifconfig wlan1 up

or wlan0, whichever your card is on.

Now just open your network manager and connect to your network and the problem should be fixed.

Just using iwconfig to set your rate, it will revert after rebooting. You can add the line to your /etc/rc.local to make it run every reboot though. I prefer to use something like:

iwconfig wlan1 rate 18M AUTO

which is "normal auto-rate up to 18M"

There are a few other things that can help with unstable/low quality connections... namely setting RTS & fragmentation threshold (default 2300ish) to 512 or lower to force smaller packet sizes (down to as low as 256). With this you could get stable at much higher data rates than before.

Overall, I start with this to my /etc/rc.local & tweak occasionally til it's rock stable.

iwconfig wlan1 rate 36M auto
iwconfig wlan1 frag 512
iwconfig wlan1 rts 512

Another thing you could try is safe removal from windows 7 (to power it down and insure is isn't left in an unstable state) prior to rebooting ubuntu and reinserting into the port.

One more thing to try is to adjust both short and long retries at the driver level. Try this.

iwconfig wlan1 retry short 21


iwconfig wlan1 retry long 21

Setting the retries to 31 has also been reported to work (see comments below)

What put me onto looking up these commands in the man page for iwconfig was information I found here: http://support.data-alliance.net/alfa-500mw-usb-improve-performance-significantly/

Solution 2

Try specifying a static IP address. You'll have to find an IP outside the block offered by your router (your router may default to offering addresses above 192.168.1.100). Set your NIC to a double static double digit IP such as 192.168.1.10.

You can do this by click:

(Click on) Network Manager Notification Icon > Edit > Edit Connections

(Select the Wifi Connection by name) > Edit > (click tab) IPv4 Setting > (Change Automatic DHCP to) Manual > Add (Fill in: Address, Netmask, Gateway) > (Fill in DNS servers coma seperated) > (optional Search domains) > Save

Anything else can be left at default.

Share:
7,640

Related videos on Youtube

nanofarad
Author by

nanofarad

Updated on September 18, 2022

Comments

  • nanofarad
    nanofarad over 1 year

    My Realtek RTL8187 USB wifi card is having trouble keeping a connection for more than a few seconds, while on the same machine under Windows 7 it has no problem. When I make the connection, I have a few seconds of full-bandwidth communication, followed by the connection completely failing to send or receive packets (the card usually makes a soft sound from the antenna, under both OSs, which cuts out, along with actual networking capabilities on Ubuntu). Network manager and WICD both report the card as still connected, with reasonable signal levels (around -40dBi, which is not a problematic level for this card on Windows). The loss of communication happens replicably and reliably, although occasionally I manage to transmit and receive a few stray packets. The indicator light on the card flickers constantly and abnormally quickly after the connection is lost.

    I've tried to connect to both my WPA2 and (with consent) a neighbor's WEP access points (mine being Netgear, and theirs being Belkin), with the same result of losing the link after roughly one second. Ethernet is un-affected. This card is being used with the rtl8187 kernel module. I'm using a clean, fresh installation of Trusty x64. This did not occur on the live CD.

    dmesg | tail -n 25 for the WEP network:

    hexafraction@ubuntu-lapdesk:~/Downloads$ dmesg | tail -n 25
    [16505.923287] wlan1: associated
    [16505.923370] IPv6: ADDRCONF(NETDEV_CHANGE): wlan1: link becomes ready
    [16505.943812] IPv6: ADDRCONF(NETDEV_CHANGE): wlan1: link becomes ready
    [16535.278129] atl1c 0000:01:00.0: atl1c: eth0 NIC Link is Down
    [16540.067784] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
    [16543.677051] wlan1: deauthenticating from [PREVIOUS AP MAC] by local choice (reason=3)
    [16543.737566] cfg80211: Calling CRDA to update world regulatory domain
    [16543.747499] cfg80211: World regulatory domain updated:
    [16543.747510] cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
    [16543.747518] cfg80211:   (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
    [16543.747524] cfg80211:   (2457000 KHz - 2482000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
    [16543.747529] cfg80211:   (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
    [16543.747534] cfg80211:   (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
    [16543.747539] cfg80211:   (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
    [16546.240014] wlan1: authenticate with [AP MAC]
    [16546.298661] wlan1: send auth to [AP MAC] (try 1/3)
    [16546.300412] wlan1: authenticated
    [16546.300741] rtl8187 1-3:1.0 wlan1: disabling HT/VHT due to WEP/TKIP use
    [16546.300747] rtl8187 1-3:1.0 wlan1: disabling HT as WMM/QoS is not supported by the AP
    [16546.300751] rtl8187 1-3:1.0 wlan1: disabling VHT as WMM/QoS is not supported by the AP
    [16546.304473] wlan1: associate with [AP MAC] (try 1/3)
    [16546.307090] wlan1: RX AssocResp from [AP MAC] (capab=0x431 status=0 aid=2)
    [16546.307946] wlan1: associated
    [16546.307992] IPv6: ADDRCONF(NETDEV_CHANGE): wlan1: link becomes ready
    [16546.308625] IPv6: ADDRCONF(NETDEV_CHANGE): wlan1: link becomes ready
    

    lsmod:

    Module                  Size  Used by
    rtl8187                64909  0 
    mac80211              626489  1 rtl8187
    cfg80211              484040  2 mac80211,rtl8187
    nls_utf8               12557  0 
    isofs                  39835  0 
    ctr                    13049  0 
    ccm                    17773  0 
    rfcomm                 69160  0 
    bnep                   19624  2 
    bluetooth             395423  10 bnep,rfcomm
    hid_generic            12548  0 
    joydev                 17381  0 
    uvcvideo               80885  0 
    videobuf2_vmalloc      13216  1 uvcvideo
    videobuf2_memops       13362  1 videobuf2_vmalloc
    videobuf2_core         40664  1 uvcvideo
    videodev              134688  2 uvcvideo,videobuf2_core
    usbhid                 52616  0 
    eeprom_93cx6           13344  1 rtl8187
    arc4                   12608  2 
    hid                   106148  2 hid_generic,usbhid
    kvm_amd                59987  0 
    kvm                   451511  1 kvm_amd
    radeon               1514165  3 
    psmouse               102222  0 
    k10temp                13126  0 
    toshiba_acpi           22901  0 
    sparse_keymap          13948  1 toshiba_acpi
    serio_raw              13462  0 
    wmi                    19177  1 toshiba_acpi
    snd_hda_codec_conexant    57441  1 
    snd_hda_codec_hdmi     46207  1 
    snd_hda_intel          52355  5 
    snd_hda_codec         192906  3 snd_hda_codec_hdmi,snd_hda_codec_conexant,snd_hda_intel
    ttm                    85115  1 radeon
    snd_hwdep              13602  1 snd_hda_codec
    snd_pcm               102099  3 snd_hda_codec_hdmi,snd_hda_codec,snd_hda_intel
    snd_page_alloc         18710  2 snd_pcm,snd_hda_intel
    snd_seq_midi           13324  0 
    snd_seq_midi_event     14899  1 snd_seq_midi
    snd_rawmidi            30144  1 snd_seq_midi
    snd_seq                61560  2 snd_seq_midi_event,snd_seq_midi
    snd_seq_device         14497  3 snd_seq,snd_rawmidi,snd_seq_midi
    snd_timer              29482  2 snd_pcm,snd_seq
    drm_kms_helper         52758  1 radeon
    snd                    69238  21 snd_hwdep,snd_timer,snd_hda_codec_hdmi,snd_hda_codec_conexant,snd_pcm,snd_seq,snd_rawmidi,snd_hda_codec,snd_hda_intel,snd_seq_device,snd_seq_midi
    soundcore              12680  1 snd
    drm                   302817  5 ttm,drm_kms_helper,radeon
    video                  19476  0 
    i2c_piix4              22155  0 
    i2c_algo_bit           13413  1 radeon
    mac_hid                13205  0 
    parport_pc             32701  0 
    ppdev                  17671  0 
    lp                     17759  0 
    parport                42348  3 lp,ppdev,parport_pc
    ahci                   25819  2 
    atl1c                  46086  0 
    libahci                32168  1 ahci
    

    I'm at a loss here, as I've tried reboots, wicd, and network-manager. The card itself is fine on Windows 7 (as I still dual-boot and can test it). I've removed network-manager before using wicd, and vice-versa, as well as having both installed. My suspicion is that some service or background program is causing the card to channel-hop, but I am not sure how to check whether that is happening, or which service is causing it. However, the hard-block issues seen on the live CD are not happening.

    Due to my not having been able to check this on previous versions due to GPU incompatibility making Ubuntu unusable, I have no evidence that this is a bug introduced in Trusty.

    Edit: sudo iwconfig wlan1 when not connected:

    wlan1     IEEE 802.11bg  ESSID:off/any  
              Mode:Managed  Access Point: Not-Associated   Tx-Power=20 dBm   
              Retry  long limit:7   RTS thr:off   Fragment thr:off
              Encryption key:off
              Power Management:off
    

    sudo iwconfig wlan1 when connected to my WPA2 net:

    wlan1     IEEE 802.11bg  ESSID:"XXXXXXXXXX"  
              Mode:Managed  Frequency:2.462 GHz  Access Point: XX:XX:XX:XX:XX:XX   
              Bit Rate=54 Mb/s   Tx-Power=20 dBm   
              Retry  long limit:7   RTS thr:off   Fragment thr:off
              Encryption key:off
              Power Management:off
              Link Quality=39/70  Signal level=-71 dBm  
              Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
              Tx excessive retries:0  Invalid misc:2   Missed beacon:0
    

    sudo iwconfig wlan1 for WEP:

    wlan1     IEEE 802.11bg  ESSID:"XXXXXXXXXX"  
              Mode:Managed  Frequency:2.437 GHz  Access Point: XX:XX:XX:XX:XX:XX   
              Bit Rate=11 Mb/s   Tx-Power=20 dBm   
              Retry  long limit:7   RTS thr:off   Fragment thr:off
              Encryption key:15A4-A159-AF
              Power Management:off
              Link Quality=47/70  Signal level=-63 dBm
              Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
              Tx excessive retries:27  Invalid misc:33   Missed beacon:0
    

    I know for a fact that Windows experiences higher signal levels, both in terms of the dBm scale, and in terms of reported percentage connection quality.

    • nanofarad
      nanofarad about 10 years
      To whomever voted to close this as a bug report, what justification do you have for same? I'm not sure if the issue is on my side, and if it is not, I'd appreciate being told that directly.
    • nilsonneto
      nilsonneto about 10 years
      please can you add to your question the output of sudo iwconfig [interface] e.g. whatever your wireless interface is being reported on with you run sudo iwconfig - my wireless is eth1 thus I would type sudo iwconfig eth1
  • nanofarad
    nanofarad about 10 years
    Can you explain what fixes, if any, exist in the newest version over rtl8187 in trusty repos? Edit: That package doesn't build for me.
  • Elder Geek
    Elder Geek about 10 years
    @hexafraction No, I haven't reviewed the code but it's SOP to install the latest driver if you have problems with a previously released one.
  • Elder Geek
    Elder Geek about 10 years
    @hexafraction what is the interface? Mini PCI(e) in a laptop, USB, PCI or PCIE in a desktop? what's the manufacturer and model # of the card?
  • nanofarad
    nanofarad about 10 years
    Alfa AWUS036H, which is a USB card fairly commonly used with Linux.
  • Elder Geek
    Elder Geek about 10 years
  • nanofarad
    nanofarad about 10 years
    Thanks, I'll try as much of it as I can (It is illegal to transmit above 20dBi in the US without licenses that I do not have)
  • Elder Geek
    Elder Geek about 10 years
    @hexafraction edited answer. Try the last 3 lines of code in my answer then after insuring you have txpower at 20. Hope this works for you!
  • Elder Geek
    Elder Geek about 10 years
    @hexafraction You mentioned having higher signal levels under Windows 7. Is that on the same hardware (dual boot)?
  • nanofarad
    nanofarad about 10 years
    Yes, that is the same hardware.
  • Elder Geek
    Elder Geek about 10 years
    @hexafraction Did adjusting the frag and rts settings help?
  • nanofarad
    nanofarad about 10 years
    No, unfortunately the issue remains (the disconnect happens equally quickly). Can't let the bounty go to waste, though, so I'll award it if no other answers come in that work
  • Elder Geek
    Elder Geek about 10 years
    @hexafraction I realize we're heading into the basement here but could you try iwconfig wlan1 frag 256 iwconfig wlan1 rts 256
  • nanofarad
    nanofarad about 10 years
    I've tried values as low as 64 (powers of 2), to no avail.
  • Elder Geek
    Elder Geek about 10 years
    @hexafraction How long has it gone (runtime) under windows 7 without dropping vs. Ubuntu without dropping?
  • nanofarad
    nanofarad about 10 years
    Windows: Virtually endlessly (as in, hours of un-interrupted communication) vs a few seconds on Ubuntu. Reconnect gives a few more seconds. I'll try the clean disconnect later tomorrow as it is fairly late in my timezone
  • Elder Geek
    Elder Geek about 10 years
    @hexafraction is this in a USB 2.0 port? What model system are you plugging it into?
  • nanofarad
    nanofarad about 10 years
    USB 2.0, being a Toshiba Satellite L755
  • Elder Geek
    Elder Geek about 10 years
    @hexafraction I did some more digging and found more info. editing answer and putting 2 lines of code at the bottom that should resolve the issue at the driver level
  • nanofarad
    nanofarad about 10 years
    How would this be related? I can't send any 802.11 frames, at a lower level than IP addressing.
  • Apologician
    Apologician about 10 years
    This has resolved the issue many times for me and clients who had wireless drops. I don't know what it is about a NIC that appears to have a more consistent connection with static IP's than dynamic IP's but it has worked for me on a variety of systems numerous times. If your disconnects are frequent, it might not take a lot of work to try it and see if it works in your case.
  • nanofarad
    nanofarad about 10 years
    Long and short retries seem to help greatly, I'll see how stable it is and report back. Can you tell me what the number 21 means? Is it just the number of retries?
  • nanofarad
    nanofarad about 10 years
    It is working stably now. Bitrate is forced to 18M auto, twpower 17, retry long and retry short are both 31 (as opposed to 21). Thanks!
  • Elder Geek
    Elder Geek about 10 years
    @hexafraction Excellent! glad I was able to help. I wanted to earn the bounty, not just receive it.