Page 1 of 1

Latency Checker and Download Adjuster

Posted: February 6th, 2013, 12:15 pm
by slugshell
I was wondering if it would be possible to implement a latency checker under sabnzb which according to the ping time response from the preferred location, regulates step by step (every minute) from maximal download speed to the minimum selected download speed in X kB/s (10KB/s per step).

Maybe looking something like this:

Image

Here a physon script for checking ping time.
Works with fping, tried it under Linux. If no ping time could be measured, a big value is returned. Usage: print get_ping_time('<ip>:<port>').

Code: Select all

import shlex  
from subprocess import Popen, PIPE, STDOUT

def get_simple_cmd_output(cmd, stderr=STDOUT):
    """
    Execute a simple external command and get its output.
    """
    args = shlex.split(cmd)
    return Popen(args, stdout=PIPE, stderr=stderr).communicate()[0]

def get_ping_time(host):
    host = host.split(':')[0]
    cmd = "fping {host} -C 3 -q".format(host=host)
    res = [float(x) for x in process.get_simple_cmd_output(cmd).strip().split(':')[-1].split() if x != '-']
    if len(res) > 0:
        return sum(res) / len(res)
    else:
        return 999999
Source: http://stackoverflow.com/questions/2525 ... ver-python

Thank you for your consideration,
greetings,

slugshell

Re: Latency Checker and Download Adjuster

Posted: February 6th, 2013, 12:23 pm
by shypike
Why do you think this would improve download speed?
Most providers only have European or US servers, so that's an easy choice for the user to make.

Re: Latency Checker and Download Adjuster

Posted: February 6th, 2013, 12:30 pm
by slugshell
No, you misunderstood my post a little, the whole thing should adjusting download speed to ensure a good Latency (ping time).

Re: Latency Checker and Download Adjuster

Posted: February 6th, 2013, 1:04 pm
by shypike
Currently you can lower SABnzbd's speed, which works most of the time.
It's an interesting idea, although it might be hard to get a consistent
experience over multiple plaforms and ISPs.
Personally I use the QoS service of my router to give usenet traffic a lower priority.

Re: Latency Checker and Download Adjuster

Posted: February 9th, 2013, 7:36 am
by slugshell
First of all, thank you for considering the idea.
Would there really be a problem with multiple platforms and ISPs if you use the already build in physon features.
Like you mentioned, sabnzb already has a download limiter so wouldn't it be as easy as telling physon to do something like this:

1. Variable = Address to ping
check pingtime every 60 seconds with physon for definable address like google.com, heise.de, duckduckgo.com ..
Something like this, sorry i am total noob with physon but you get the idea ;)

Code: Select all

    import subprocess
    # execute the code and pipe the result to a string
    test = "ping xxx.xxx.xxx.xxx"
    process = subprocess.Popen(test, shell=True, stdout=subprocess.PIPE)
    # give it time to respond
    process.wait()
    # optional check (0 --> success)
    print process.returncode
    # read the result to a string
    result_str = process.stdout.read()
    # test it ...
    print result_str
2. Some value is returned

3. Variable = Maximal allowed pingtime
Compare value with maximal allowed set ping time

4. Variable = Maximal download & minimal download speed
Set new download speed = (returned ping - minimal ping - maximal download speed until minimum download speed is reached??!! :D
example: maximal allowed ping time is set to 50, maximal download speed is set to 1000, minimal download speed is set to 500 and pingtime returned lets say 200

Code: Select all

*300 - 1000 = new download speed (*200 - 50 = 150 = 300% of 50)
5.After lets say 60 seconds it starts from the beginning.

Greetings,
slugshell