例子一:

  1. # tc qdisc add dev eth0 root handle 1: htb default 30
  2.  
  3. # tc class add dev eth0 parent 1: classid 1:1 htb rate 6mbit burst 15k
  4.  
  5. # tc class add dev eth0 parent 1:1 classid 1:10 htb rate 5mbit burst 15k
  6. # tc class add dev eth0 parent 1:1 classid 1:20 htb rate 3mbit ceil 6mbit burst 15k
  7. # tc class add dev eth0 parent 1:1 classid 1:30 htb rate 1kbit ceil 6mbit burst 15k

The author then recommends SFQ for beneath these classes:

  1. # tc qdisc add dev eth0 parent 1:10 handle 10: sfq perturb 10
  2. # tc qdisc add dev eth0 parent 1:20 handle 20: sfq perturb 10
  3. # tc qdisc add dev eth0 parent 1:30 handle 30: sfq perturb 10

Add the filters which direct traffic to the right classes:

  1. # U32="tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32"
  2. # $U32 match ip dport 80 0xffff flowid 1:10
  3. # $U32 match ip sport 25 0xffff flowid 1:20

同一个root class下的子类可以相互借流量,如果直接不在qdisc下面创建一个root,而是直接创建三个class,他们之间是不能相互借流量的。

例子二:

tc qdisc add dev eth0 root handle 1: htb default 12

  • This command attaches queue discipline HTB to eth0 and gives it the "handle" 1:.
  • This is just a name or identifier with which to refer to it below.
  • The default 12 means that any traffic that is not otherwise classified will be assigned to class 1:12.

tc class add dev eth0 parent 1: classid 1:1 htb rate 100kbps ceil 100kbps
tc class add dev eth0 parent 1:1 classid 1:10 htb rate 30kbps ceil 100kbps

tc class add dev eth0 parent 1:1 classid 1:11 htb rate 10kbps ceil 100kbps

tc class add dev eth0 parent 1:1 classid 1:12 htb rate 60kbps ceil 100kbps

The first line creates a "root" class, 1:1 under the qdisc 1:. The
definition of a root class is one with the htb qdisc as its parent.

同一个root class下的子类可以相互借流量,如果直接不在qdisc下面创建一个root,而是直接创建三个class,他们之间是不能相互借流量的。

  1. tc qdisc add dev eth0 parent 1:10 handle 20: pfifo limit 5
  2. tc qdisc add dev eth0 parent 1:11 handle 30: pfifo limit 5
  3. tc qdisc add dev eth0 parent 1:12 handle 40: sfq perturb 10
  1. tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32 match ip src 1.2.3.4 match ip dport 80 0xffff flowid 1:10
    tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32 match ip src 1.2.3.4 flowid 1:11

Hierarchical Token Bucket的更多相关文章

  1. 分布式环境下限流方案的实现redis RateLimiter Guava,Token Bucket, Leaky Bucket

    业务背景介绍 对于web应用的限流,光看标题,似乎过于抽象,难以理解,那我们还是以具体的某一个应用场景来引入这个话题吧. 在日常生活中,我们肯定收到过不少不少这样的短信,“双11约吗?,千款….”,“ ...

  2. Token bucket

    w https://en.wikipedia.org/wiki/Token_bucket

  3. Linux TC流量控制HOWTO中文版

    <本文摘自Linux的高级路由和流量控制HOWTO中文版 第9章节>网人郭工进行再次编译: 利用队列,我们可以控制数据发送的方式.记住我们只能对发送数据进行控制(或称为整形).其实,我们无 ...

  4. Linux TC (traffic control)

    在着手学习TC采用如下单位来描述带宽: mbps = 1024 kbps = 1024 * 1024 bps => byte/s mbit = 1024 kbit => kilo bit/ ...

  5. 编译个性化的openwrt固件

    基本流程是:下载openwrt源码(推荐attitude adjustment版本).执行feeds更新.make menuconfig(通过配置feed.conf.default和menuconfi ...

  6. the Linux Kernel: Traffic Control, Shaping and QoS

    −Table of Contents Journey to the Center of the Linux Kernel: Traffic Control, Shaping and QoS 1 Int ...

  7. Queueing in the Linux Network Stack !!!!!!!!!!!!!!!

    https://www.coverfire.com/articles/queueing-in-the-linux-network-stack/ Queueing in the Linux Networ ...

  8. Linux红黑树(一)——数据结构

    摘要 兹博文探讨四个重点:1.简单介绍红黑树:2.红黑树节点数据结构:3.红黑树节点中父节点指针域和自身节点颜色有机结合:4.定义红黑树和操作树节点父节点指针和节点颜色的接口,包括一系列宏和两个函数. ...

  9. Openvswitch手册(6): QoS

    这一节我们看QoS,Qos的设置往往是和flow中的policy一起使用的 Open vSwitch QoS capabilities 1 Interface rate limiting 2 Port ...

随机推荐

  1. 使用NuGet时的一个乌龙

    问题描述 最近自己做的一个项目,计划开始使用NuGet来管理dll,但是遇到一个奇怪,但是结果证明是个乌龙的问题. 新建一个WebApi项目,使用NuGet管理第三方dll,其中有引用Newtonso ...

  2. 重点关注之自定义序列化方式(Protobuf和Msgpack)

    除了默认的JSON和XML序列化器外,如果想使用其它格式的(比如二进制)序列化器,也是可以的.比如著名的Protobuf和Msgpack,它们都是二进制的序列化器,特点是速度快,体积小.使用方法如下. ...

  3. 检索 COM 类工厂中 CLSID 为 {000209FF-0000-0000-C000-000000000046} 的组件失败,原因是出现以下错误: 8000401a 因为配置标识不正确,系统无法开始服务器进程。请检查用户名和密码。 (异常来自 HRESULT:0x8000401A)。

    检索 COM 类工厂中 CLSID 为 {000209FF-0000-0000-C000-000000000046} 的组件失败,原因是出现以下错误: 8000401a 因为配置标识不正确,系统无法开 ...

  4. ace-下载-安装

    安装ACE 1.获取安装包 到ACE的官方网站http://www.cs.wustl.edu/~schmidt/ACE.html或者http://riverace.com/index.htm下载最新版 ...

  5. ASP.NET MVC 输出字符串

    @{Output.Write("<h1>输出字符串</h1>");}

  6. redis sort

    redis sort命令用法 1.命令描述返回或保存给定列表.集合.有序集合key中经过排序的元素.排序默认以数字作为对象,值被解释为双精度浮点数,然后进行比较. 2.一般sort用法最简单的sort ...

  7. JSON.NET 教程(一)

    下载地址:http://www.newtonsoft.com/json 参考官网文档:http://www.newtonsoft.com/json/help/html/SerializingJSON. ...

  8. svn自动更新

    果对svn不熟悉,当svn上面有更新时,想看到实时效果,就得去web目录手动更新,比较麻烦 其它svn有一个自动更新的功能 利用 hook   在svn 仓库目录下面有一个hook目录 在post-c ...

  9. RPI学习--wiringpi_API

    reference: https://projects.drogon.net/raspberry-pi/wiringpi/functions/ Functions (API) Some of the ...

  10. maven的简单安装与配置

    什么是Maven? Maven可以被理解成"知识的积累",也可以被翻译为"专家".它是一个项目管理工具. 它的主要服务即源于java平台的项目构建.依赖管理和项 ...