编译TC软件包
可以在下面的地址下载到我们需要的软件,然后按照软件包里的说明编译它:
ftp://linux.wauug.org/pub/net/ip-routing/iproute2-current.tar.gz
通常我们要做的只是简单的输入make就可以了 。
TC 的设定
图1. CBQ 树图
图一是我们将配置的一个系统的简单的树形图示范 。两个叶子节点从父节点分配带宽,IP地址10.0.0.10(标识符1:1)和地址10.0.0.11(标识符1:2)是接口eth0上的IP别名,它们共同分享父节点(标识符1:0)的带宽 。这个例子里面只涉及到了对一个接口上的流量控制,大家可以仿照这个例子构造自己感兴趣的控制多个接口设备的配置 。
配置QoS特性的第一步就是将qdisc加入到一个接口上,例如本例子:
qdisc add dev eth0 root handle 1: ...
然后定义你需要区别的类别 。不同的类别对应不同的流量控制类型 。我们的例子中,使用如下的语句:
tc class add dev eth0 parent 1:0 classid X:Y ...
我们的例子中只使用了一层深的类别树 。当然,我们可以构造多层深度的复杂的树,基本的原则是一样的:就是一个子节点(如图1所示)继承一个父节点的资源同时进一步根据类的定义去分配父节点的资源 。例如,父类1:0拥有该设备的全部带宽,那么子节点1:1不可能获得超过10Mbits的带宽,当然本例子中是限制为1Mbps 。
最后定义"IP分组--类别"的映射规则,用来告诉系统的分类器,经过路由器调度的某IP分组该对应什么类型 。首先,将一个分类器与输出接口关联起来:
filter add dev eth0 parent 1:0 protocol ip ...
然后,定义"IP分组--类别"的映射规则 。本例子中,将利用IP分组的源地址来作为分类的关键词 。下面的脚本完成了这个功能 。关于脚本中TC等命令的参数,大家可以参考随机的文档,这里限于篇幅,不做介绍了 。
#! /bin/sh
#path to tc and the ip utilities;
#change to reflect yours.
TC=./iproute2/tc/tc
IP=./iproute2/ip/ip
##################################################
#Addresses to be aliased
#change;or;add more to reflect yours
#
ALIAS1=10.0.0.10
ALIAS2=10.0.0.11
##################################################
# add ip aliasing support
#uncomment if you want to use the ip utility to
#add ip-aliasing for you
#
#$IP addr add $ALIAS1 dev eth0
#$IP addr add $ALIAS2 dev eth0
##################################################
# Attaching a device queue discipline to an
# interface a device queue discipline is
# equivalent almost to a device manager
#
#Attach CBQ to eth0
#Things you might need to change:
# bandwidth -- the bandwidth of the eth0 device
# note it must match the devices real bandwidth
# allot -- it is safe to leave it at the MTU of
# the device
# avpkt -- the average packet size that you
# suspect will be seen safe to leave at 1000
# for Ethernet with MTU of 1514 bytes
# mpu -- minimum packet size
#
$TC qdisc add dev eth0 root handle 1: cbq
bandwidth 10Mbit allot 1514 cell 8 avpkt 1000
mpu 64
##################################################
# Attaching class queue disciplines
# bounded -- it is bound to the rate allocated;
# can borrow even if there is a lot of idle
# bandwidth just sitting there isolated -- cannot
# share its bandwidth to other classes prio is the
# priority assigned 0 being the highest and 7 the
# lowest weight -- safer to leave at 1
# queue discipline setup. Classid 1:1 will have a
# rate of 1Mbps which is bounded.
#
$TC class add dev eth0 parent 1:0 classid 1:1 cbq
- CISCO路由器的基本安装维护
- 排除路由器崩溃故障
- BEFSR81-具有QoS功能的EtherFast Cable/DSL路由器
- RV042-4口10/100Mbps VPN路由器
- 路由器基本维护-如何xmodem升级vrp
- 路由器基本维护-如何xmodem升级bootrom
- 七武海都有谁
- 路由器基本维护-如何操作新命令行
- 路由器基本操作和简单配置命令-如何捕获文本
- 常见ADSL宽带路由器默认密码集合
