|WP1 - RTOS State of the Art Analysis: Deliverable D1.1 - RTOS Analysis
|Chapter 6. Realtime Support in Linux
Nowadays, linux offers a sophisticated component for bandwidth management called Traffic Control. This component supports method for classifying, prioritising, and limiting both incoming and out-coming traffic. Therefore, linux can do the following list of things: limit bandwidth for certain computers, help to fairly share bandwidth, protect the Internet from abuses, restrict access, do routing based on user id, MAC address, source IP address ... and so on.
For working with this subsystem, the kernel versions 2.2.x has to be patched, but the versions 2.4.x and uppers implement directly this functioning.
The following figure shows the network subsystem:
There are four components:
Input demultiplexing: Decides if a incoming packets are passed to higher layers or are directly forwarded to the network.
Upper Layers: Processes packets and may also generate new traffic and pass it to the lower layers.
Forwarding: This layer performs the selection of the output interface, the selection of the next hop, encapsulation, etc.
Output Queueing or Traffic Control: This is the most important component and decides if packets are queued or dropped, decides in which order packets are sent, etc.
Once the traffic control releases a packet for sending, the network device driver sends it to the network.
The traffic control component consist of the following elements: queueing disciplines (qdisc), classes (within a queueing discipline), filters and policing
In this way, queueing discipline provides a method to enqueue a packet. A class is the place where packets are stored and processed in a specific way, afterwards, the qdisc selects the following packet for sending from classes. Filters are used by a qdisc to assign incoming packets to one of its classes. And finally, policing is used to ensure that incoming traffic does not exceed certain bounds.
The following picture illustrates an example of traffic control configuration:
This configuration consists of a queuing discipline with two delay priorities, as well as, two classes: the higher class contains a token bucket filter discipline that limits the traffic, while the lower class contains a FIFO qdisc. Therefore, while the higher class has packets for sending (rate < 1Mbps), the priority qdisc selects a packets from this class. The filter decides which packets are sent to the higher class. Once a priority qdisc selects the following packet for sending, the network driver sends it on the network.
In conclusion, the traffic control layer decides whether the packets are queued or dropped, in which order the packets are sent, and finally it may delay packet transmission. Moreover, the traffic control elements can be combined in a modular way to support Differentiated Service (DS), Integrated Service (RSVP), ATM and so on.
The following four sections describe the traffic control elements.
Each network interface has a queue discipline attached with it, which controls how packets are enqueued and treated.
A qdisc is a black box, which is able to enqueue packets and dequeue them using its own algorithm, for example, a CBQ qdisc uses a WRR (Weight Round Robin) scheduling to select the following packet for sending on the network.
Moreover, qdisc are divided into two categories:
Classfull: Qdiscs that may have child qdiscs attached to them.
Leafs: Qdiscs that have not child's.
The available classfull qdiscs are:
PRIO a n-band strict priority scheduler,
CBQ Class Based Queue,
ATM Asynchronous Transfer Model,
DSMARK - DSCP a Diff-Serv Code Point marker and
The available leafs qdiscs are:
FIFO a simple FIFO (it is the default qdisc),
TBF Token Bucket Filter,
RED Random Early Detection,
GRED Generalised Random Early Detection,
TEQL Traffic Equaliser and
SFQ Stochastic Fair Queue.
A class is attached to a qdisc. However, queueing disciplines and classes are intimately tied together; the presence of classes and their semantics are fundamental properties of the queueing discipline. There is only one available class. This is the CBQ class. Note that a CBQ may work as queue discipline or class.
Filters are used to classify packets based on certain properties of them (address IP ...). The supported filters are:
rsvp (use RSVP protocol for classification),
u32 (anything in the header may be used for classification),
fw (use the firewall rules for classification),
route (use routing table for classification decisions) and
tcindex (use the DS field for classification).
Note that the u32 filter is the most advanced filter available and the tcindex filter is used in DiffServ (differentiation services).
The goal of policing is to ensure that traffic does not exceed certain bounds. There are four types of policing mechanisms: policing decisions by filter, refusal to enqueue a packet, dropping a packet from an inner queueing discipline and dropping a packet when en-queuing a new one.