Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have a network switch here and we can easily ask it to limit the bandwidth it allows, which is nice. It would be great if we could also ask it to generate packet losses for us - doing this with WANem is possible, but adds latencies and we are dealing with real-time applications, so any latency that we add is bad for us. Anyone knows of a network switch or a router that allows this or can be hacked to accomodate for it?

share|improve this question
up vote 1 down vote accepted

All switches that have rate-limiting either on port or vlan should allow you to "simulate" packet loss. If your application needs 1mb of traffic then set the limit to just below that and the switch should drop packets.

Remember that all switches that have this functionality have to sample to be able to limit. For example: port 1 is set to 1mb limit. Port 1 sends 2mb traffic for a fraction of a second. Most of it will probably make it through. This is because until the switch can detect and measure how much traffic comes through then it doesn't know what to drop. Depending on your vendor this can be implemented in many ways, some buffer and then will drop packets from the buffer, and some will just allow the moment in and out and then limit.

If you are looking for exactly how your application will respond I would suggest setting up a BSD box right in front of the computer you are testing the application on. BSD (just because I use them for my firewalls) has a command called ipfw that will allow you to directly control a connection. So lets assume the following is your current scenario:

+--------------------+      +----------------+
| Application Server | ---> | Client Machine |
+--------------------+      +----------------+

I understand that this would be an over-simplification but it illustrates the concept. What you can do is setup a nat in the middle and have it rate limit

+--------------------+      +-----------------------+      +----------------+
| Application Server | ---> | Rate Limit Box        | ---> | Client Machine |
|  |      | |      |    |
+--------------------+      +-----------------------+      +----------------+

Once again I know this is an over-simplification. I added IP's so that I could show you what the commands would be in BSD on the Rate Limit Box. First set up BSD to act as a normal router, you could use pf sense etc. Then you could add the following commands at prompt.

ipfw pipe 1 config bw 101Kbit
ipfw add 1 pipe 1 ip from to
ipfw add 2 pipe 1 ip from to

This would simulate a 101kb connection to and from the client to server. You can then change the 101 value to anything to be able to see what happens at various limits. The real advantage that this has over a switch that supports the limiting features is that it is cheap (a simple computer with a couple of interfaces) and that you can use wireshark to capture the traffic if necessary to then see what exactly is being dropped and how much. This information could be very useful in designing a better application.


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.