2

The following rule corrupts 5% of the packets by introducing a single bit error at a random offset in the packet:

sudo tc qdisc change dev ens8 root netem corrupt 5%

But recently it gave me the following error:

Error: Qdisc not found. To create specify NLM_F_CREATE flag

Could you kindly help me or provide me with some other methods to simulate packet corruption? I'm trying to simulate packet corruption to see how well my error detection mechanism works.

1 Answer 1

3

The initial default qdisc set by the kernel with special handle 0: can't be modified nor referenced. It can only be overridden by a new qdisc. Using change references the existing root qdisc, but as this can't be the default kernel's qdisc, that's an error.

So the first time this netem qdisc is used, the add keyword should be used, and that's probably what was done at some point in the past. Then later the change keyword can be used to alter some of its parameters (like the corruption percent), since referencing it by the root keyword is enough.

As a shortcut replace will attempt change and if it fails will perform add instead.

So in the end this command will work the first and the following times too:

sudo tc qdisc replace dev ens8 root netem corrupt 5%

To remove this qdisc this should be done once (it would fail the 2nd time because that would be again done on the default qdisc installed by the kernel which is off-limits):

sudo tc qdisc delete dev ens8 root

The usage of add, change, replace (which is change or else add) and delete follows a similar pattern among many other iproute2 commands.

2
  • Thank you for your great answer. I want to use this method to test the TCP error rate (in detecting faulty packets), but it appears that TCP detects every corruption. Do you have any recommendations? Commented Aug 11, 2022 at 17:48
  • TCP being provided as a reliable service will trigger retransmission of lost packets (IP checksum or TCP checksum causing the corrupted packets to be dropped) so in the end, beside a slowdown (5% might be enough for an important slowdown), the application won't notice nor be able to notice. So I don't understand what you mean. Perhaps that's a case of X Y problem? Commented Aug 12, 2022 at 6:50

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.