is there a way in Linux to simulate slow traffic inbound to my server at a specific port? I looked at NETEM but it only seems to WAN wide.
An example of limiting all traffic matching tcp (protocol 6) destination port of 54000 at 256Kbits inbound to eth0
, using tc
...
As root...
tc qdisc add dev eth0 handle ffff: ingress
tc filter add dev eth0 parent ffff: protocol ip prio 50 u32 \
match ip protocol 6 0xff \
match ip dport 54000 0xffff police rate 256kbit burst 10k drop \
flowid :1
You can monitor it like this... notice the dropped
number for ffff
, below
[mpenning@Bucksnort ~]$ sudo tc -s qdisc show
qdisc pfifo_fast 0: dev eth0 root refcnt 2 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
Sent 17796311917 bytes 5850423 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
qdisc ingress ffff: dev eth0 parent ffff:fff1 ----------------
Sent 140590 bytes 1613 pkt (dropped 214, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
qdisc pfifo_fast 0: dev eth1 root refcnt 2 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
[mpenning@Bucksnort ~]$
To delete all ingress traffic filters:
tc qdisc del dev eth0 ingress
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With