Linux command
tc 命令
安全
权限或系统影响较大,执行前请核对目标。
常用示例
Example
sudo tc qdisc add dev eth0 root netem delay 100ms
Example
sudo tc qdisc add dev eth0 root netem delay 100ms 20ms
Example
sudo tc qdisc add dev eth0 root netem loss 5%
Limit
sudo tc qdisc add dev eth0 root tbf rate 10mbit burst 32kbit latency 400ms
Show
tc qdisc show dev eth0
Delete
sudo tc qdisc delete dev eth0
Change
sudo tc qdisc change dev eth0 root netem delay 50ms
说明
tc (traffic control) configures kernel packet scheduling, shaping, and filtering. It can simulate network conditions like latency, packet loss, and bandwidth limits for testing or quality of service management.
参数
- qdisc
- Queuing discipline - manage packet queuing
- add
- Add a new traffic control policy
- delete
- Remove traffic control policy
- change
- Modify existing policy
- show
- Display current policies
- netem
- Network emulation (delay, loss, corruption)
- tbf
- Token bucket filter (bandwidth limiting)
- delay _ms_
- Add latency to packets
- loss _percent_
- Drop percentage of packets
- rate _bandwidth_
- Maximum bandwidth rate
FAQ
What is the tc command used for?
tc (traffic control) configures kernel packet scheduling, shaping, and filtering. It can simulate network conditions like latency, packet loss, and bandwidth limits for testing or quality of service management.
How do I run a basic tc example?
Run `sudo tc qdisc add dev eth0 root netem delay 100ms` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does qdisc do in tc?
Queuing discipline - manage packet queuing