0

I am kinda new to doing traffic control using Linux tc commands. So i am doing some hands-on on introducing network delay, packet loss and corruption etc across two hosts in the same network. The below commands were used to corrupt all traffic from port 20786 in Host A to port 202 in Host machine B.

sudo tc qdisc add dev eth0 root handle 1: prio priomap 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
sudo tc qdisc add dev eth0 parent 1:2 handle 20: netem corrupt 30%
sudo tc filter add dev eth0 parent 1:0 protocol ip u32 match ip sport 20786 0xffff flowid 1:2
sudo tc filter add dev eth0 parent 1:0 protocol ip u32 match ip dport 202 0xffff flowid 1:2

How do i make sure the packets will be corrupted? I am asking this because won't there be TCP error control which make sure that the packets don't get corrupted?

Pranooy
  • 1
  • 1

1 Answers1

0

If packets are corrupt then they will be dropped at the destination and the source will (eventually) retransmit them. So you will see a lot of retransmits in Wireshark. At 30% corruption the connection will have a LOT of them and thus be very slow.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • So corruption using tc command is meaningless, since it the corrupt packets are dropped and source retransmits them. Basically there is no way, you can get the corrupted packets at the destination. Can i ask what happens in the case of packet loss using "tc qdisc add dev eth0 parent 1:2 handle 20: netem loss 30%"? Packet loss should result in the loss of packets to the destination, since the destination has no way of knowing the packet loss and hence no retransmission. Is that correct? – Pranooy Jul 03 '20 at 05:19
  • Have you read about TCP yet? Every packet must get an ACK back from the destination or it is assumed to be lost and retransmitted. – Michael Hampton Jul 03 '20 at 05:24
  • You can get the corrupted packets at destination network stack. It simply discards them. You can see the corrupted packets by using Wireshark for example. – Tero Kilkanen Jul 03 '20 at 06:06