Subject:

Making your connection bad


Date: Message-Id: https://www.5snb.club/posts/2024/making-your-connection-bad/

This is directly inspired by Engineering for Slow Internet. I figured I’d give running with dogshit internet on my desktop and phone a go to see how poorly (or well!) specific applications behave.

This is not an in-depth review of the behavior, but just my general impressions running for a few hours on 200kbit internet with significant packet loss.

F-Droid doesn’t have a download pause feature, but does resume interrupted downloads. Well done :) Though it does seem to crash sometimes (I have reported this).

Steam has a download pause feature, and does seem to resume interrupted downloads across steam restarts.

Telegram is quite usable. Images are slow, but for chat, I’d be perfectly happy with it.

Discord will sometimes just kick you to a loading screen if it thinks your internet isn’t working. If it doesn’t do that, it works pretty okay.

git fetches/clones simply do not have any resumption, as far as I can see. But if you fetch often enough, the transferred data might be small enough to be able to finish in one transfer. The kernel has instructions to clone from a bundle, which is one workaround for this issue. Doesn’t help you with pushes, though.

How to do this on linux

Your name for enp3s0 may be different. Change it to whatever your network adapter is.

sudo modprobe ifb

sudo ip link add name ifb0 type ifb
sudo ip link set dev ifb0 up

sudo tc qdisc add dev enp3s0 ingress
sudo tc filter add dev enp3s0 parent ffff: \
    u32 match u32 0 0 flowid 1:1 action mirred egress redirect dev ifb0

sudo tc qdisc add dev ifb0 root netem \
    delay 200ms 50ms 50 loss random 2% rate 200kbit
sudo tc qdisc add dev enp3s0 root netem \
    delay 200ms 50ms 50 loss random 2% rate 200kbit

If you want to test services running on localhost, replace enp3s0 with lo. Though some other programs on your system may Not Like It if localhost is slow, so do that at your own risk :3 (Be sure to replace enp3s0 with lo on the undo script!)

The post says

If you’re an app developer reading this, can you tell me, off the top of your head, how your app behaves on a link with 40 kbps available bandwidth, 1,000 ms latency, occasional jitter of up to 2,000 ms, packet loss of 10%, and a complete 15-second connectivity dropout every few minutes?

If you want to change the settings to those, do:

(I can’t seem to emulate the connection dropout, but the 10% packet loss should be harsh enough. Also, this is 40kbit up, and 40kbit down. Still, it’s Bad Enough.)

sudo tc qdisc change dev ifb0 root netem \
    delay 1000ms 2000ms 90 loss random 10% reorder 10% rate 40kbit
sudo tc qdisc change dev enp3s0 root netem \
    delay 1000ms 2000ms 90 loss random 10% reorder 10% rate 40kbit

To undo:

sudo tc qdisc delete dev ifb0 root
sudo tc qdisc delete dev enp3s0 root
sudo tc qdisc delete dev enp3s0 ingress
sudo modprobe --remove ifb

How to do this on android

And on an android device, it’s even easier to set up, but it only affects incoming download rate. But for testing “Hey, does this application utterly shit itself if it doesn’t have a fast network?”, that’s just fine. You need to enable developer options, though.

Inside Android Developer Options, Configure network rate limit set to 128kbps
android-incoming-limit.png 144.86 kB (864x1920)

How to do this on the web

Firefox developer tools, network tab, GPRS limiting selected
firefox-limit.png 57.96 kB (792x389)

On firefox, you can enable network rate limiting by going to the Web Developer Tools (Ctrl+Shift+I), going to the Network tab, then selecting the ratelimit using the dropdown in the top right. If you hover over the dropdown, you can see the limiting applied.

Further Reading