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
 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)
Example #4
0
 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)
Example #5
0
            'delay': 5,
            'jitter': 5
        },
        ("127.0.0.3", ): {
            'upload': 256,
            'download': 512,
            'delay': 20
        },
        ("127.0.0.4", ): {
            'upload': 256,
            'download': 512,
            'delay': 20
        },
    }

    sh = Shaper()
    sh.set_shaping(ps)

    #print sh.ip_handles

    #sh.teardown_all()

    #up, down = sh.get_traffic("127.0.0.2")
    #print up, down

    # Please be aware that second call to set_shaping with the same IP will not change the settings

    # How to generate large range of IP adresses:
    #ps = {tuple([ "127.0.0.%d" % x for x in range(1,250) ]) : {'upload': 256, 'download': 1024, 'delay': 25},
    #      }
#
Example #6
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 #7
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 #8
0
import logging
logging.basicConfig(level=logging.INFO, datefmt='%H:%M:%S',
                    format='%(asctime)s %(name)s %(levelname)s: %(message)s')

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

if __name__ == '__main__':
    ps = {("127.0.0.2",) : {'upload': 1024, 'download': 1024, 'delay': 5, 'jitter': 5},
          ("127.0.0.3",) : {'upload': 256, 'download': 512, 'delay': 20},
          ("127.0.0.4",) : {'upload': 256, 'download': 512, 'delay': 20},
          }

    sh = Shaper()
    sh.set_shaping(ps)

    #print sh.ip_handles
    
    #sh.teardown_all()
    
    #up, down = sh.get_traffic("127.0.0.2")
    #print up, down
    
    
    # Please be aware that second call to set_shaping with the same IP will not change the settings

    # How to generate large range of IP adresses:    
    #ps = {tuple([ "127.0.0.%d" % x for x in range(1,250) ]) : {'upload': 256, 'download': 1024, 'delay': 25},
    #      }