Example #1
0
class ShaperMixin(object):
    def setUp(self):       
        self.shaper_conf = {
            (self.server_addr[0],) : {'upload': 256, 'download': 1024, 'delay': 5},
            (self.client_addr[0],) : {'upload': 128, 'download': 512, 'delay': 30},
        }
        self.sh = Shaper()
        self.sh.set_shaping(self.shaper_conf)
    
    def tearDown(self):
        self.sh.teardown_all()
    
    def estimate_transfer_time(self, filesize, a, b):
        """
        Determines how long the transfer of filesize bytes from A to B should take.
        units for filesize are bytes, a and b are IP addresses
        """
        up = self.shaper_conf[(a,)]['upload']
        down = self.shaper_conf[(b,)]['download']
        return eta(filesize, up, down)
        
    def estimate_delay(self, a, b):
        da = self.shaper_conf[(a,)]['delay']
        db = self.shaper_conf[(b,)]['delay']
        return da+db
Example #2
0
class ShaperMixin(object):
    def setUp(self):
        self.shaper_conf = {
            (self.server_addr[0], ): {
                'upload': 256,
                'download': 1024,
                'delay': 5
            },
            (self.client_addr[0], ): {
                'upload': 128,
                'download': 512,
                'delay': 30
            },
        }
        self.sh = Shaper()
        self.sh.set_shaping(self.shaper_conf)

    def tearDown(self):
        self.sh.teardown_all()

    def estimate_transfer_time(self, filesize, a, b):
        """
        Determines how long the transfer of filesize bytes from A to B should take.
        units for filesize are bytes, a and b are IP addresses
        """
        up = self.shaper_conf[(a, )]['upload']
        down = self.shaper_conf[(b, )]['download']
        return eta(filesize, up, down)

    def estimate_delay(self, a, b):
        da = self.shaper_conf[(a, )]['delay']
        db = self.shaper_conf[(b, )]['delay']
        return da + db
Example #3
0
    """Parses a list of all interfaces reported by `ip link`"""
    import subprocess
    import re
    ifcs = []
    out = subprocess.check_output(["ip", "link"]).split('\n')
    for line in out:
        m = re.match("^[0-9]+:[ ]([a-z0-9]+):", line)
        if m:
            ifcs.append(m.group(1))
    return ifcs


from shapy import register_settings
register_settings('settings')
from shapy.emulation.shaper import Shaper

from shapy import settings
settings.EMU_INTERFACES = scan_interfaces()

notice = """\
This will clear entire Traffic Control configuration and unload IFB module.
Please note reported errors usually do not mean anything bad, just that there
was nothing to tear down on that particular interface."""

if __name__ == '__main__':
    print "Tearing down all interfaces: %s" % ', '.join(settings.EMU_INTERFACES)
    print notice
    print "-"*80
    sh = Shaper()
    sh.teardown_all()
Example #4
0
    """Parses a list of all interfaces reported by `ip link`"""
    import subprocess
    import re
    ifcs = []
    out = subprocess.check_output(["ip", "link"]).split('\n')
    for line in out:
        m = re.match("^[0-9]+:[ ]([a-z0-9]+):", line)
        if m:
            ifcs.append(m.group(1))
    return ifcs


from shapy import register_settings
register_settings('settings')
from shapy.emulation.shaper import Shaper

from shapy import settings
settings.EMU_INTERFACES = scan_interfaces()

notice = """\
This will clear entire Traffic Control configuration and unload IFB module.
Please note reported errors usually do not mean anything bad, just that there
was nothing to tear down on that particular interface."""

if __name__ == '__main__':
    print "Tearing down all interfaces: %s" % ', '.join(settings.EMU_INTERFACES)
    print notice
    print "-"*80
    sh = Shaper()
    sh.teardown_all()