{"id":1728,"date":"2019-12-27T19:33:04","date_gmt":"2019-12-27T11:33:04","guid":{"rendered":"http:\/\/www.eumz.com\/?p=1728"},"modified":"2019-12-27T19:33:04","modified_gmt":"2019-12-27T11:33:04","slug":"%e7%bb%99%e7%bd%91%e7%bb%9c%e6%b3%a8%e5%85%a5%e7%82%b9%e5%bb%b6%e8%bf%9f","status":"publish","type":"post","link":"https:\/\/www.wxcn.com\/?p=1728","title":{"rendered":"\u7ed9\u7f51\u7edc\u6ce8\u5165\u70b9\u5ef6\u8fdf"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\" id=\"\u524d\u8a00\">\u524d\u8a00<\/h1>\n\n\n\n<p>\u6709\u4e9b\u65f6\u5019\uff0c\u9700\u8981\u4eba\u4e3a\u5f15\u5165\u7f51\u7edc\u5ef6\u8fdf\uff0c\u6a21\u62df\u7f51\u7edc\u6761\u4ef6\u6bd4\u8f83\u5dee\u7684\u60c5\u51b5\u4e0b\uff0c\u96c6\u7fa4\u7684\u884c\u4e3a\u3002\u8fd9\u65f6\u5019\uff0ctc\u8fd9\u4e2a\u5de5\u5177\u5c31\u6a2a\u7a7a\u51fa\u4e16\u4e86\u3002 tc\u662f Traffic Control\u7684\u7b80\u5199\uff0c\u7528\u6765\u63a7\u5236\u7f51\u7edc\u6d41\u91cf\u7684\u3002\u5b83\u7684\u529f\u80fd\u8fd8\u662f\u5f88\u5f3a\u5927\u7684\uff0c\u6211\u4eec\u672c\u6587\u4ec5\u7b80\u5355\u4ecb\u7ecd\u5982\u4f55\u60f9\u4eba\u4e3a\u5730\u6ce8\u5165\u7f51\u7edc\u5ef6\u8fdf\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"\u6ce8\u5165\u5ef6\u8fdf\">\u6ce8\u5165\u5ef6\u8fdf<\/h1>\n\n\n\n<p>\u6ce8\u5165\u5ef6\u8fdf\u4e4b\u524d\uff0c\u770b\u4e0b\u7f51\u8def\u5ef6\u8fdf\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root@BEAN-1:~# ping 10.10.125.1\nPING 10.10.125.1 (10.10.125.1) 56(84) bytes of data.\n64 bytes from 10.10.125.1: icmp_req=1 ttl=64 time=0.178 ms\n64 bytes from 10.10.125.1: icmp_req=2 ttl=64 time=0.090 ms\n64 bytes from 10.10.125.1: icmp_req=3 ttl=64 time=0.270 ms\n64 bytes from 10.10.125.1: icmp_req=4 ttl=64 time=0.156 ms\n64 bytes from 10.10.125.1: icmp_req=5 ttl=64 time=0.145 ms\n^C\n--- 10.10.125.1 ping statistics ---\n5 packets transmitted, 5 received, 0% packet loss, time 3998ms\nrtt min\/avg\/max\/mdev = 0.090\/0.167\/0.270\/0.061 ms\n\n<\/code><\/pre>\n\n\n\n<p>\u7ed9eth0 \u6ce8\u51658ms\u7684\u5ef6\u8fdf\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tc qdisc add dev eth0 root netem delay 8ms\n<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\u901a\u8fc7ping\u67e5\u770b\u662f\u5426\u751f\u6548\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ping 10.10.125.1\nPING 10.10.125.1 (10.10.125.1) 56(84) bytes of data.\n64 bytes from 10.10.125.1: icmp_req=1 ttl=64 time=8.17 ms\n64 bytes from 10.10.125.1: icmp_req=2 ttl=64 time=8.17 ms\n64 bytes from 10.10.125.1: icmp_req=3 ttl=64 time=8.18 ms\n64 bytes from 10.10.125.1: icmp_req=4 ttl=64 time=8.28 ms\n64 bytes from 10.10.125.1: icmp_req=5 ttl=64 time=8.13 ms\n^C\n--- 10.10.125.1 ping statistics ---\n5 packets transmitted, 5 received, 0% packet loss, time 4003ms\nrtt min\/avg\/max\/mdev = 8.139\/8.190\/8.286\/0.050 ms\n\n<\/code><\/pre>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\u7f51\u7edc\u5ef6\u8fdf\u589e\u52a0\u4e868ms\u5de6\u53f3\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"\u67e5\u770b\u5f53\u524d\u7684\u5ef6\u8fdf\u4fe1\u606f\">\u67e5\u770b\u5f53\u524d\u7684\u5ef6\u8fdf\u4fe1\u606f<\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>tc qdisc show dev eth1 \nqdisc netem 8121: root refcnt 2 limit 1000 delay 8.0ms\n<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"\u6539\u53d8\u7f51\u7edc\u5ef6\u8fdf\u5927\u5c0f\">\u6539\u53d8\u7f51\u7edc\u5ef6\u8fdf\u5927\u5c0f<\/h1>\n\n\n\n<p>\u6ce8\u610f\uff0c\u5982\u679c\u5df2\u7ecf\u5f15\u5165\u4e86\u5ef6\u8fdf\uff0c\u4f46\u662f\u8981\u4fee\u6539\u5ef6\u8fdf\u5927\u5c0f\uff0c\u4f7f\u7528add\u5c31\u4e0d\u884c\u4e86\uff0c\u8981\u7528change<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tc qdisc add  dev eth1 root netem delay 10ms\nRTNETLINK answers: File exists\n\ntc qdisc change  dev eth1 root netem delay 10ms\n\ntc qdisc show dev eth1 \nqdisc netem 8121: root refcnt 2 limit 1000 delay 10.0ms\n\n<\/code><\/pre>\n\n\n\n<p>\u6216\u8005\u6211\u4eec\u4e0d\u60f3\u533a\u522b\u7b2c\u4e00\u6b21\u548c\u4fee\u6539\uff0c\u53ef\u4ee5\u4e00\u5f8b\u4f7f\u7528replace<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u5220\u9664\u5f15\u5165\u7684\u7f51\u7edc\u5ef6\u8fdf\ntc qdisc del dev eth1 root netem delay 1ms\n\n\u663e\u793a\u5f53\u524d\u7684\u72b6\u6001\uff0c\u65e0\u5ef6\u8fdf\ntc qdisc show dev eth1 \nqdisc pfifo_fast 0: root refcnt 2 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1\n\n\uff03replace\u8bbe\u7f6e\u5ef6\u8fdf\u4e3a9ms\ntc qdisc replace  dev eth1 root netem delay 9ms\n\n# \u663e\u793a\u5f53\u524d\u72b6\u6001\uff0c\u7684\u786e\u662fdelay 9ms\ntc qdisc show dev eth1 \nqdisc netem 8123: root refcnt 2 limit 1000 delay 9.0ms\n\n# \u7528replace\u6765\u4fee\u6539\u7f51\u7edc\u5ef6\u8fdf\u4e3a4ms\ntc qdisc replace  dev eth1 root netem delay 4ms\n\n# \u663e\u793a\u5f53\u524d\u7f51\u7edc\u5ef6\u8fdf\uff0c\u7684\u786e\u662f4ms\ntc qdisc show dev eth1 \nqdisc netem 8123: root refcnt 2 limit 1000 delay 4.0ms\n\n<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"\u5220\u9664\u5f15\u5165\u7684\u5ef6\u8fdf\">\u5220\u9664\u5f15\u5165\u7684\u5ef6\u8fdf<\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>tc qdisc del dev eth1 root netem delay 1ms\n\n<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"\u5176\u4ed6\">\u5176\u4ed6<\/h1>\n\n\n\n<p>\u6211\u4eec\u5728\u6d4b\u8bd5\u811a\u672c\u4e2d\u5f15\u5165\u5ef6\u8fdf\uff0c\u4f46\u662f\u987b\u77e5\uff0c\u811a\u672c\u53ef\u80fd\u4f1a\u88ab\u4fe1\u53f7\u6740\u6b7b\uff0c\u6211\u4eec\u5e0c\u671b\uff0c\u811a\u672c\u9000\u51fa\u7684\u65f6\u5019\uff0c\u7f51\u7edc\u5ef6\u8fdf\u88ab\u91cd\u7f6e\u4e3a0\uff0c\u8fd9\u65f6\u5019\uff0c\u5bf9\u4e8eshell\u811a\u672c\u800c\u8a00\uff0c\u9700\u8981\u4f7f\u7528trap\uff0c\u505a\u6e05\u7406\u5de5\u4f5c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function clean\n{\n   #\u6b64\u51fd\u6570\u4e3a\u6e05\u7406\u51fd\u6570\uff0c\u4e00\u822c\u662f\u5c06\u4eba\u4e3a\u5f15\u5165\u7684\u7f51\u7edc\u5ef6\u8fdf\u5220\u9664\n}\n\ntrap clean EXIT<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u6709\u4e9b\u65f6\u5019\uff0c\u9700\u8981\u4eba\u4e3a\u5f15\u5165\u7f51\u7edc\u5ef6\u8fdf\uff0c\u6a21\u62df\u7f51\u7edc\u6761\u4ef6\u6bd4\u8f83\u5dee\u7684\u60c5\u51b5\u4e0b\uff0c\u96c6\u7fa4\u7684\u884c\u4e3a\u3002\u8fd9\u65f6\u5019\uff0ctc\u8fd9\u4e2a\u5de5\u5177\u5c31\u6a2a\u7a7a\u51fa\u4e16\u4e86 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[284,440],"class_list":["post-1728","post","type-post","status-publish","format-standard","hentry","category-tech","tag-tc","tag-440"],"_links":{"self":[{"href":"https:\/\/www.wxcn.com\/index.php?rest_route=\/wp\/v2\/posts\/1728","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wxcn.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wxcn.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wxcn.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wxcn.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1728"}],"version-history":[{"count":0,"href":"https:\/\/www.wxcn.com\/index.php?rest_route=\/wp\/v2\/posts\/1728\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wxcn.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1728"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wxcn.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1728"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wxcn.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1728"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}