On Linux, see netem: the kernel already contains support for traffic shaping, and can simulate high latency, low bandwidth, packet losses, and all sort of other adverse conditions, even on a loopback device (so you don't need a real, physical network to test across).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…