Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulating a bad internet connection

I'm developing an embedded device which has access to the internet through LAN. I'm in the testing phase now, and I would like to test how the device performs when the connection to the internet is poor. Currently, the device is connected to a router through a hub, which I use to monitor the packets with Wireshark. What's the best way to throttle down the internet speed of the device to mimic a scenario that may happen?

Can I do it through a PC? Do I need access to the router? If so, is it possible to limit the speed of each IP in the router interface?

Actually, a friend suggested that I will purchase a usb2lan ethernet card, and to bridge the PC lan connection to the embedded device, and then using a software QoS limiter. do you think it will work ?

like image 708
stdcall Avatar asked Aug 06 '12 04:08

stdcall


People also ask

How do I simulate a bad Internet connection on my iPhone?

iPhone Device. Go to your Settings and go to Developer menu. Like the Network Link Conditioner in macOS, you can choose a desired profile to simulate for example a poor connection (100% Loss), or a 3G connection and so on.


2 Answers

If you have a Mac handy, Macs have kernel facility called dummynet built in, which you control through ipfw. It allows you to simulate a slow connection, randomly drop packets with certain probabilities, and more.

The same facility exists in Linux and other OSes.

From the dummynet homepage:

As of Feb.2010 we have released the third major version of dummynet, which now runs on all main platforms: FreeBSD, Mac OS X as part of the native distributions, and you can find Linux, OpenWRT and Windows versions here.

It can do a lot for you:

limit the total incoming TCP traffic to 2Mbit/s, and UDP to 300Kbit/s

ipfw add pipe 2 in proto tcp ipfw add pipe 3 in proto udp ipfw pipe 2 config bw 2Mbit/s ipfw pipe 3 config bw 300Kbit/s 

limit incoming traffic to 300Kbit/s for each host on network 10.1.2.0/24.

ipfw add pipe 4 src-ip 10.1.2.0/24 in ipfw pipe 4 config bw 300Kbit/s queue 20 mask dst-ip 0x000000ff 

simulate an ADSL link to the moon:

ipfw add pipe 3 out ipfw add pipe 4 in ipfw pipe 3 config bw 128Kbit/s queue 10 delay 1000ms ipfw pipe 4 config bw 640Kbit/s queue 30 delay 1000ms 
like image 142
Spiff Avatar answered Oct 03 '22 11:10

Spiff


You can try using "Fiddler"

You have options to simulate bad network (like old modems 33k or 56k)

You need to plug in your device to your PC and turn on the proxy (every request will be transfered through Fiddler)

Then you could test your code with a bad network then see what happening ;)

like image 32
Pouki Avatar answered Oct 03 '22 12:10

Pouki