Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Improve stability of some USB-based wireless adapters Network
I'm using a D-Link DWL-G122 in versions C1 (and own a version B1, a D-Link DWL-122, a Linksys@Home 54g USB, and a Belkin F5D6050 USB -- insert sarcasm here), and have worked with (too) many similar Ralink or Prism-based USB wi-fi adapters on OS X over the last four years or so. One issue I experienced (with all of these adapters) was when the adapter was either under heavy load, or (especially) when using Internet Sharing in OS X, the adapter would randomly disconnect from its wireless network and lose all communication with the driver/config software. To fix things, it would require an unplug/replug to resume operation. With many people reporting this on the net, and having tried every suggestion I could find, I have finally found the answer that has since worked solid for over three weeks (and over 150gb of transfer) now without a single disconnection with any of my adapters!

Just for good measure, I tried (and failed) with these solutions:
  1. A wide selection of Mac OS versions/subversions, Mac hardware, USB ports, etc.
  2. All variations of network encryption options.
  3. Running every version of driver software (D-Link as well as Ralink) I could find.
  4. Many different USB extension cables, as well as without extension cables.
  5. Powered hubs - No luck, although this did make things notedly quicker and is highly recommended especially if you are using a G4 PowerBook as their USB power is pathetically unstable.
Beyond that, I tried probably everything else you can think of, but still, the problem persisted.

What I deduced from the system logs was that the Mac OS kernel was reporting repeated issues with the traffic going in and out at the USB end of the chain (USB msg queue errors and the like). This initially lead me (and most others) to always blame the USB ports, cables, etc., but nothing was ever consistent enough to resolve it. Once enough of these kernel misfires occurred, OS X would close the door on the adapter at the USB level, hence the unplug/replug that would reestablish things until the problem decided to recur.

Often the adapter would last longer if I wasn't running Internet Sharing, but it could equally as easily have dropped off after the next packet. I was leaning towards kernel loading as the catalyst, and made worse by any wavering wi-fi strength, unstable available USB power, etc.

My instinct kept saying it wasn't actually a USB-related cause, since it seemed so kernel-load-related rather than solely USB hardware or adapter-load related...perhaps the network stack's configuration was too strictly-set to expect a perfect dataflow from such USB-based wi-fi adapters. In other words, the data handed from the kernel's network layer to the physical USB layer was always too early, too late, not steady -- generally inconsistent. The USB layer seems a precious wee madam and intolerant of such things, so it complains, spits errors, traffic pauses, resumes, rinses/repeats until it has had enough and finally shuts the offending adapter out in the cold. So while we always think it's a USB related problem, if your signal fluctuates (causing the radio to pause and renegotiate, thus causing packet/USB message queues to bloat and empty), then this will cause the problems we've been seeing.

Based on these assumptions, I decided to try tweaking OS X's network settings to make sure the system was being as lenient as possible in terms of buffering more before handing things off to the USB layer, etc. Thus, a fix was born!

At present, I've been able to replicate the following results on my G4 1.33ghz PowerBook and G4 1.42ghz Mac mini, and other users' G5 tower, G5 iMac, G4 iMac. So far, it's solved the problem for each one I've looked at.

Create a txt file called sysctl.conf, paste in the contents below, and save it in /etc with root privileges (if you don't know how to do so, look around for a good how-to):
These OS network adjustments are then loaded at each subsequent boot automatically by OS X's startup routine (no startup item etc. is required). These changes increase the buffer sizes and general network tolerance, meaning traffic via USB will be smoothed out, regular and well behaved, and far less likely to cause the USB layer to freak out and slam the door on the adapter. (This sysctl.conf file will also smooth out any rough network performance on your Apple TV too ... search around if you don't know how to copy the file over to the ATV.)

The result? I am finally allowed a good hard thrash of the adapter for hours and hours -- even via Internet Sharing -- without a single hitch!

To undo the settings, simply sudo rm /etc/sysctl.conf the file and reboot, and OS X's default options return. Note that none of these settings have affected any other LAN performance aside from making file copies go a chunk faster! I also load the settings on my MacBook and other Macs for good measure, but that is entirely up to you.

Previously, when connecting to the net from my Macbook via the DWL-G122 (or any of the above adapters which previously behaved similarly or terribly unreliably) via Internet Sharing, light browsing might survive for a while, but open anything packet-heavy, such as Skype or even trying to watch one of Uncle Steve's Keynotes would drop the adapter out instantly. After applying this fix, I was able to watch a keynote in HD on my MacBook via the D-link sharing the net to me without a single hitch, with Azureus running and my roommate browsing away on her laptop. Good luck!
  • Currently 2.25 / 5
  You rated: 3 / 5 (8 votes cast)

Improve stability of some USB-based wireless adapters | 6 comments | Create New Account
Click here to return to the 'Improve stability of some USB-based wireless adapters' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Improve stability of some USB-based wireless adapters
Authored by: corienti on May 09, '08 04:25:44PM

Hmmm very interesting.

My understanding was that in 10.5, all these kernel parameters for network buffers and so forth were auto-adjusting - auto-tuned on the fly - by OS X, and as a result were supposed to never need manual tuning, for anything.

However, that's only what I've come to understand, from reading vague bits and pieces here and there, and could be entirely incorrect for all I know.

Does anyone know more on this stuff?

[ Reply to This | # ]
Improve stability of some USB-based wireless adapters
Authored by: greengeek on May 09, '08 06:03:41PM

To my knowledge, the auto-tuning that occurs happens within a range which is defined by several of the parameters mentioned in the hint. Increasing some of the maximums will allow the auto-turning to use larger buffers than it might have otherwise.

Other options are related to how the network stack will deal with queued up packets or other forms of network congestion.

[ Reply to This | # ]
Improve stability of some USB-based wireless adapters
Authored by: Hunted Charlie on May 09, '08 07:41:35PM
For those who don't know how to create the sysctl.conf file, all you have to do is:

0) Make sure you're logged in as an administrator.

1) Open in /Applications/Utilities.

2) Type sudo nano /etc/sysctl.conf and hit Enter.

3) Copy/paste the the given text into the editor.

4) Hold Control-X at the same time (^X for those who like that notation) and then type y and hit Enter to save the file and exit.

Also, I've got to say, the moment I heard 150GB in three weeks, I knew instantly that Azureus was involved.

[ Reply to This | # ]
Improve stability of some USB-based wireless adapters
Authored by: djlmc on May 10, '08 05:51:14AM
Also, I've got to say, the moment I heard 150GB in three weeks, I knew instantly that Azureus was involved.
LOL not quite, (when I could be bothered) I made some large file copies to and from the machine involved via the wireless adaptor to give it a good stressout, as well as performing it's Internet Sharing function. :)

[ Reply to This | # ]
Improve stability of some USB-based wireless adapters
Authored by: mjb on May 09, '08 09:19:11PM
You can change these values 'on the fly' without having to reboot.

With root privileges, you can use the sysctl tool. The arguments are exactly the same format as each line in the file /etc/sysctl.conf. As an example:

sudo sysctl net.inet.udp.recvspace=42080
To re-run the entire file, you could do something like:
while read line;do sudo sysctl $line;done < /etc/sysctl.conf

[ Reply to This | # ]
Improve stability of some USB-based wireless adapters
Authored by: drmacnut on May 12, '08 02:35:57AM

Thanks, djlmc, for taking the time to post this. All very interesting.

[ Reply to This | # ]