~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to utilities/local-latency

  • Committer: Aaron Bentley
  • Date: 2011-08-05 15:47:22 UTC
  • mto: This revision was merged to the branch mainline in revision 13619.
  • Revision ID: aaron@canonical.com-20110805154722-aas1d2wrk9vlfrqh
Update docs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 
15
15
 
16
16
def tc(command):
 
17
    """Run a tc command under sudo.
 
18
 
 
19
    :param tc: The remainder of the command (leaving out tc).
 
20
    """
17
21
     subprocess.call('sudo tc ' + command, shell=True)
18
22
 
19
23
 
20
24
@helps(delay='Length of delay in miliseconds (each way).',
21
25
       port='Port to induce delay on.')
22
26
def start(delay=500, port=443):
 
27
    """Add artificial latency to the lo interface on the specified port."""
23
28
    tc('qdisc add dev lo root handle 1: prio')
24
29
    tc('qdisc add dev lo parent 1:3 handle 30: netem delay %dms' % delay)
25
30
    tc('filter add dev lo protocol ip parent 1:0 prio 3 u32 match ip'
29
34
 
30
35
 
31
36
def stop():
 
37
    """Add latency from the lo."""
32
38
    tc('qdisc del dev lo root')
33
39
 
34
40