找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 4375|回复: 3

[负载平衡] ros3.0下的NTH用法有了一点变化!!

[复制链接]
发表于 2008-1-12 14:40:48 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
NTH in routeros 3.x
From MikroTik Wiki
Jump to: navigation, search
In v3.0 it is a little different implementation of NTH. It has only two parameters 'every' and 'packet'.

[edit] How it works in v3.0
Every rule has its own counter. When rule receives packet counter for current rule is increased by one. If counter matches value of 'every' packet will be matched and counter will be set to zero.

If passthrough is not set then packets will be marked as follows:

first rule nth=2,1 rule will match every first packet of 2, hence, 50% of all the traffic that is matched by the rules
second rule if passthrough=no will match ONLY 25% of traffic because in 3.0 you need only one rule to catch traffic not like 2.9
[edit] Example
Now it is possible to match 50% of all traffic only with one rule:

/ip firewall mangle
add action=mark-packet chain=prerouting new-packet-mark=AAA nth=2,1;
If more than one rule is needed, then there are two ways to match packets:

first rule sees all packets and matches 1/3 of all, second rule sees 2/3 of packets and matches 1/2, third rule sees and matches all packets that passed through first two rules ( 1/3 of all packets ).
/ip firewall mangle
add action=mark-packet chain=prerouting new-packet-mark=AAA nth=3,1 passthrough=no;
add action=mark-packet chain=prerouting new-packet-mark=BBB nth=2,1 passthrough=no;
add action=mark-packet chain=prerouting new-packet-mark=CCC ;
all rules can see all packets and each rule matches every 3-rd packet.
/ip firewall mangle
add action=mark-packet chain=prerouting new-packet-mark=AAA nth=3,1 passthrough=yes;
add action=mark-packet chain=prerouting new-packet-mark=BBB nth=3,2 passthrough=yes;
add action=mark-packet chain=prerouting new-packet-mark=CCC nth=3,3 passthrough=yes;


很容易看懂的!!!参数少了一个!
routeros
发表于 2008-12-9 11:15:43 | 显示全部楼层
In v3.0 it is a little different implementation (执行)of NTH.  
  NTH在执行上有一点点不同之处
It has only two parameters(参数) 'every' and 'packet'.     
它只有俩个参数,每一个和包
[edit] How it works in v3.0                                 
在3.0这个个版本是怎么工作的呢?
Every rule has its own counter(计数器).                    
每一条规则都有它自己的计数器
When rule(规则) receives(接受) packet counter(包计数器) for current(通用?) rule is increased (增加)by one.

If counter(计数器) matches(比赛,对比,匹配) value(值) of 'every' packet will be matched and counter will be set to zero.(包会被匹配并且计数器会置为0)

If passthrough (路径)is not set then packets will be marked (做匹配?)as follows:

first rule nth=2,1 rule will match(匹配) every first packet of 2, hence(因此), 50% of all the traffic that is matched by the rules (50%的流量被这条规则匹配)

second rule if passthrough=no(路径=NO) will match ONLY 25% of traffic because in 3.0 you need only one rule to catch traffic not like 2.9 [edit] Example(2:如果路径=N0,将会匹配少许的25%的流量,因为在3.0的版本你需要仅仅一条规则去控制流量而不像2.9版本的)
Now it is possible to match 50% of all traffic only with one rule:
现在仅仅通过一条规则来匹配50%的流量是可能的
/ip firewall mangle
add action=mark-packet chain=prerouting new-packet-mark=AAA nth=2,1;
If more than one rule is needed, then there are two ways to match packets:
如果多条规则被需要,那这里就有两张种方式去匹配包

first rule sees all packets and matches 1/3 of all, 第一条规则,检查所有的包,并且匹配其中的3分子1
second rule sees 2/3 of packets and matches 1/2, 第二条规则检查3分子2,匹配一半
third rule sees and matches all packets that passed through first two rules ( 1/3 of all packets ).第三条规则查看匹配剩下的,
/ip firewall mangle
add action=mark-packet chain=prerouting new-packet-mark=AAA nth=3,1 passthrough=no;
add action=mark-packet chain=prerouting new-packet-mark=BBB nth=2,1 passthrough=no;
add action=mark-packet chain=prerouting new-packet-mark=CCC ;


all rules can see all packets and each rule matches every 3-rd packet. 所有的规则都可以检查到所有的包,每一规则匹配3分之1的包
/ip firewall mangle
add action=mark-packet chain=prerouting new-packet-mark=AAA nth=3,1 passthrough=yes;
add action=mark-packet chain=prerouting new-packet-mark=BBB nth=3,2 passthrough=yes;
add action=mark-packet chain=prerouting new-packet-mark=CCC nth=3,3 passthrough=yes;
一年之后我来翻译
routeros
回复

使用道具 举报

发表于 2010-1-20 09:16:50 | 显示全部楼层
不是很懂~!
routeros
回复

使用道具 举报

发表于 2010-2-22 14:43:06 | 显示全部楼层
这玩意,要是有图解就好了,这看很难理解。
routeros
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|软路由 ( 渝ICP备15001194号-1|渝公网安备 50011602500124号 )

GMT+8, 2024-5-7 01:55 , Processed in 0.071028 second(s), 4 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表