linux中模拟延时与丢包的实现
生活随笔
收集整理的這篇文章主要介紹了
linux中模拟延时与丢包的实现
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
延遲模擬:
1模擬eth0 網(wǎng)卡傳輸設(shè)置延遲為100ms發(fā)送
# tc qdisc add dev eth0 root netem delay 100ms2設(shè)置帶有波動的延遲情況,該命令將 eth0 網(wǎng)卡的傳輸設(shè)置為延遲 100ms ± 10ms (90 ~ 110 ms 之間的任意值)發(fā)送。
# tc qdisc add dev eth0 root netem delay 100ms 10ms3該命令將 eth0 網(wǎng)卡的傳輸設(shè)置為 100ms ,同時,大約有 30% 的包會延遲 ± 10ms 發(fā)送。示例:現(xiàn)在 ping 一下 216 機器:
# tc qdisc add dev eth0 root netem delay 100ms 10ms 30%丟包模擬:
1該命令將 eth0 網(wǎng)卡的傳輸設(shè)置為隨機丟掉 1% 、10%的數(shù)據(jù)包。
# tc qdisc add dev eth0 root netem loss 1% #tc qdisc add dev eth0 root netem loss 10% 該命令將 eth0 網(wǎng)卡的傳輸設(shè)置為隨機丟掉 1% 的數(shù)據(jù)包,成功率為 30% 。 # tc qdisc add dev eth0 root netem loss 1% 30%2 刪除網(wǎng)卡上面的相關(guān)配置:將之前命令中的 add 改為 del 即可刪除配置:
# tc qdisc del dev eth0 XXXXXXXXXXX(自己加的配置)該命令將 刪除 eth0 網(wǎng)卡的相關(guān)傳輸配置3模擬包重復(fù):該命令將 eth0 網(wǎng)卡的傳輸設(shè)置為隨機產(chǎn)生 1% 的重復(fù)數(shù)據(jù)包 。
# tc qdisc add dev eth0 root netem duplicate 1% #該命令將 eth0 網(wǎng)卡的傳輸設(shè)置為隨機產(chǎn)生 0.2% 的損壞的數(shù)據(jù)包 。 # tc qdisc add dev eth0 root netem corrupt 0.2%4模擬數(shù)據(jù)包亂序:該命令將 eth0 網(wǎng)卡的傳輸設(shè)置為:有 25% 的數(shù)據(jù)包(50%相關(guān))會被立即發(fā)送,其他的延遲10 秒。
# tc qdisc change dev eth0 root netem delay 10ms reorder 25% 50%5查看已經(jīng)配置的網(wǎng)絡(luò)條件:# tc qdisc show dev eth0
新人創(chuàng)作打卡挑戰(zhàn)賽發(fā)博客就能抽獎!定制產(chǎn)品紅包拿不停!總結(jié)
以上是生活随笔為你收集整理的linux中模拟延时与丢包的实现的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 十八年开发经历小结
- 下一篇: python替换文件内容_Python实