Skip to contentSkip to conversation

Simulating (emulating?) bad network conditions

DISCUSSION Erik Auerswald 4 participants 4 messages May 23, 2020

lore
Share & tools
lore
#0 lore raw

Hi,

recently someone asked about a script for simulating or emulating degraded network conditions. I could not provide an answer, because I do not have something like that available, yet.

But I have just read about "Comcast" which seems to do just that:
https://github.com/tylertreat/Comcast

The README.md contains information on how to use iptables and/or tc directly instead of through Comcast as well:

"""
Linux

On Linux, you can use iptables to drop incoming and outgoing packets.

    $ iptables -A INPUT -m statistic --mode random --probability 0.1 -j DROP
    $ iptables -A OUTPUT -m statistic --mode random --probability 0.1 -j DROP

Alternatively, you can use tc which supports some additional options.

    $ tc qdisc add dev eth0 root netem delay 50ms 20ms distribution normal
    $ tc qdisc change dev eth0 root netem reorder 0.02 duplicate 0.05 corrupt 0.01

To reset:

    $ tc qdisc del dev eth0 root netem
"""
                -- https://github.com/tylertreat/Comcast#linux

I have not tested this, but it seems to provide a starting point for experimentation.

HTH,
Erik

Signature · 3 lines
To a first approximation, we can say that accidents are almost always
the result of incorrect estimates of the likelihood of one or more things.
                        -- C. Michael Holloway, NASA
#1 lore raw

Yes, we have used tc netem to successfully make a connection bad.

Signature · 2 lines
  Jehan Tremback
  [email protected]
Quoted 43 lines · Erik Auerswald

Hi,

recently someone asked about a script for simulating or emulating degraded network conditions. I could not provide an answer, because I do not have something like that available, yet.

But I have just read about "Comcast" which seems to do just that:
https://github.com/tylertreat/Comcast

The README.md contains information on how to use iptables and/or tc directly instead of through Comcast as well:

"""
Linux

On Linux, you can use iptables to drop incoming and outgoing packets.

    $ iptables -A INPUT -m statistic --mode random --probability 0.1 -j DROP
    $ iptables -A OUTPUT -m statistic --mode random --probability 0.1 -j DROP

Alternatively, you can use tc which supports some additional options.

    $ tc qdisc add dev eth0 root netem delay 50ms 20ms distribution 
normal
    $ tc qdisc change dev eth0 root netem reorder 0.02 duplicate 0.05 
corrupt 0.01

To reset:

    $ tc qdisc del dev eth0 root netem
"""
                -- https://github.com/tylertreat/Comcast#linux

I have not tested this, but it seems to provide a starting point for experimentation.

HTH,
Erik

Signature · 3 lines
To a first approximation, we can say that accidents are almost always
the result of incorrect estimates of the likelihood of one or more things.
                        -- C. Michael Holloway, NASA
#2 lore raw
In reply to Erik Auerswald

If you want terribad network conditions, you can use cellsim (instructions at http://alfalfa.mit.edu/) which will let you replay actual network condition traces from cellular links (including such awesome properties as intermittent 60+s latency).

--Quentin

Quoted 51 lines · Jehan Tremback

Yes, we have used tc netem to successfully make a connection bad.

--
Jehan Tremback
[email protected]

Quoted 43 lines · Erik Auerswald

Hi,

recently someone asked about a script for simulating or emulating degraded network conditions. I could not provide an answer, because I do not have something like that available, yet.

But I have just read about "Comcast" which seems to do just that:
https://github.com/tylertreat/Comcast

The README.md contains information on how to use iptables and/or tc directly instead of through Comcast as well:

"""
Linux

On Linux, you can use iptables to drop incoming and outgoing packets.

    $ iptables -A INPUT -m statistic --mode random --probability 0.1 -j DROP
    $ iptables -A OUTPUT -m statistic --mode random --probability 0.1 -j DROP

Alternatively, you can use tc which supports some additional options.

    $ tc qdisc add dev eth0 root netem delay 50ms 20ms distribution
normal
    $ tc qdisc change dev eth0 root netem reorder 0.02 duplicate 0.05
corrupt 0.01

To reset:

    $ tc qdisc del dev eth0 root netem
"""
                -- https://github.com/tylertreat/Comcast#linux

I have not tested this, but it seems to provide a starting point for experimentation.

HTH,
Erik
--
To a first approximation, we can say that accidents are almost always the result of incorrect estimates of the likelihood of one or more things.
-- C. Michael Holloway, NASA

#3 lore raw
In reply to Erik Auerswald

Thanks all for these comments. (I appreciate the snarkiness of the name "comcast".)

Rich

Quoted 42 lines · Erik Auerswald

Hi,

recently someone asked about a script for simulating or emulating degraded network conditions. I could not provide an answer, because I do not have something like that available, yet.

But I have just read about "Comcast" which seems to do just that:
https://github.com/tylertreat/Comcast

The README.md contains information on how to use iptables and/or tc directly instead of through Comcast as well:

"""
Linux

On Linux, you can use iptables to drop incoming and outgoing packets.

   $ iptables -A INPUT -m statistic --mode random --probability 0.1 -j DROP
   $ iptables -A OUTPUT -m statistic --mode random --probability 0.1 -j DROP

Alternatively, you can use tc which supports some additional options.

   $ tc qdisc add dev eth0 root netem delay 50ms 20ms distribution normal
   $ tc qdisc change dev eth0 root netem reorder 0.02 duplicate 0.05 corrupt 0.01

To reset:

   $ tc qdisc del dev eth0 root netem
"""
               -- https://github.com/tylertreat/Comcast#linux

I have not tested this, but it seems to provide a starting point for experimentation.

HTH,
Erik

Signature · 3 lines
To a first approximation, we can say that accidents are almost always
the result of incorrect estimates of the likelihood of one or more things.
                       -- C. Michael Holloway, NASA