5
Most read
9
Most read
11
Most read
Linux Traffic Control
SUSE Labs Taipei technology sharing day 2018
David Chang
Software Engineer
SUSE / dchang@suse.com
2
Overview
• What is Traffic Control
• Why use Traffic Control
• How it works
• Traffic Control elements
• Linux Traffic Control components
• Traffic Control with tc command
3
What is Traffic Control
• The sets of queuing systems and mechanisms by which packets are received
and transmitted on a router
– Deciding which packets to accept at what rate on the input of an interface
– Determining which packets to transmit in what order at what rate on the output of an
interface
• Quality of Service (QoS) is often used as a synonym for network traffic control
4
Why use Traffic Control
• Traffic control tools allow administrator to enqueue packets into the network
differently based on attributes of the packet
• Advantages
– Lead to more predictable usage of network resources and less volatile contention for
these resources
• Disadvantages
– Complexity
– Complexity
– Complexity
5
Common Traffic Control solutions
• Limit total bandwidth to a known rate
• Limit the bandwidth of a particular user, service or client
• Reserve bandwidth for a particular application or user
• Prefer latency sensitive traffic
• Managed oversubscribed bandwidth
• Allow equitable distribution of unreserved bandwidth
• Ensure that a particular type of traffic is dropped
6
How it works
Origin: http://web.opalsoft.net/qos/default.php?p=linux101-ds
7
Source code
• Linux kernel source
– net/sched/sch_*.c (qdisc)
– net/sched/cls_*.c (filter)
– net/sched/act_*.c (action)
• iproute2 source
– tc/q_*.c (qdisc)
– tc/f_*.c (filter)
– tc/m_*.c (action)
8
Traffic Control elements
• Shaping - Shapers delay packets to meet a desired rate
• Scheduling - Schedulers arrange and/or rearrange packets for output
• Classifying - Classifiers sort or separate traffic into queues
• Policing - Policers measure and limit traffic in a particular queue
• Dropping - Dropping discards an entire packet, flow or classification
• Marking - Marking is a mechanism by which the packet is altered
9
Linux Traffic Control components
• qdisc (queuing discipline)
– A qdisc is a scheduler, attached to a network interface
– Classless qdiscs
• pfifo_fast qdisc - the default qdisc for all interfaces under Linux
• Stochastic Fairness Queueing (SFQ) - link is truly full share outgoing bandwidth
• Token Bucket Filter (TBF) - slows down outgoing traffic to the specified rate
– Classfull qdiscs
• Hierarchical Token Bucket (HTB) – fixed bandwidth divide for different purposes a guaranteed
bandwidth
• Class Based Queuing (CBQ)
– txqueuelen - current size of the transmission queue
• ifconfig eth0
• ip link show dev eth0
10
Linux Traffic Control components
• class
– A Class is a sub-qdisc. A class may contain another class.
• filter
– Filters are used for classification of packets
– Classifier (must)
• Filter objects, which can be manipulated using tc, can use several different classifying mechanisms
• To identify characteristics of a packet or a packet's metadata
• u32, fw, route, rsvp, basic, bpf
• u32 classifier which is used by filers for selecting packets based on packet attributes
– Policer
• A policer calls one action above and another action below the specified rate
• Only used in Linux traffic control as part of a filter
11
An example of qdisc contain filter and class
Origin: http://web.opalsoft.net/qos/default.php?p=linux101-ds
12
Linux Traffic Control components
• drop
– Any policer attached to any filter could have a drop action
– Only used in Linux traffic control as part of a policer
• handle
– Every class and classful qdisc requires a unique identifier within the traffic control
structure
– a handle and has two constituent members, a major number and a minor number
13
14
Traffic Control with tc command
linux-kyyb:/home/dchang # tc
Usage: tc [ OPTIONS ] OBJECT { COMMAND | help }
tc [-force] -batch filename
where OBJECT := { qdisc | class | filter | action | monitor | exec }
OPTIONS := { -s[tatistics] | -d[etails] | -r[aw] | -p[retty] | -b[atch] [filename] |
-n[etns] name | -nm | -nam[es] | { -cf | -conf } path }
linux-kyyb:/home/dchang # tc -s qdisc show dev eth1
qdisc pfifo_fast 0: root refcnt 2 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
15
tc qdisc
linux-kyyb:~ # tc qdisc help
Usage: tc qdisc [ add | del | replace | change | show ] dev STRING
[ handle QHANDLE ] [ root | ingress | parent CLASSID ]
[ estimator INTERVAL TIME_CONSTANT ]
[ stab [ help | STAB_OPTIONS] ]
[ [ QDISC_KIND ] [ help | OPTIONS ] ]
tc qdisc show [ dev STRING ] [ingress]
Where:
QDISC_KIND := { [p|b]fifo | tbf | prio | cbq | red | etc. }
OPTIONS := ... try tc qdisc add <desired QDISC_KIND> help
STAB_OPTIONS := ... try tc qdisc add stab help
16
Example of tc
* Limit ip 192.168.1.1 download speed 30Mbit to 50Mbit
linux-kyyb:~ # tc qdisc add dev eth0 root handle 1: htb default 20
linux-kyyb:~ # tc class add dev eth0 parent 1: classid 1:1 htb rate 30mbit ceil 50mbit
linux-kyyb:~ # tc filter add dev eth0 parent 1: prio 1 protocol ip u32 match 
ip src 192.168.1.1 flowid 1:1
- rate rate allocated to this class
- ceil definite upper class rate
- prio priority of leaf; lower are served first
* Add delay (man tc-netem)
linux-kyyb:~ # tc qdisc add dev eth1 root netem delay 200ms
* https://wiki.openwrt.org/doc/howto/packet.scheduler/packet.scheduler#examples
17
Reference
• http://tldp.org/en/Traffic-Control-HOWTO/index.html
• http://www.lartc.org/lartc.html
• https://people.netfilter.org/pablo/netdev0.1/papers/Linux-Traffic-Control-Classifier-
Action-Subsystem-Architecture.pdf
Linux Linux Traffic Control
19

