Classe Qdisc para eth0 desaparecendo

2

Eu tenho um script que configura a modelagem de tráfego na porta eth0. O script é o seguinte:

import os
import subprocess

def run(cmd):
    print cmd
    result = subprocess.check_output(cmd, shell=True)
    print result

interface_name = 'eth0'
bandwidth = 1

remove_rule = "sudo tc qdisc del dev {} root".format(interface_name)
cmd1 = 'sudo tc qdisc add dev {} handle 1: root htb default 11'.format(interface_name)
cmd2 = 'sudo tc class add dev {} parent 1: classid 1:1 htb rate {}kbit ceil {}kbit'.format(interface_name, bandwidth, bandwidth)
cmd3 = 'sudo tc class add dev {} parent 1:1 classid 1:11 htb rate {}kbit ceil {}kbit'.format(interface_name, bandwidth, bandwidth)

try:
    run(remove_rule)
except:
    print 'Qdisc does not exist yet'
run(cmd1)
run(cmd2)
run(cmd3)

show_qdisc = 'tc -s -d qdisc show dev {}'.format(interface_name)
show_class = 'tc -s -d class show dev {}'.format(interface_name)
run(show_qdisc)
run(show_class)

Classificação de tráfego razoavelmente direta. Quando executo o script, tc show informa os seguintes detalhes.

tc -s -d qdisc show dev eth0
qdisc htb 1: root refcnt 3 r2q 10 default 11 direct_packets_stat 6 ver 3.17 direct_qlen 1000
 Sent 1154 bytes 9 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0

tc -s -d class show dev eth0
class htb 1:11 parent 1:1 prio 0 quantum 1000 rate 1Kbit ceil 1Kbit linklayer ethernet burst 1600b/1 mpu 0b overhead 0b cburst 1600b/1 mpu 0b overhead 0b level 0
 Sent 680 bytes 4 pkt (dropped 0, overlimits 0 requeues 0)
 rate 0bit 0pps backlog 0b 0p requeues 0
 lended: 4 borrowed: 0 giants: 0
 tokens: 115032210 ctokens: 115032210

class htb 1:1 root rate 1Kbit ceil 1Kbit linklayer ethernet burst 1600b/1 mpu 0b overhead 0b cburst 1600b/1 mpu 0b overhead 0b level 7
 Sent 680 bytes 4 pkt (dropped 0, overlimits 0 requeues 0)
 rate 0bit 0pps backlog 0b 0p requeues 0
 lended: 0 borrowed: 0 giants: 0
 tokens: 115032210 ctokens: 115032210

No entanto, quando eu envio o tráfego para fora do eth0 usando o iperf3, não há limitação do whatsover. Quando eu executo o programa tc (desta vez manualmente), o resultado é:

$sudo tc -s -d class show dev eth0
class mq :1 root
 Sent 901415262 bytes 100878 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
class mq :2 root
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0

Alguma idéia de por que 1.) o throttling não está funcionando e 2.) por que o resultado da classe tc show é inconsistente?

    
por user3249763 12.06.2017 / 01:08

0 respostas