首页 > linux, ubuntu, xen > linux tc 对本机网卡限速

linux tc 对本机网卡限速

2010年1月25日 eric 发表评论 阅读评论

今天由于项目要测试在网络环境不好的情况下,会不会对平台有所影响,要求测试限制服务器流量,我想到了TC,我对TC不是很了解, google了一下,看到了不少文章都是做路由用的,对我来说不是很实用,因为我是对单机测试。先看看TC命令在说,没想到报错,错误如下:
shell$> tc -s qdisc
RTNETLINK answers: Invalid argument
看到这个错误很迷茫,命令是支持的啊,在网上查询了很久,发现是内核不支持,不支持QOS,不支持正常,因为我的内部测试服务器用XEN,虚拟的系统,所以我重新编译DomU内核,添加 QOS,CBQ等

环境:
xen domU : ubuntu-server 8.0.4  IP:192.168.6.101
kernel : linux-2.6.18-xen
xen dom0 : ubuntu-server 8.0.4  IP:192.168.6.209
操作:

DomU $> tc -s qdisc
RTNETLINK answers: Invalid argument

进入父系统:
Dom0 $> cd xen-3.4.2
编译xen DomU 内核
Dom0 $> make linux-2.6-xenU-config CONFIGMODE=menuconfig
选择 Networking  —>
          Networking options  —>
                QoS and/or fair queueing  —>
                      [*] QoS and/or fair queueing
把下面的最好都选上吧 * 是打入内核,M 是以模块方式。我全选择 *
选择好,保存退出

Dom0 $> make linux-2.6-xenU-build        

Dom0 $> cd xen-3.4.2/dist/install/boot

Dom0 $> scp vmlinuz-2.6.18.8-xenU root@192.168.6.101:~

好,然后进入 DomU

DomU $> ls
vmlinuz-2.6.18.8-xenU
覆盖 以前的vmlinuz-2.6.18.8-xenU
DomU $> mv vmlinuz-2.6.18.8-xenU /boot/
DomU $> reboot

重启后,在进入系统,看是否还报错:

DomU $> tc -s qdisc
好没有报错“下来我们对 服务器 1935 端口进行限速,限制为 上传下载都为50Kbit

CBQ 算法:

DomU $> tc qdisc del dev eth0 root
DomU $> tc qdisc add dev eth0 root handle 1:0 cbq bandwidth 100Mbit avpkt 1000 cell 8
DomU $> tc class add dev eth0 parent 1:0 classid 1:1 cbq bandwidth 100Mbit rate 50Kbit weight 50Kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 1000 bounded
DomU $> tc class add dev eth0 parent 1:1 classid 1:4 cbq bandwidth 100Mbit rate 50Kbit weight 50Kbit prio 5 allot 1514 cell 8 maxburst 20 avpkt 1000
DomU $> tc qdisc add dev eth0 parent 1:4 handle 40: sfq
DomU $> tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 match ip sport 1935 0xffff flowid 1:4

