此处显示的示例是可下载配置文件的修改示例,这些配置文件位于 此目录 中。
这些示例可以用作独立的配置文件,以馈送到 tcc 解析器中,或者它们可以与示例 SysV 启动脚本 结合使用。该启动脚本是对 raptor 在 LARTC 邮件列表中发布的脚本 的修改。
如果您要使用上述启动脚本,请查看此示例/etc/sysconfig/tcng:
示例 1。/etc/sysconfig/tcng
# - tcng meta-configuration file # (I never meta-configuration file I didn't like) # # -- 2003-03-15 created; -MAB # -- 2003-03-31 modified to allow ENVAR override; -MAB # # -- this directory will hold all of the tcng configurations # used on this host # TCCONFBASEDIR=${TCCONFBASEDIR:-/etc/sysconfig/tcng-configs} # -- this is the active, desired tcng configuration # note, that, because tcng provides the #include construct, # the modularity of configuration can be built into the # configuration files in $TCCONFBASEDIR # TCCONF=${TCCONF:-$TCCONFBASEDIR/global.tcc} tcstats=${tcstats:-no} # -- will suppress statistical output tcstats=${tcstats:-yes} # -- will throw the "-s" option to tc tcdebug=${tcdebug:-0} # -- for typical startup script usage tcdebug=${tcdebug:-1} # -- for a bit of information about what's happening tcdebug=${tcdebug:-2} # -- for debugging information # # # -- an additional measure to take, you can override the default tc and tcc # command line utilities by specifying their pathnames here, for example: # # tc=/usr/local/bin/tc # tcc=/usr/local/tcng/bin/tcc # # |
许多通用概念将通过此示例介绍。此示例可以使用以下命令编译为其 tc 输出tccclass-selection-path.tcc.
示例 2。/etc/sysconfig/tcng/class-selection-path.tcc
/* * Simply commented example of a tcng traffic control file. * * Martin A. Brown <martin@linux-ip.net> * * Example: Using class selection path. * * (If you are reading the processed output in HTML, the callouts are * clickable links to the description text.) * */ #include "fields.tc" |
使用#include可以灵活地定义变量并包含通用的流量控制元素。
另请参阅 tcng 手册中关于 includes 的部分。
有关更多详细信息,请查阅 tcng 手册中关于 class selection path 的部分。
名称和数字同样可接受且有效。
参数rate和ceil对于任何使用过 HTB 的人来说都应该很熟悉。这些是 HTB 特定的参数,并且由 tcc 实用程序正确转换。请参阅关于 tcng 速率和速度规范 的表。
如果未为叶子类指定排队规则,则它们包含默认的 pfifo_fast qdisc。在叶子类中包含随机公平排队 qdisc 抑制了单个连接在给定类中占主导地位的能力。
示例 3。/etc/sysconfig/tcng/two-rate-three-color-meter.tcc
/* * Simply commented example of a tcng traffic control file. * * Martin A. Brown <martin@linux-ip.net> * * Example: Using a meter. * * (If you are reading the processed output in HTML, the callouts are * clickable links to the description text.) * */ #define EXCEPTION 192.168.137.50 #define INTERFACE eth0 $meter = trTCM( cir 128kbps, cbs 10kB, pir 256kbps, pbs 10kB ); |
此计量器是双速率三色计量器,是 tcng 语言中最复杂的计量器。此计量器根据承诺和峰值桶中提供的速率返回颜色绿色、黄色和红色。如果计量速率超过承诺速率,则此计量器将变为黄色;如果计量速率超过峰值速率,则此计量器将变为红色。
变量$meter可以通过适用于计量器类型的函数对其进行操作。在这种情况下,有三个函数可用于测试$meter的状态,trTCM_green, trTCM_yellow和trTCM_red。为了提高效率,还可以考虑 加速的对应物。
计量器为绿色。
计量器为黄色。
计量器为红色。