More Related Content

PDF
Introduction to container based virtualization with docker
PDF
MQTT - MQ Telemetry Transport for Message Queueing
PDF
BPF Internals (eBPF)
PDF
Page cache in Linux kernel
PPTX
Fundamentals of EtherNet/IP Network Technology
PDF
CCNA - Routing & Switching Commands
PDF
DPDK in Containers Hands-on Lab
PDF
閉域網接続の技術入門
Introduction to container based virtualization with docker
MQTT - MQ Telemetry Transport for Message Queueing
BPF Internals (eBPF)
Page cache in Linux kernel
Fundamentals of EtherNet/IP Network Technology
CCNA - Routing & Switching Commands
DPDK in Containers Hands-on Lab
閉域網接続の技術入門

What's hot (20)

PPTX
Linux Network Stack
PDF
DPDK In Depth
PDF
eBPF - Rethinking the Linux Kernel
PDF
LinuxCon 2015 Linux Kernel Networking Walkthrough
PDF
Intel dpdk Tutorial
PDF
DevConf 2014 Kernel Networking Walkthrough
PDF
BPF & Cilium - Turning Linux into a Microservices-aware Operating System
PPTX
Understanding DPDK
PPTX
Tc basics
PDF
Linux 4.x Tracing: Performance Analysis with bcc/BPF
PPTX
Introduction to DPDK
PDF
Meet cute-between-ebpf-and-tracing
PDF
Linux Networking Explained
PDF
UM2019 Extended BPF: A New Type of Software
ODP
eBPF maps 101
PDF
Introduction to eBPF and XDP
PDF
Cilium - BPF & XDP for containers
PPTX
Understanding eBPF in a Hurry!
PDF
BPF - in-kernel virtual machine
PDF
Xdp and ebpf_maps
Linux Network Stack
DPDK In Depth
eBPF - Rethinking the Linux Kernel
LinuxCon 2015 Linux Kernel Networking Walkthrough
Intel dpdk Tutorial
DevConf 2014 Kernel Networking Walkthrough
BPF & Cilium - Turning Linux into a Microservices-aware Operating System
Understanding DPDK
Tc basics
Linux 4.x Tracing: Performance Analysis with bcc/BPF
Introduction to DPDK
Meet cute-between-ebpf-and-tracing
Linux Networking Explained
UM2019 Extended BPF: A New Type of Software
eBPF maps 101
Introduction to eBPF and XDP
Cilium - BPF & XDP for containers
Understanding eBPF in a Hurry!
BPF - in-kernel virtual machine
Xdp and ebpf_maps
Ad

