Monday, July 18, 2011

Workaround for Stuck Beacon Problem

Stuck beacon is a notorious problem on madwifi (the wireless driver DD-WRT used for Atheros routers).  If you never experienced any wireless interruptions with DD-WRT then just ignore this article. However, if you're annoyed by this stuck beacon problem with constantly dropping wireless connection, then I hope this can be of help.

Below is a quick hack, not a completely fix but would make life a little easier. The idea is to watch the output of dmesg and when the "stuck beacon" error messages flood, reset the wireless interface to bring it back to life.

  1. The watchdog script
    When wireless connection is dropeed, a typical out from dmesg would like this

    ath_bstuck_tasklet : Entering
    Resetting; Code: 01
    ath_bstuck_tasklet : Entering
    Resetting; Code: 01
    ath_bstuck_tasklet : Entering
    Resetting; Code: 01
    ath_bstuck_tasklet : Entering
    Resetting; Code: 01
    ath_bstuck_tasklet : Entering
    Resetting; Code: 01
    ath_bstuck_tasklet : Entering
    Resetting; Code: 01

    The same error message will keep repeating and flood the kernel log. So we can use this as a trigger and reset wireless interface when the error occurs.

    Below is the
    /opt/usr/local/bin/wifi-watchdog.sh script
    #!/bin/sh dmesg | tail -n 5 | grep -q ath_bstuck_tasklet || exit echo fixing...
    #a log file
    echo `date` >> /tmp/wifi-wathdog.log

    ifconfig ath0 down
    #for VAP, bring additional interface(s) down
    #ifconfig ath0.1 down
    sleep 2
    ifconfig ath0 up
    #bring it back
    #ifconfig ath0.1 up

    Set permissions:
    chmod a+x /opt/usr/local/bin/wifi-watchdog.sh

  2. Set cron job
    With the watchdog script ready, we can use cron to set it run every one minute.
    Add a new job: * * * * * /opt/usr/local/bin/wifi-watchdog.sh

    and it's done. Again, its not a completely fix just save the trouble of resetting the router each time.

0 comments:

Post a Comment