How can I simulate WAN latency with tc netem qdisc?

本文介绍如何使用tc工具在Red Hat Enterprise Linux 6.x和7.x上模拟WAN延迟,通过设置特定应用(监听端口1521)在局域网连接上的往返时间延迟,为系统1和系统2之间的通信引入约148毫秒的延迟。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

https://access.redhat.com/solutions/1983003

SOLUTION 已验证 - 已更新 2018年八月14日22:28 - 

English 

环境

  • Red Hat Enterprise Linux 6.x
  • Red Hat Enterprise Linux 7.x

问题

  • Unable to simulate latency using tc netem qdisc (delay never works)
  • Need to simulate WAN delays on LAN connection for specific Application

决议

  • Introducing delay of 74ms one end delay (~148ms RTT)
  • System1: 10.10.10.1 source port 1521 (Application's listening port)
  • System2: 10.10.10.2

Creating rules introducing delay from System1 towards System2:

Raw

System1# tc qdisc add dev eth0 root handle 1: prio
System1# tc qdisc add dev eth0  parent 1:1 handle 2: netem delay 74ms
System1# tc filter add dev eth0 protocol ip u32 match ip sport 1521 0xffff match ip dst 10.10.10.2/32 flowid 1:1

Creating rules introducing delay from System2 towards System1:

Raw

System2# tc qdisc add dev eth0 root handle 1: prio
System2# tc qdisc add dev eth0  parent 1:1 handle 2: netem delay 74ms
System2# tc filter add dev eth0 protocol ip u32 match ip dport 1521 0xffff match ip dst 10.10.10.1/32 flowid 1:1

Checking results:

Raw

System1# nping --tcp -p 1521 10.10.10.2

Starting Nping 0.6.47 ( http://nmap.org/nping ) at 2015-10-08 14:04 AEST
SENT (0.0259s) TCP 10.10.10.1:3196 > 10.10.10.2:1521 S ttl=64 id=41690 iplen=40  seq=3092419819 win=1480 
RCVD (0.1748s) TCP 10.10.10.2:1521 > 10.10.10.1:3196 RA ttl=61 id=0 iplen=40  seq=0 win=0 
SENT (1.0260s) TCP 10.10.10.1:3196 > 10.10.10.2:1521 S ttl=64 id=41690 iplen=40  seq=3092419819 win=1480 
RCVD (1.1747s) TCP 10.10.10.2:1521 > 10.10.10.1:3196 RA ttl=61 id=0 iplen=40  seq=0 win=0 
SENT (2.0272s) TCP 10.10.10.1:3196 > 10.10.10.2:1521 S ttl=64 id=41690 iplen=40  seq=3092419819 win=1480 
RCVD (2.1761s) TCP 10.10.10.2:1521 > 10.10.10.1:3196 RA ttl=61 id=0 iplen=40  seq=0 win=0 
SENT (3.0282s) TCP 10.10.10.1:3196 > 10.10.10.2:1521 S ttl=64 id=41690 iplen=40  seq=3092419819 win=1480 
RCVD (3.1770s) TCP 10.10.10.2:1521 > 10.10.10.1:3196 RA ttl=61 id=0 iplen=40  seq=0 win=0 
SENT (4.0293s) TCP 10.10.10.1:3196 > 10.10.10.2:1521 S ttl=64 id=41690 iplen=40  seq=3092419819 win=1480 
RCVD (4.1781s) TCP 10.10.10.2:1521 > 10.10.10.1:3196 RA ttl=61 id=0 iplen=40  seq=0 win=0 

Max rtt: 148.871ms | Min rtt: 148.729ms | Avg rtt: 148.786ms
Raw packets sent: 5 (200B) | Rcvd: 5 (230B) | Lost: 0 (0.00%)
Nping done: 1 IP address pinged in 4.19 seconds
#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值