Similar to Linux Linux Traffic Control (20)

PDF
8 Tc
PPT
Quality of service
PPTX
400-101 CCIE Routing and Switching IT Certification
PDF
Security defined routing_cybergamut_v1_1
PPTX
Securing management, control & data plane
PPTX
Fast Userspace OVS with AF_XDP, OVS CONF 2018
PPTX
lect4_SDNbasic_openflow.pptx
PPTX
Pyretic - A new programmer friendly language for SDN
PPTX
501 ch 3 network technologies tools
PDF
The Next Generation Firewall for Red Hat Enterprise Linux 7 RC
PPT
Chapter07
PPT
2.1 Red_Hat_Cluster1.ppt
PPTX
Systems and network architectures
PDF
Linux cgroups and namespaces
PPTX
Applied Detection and Analysis Using Flow Data - MIRCon 2014
PPT
Dynamic routing in microservice oriented architecture
PPTX
Packet Analysis - Course Technology Computing Conference
PPTX
Network protocols and vulnerabilities
PPT
Chapter14ccna
PPT
snort.ppt
8 Tc
Quality of service
400-101 CCIE Routing and Switching IT Certification
Security defined routing_cybergamut_v1_1
Securing management, control & data plane
Fast Userspace OVS with AF_XDP, OVS CONF 2018
lect4_SDNbasic_openflow.pptx
Pyretic - A new programmer friendly language for SDN
501 ch 3 network technologies tools
The Next Generation Firewall for Red Hat Enterprise Linux 7 RC
Chapter07
2.1 Red_Hat_Cluster1.ppt
Systems and network architectures
Linux cgroups and namespaces
Applied Detection and Analysis Using Flow Data - MIRCon 2014
Dynamic routing in microservice oriented architecture
Packet Analysis - Course Technology Computing Conference
Network protocols and vulnerabilities
Chapter14ccna
snort.ppt
Ad

More from SUSE Labs Taipei (20)

PDF
New things about SUSE shim, SUSE Labs Conference 2025, Brno
PDF
shim and things related to it, COSCUP 2025, Taipei
PDF
Locked down openSUSE Tumbleweed kernel
PDF
SUSE shim and things related to it
PDF
Multi-signed Kernel Module
PDF
ACPI Debugging from Linux Kernel
PDF
Profiling the ACPICA Namespace and Event Handing
PDF
Kernel debug log and console on openSUSE
PDF
The bright future of SUSE and openSUSE
PDF
EFI Secure Key
ODP
Convert your package to multibuild on Open Build Service
PDF
Ixgbe internals
ODP
Looking into trusted and encrypted keys
ODP
Use bonding driver with ethernet
ODP
Use build service API in your program
PDF
Hands-on ethernet driver
PDF
eBPF Trace from Kernel to Userspace
ODP
S4 sig-check-lpc-20130918
ODP
openSUSE12.2 Review
ODP
oS KDE Repos & MM
New things about SUSE shim, SUSE Labs Conference 2025, Brno
shim and things related to it, COSCUP 2025, Taipei
Locked down openSUSE Tumbleweed kernel
SUSE shim and things related to it
Multi-signed Kernel Module
ACPI Debugging from Linux Kernel
Profiling the ACPICA Namespace and Event Handing
Kernel debug log and console on openSUSE
The bright future of SUSE and openSUSE
EFI Secure Key
Convert your package to multibuild on Open Build Service
Ixgbe internals
Looking into trusted and encrypted keys
Use bonding driver with ethernet
Use build service API in your program
Hands-on ethernet driver
eBPF Trace from Kernel to Userspace
S4 sig-check-lpc-20130918
openSUSE12.2 Review
oS KDE Repos & MM

Recently uploaded (20)

