0

I want to build a server with two NICs that I can deploy between a test machine and its uplink so I can reduce the network speed for testing some other software. I have read this routing post, how to set up a router and How do I limit internet bandwidth. I want this server to be transparent on the network; however, not a router.

1
  • the tc command.
    – user610658
    Jun 13, 2018 at 6:13

1 Answer 1

1

I think it is possible with ebtables, see:

http://ebtables.netfilter.org/examples/example5.html

However you might have trouble getting the setup to be realistic (i.e. to behave like a network link that offers a rate equal to your throughput cap). This really depends on your requirements.

The average throughput will indeed be capped if you measure it over long periods (e.g. seconds), but if you do throttling in software the machine might process packets in bursts (meaning that you will have a processing delay a.k.a latency for each packet, and this delay might vary wildly between different packets). The effect is that for short time scales your throughput will be sometimes much higher than the cap, for others much lower. Only the averaged throughput over long periods will match the cap.

It is possible to lower the processing delay with some crazy optimizations, similar to those used in high-frequency trading, but it is very difficult and you will have to buy expensive hardware (e.g. racked servers) to get them working reliably.

If I were you, instead of spending money on the server, I would get a cheap managed switch (~$100). For instance SG-200s support rate limiting, see "Traffic Shaping" in the manual at page 174 https://www.cisco.com/c/dam/en/us/td/docs/switches/lan/csbss/sg200/administration_guide/78-19562.pdf These switches support rate limiting implemented in hardware and ideally should introduce a packet processing delay that is much smaller than what you get from a software box emulating the switch. You can also rest assured that it works correctly; anything you try to emulate in software needs to be tested and benchmarked carefully.

If you have very strict requirements, you might want to know that the cheap switches usually implement packet queuing using a method called WRR (weighted round robin). There is a more accurate rate limiting method called SRR (shaped round robin), for which the delay variations are even lower; however the price of those switches (certain Catalyst models) is usually above $1-2,000 because the chips run at a much higher clock frequency. Also, the fact that you have only one class of traffic might reduce the gap between them. The implementation difference between WRR and SRR is described here http://www.cisco.com/c/en/us/products/collateral/switches/catalyst-3560-e-series-switches/prod_qas0900aecd805bacc7.html (see Q. What is the difference between WRR and SRR in shared mode?)

(Of course there are other brands/models of managed switches that offer rate limiting; I'm not promoting anything, I'm just telling you about these because that's what I know about. Other brands/models most likely implement very similar mechanisms for rate limiting that might work just fine :) ).

9
  • I want to test adaptive streaming (HLS). A $100 managed switch is a good idea! I have plenty of servers to use at hand, too.
    – jnajna
    Sep 28, 2015 at 21:57
  • I think a switch would work. Make sure you use something that can be configured to not send Ethernet pause frames (layer 2 flow control). I'm assuming you want excess traffic to be dropped on the bottleneck link, as it would normally happen if the bottleneck was outside your LAN. en.wikipedia.org/wiki/Ethernet_flow_control
    – o9000
    Sep 28, 2015 at 22:41
  • I think I will get a NETGEAR ProSafe GS108Tv2, it supports shaping per interface in 16k increments.
    – jnajna
    Oct 1, 2015 at 23:59
  • I have never used NETGEAR, but from the manual it looks like you have 2 options: (1) it can shape either the whole interface as you said, or (2) you can create a policy, assign a Committed Rate (average traffic rate) and Committed Burst Size (buffer size) and set Violate Action to Drop. I'm not sure how exactly they implement the shaping and policing, but if it is the same algorithm as the one used by Cisco, the effect will be like this cisco.com/c/en/us/support/docs/quality-of-service-qos/…
    – o9000
    Oct 2, 2015 at 8:37
  • The difference between shaping and policing is that shaping is smoother and TCP adapts better to it.
    – o9000
    Oct 2, 2015 at 8:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .