LinuxCommandLibrary

tc-choke

Control queue congestion using stochastic fair blue

SYNOPSIS

tc qdisc add ... choke [limit packets] [minlen bytes] [ptb probability] [avpkt bytes] [mtu bytes] [ecn]

PARAMETERS

limit packets
    Specifies the maximum number of packets that can be queued.

minlen bytes
    Specifies the minimum packet size (in bytes) to which the algorithm applies. Packets smaller than this size are not subject to Choke.

ptb probability
    Sets the probability of marking or dropping packets. Expressed as a floating-point number between 0.0 and 1.0 (e.g., 0.5 for 50%).

avpkt bytes
    Specifies the average packet size (in bytes). Used in calculations to estimate queue length. A good starting point is your MTU.

mtu bytes
    Specifies the Maximum Transmission Unit (MTU) size in bytes. Used for determining packet size characteristics of the network.

ecn
    Enables Explicit Congestion Notification (ECN). Instead of dropping packets, sets the ECN bit in the IP header to signal congestion to the sender.

DESCRIPTION

The tc-choke command is part of the Linux traffic control (tc) subsystem. It's a traffic control algorithm used for congestion control, specifically, it aims to limit traffic rates based on observed network congestion. Choke, standing for "CHoose and Keep for responsive flow Control," is designed to be responsive to congestion, providing a method for reducing packet loss and improving network performance. It's a probabilistic early packet marking/dropping mechanism. When network congestion is detected, tc-choke will randomly drop or ECN-mark packets. The probability of dropping/marking increases as the queue length grows.

tc-choke is commonly used in conjunction with queueing disciplines (qdiscs) like pfifo_fast, or more sophisticated qdiscs such as Hierarchical Token Bucket (HTB) to manage network bandwidth and prioritize different types of traffic. Its primary function is to prevent queues from overflowing, contributing to more stable network behavior.

CAVEATS

The effectiveness of tc-choke depends heavily on proper parameter tuning. Incorrect parameters can lead to under-utilization of bandwidth or excessive packet loss. It's best used when dealing with TCP traffic, as UDP traffic does not inherently respond to congestion signals. It's also important to consider the overall network architecture and other traffic control mechanisms in place when deploying tc-choke.

USAGE EXAMPLE

Example: To add a choke qdisc to interface eth0 with a limit of 1000 packets, a minimum packet size of 64 bytes, a dropping probability of 0.1, average packet size of 1500 bytes and enabling ECN: tc qdisc add dev eth0 root choke limit 1000 minlen 64 ptb 0.1 avpkt 1500 mtu 1500 ecn

ADVANCED CONSIDERATIONS

For optimal performance, experiment with different ptb (probability) values. Start with a low value (e.g., 0.01) and gradually increase it until you observe a good balance between throughput and latency. Monitoring queue lengths and packet loss is crucial for tuning tc-choke effectively.

HISTORY

tc-choke was developed as part of the Linux traffic control infrastructure to provide a relatively simple and effective means of congestion control. It was designed to address the limitations of simpler queueing disciplines in handling bursty traffic and preventing queue overflow. Its adoption has been relatively limited compared to RED (Random Early Detection) due to the complexity of parameter tuning, but it remains a viable option for specific network scenarios.

SEE ALSO

tc(8), tc-pfifo(8), tc-htb(8), tc-red(8)

Copied to clipboard