PDF
Multiverse AI Review 2025_ The Ultimate All-in-One AI Platform.pdf
PDF
SOFTWARE ENGINEERING Software Engineering (3rd Edition) by K.K. Aggarwal & Yo...
PPTX
Relevance Tuning with Genetic Algorithms
PPTX
AI Tools Revolutionizing Software Development Workflows
PDF
How to Set Realistic Project Milestones and Deadlines
PDF
Coding with GPT-5- What’s New in GPT 5 That Benefits Developers.pdf
PPTX
Independent Consultants’ Biggest Challenges in ERP Projects – and How Apagen ...
PPTX
Presentation - Summer Internship at Samatrix.io_template_2.pptx
PPTX
ESDS_SAP Application Cloud Offerings.pptx
PPTX
UNIT II: Software design, software .pptx
PPTX
Bandicam Screen Recorder 8.2.1 Build 2529 Crack
PPTX
Improving Audience Engagement ROI with ERP-Powered Insights
PDF
What Makes a Great Data Visualization Consulting Service.pdf
PPTX
WJQSJXNAZJVCVSAXJHBZKSJXKJKXJSBHJBJEHHJB
PPTX
DevOpsDays Halifax 2025 - Building 10x Organizations Using Modern Productivit...
PDF
Adlice Diag Crack With Serial Key Free Download 2025
PPTX
Why 2025 Is the Best Year to Hire Software Developers in India
PPTX
Greedy best-first search algorithm always selects the path which appears best...
PDF
infoteam HELLAS company profile 2025 presentation
PPTX
Post-Migration Optimization Playbook: Getting the Most Out of Your New Adobe ...
Multiverse AI Review 2025_ The Ultimate All-in-One AI Platform.pdf
SOFTWARE ENGINEERING Software Engineering (3rd Edition) by K.K. Aggarwal & Yo...
Relevance Tuning with Genetic Algorithms
AI Tools Revolutionizing Software Development Workflows
How to Set Realistic Project Milestones and Deadlines
Coding with GPT-5- What’s New in GPT 5 That Benefits Developers.pdf
Independent Consultants’ Biggest Challenges in ERP Projects – and How Apagen ...
Presentation - Summer Internship at Samatrix.io_template_2.pptx
ESDS_SAP Application Cloud Offerings.pptx
UNIT II: Software design, software .pptx
Bandicam Screen Recorder 8.2.1 Build 2529 Crack
Improving Audience Engagement ROI with ERP-Powered Insights
What Makes a Great Data Visualization Consulting Service.pdf
WJQSJXNAZJVCVSAXJHBZKSJXKJKXJSBHJBJEHHJB
DevOpsDays Halifax 2025 - Building 10x Organizations Using Modern Productivit...
Adlice Diag Crack With Serial Key Free Download 2025
Why 2025 Is the Best Year to Hire Software Developers in India
Greedy best-first search algorithm always selects the path which appears best...
infoteam HELLAS company profile 2025 presentation
Post-Migration Optimization Playbook: Getting the Most Out of Your New Adobe ...

