在工做中遇到了制造延迟测试
tc qdisc add dev eth1 root netem delay 600msip
测试部须要的场景比较特殊,只针对核心与组件之间延迟,对于普通设备等不作延迟。还须要保存延迟配置重启不失效ci
具体的作法是加过滤限制,只针对核心通讯的组件进行延迟,组件自己作延迟。get
针对不一样设备,加到平台配置层里面io
核心网上具体的配置
将
tc qdisc add dev eth1 root handle 1: prio priomap 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
tc qdisc add dev eth1 parent 1:2 handle 20: netem delay 600ms
tc filter add dev eth1 parent 1:0 protocol ip u32 match ip dst 192.168.69.23 flowid 1:2
tc filter add dev eth1 parent 1:0 protocol ip u32 match ip dst 192.168.69.24 flowid 1:2
写在/etc/rc.d/rc.local里面 其中192.168.69.23,24是组件ip eth1是核心对外网卡class
组件设备上的具体配置
将
cd /tcdir && chmod 777 tc
./tc qdisc add dev eth1 root netem delay 600ms配置
写在/opt/local/sbin/osscripts/OSStart 脚本中 其中 tcdir是tc文件所在的目录(不要放在root下) ,eth1是组件对外网卡network
tc qdisc del dev eth1 root #删除以前的延迟配置
tc也能够针对端口作限制
以上参考
https://stackoverflow.com/questions/40196730/simulate-network-latency-on-specific-port-using-tcmap