https://access.redhat.com/solutions/69133
How to apply a bandwidth or latency limitation to network interface or protocol?
SOLUTION 已验证 - 已更新 2017年六月26日09:52 -
环境
- Red Hat Enterprise Linux
- Networking
问题
- How to apply a bandwidth or latency limitation to network interface or protocol?
- How to configure latency on Ethernet interfaces in a test environment to simulate production?
- How do I use the
tc
traffic control command and qdisc (queueing disciplines)? - How to limit bandwidth for a single protocol like NFS?
- We found excessive use of bandwidth, how can we restrict it?
- How can a QoS (Quality of Service) policy be setup on a system to prioritize the network bandwidth usage?
- Outage is experienced at times when NetBackup jobs starts running. Is there a way to throttle bandwidth on the network interface that will provide lower priority to the backup traffic and reserve the network bandwidth on the interface?
决议
The limiting of network bandwith can be done on Linux with the tc
(traffic control) program and by the use of different "qdisc" (queueing discipline) when transmitting traffic.
Network traffic is submitted to the queuing discipline, which may buffer and re-order traffic, before submitting that traffic to the network card.
Following from left to right:
[ application - high priority ] --\
[ application - med priority ] --->--- [ qdisc ] --- [ NIC transmit ]
[ application - low priority ] --/
The qdisc is able to match traffic on certain parameters, allowing the "high priority" application to have guaranteed bandwidth over the lower applications, and the "medium priority" application to have guaranteed bandwidth over the lower application, but not the higher.
The qdisc can also only submit packets of all types (or certain types) at a specific rate to the network interface, resulting in a traffic ratelimit.
Whilst most bandwidth and latency ratelimiting focuses on transmit (outgoing) traffic, Linux enables receive (incoming) traffic to also be throttled with reasonably good results.
Specific Examples
The following examples are documented and could be used as a basis for further specific modifications:
- Ratelimit of one protocol
- Ratelimit of an entire network interface
- Ratelimit of a specific application using cgroups
- Ratelimit the incoming bandwith of an entire network interface
- Ratelimit using the CBQ service and initscript
- Packet rate limit of specific traffic using iptables
Useful Resources
-
Linux Advanced Routing & Traffic Control HOWTO
LARTC is considered the upstream source of documentation for learning abouttc
and qdiscs. -
Using iperf to test network bandwidth throughput
Theiperf
network bandwidth management tool can be used to test ratelimits and traffic matches to confirm operation. -
tc command's transport rate does not seem normal
Whilst bandwidth ratelimits generally get within 10% of their target, if results are far off, network send and receive offloading may need to be disabled as documented above.
Assistance
Red Hat Production Support assistance is available for queries relating to the configuration and usage of tc
and related commands.
Asking Red Hat Production Support to directly write configuration for specific customer needs is beyond the Scope of Coverage. If you would like Red Hat to perform this work for you, please contact your Red Hat Sales representative to discuss a consulting engagement.