Linux Linux Traffic Control

  • 1. Linux Traffic Control SUSE Labs Taipei technology sharing day 2018 David Chang Software Engineer SUSE / [email protected]
  • 2. 2 Overview • What is Traffic Control • Why use Traffic Control • How it works • Traffic Control elements • Linux Traffic Control components • Traffic Control with tc command
  • 3. 3 What is Traffic Control • The sets of queuing systems and mechanisms by which packets are received and transmitted on a router – Deciding which packets to accept at what rate on the input of an interface – Determining which packets to transmit in what order at what rate on the output of an interface • Quality of Service (QoS) is often used as a synonym for network traffic control
  • 4. 4 Why use Traffic Control • Traffic control tools allow administrator to enqueue packets into the network differently based on attributes of the packet • Advantages – Lead to more predictable usage of network resources and less volatile contention for these resources • Disadvantages – Complexity – Complexity – Complexity
  • 5. 5 Common Traffic Control solutions • Limit total bandwidth to a known rate • Limit the bandwidth of a particular user, service or client • Reserve bandwidth for a particular application or user • Prefer latency sensitive traffic • Managed oversubscribed bandwidth • Allow equitable distribution of unreserved bandwidth • Ensure that a particular type of traffic is dropped
  • 6. 6 How it works Origin: http://web.opalsoft.net/qos/default.php?p=linux101-ds
  • 7. 7 Source code • Linux kernel source – net/sched/sch_*.c (qdisc) – net/sched/cls_*.c (filter) – net/sched/act_*.c (action) • iproute2 source – tc/q_*.c (qdisc) – tc/f_*.c (filter) – tc/m_*.c (action)
  • 8. 8 Traffic Control elements • Shaping - Shapers delay packets to meet a desired rate • Scheduling - Schedulers arrange and/or rearrange packets for output • Classifying - Classifiers sort or separate traffic into queues • Policing - Policers measure and limit traffic in a particular queue • Dropping - Dropping discards an entire packet, flow or classification • Marking - Marking is a mechanism by which the packet is altered
  • 9. 9 Linux Traffic Control components • qdisc (queuing discipline) – A qdisc is a scheduler, attached to a network interface – Classless qdiscs • pfifo_fast qdisc - the default qdisc for all interfaces under Linux • Stochastic Fairness Queueing (SFQ) - link is truly full share outgoing bandwidth • Token Bucket Filter (TBF) - slows down outgoing traffic to the specified rate – Classfull qdiscs • Hierarchical Token Bucket (HTB) – fixed bandwidth divide for different purposes a guaranteed bandwidth • Class Based Queuing (CBQ) – txqueuelen - current size of the transmission queue • ifconfig eth0 • ip link show dev eth0
  • 10. 10 Linux Traffic Control components • class – A Class is a sub-qdisc. A class may contain another class. • filter – Filters are used for classification of packets – Classifier (must) • Filter objects, which can be manipulated using tc, can use several different classifying mechanisms • To identify characteristics of a packet or a packet's metadata • u32, fw, route, rsvp, basic, bpf • u32 classifier which is used by filers for selecting packets based on packet attributes – Policer • A policer calls one action above and another action below the specified rate • Only used in Linux traffic control as part of a filter
  • 11. 11 An example of qdisc contain filter and class Origin: http://web.opalsoft.net/qos/default.php?p=linux101-ds
  • 12. 12 Linux Traffic Control components • drop – Any policer attached to any filter could have a drop action – Only used in Linux traffic control as part of a policer • handle – Every class and classful qdisc requires a unique identifier within the traffic control structure – a handle and has two constituent members, a major number and a minor number
  • 13. 13
  • 14. 14 Traffic Control with tc command linux-kyyb:/home/dchang # tc Usage: tc [ OPTIONS ] OBJECT { COMMAND | help } tc [-force] -batch filename where OBJECT := { qdisc | class | filter | action | monitor | exec } OPTIONS := { -s[tatistics] | -d[etails] | -r[aw] | -p[retty] | -b[atch] [filename] | -n[etns] name | -nm | -nam[es] | { -cf | -conf } path } linux-kyyb:/home/dchang # tc -s qdisc show dev eth1 qdisc pfifo_fast 0: root refcnt 2 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
  • 15. 15 tc qdisc linux-kyyb:~ # tc qdisc help Usage: tc qdisc [ add | del | replace | change | show ] dev STRING [ handle QHANDLE ] [ root | ingress | parent CLASSID ] [ estimator INTERVAL TIME_CONSTANT ] [ stab [ help | STAB_OPTIONS] ] [ [ QDISC_KIND ] [ help | OPTIONS ] ] tc qdisc show [ dev STRING ] [ingress] Where: QDISC_KIND := { [p|b]fifo | tbf | prio | cbq | red | etc. } OPTIONS := ... try tc qdisc add <desired QDISC_KIND> help STAB_OPTIONS := ... try tc qdisc add stab help
  • 16. 16 Example of tc * Limit ip 192.168.1.1 download speed 30Mbit to 50Mbit linux-kyyb:~ # tc qdisc add dev eth0 root handle 1: htb default 20 linux-kyyb:~ # tc class add dev eth0 parent 1: classid 1:1 htb rate 30mbit ceil 50mbit linux-kyyb:~ # tc filter add dev eth0 parent 1: prio 1 protocol ip u32 match ip src 192.168.1.1 flowid 1:1 - rate rate allocated to this class - ceil definite upper class rate - prio priority of leaf; lower are served first * Add delay (man tc-netem) linux-kyyb:~ # tc qdisc add dev eth1 root netem delay 200ms * https://wiki.openwrt.org/doc/howto/packet.scheduler/packet.scheduler#examples
  • 17. 17 Reference • http://tldp.org/en/Traffic-Control-HOWTO/index.html • http://www.lartc.org/lartc.html • https://people.netfilter.org/pablo/netdev0.1/papers/Linux-Traffic-Control-Classifier- Action-Subsystem-Architecture.pdf
  • 19. 19