tc (Linux)
tc, short for traffic control, is a command-line utility in Linux used for configuring the Quality of Service (QoS) features of the Linux kernel's traffic control layer. It provides granular control over network traffic, allowing administrators to prioritize, shape, and filter network packets.
The tc
command is part of the iproute2
package and is used to create and manage traffic control objects such as:
-
Queuing Disciplines (qdiscs): Algorithms that determine how packets are queued and scheduled for transmission. Examples include pfifo_fast, HTB (Hierarchical Token Bucket), TBF (Token Bucket Filter), and RED (Random Early Detection). The qdisc is the core component of the traffic control system.
-
Classes: Hierarchical subdivisions within a qdisc that allow for different traffic classes to be treated differently. Classes can be nested to create a complex traffic control hierarchy.
-
Filters: Rules that classify packets based on various criteria (e.g., source/destination IP address, port number, protocol) and direct them to specific classes. Filters link network traffic to specific classes.
Using tc
, administrators can implement various traffic management strategies, including:
-
Bandwidth limiting: Restricting the amount of bandwidth available to certain types of traffic.
-
Prioritization: Giving higher priority to critical traffic, such as VoIP or video conferencing.
-
Traffic shaping: Smoothing out bursty traffic patterns to improve network performance.
-
Fair queuing: Ensuring that all traffic flows receive a fair share of available bandwidth.
Configuring traffic control with tc
can be complex, requiring a deep understanding of networking concepts and the specific queuing disciplines available. Changes made using tc
are generally not persistent across reboots unless they are saved to a configuration file and loaded at system startup. The configuration is typically applied to network interfaces.