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:
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):
kern.ipc.somaxconn=512
net.inet.tcp.mssdflt=1460
net.inet.tcp.sendspace=98304
net.inet.tcp.recvspace=98304
kern.ipc.maxsockbuf=1048576
net.inet.udp.maxdgram=57344
net.inet.udp.recvspace=42080
net.local.stream.sendspace=98304
net.local.stream.recvspace=98304
net.inet.tcp.delayed_ack=0
net.inet.tcp.rfc1323=1
net.inet.tcp.rfc1644=1
net.inet.tcp.newreno=1
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.)
Mac OS X Hints
http://hints.macworld.com/article.php?story=20080509063421962