找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 8392|回复: 16

[限速] 用PCQ实现线路带宽的平均分配

[复制链接]
发表于 2006-4-24 09:52:01 | 显示全部楼层 |阅读模式

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

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

×
用PCQ实现线路带宽的平均分配

搜索了很多关于PCQ的文章,均不甚了了.还是看看官方文档吧

神仙摘译自:
http://www.mikrotik.com/docs/ros/2.9/root/queue#6.54.6.3

挨个限制速度(simple queue)并进行保底是不错的方案,不过也可以试试别的,如PCQ。
挨个限制最大速度要建立几百个规则,且限速后每客户机除了峰值时段外不能
使用全部的带宽,即使线路是空闲的,有点浪费??很浪费


要实现带宽的最大化利用,可以考虑PCQ


下图是PCQ对通过的数据包按源地址进行分组的示意图

                               
登录/注册后可看大图


PCQ:Per Connection Queue 即按连接分组


If you classify the packets by src-address then all packets with different source
IP addresses will be grouped into different subqueues. Now you can do the limitation
or equalization for each subqueue with the pcq-rate parameter. Perhaps, the most
significant part is to decide to which interface should we attach this queue. If we
will attach it to the Local interface, all traffic from the Public interface will be
grouped by src-address (probably it's not what we want), but if we attach it to the
Public interface, all traffic from our clients will be grouped by src-address - so we
can easily limit or equalize upload for clients.
最关键的地方是决定关联哪块网卡。如果按源地址分组关联到内网网卡,那就等于是按外网的每个
地址进行分组了,这显然是错误的。但如果按源地址分组关联到外网网卡,就可以对按内网地址对
其上传进行带宽控制了。

To equalize rate among subqueues, classified by the pcq-classifier, set the pcq-rate to 0!
要平均分配的话,pcq-rate一定要设为0(这是默认值)。

PCQ can be used to dynamically equalize or shape traffic for multiple users, using
little administration.
使用PCQ只需很少的管理动作就可以实现多用户间的动态平均分配带宽。






Equal bandwidth sharing among users
怎样用PCQ实现平均分配带宽???

This example shows how to equally share 10Mibps download and 2Mibps upload among
active users in the network 192.168.0.0/24. If Host A is downloading 2 Mibps,
Host B gets 8 Mibps and vice versa. There might be situations when both hosts want
to use maximum bandwidth (10 Mibps), then they will receive 5 Mibps each, the same
goes for upload. This setup is also valid for more than 2 users.
举例说明一下怎样分配网络带宽.比如说某线路是下行10M,上行2M.现在要在192.168.0.0/24这个
网段里平均分配,也就是说,如果客户机A只使用了2M带宽进行下载(约200K),另个的客户机B就最高
可以达到8M的带宽,如果客户机A和B都想同时使用10M的带宽进行下载,结果就是两个客户机间进行
平均分配,即每客户机只能分得5M的带宽。更多客户按此类推。

At first,mark all traffic, coming from local network 192.168.0.0/24 with a mark 'users':
第一步是将来自192.168.0.0/24这个网段的流量打上标识,如'users'(神仙看前面有资料显示说过要
先标识相关连接才能标识相关数据包)

/ip firewall mangle add chain=forward src-address=192.168.0.0/24 \
action=mark-connection new-connection-mark=users-con
/ip firewall mangle add connection-mark=users-con action=mark-packet \
new-packet-mark=users chain=forward

Now we will add 2 new PCQ types. The first, called pcq-download will group all traffic
by destination address. As we will attach this queue type to the Local interface, it
will create a dynamic queue for each destination address (user) which is downloading
to the network 192.168.0.0/24. The second type, called pcq-upload will group the traffic
by source address. We will attach this queue to the Public interface so it will make one
dynamic queue for each user who is uploading to Internet from the local network 192.168.0.0/24.
然后是添加两种PCQ:第一种是关于下载的,名为pcq-download,关联到内网网卡Local,并动态地按
目标地址(相对于服务器就是指客户机)分组计算内网客户从外网下载的流量;第二种是关于上传的,
名为pcq-upload,关联到外网网卡Public,并动态地按源地址(相对于服务器还是指客户机)分组计算
向外网上传的流量。

/queue type add name=pcq-download kind=pcq pcq-classifier=dst-address
/queue type add name=pcq-upload kind=pcq pcq-classifier=src-address

Finally, make a queue tree for download traffic:
最后,生成下载流量树
/queue tree add name=Download parent=Local max-limit=10240000
/queue tree add parent=Download queue=pcq-download packet-mark=users

And for upload traffic:
和上传流量树
/queue tree add name=Upload parent=Public max-limit=2048000
/queue tree add parent=Upload queue=pcq-upload packet-mark=users

Note! If your ISP cannot guarantee you a fixed amount of traffic, you can use just
one queue for upload and one for download, attached directly to the interface:
当然,如果你的ISP提供的带宽经常在变化或者说根本不知道具体的带宽是多少,你可以只按网卡
给上传和下载各用一条规则就够了(即将上面的两组命令分别合二为一)
/queue tree add parent=Lan queue=pcq-download packet-mark=users
/queue tree add parent=Public queue=pcq-upload packet-mark=users

也就是说整个实现只需6行代码就可以了:
/ip firewall mangle add chain=forward src-address=192.168.0.0/24 \
action=mark-connection new-connection-mark=users-con
/ip firewall mangle add connection-mark=users-con action=mark-packet \
new-packet-mark=users chain=forward
/queue type add name=pcq-download kind=pcq pcq-classifier=dst-address
/queue type add name=pcq-upload kind=pcq pcq-classifier=src-address
/queue tree add parent=Lan queue=pcq-download packet-mark=users
/queue tree add parent=Public queue=pcq-upload packet-mark=users

这是我这个新手最近搞ros的一个作业,希望对你有所帮助哈
routeros
发表于 2006-4-24 10:11:50 | 显示全部楼层

回复 #1 神仙 的帖子

PCQ也有bug,改天发出来给大家看看.
这两天太忙了
routeros
回复

使用道具 举报

发表于 2006-4-24 13:10:06 | 显示全部楼层
原帖由 wwjun 于 2006-4-24 10:11 发表
PCQ也有bug,改天发出来给大家看看.
这两天太忙了


什么BUG?尽快给出来看看
routeros
回复

使用道具 举报

发表于 2006-4-25 21:58:39 | 显示全部楼层
我按照原版教程做了PCQ,但是发现并没有真正实现平均带宽,只要有人用P2P,别人的速度就会很卡!
routeros
回复

使用道具 举报

发表于 2006-4-26 03:15:11 | 显示全部楼层

强烈支持!!!

如花,等了你好久了!!!!!!!!!!
routeros
回复

使用道具 举报

发表于 2006-9-27 13:15:43 | 显示全部楼层
原帖由 专卖精品 于 2006-4-25 21:58 发表
我按照原版教程做了PCQ,但是发现并没有真正实现平均带宽,只要有人用P2P,别人的速度就会很卡!

P2P主要是堵上行带宽,你查一下你的ISP服务商给你提供的总上行带宽,另外P2P最好限线程,ROS内置的p2p包识别包不能识别新出的p2p软件包,基本上没多大用
routeros
回复

使用道具 举报

发表于 2006-9-27 14:26:15 | 显示全部楼层
P2P不能用这个做限制
routeros
回复

使用道具 举报

发表于 2006-9-27 17:28:20 | 显示全部楼层
我在单位试过adsl的,用pcq限下载可以80K(2M),上传限制就掉线20k(512K)
routeros
回复

使用道具 举报

发表于 2006-9-29 12:18:21 | 显示全部楼层
我用了还可以
就是监视器那不可以设时间,有些人使用P2P软件,PCQ一开,速度就降下来,但一降下来,PCQ就会关掉,然后速度又上去了
这样就会造成网速一卡一卡的
不知道大家有没什么好方法
routeros
回复

使用道具 举报

发表于 2006-9-29 17:48:18 | 显示全部楼层
辛苦了,顶顶你
routeros
回复

使用道具 举报

发表于 2007-2-5 09:43:12 | 显示全部楼层
唉,这样的帖子居然不加精,网上很多录象、教程,都是一知半解的家伙在误导人
routeros
回复

使用道具 举报

发表于 2007-2-5 17:22:07 | 显示全部楼层
去simple queue里运用pcq试试
routeros
回复

使用道具 举报

lawman 该用户已被删除
发表于 2007-2-5 17:46:47 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
routeros
回复

使用道具 举报

发表于 2007-2-5 18:26:47 | 显示全部楼层
这是pcq么??
routeros
回复

使用道具 举报

发表于 2007-2-5 18:55:21 | 显示全部楼层
这个PCQ的限速好像非要针对包标记才OK,只按接口的话,有些软件的确没办法限制
而且PCQ最大的特点是均分流量,限速更觉得采用阀值来的好些
也可以在简单队列中搭配PCQ,这个就有点复杂,没有具体做过
队列开关我觉得还是不可行的,我采用较长的阀值时间与不超过最大流量的阀值就可以针对每IP限速了,也不会有频繁转换的问题
routeros
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-6-2 05:45 , Processed in 0.121818 second(s), 6 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2023 Discuz! Team.

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