Skip to content

Ideas for managing tunnel selection #84

@markfoodyburton

Description

@markfoodyburton

Hi, thinking about #64 and #82 - I have tried two experiments.
Firstly, instead of using a 'round robin' selection mechanism, I used a weighted random selection.
As far as I can tell, in my set up, the effect is minimal, if anything it's somewhat worse. If we think about a round robin mechanism, most of the time, the tunnels take things in turn. With a random approach you are quite likely to get packets following each other on the tunnel. Although the average throughput may be right, this causes the tunnels to get 'peeks' of traffic that they can't deal with... which in the end has a negative impact on performance

I dont think this will surprise anybody, but I wanted to try :-)

Second, for my ADSL connections, I notice, as the links get heavily used the SRTT can go through the roof. Further more, the slower line has a longer SRTT - very approximately related to it's bandwidth (or at least, that is my guess).

I implemented a mechanism which adjusts the weights for the tunnels based on the SRTT. This is surprisingly successful. In order to avoid the 'random' effect above, the ratio needs to stay fairly steady, e.g. it needs to change slowly. Looks like you need a rolling average of at least 20000 packets. Over which time, the impact of the return going one route or the other should also be minimised.

Doing this would mean you dont need to supply bandwidth numbers (which are subject to change), and the ratio used adjusts to circumstances.

HOWEVER - this is favouring one tunnel as opposed to another based on their speed, rather than their bandwidth, which is clearly not the case for anything like a mixed medium environment - and only has any hope of working for common mediums (e.g. some ADSL lines).

None the less - this approach seems to work very nicely indeed. Highly unscientifically, I seem to get much steading and marginally higher download and upload speeds. Whats interesting is that the connection seems to 'self adjust' to both the ADSL fluctuations, but also the load imposed on it. During heavy download, the faster download tunnel seems to be favoured for the return path (giving up better throughput overall), while during upload, as the uplinks become saturated, their speed evens out, and we seem to better use the available upload bandwidth!

The guts of my approach are below, if anybody wants to try this out themselves, or if you like the approach, let me know and I'll open a pull request.

`static void
mlvpn_rtun_recalc_weight_srtt()
{
mlvpn_tunnel_t *t;
double total_srtt = 0;
int error = 0;

LIST_FOREACH(t, &rtuns, entries)
{
    if (t->srtt >= 1000)
        error++;
    total_srtt += (t->srtt);
}
if ( error ) {
    log_debug("srtt", "srtt seems not stable (yet)");
} else {
    LIST_FOREACH(t, &rtuns, entries)
    {
        /* useless, but we want to be sure not to divide by 0 ! */
        if (t->srtt > 0 && total_srtt > 0)
        {
          /* lets try moving things a little slower, we'll take a rolling
           * average over lots of  samples... */
          double new=((double)(total_srtt - (t->srtt/)) *100 / (double)total_srtt);
          t->weight = ((t->weight *19999.0) + new)/20000.0;
          log_debug("wrr", "%s weight = %f (%f %f)", t->name, t->weight,
                    t->srtt, total_srtt);
        }
    }
}

}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions