Title: Traffic control and queuing discipline
1Traffic control and queuing discipline
- Jennifer Hou and Honghai Zhang
2Outline
- Linux traffic control overview
- Queuing discipline
- Queuing functions
- Interaction of kernel with queuing functions
- Interaction of user with queuing functions
- Case Study TCP RED
3Linux traffic control
4Processing of network data
A non-terminal machine
Upper layers (TCP, UDP, )
Traffic control
Input de-multiplexing
forwarding
Output queuing
5Components of traffic control
- Queuing disciplines
- Classes (within a queuing disciplines)
- Filters
- policing
6Queuing discipline
- Each network device has a queuing discipline
- It controls how packets enqueued on that device
are treated - Keep, drop, mark
- A simple one may just consist of a single queue
Queuing discipline
7Complex queuing discipline
- Queuing discipline
- May use filters to distinguish among different
classes of packets - Process each class in a specific way
- Two filters can point to one class
- Classes
- do not store packets
- They use another queuing discipline to do that
8Complex queuing discipline (cont)
9Policing
- When enqueuing packets, the corresponding flow
can be policed - Letting it go
- Dropping
- Letting it going but marking
10Queuing disciplines data structure
- struct Qdisc_ops
- struct Qdisc_ops next
- struct Qdisc_class_ops cl_ops
- char idIFNAMSIZ
- int priv_size
- int (enqueue)(struct sk_buff , struct Qdisc
) - struct sk_buff (dequeue)(struct Qdisc )
- int (requeue)(struct sk_buff , struct Qdisc
) - unsigned int (drop)(struct Qdisc )
- int (init)(struct Qdisc , struct rtattr
arg) - void (reset)(struct Qdisc )
- void (destroy)(struct Qdisc )
- int (change)(struct Qdisc , struct rtattr
arg) - int (dump)(struct Qdisc , struct sk_buff )
-
11Queuing disciplinesFunctions
- enqueue)()
- Enqueues a packet
- dequeue()
- Returns the next packet eligible for sending
- requeue()
- Puts a packets back into the queue after
dequeuing it with dequeue - Drop()
- Drops one packet from the queue
12Queuing disciplinesFunctions (cont)
- Init()
- Initalize and configures the queuing discipline
- reset()
- Reset the queuing discipline to its initial state
- destroy()
- Remove a queuing discipline
- change()
- Change the configurations of a queuing discipline
- dump()
- Returns diagnostic data for maintenance.
13TCP RED
14Dropping probability pa
Linux implementation
pb
15TCP RED implementation I
- struct red_sched_data / Parameters /
- u32 limit / HARD maximal queue length /
- u32 qth_min / Min average length threshold A
scaled / - u32 qth_max / Max average length threshold A
scaled / - char Wlog / log(W) /
- char Plog / random number bits /
-
- unsigned long qave / Average queue length A
scaled / - int qcount / Packets since last random number
generation / - u32 qR / Cached random number /
- psched_time_t qidlestart / Start of idle period
/ - struct tc_red_xstats st
16TCP RED implementation II Compute average queue
length
- We want
- avg avg (1- w) w backlog
- Code in Linux
- q-gtqave sch-gtstats.backlog - (q-gtqave gtgt
q-gtWlog) - Explain
- avg q-gtqave w
- w 2(-wlog)
17TCP RED implementation III
- Ideally avg should be calculated every constant
clock interval - In Linux it is updated every packet outgoing
- Care need to be taken for idle period
18TCP RED implementation IVDecide dropping
probability
- We want enqueue if
- Linux code
- if (((q-gtqave - q-gtqth_min)gtgtq-gtWlog)q-gtqcount lt
q-gtqR) goto enqeue - max_P (qth_max qth_min)/2Plog
- q-gtqR rnd 2Plog
19Interaction with Kernel
20Interaction with User
- Command tc usage example
- tc qdisc add dev eth0 root red HELP OPTIONS
- tc qdisc show dev eth0
- Source code of tc http//snafu.freedom.org/linux2
.2/iproute-notes.html - Directory of the source code for tc
- Iproute2/tc/
21Flow of functions when calltc qdisc add dev eth0
root red
tc
filter
qdisc do_qdisc() in tc.c
class
add tc_qdisc_modify
q-gtparse_qopt() rtnl_open() rtnl_talk()
22Flow of functions when calltc qdisc show (or tc
s qdisc)
tc
filter
qdisc do_qdisc in tc.c
class
show tc_qdisc_list
rt_open
rtnl_dump_request
rtnl_dump_filter
print_qstat print_qopt print_tcstat