dummynet is a live network emulation tool, originally designed for
testing networking protocols, and since then used for a variety of
applications including bandwidth management. It simulates/enforces
queue and bandwidth limitations, delays, packet losses, and multipath
effects. It also implements various scheduling algorithms.
dummynet can be used on the machine running the user's application,
or on external boxes acting as routers or bridges.
dummynet runs within your operating system (FreeBSD, OSX, Linux, Windows)
and works by intercepting selected traffic on its way
through the network stack, as in the figure above, and passing
packets to objects called pipes which implement a set of
queues, a scheduler, and a link, all
with configurable features (bandwidth, delay,
loss rate, queue size, scheduling policy...).
Traffic selection is done using the ipfw firewall,
which is the main user interface for dummynet. ipfw lets
you select precisely the traffic and direction you want
to work on, making configuration and use incredibly simple.
You can create multiple pipes, send traffic to different
pipes, even build cascades of pipes.
Just a few examples:

For performance please read the Dummynet Revisited paper.
On a modern system you should be able to deal 2-300 Kpps. The standard
timer resolution is 1 ms but you can reduce it to 100 us.
If you need higher packet rates, you may want to check the
netmap-enabled version, which
is 10 times faster.

dummynet and ipfw are standard components of FreeBSD and OSX.
They are also available as external kernel modules for Linux and Windows
(both 32 and 64 bit).
The source code
distribution contains source code to build it on Linux and Windows,
as well as precompiled modules for Windows XP/Win7 (both 32 and 64 bit).
In addition to the source code, we also distribute some bootable
images and precompiled binaries:

PicoBSD image (feb.2010)
with dummynet and several utilities (ssh, sshd, natd and so on).
You can copy it on a USB key and boot from it, or run it in qemu.

In May 2012 ACM SIGCOMM has granted the dummynet project a
SIGCOMM Community Projects Award.
The award will be used to support development
of dummynet on multiple platforms and improve its performance.

A userspace version of ipfw and dummynet
is now available, using netmap for packet I/O.
On an i7-3400, this version is able to process over 6 million packets per second (Mpps)
with simple rulesets, and over 2.2 Mpps through dummynet pipes,
5..10 times faster than the in-kernel equivalent.
You can use a couple of VALE switches or netmap pipes (part of netmap) to connect
a source and sink to the userspace firewall, as follows