Main Page | Class Hierarchy | Data Structures | File List | Data Fields | Globals | Related Pages

Moonlight's Upload/Download Regulator (MUDR)

What is this?

You could say this mod was born out of necessity: my ISP is the fastest and cheapest one around... the catch is that it's got quotas...

Because using the most of my download quota means I have to avoid running up my upload quota for nothing, I needed something to help me bias my UL:DL ratio towards whatever my ISP is offering... this means 1:3 today but used to mean 1:6 (practically no upload allowed since most of it was being consumed by overhead) in 2000-2001.

News, updates and other such things...

What does it do?

The first "version" was on eDonkey... a simple binary hack that changed the ratios for <10KB/sec to 1:10 000... this way, I could manually change my upload and download speeds to any value I had to set it to in order to re-establish my quota's balance. With only 1GB up, this usually meant 0.25KB up and unlimited down.

When eDonkey started including spyware, I decided to ditch it and use eMule... but eMule used integers to store its values and finding constant integers is far more burdensome than finding floats. The second 'version' was to manually set upload and download speeds because I did not have VisualStudio at the time and no time to mess with it either. With the 5GB up and 6GB down ratio at the time, setting the upload speed at 1-4KB/sec when I could not babysit was good enough.

Then I got VisualStudio at around the same time the download quota was increased to 10GB... if I ended up setting upload speed to 1KB/sec no matter how fast downloads were going, I would get nowhere slow. The babysitting approach was clearly not suitable so I started modding... and the third 'version' was to remove the "don't be a lam3r" code so I could set the download speed independently of upload speed, manually adjusting upload speed to compensate for how well/bad they have been since the last time I checked.

At this time, talks about the credit system were all over the place so I thought I should make my client look roughly as fair as the regular ratio system would usually allow, thinking someone might write something to detect clients that are too far out of line... so I decided to make my upload speed adjust dynamically to the download speed but with a filter/delay to avoid boosting/reducing limits on spikes. The first version was a simple IIR filter with hard-coded coefficients... (the current implementation still uses pretty much the same code)

lastdownrate=theApp.downloadqueue->GetDatarate();
lastuprate=theApp.uploadqueue->GetDatarate();

float lastdownratef = lastdownrate / 1024.0;    // bytes/sec -> KB/sec
if (lastdownratef > hystdown) {
    hystup = hystdown/4 * 0.05 + hystup * 0.95;
    hystdown = lastdownratef * 0.15 + hystdown * 0.85;
} else {
    hystup = hystdown/4 * 0.10 + hystup * 0.90;
    hystdown = lastdownratef * 0.05 + hystdown * 0.95;
}
uint16 newuprate = ceil(hystup + 0.01);
uint16 newdownrate = ceil((hystdown + 2)/3)*3;

if (newuprate >= 10) newuprate = 10;
theApp.glob_prefs->SetMaxUpload(newuprate);
theApp.glob_prefs->SetMaxDownload(newdownrate);

But after a few attemps at tuning this filter, doing this hard-coded soon prooved to be extremely inconvenient and time-consuming...

At this point, I quickly patched together a simple GUI which eventually lead to its current form in What does it look like?

The Upload:Download regulator is built into Moonlight's Mod (Latest build: 0.30e-0.22f, 2003-12-15).

What does it look like?

Moonlight-UDReg.png

A picture is worth a thousand words

  1. Bandwidth filter's response time. The higher the value, the more time it will take UDReg to react to changing UL and DL speeds. Internally, those values are converted to become the 'alpha' value for a simple filter of the following form: Y = Yz^(-1)*a + X*(1-a)... a simple first-order IIR filter.
  2. Enable/disable the speed regulators. Disabling the regulator sets your current speed to the Maximum speed specified below in #3.
  3. These let you set the baseline UL/DL speeds along with the absolute maximum UL/DL speeds. I created this mod so I could upload without busting my quota while receiving nothing. With the UL regulator enabled, set your Max UL speed to ~80% of your actual wire speed, the minimum UL speed to whatever speed you are willing to share at all times and let the ratios in #4 boost your UL speed from Min up to Max proportionally to your actual DL speed.
  4. The ratios and ratio thresholds let you adjust how much of a UL boost you are willing to give for each KB/sec of actual DL speed you manage to get.
  5. The newer UDReg version has a button in the lower right to open the filter coefficient monitoring window.

This is how my graphs typically looked like with eMule 0.30a:

Moonlight-UDReg-Stats.png

Typical low-speed rollercoaster.

The maximum download speed is locked at 150KB/sec, a little pointless since I have not seen peak download speeds over 100KB/sec on eMule/eDonkey in over a year.

Note:
UDReg overrides the limits settings in the "Connection" Preferences pannel when their respective regulators are enabled.
Hits since December 5, 2003:
Count.cgi?display=counter|df=vllmtqtwVL2.dat

Generated on Sat Feb 7 00:52:25 2004 for Moonlight's eMule Hacks by doxygen 1.3.4