When I added the delay command, paramiko returns back "2" as exit status(while it returns "0" for bandwidth command setting). Is 2 alright? (Googling didn't help with this, I am guessing 2 must be an error of some sort).
The command I use is:-
delay_cmd = "sudo tc qdisc add dev eth0 parent 1: handle 1: netem delay %dms" %(delay)
We were basically trying to follow this:
# tc qdisc add dev eth0 root netem delay 100ms
from an online tutorial.
The block of commands which should set the bw,filter and delay is this. (I am guessing I might be messing up with the parent/class ids). Can you see what I might be doing wrong?
cmd2 = "sudo tc class add dev %s parent 1: classid 1:1 htb rate %dmbps ceil %dmbps" % (interface, bandwidth, 2*bandwidth )
filter_cmd = "sudo tc filter add dev %s protocol ip parent 1:0 prio 1 u32 match ip dst %s/%d flowid 1:1" % (interface, ip, subnetmasklength)
delay_cmd = "sudo tc qdisc add dev eth0 parent 1:0 handle 1: netem delay %dms" %(delay)
This is the error I receive:
'RTNETLINK answers: File exists'
This is our script for setting the delay and bandwidth:
def exec_bw_config2(ssh, interface, bandwidth, ip, subnetmasklength, delay):
clear_bw_config2(ssh, interface)
# create a qdisc (queuing discipline), 12 is default class
cmd1 = "sudo tc qdisc add dev %s root handle 1: htb default 12" % interface
print cmd1
block_exec(ssh, cmd1)
# define the performance for default class
cmd2 = "sudo tc class add dev %s parent 1: classid 1:1 htb rate %dmbps ceil %dmbps" % (interface, bandwidth, 2*bandwidth )
print cmd2
block_exec(ssh, cmd2)
filter_cmd = "sudo tc filter add dev %s protocol ip parent 1:0 prio 1 u32 match ip dst %s/%d flowid 1:1" % (interface, ip, subnetmasklength)
print filter_cmd
block_exec(ssh, filter_cmd)
delay_cmd = "sudo tc qdisc add dev eth0 parent 1: handle 1: netem delay %dms" %(delay)
print delay_cmd
block_exec(ssh, delay_cmd)
So is anything wrong with delay_cmd above?
This is how we call it in our code:
def main():
myhosts = ["10.0.1.192", "10.0.1.191", "10.0.1.190"]
username="ubuntu"
port=22
#key = get_private_key()
for host in myhosts:
ssh = get_ssh(username, host, port)
clear_bw_config2(ssh, "eth0")
exec_bw_config2(ssh, "eth0", int(sys.argv[1]) , "10.0.1.0", 24, int(sys.argv[2]))
# iterate over hosts here
# for everyhost,
# 1. create ssh connection
# 2. run the exec_bw_config with params
return
On a further note what's the difference between parent 1: handle
and parent 1:2 handle
per se?