好了 连接 1935 试试吧`

转载请注明:文章转载自:Eric's linux and nginx! (http://www.nginxs.com)
本文地址:http://www.nginxs.com/linux/29.html

  1. 2018年12月22日10:26 | #1

    The precise advice can save you time and money.

  2. 2018年12月22日16:57 | #2

    Hello to all, how is all, I think every one is
    getting more from this website, and your views are pleasant in favor of new viewers.

  3. 2018年12月23日17:11 | #3

    The fitting advice can save you time and money.

  4. 2018年12月24日04:19 | #4

    I’m considering a wood privateness fence.

  5. 2018年12月24日16:58 | #5

    The proper advice can prevent money and time.

  6. 2018年12月25日00:55 | #6

    Valuable information. Lucky me I found your web site accidentally, and I’m
    shocked why this twist of fate did not took place earlier!
    I bookmarked it.

  7. 2018年12月25日05:26 | #7

    The appropriate recommendation can save you
    time and money.

  8. 2018年12月25日08:53 | #8

    Thank you for sharing your thoughts. I truly appreciate
    your efforts and I am waiting for your next write ups thank you
    once again.

  9. 2018年12月25日19:22 | #9

    The correct advice can prevent time and money.

  10. 2018年12月26日03:27 | #10

    Very shortly this web page will be famous among all blogging visitors, due to it’s good articles

  11. 2018年12月26日04:28 | #11

    Good post! We will be linking to this great content
    on our website. Keep up the great writing.

  12. 2018年12月26日04:54 | #12

    It’s remarkable to pay a quick visit this site and reading the views of all mates concerning this post, while I am also eager of getting know-how.

  13. 2018年12月26日05:58 | #13

    The correct recommendation can save you time and money.

  14. 2018年12月26日06:24 | #14

    The fitting recommendation can save you time and money.

  15. 2018年12月28日15:41 | #15

    This is the right web site for anyone who hopes to find out about this topic.
    You know a whole lot its almost hard to argue with you (not that I personally would want to…HaHa).
    You certainly put a new spin on a topic which has been discussed for years.

    Excellent stuff, just wonderful!

  16. 2019年1月2日17:50 | #16

    I do consider all of the ideas you’ve introduced on your post.
    They’re very convincing and will definitely work. Still, the posts are too quick for newbies.
    May just you please extend them a bit from next time?
    Thank you for the post.

  17. 2019年1月4日10:28 | #17

    Very nice article. I absolutely appreciate this website. Continue the
    good work!

  18. 2019年1月5日12:37 | #18

    First of all I would like to say terrific blog! I had a quick question in which I’d
    like to ask if you do not mind. I was curious to know how you center yourself
    and clear your thoughts prior to writing.
    I have had a tough time clearing my thoughts in getting
    my thoughts out there. I do take pleasure in writing
    but it just seems like the first 10 to 15 minutes
    are generally wasted simply just trying to figure out how to begin. Any ideas or hints?
    Cheers!

  19. 2019年1月7日07:43 | #19

    When someone writes an piece of writing he/she maintains the thought of a user in his/her brain that how a user can understand it.
    So that’s why this paragraph is outstdanding. Thanks!

  20. 2019年1月8日09:39 | #20

    I read this post fully about the comparison of most recent and previous technologies,
    it’s awesome article.

  21. 2019年1月15日16:35 | #21

    I am regular visitor, how are you everybody? This paragraph posted at this web site is actually pleasant.

  22. 2019年1月20日13:01 | #22

    Unquestionably believe that that you stated. Your favorite justification seemed to be
    at the internet the simplest factor to take into account of.
    I say to you, I definitely get irked while other folks consider
    worries that they plainly do not know about.
    You controlled to hit the nail upon the top and also outlined out the whole thing without having side-effects , folks
    could take a signal. Will likely be back to get more.
    Thank you

  23. 2019年1月25日02:38 | #23

    Write more, thats all I have to say. Literally, it seems as though you relied on the video
    to make your point. You definitely know what youre talking about, why waste your intelligence on just posting videos to your site when you could be giving us something enlightening to read?

  24. 2019年2月2日03:50 | #24

    What a stuff of un-ambiguity and preserveness of precious familiarity on the topic of unexpected emotions.

  25. 2019年2月23日17:20 | #25

    Very great post. I simply stumbled upon your weblog and
    wanted to say that I have really loved browsing your weblog posts.
    After all I’ll be subscribing for your feed and I am hoping you write again very
    soon!

  26. 2019年3月3日11:13 | #26

    Hello, this weekend is good for me, for the reason that this point in time i am reading this fantastic informative piece of writing here
    at my house.

  27. 2019年3月22日04:41 | #27

    Wow, wonderful blog layout! How long have you been blogging
    for? you made blogging look easy. The overall look of your
    site is magnificent, as well as the content!

评论分页
1 ... 3 4 5 29
订阅评论
5+6= (必填)