Add new common chapter about QoS, IP DSCP and IEEE 802.1q PCP

Related: SYS#5427
Change-Id: Id344c29eda2a9b3e36376302b425e9db1f6c0f28
This commit is contained in:
Harald Welte 2021-04-28 11:20:00 +02:00
parent e87733176f
commit 2ee1a2f34d
5 changed files with 179 additions and 0 deletions

View File

@ -166,6 +166,9 @@
system for telecommunication application providers
https://www.etsi.org/deliver/etsi_ts/101200_101299/101220/12.00.00_60/ts_101220v120000p.pdf
- [[[ieee-802.1q]]] IEEE 802.1Q: Bridges and Bridged Networks
https://ieeexplore.ieee.org/document/6991462
- [[[ietf-rfc768]]] IETF RFC 768: User Datagram Protocol
https://tools.ietf.org/html/rfc768
- [[[ietf-rfc791]]] IETF RFC 791: Internet Protocol
@ -178,6 +181,9 @@
https://tools.ietf.org/html/rfc1350
- [[[ietf-rfc2131]]] IETF RFC 2131: Dynamic Host Configuration Protocol
https://tools.ietf.org/html/rfc2131
- [[[ietf-rfc2474]]] IETF RFC 2474: Definition of the Differentiated Services Field (DS Field) in the IPv44
and IPv6 Headers
https://tools.ietf.org/html/rfc2474
- [[[ietf-rfc2719]]] IETF RFC 2719: Signal Transport over IP
https://tools.ietf.org/html/rfc2719
- [[[ietf-rfc3331]]] IETF RFC 3331: Message Transfer Part 2 User Adaptation Layer

View File

@ -81,6 +81,8 @@ DHCP::
downlink::
Direction of messages / signals from the network core towards the
mobile phone
DSCP::
Diffrentiated Services Code Point (_IETF RFC 2474_ <<ietf-rfc2474>>
DSP::
Digital Signal Processor
dvnixload::
@ -264,6 +266,8 @@ PC::
Point Code; an address in MTP
PCH::
Paging Channel on downlink Um interface; used by network to page an MS
PCP::
Priority Code Point (_IEEE 802.1Q_ <<ieee-802.11>>)
PCU::
Packet Control Unit; used to manage Layer 2 of the GPRS radio interface
PDCH::
@ -354,6 +358,8 @@ TCP::
Transmission Control Protocol; (_IETF RFC 793_ <<ietf-rfc793>>)
TFTP::
Trivial File Transfer Protocol; (_IETF RFC 1350_ <<ietf-rfc1350>>)
TOS::
Type Of Service; bit-field in IPv4 header, now re-used as DSCP (_IETF RFC 791_ <<ietf-rfc791)
TRX::
Transceiver; element of a BTS serving a single carrier
TS::
@ -388,6 +394,8 @@ VCTCXO::
Voltage Controlled, Temperature Compensated Crystal Oscillator; a
precision oscillator, superior to a classic crystal oscillator, but
inferior to an OCXO
VLAN::
Virtual LAN in the context of Ethernet (_IEEE 802.1Q_ <<ieee-802.1q>>)
VLR::
Visitor Location Register; volatile storage of attached subscribers in
the MSC

View File

@ -0,0 +1,161 @@
[[qos-dscp-pcp]]
== QoS, DSCP/TOS, Priority and IEEE 802.1q PCP
In many use cases operators want to apply different QoS classes for user plane
vs. control plane traffic. IP Routers, Ethernet switches and other network gear
can then perform intelligent queue management as required for the respective service.
For example, voice user plane frames need a rather stable and short latency,
while IP user plane and control plane traffic has less critical latency requirements.
=== IP Level (DSCP)
At IP level, different priorities / classes of traffic are expressed
in accordance to <<ietf-rfc2474>> by the DSCP (Differentiated Services Code
Point) field of the IP header. DSCP resembles the upper 6 bits of the
field formerly known as the TOS bits as per <<ietf-rfc791>>.
On Linux and other operating systems with BSD-style sockets API, the
applications can request a specific DSCP value to be used for packets
generated by those sockets.
Osmocom CNI software such as osmo-bts and osmo-mgw support setting the
DSCP value via VTY commands, see e.g. the `rtp ip-dscp` setting of the
`bts` node in osmo-bts.
=== Packet Priority
In the Linux network stack, every packet is represented by `struct
sk_buff`, which has an associated _priority_. Furthermore, every socket
through which applications send data have an associated _socket
priority_. Each time a packet is transmitted through a given socket,
the packet inherits the packet priority from the socket priority.
Furthermore, there is a mapping table that maps DSCP/TOS bits to
priority. The sixteen different TOS bit values are mapped to priority
values as follows:
.Linux kernel default DSCP/TOS -> priority mapping
[options="header",width="50%"]
|===
|TOS (binary)|DSCP (binary)|Priority (decimal)
|xxx0000x|xxx000|0
|xxx0001x|xxx000|0
|xxx0010x|xxx001|0
|xxx0011x|xxx001|0
|xxx0100x|xxx010|2
|xxx0101x|xxx010|2
|xxx0110x|xxx011|2
|xxx0111x|xxx011|2
|xxx1000x|xxx100|6
|xxx1001x|xxx100|6
|xxx1010x|xxx101|6
|xxx1011x|xxx101|6
|xxx1100x|xxx110|4
|xxx1101x|xxx110|4
|xxx1110x|xxx111|4
|xxx1111x|xxx111|4
|===
This table of default DSCP/TOS -> priority bit mappings cannot be
modified.
However, the per-packet _priority_ values can be set by various means
of network policy, including
* by packet filter rules (iptables, ip6tables, nftables)
** if you use `iptables`, using `CLASSIFY --set-class` in the `mangle` table
** if you use `nftables`, using `meta priority set` in the `mangle` table
* by the application using the SO_PRIORITY socket option (currently not yet supported by Osmocom CNI)
=== Ethernet Level (PCP)
At Ethernet level, different priorities / QoS classes are expressed by
the so-called PCP (Priority Code Point) field in the IEEE 802.1q (VLAN)
header.
NOTE:: This means that PCP functionality requires the use of IEEE 802.q
VLAN. You cannot use PCP without VLAN
The Linux kernel assigns IEEE 802.1q PCP bits based on a _mapping_
between the _priority_ and the PCP value. Each VLAN network device
maintains a separate map for both egress (transmit) and ingress
(receive) path.
The current priority mappings can be inspected via the `/proc`
filesystem. For example, if you have a VLAN device `eth0.9` for
VLAN ID 9 on the net-device `eth0`, you can use the following example:
.Example: Inspecting the current egress QoS map
----
$ sudo cat /proc/net/vlan/eth0.9<1>
eth0.9 VID: 9 REORDER_HDR: 1 dev->priv_flags: 1021
total frames received 123340
total bytes received 40668066
Broadcast/Multicast Rcvd 1106
total frames transmitted 10499
total bytes transmitted 1570809
Device: eth0
INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 <2>
EGRESS priority mappings: <3>
----
<1> make sure to specify your specific VLAN interface name here instead of `eth0.9`
<2> ingress priority mappings (all PCP values mapped to priority 0)
<3> egress priority mappings (empty)
As we can see in the above example, there are no egress priority
mappings yet. Let's create three new mappings, mapping _priority_
value 1 to PCP 1, _priority_ 2 to PCP 2, and _priority_ 3 to PCP 3:
.Example: Creating three new egress QoS mappings
----
$ sudo ip link set dev eth0.9<1> type vlan egress-qos-map 1:1 2:2 3:3 <2>
$ sudo cat /proc/net/vlan/eth0.9 <3>
eth0.9 VID: 9 REORDER_HDR: 1 dev->priv_flags: 1021
total frames received 123898
total bytes received 40843611
Broadcast/Multicast Rcvd 1106
total frames transmitted 10517
total bytes transmitted 1574357
Device: eth0
INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0
EGRESS priority mappings: 1:1 2:2 3:3 <4>
----
<1> make sure to specify your specific VLAN interface name here instead of `eth0.9`
<2> command to define three new egress QoS maps
<3> command to re-display the current status
<4> three new egress mappings are shown as given in `ip` command
NOTE:: The settings of the `ip` command are volatile and only active until
the next reboot (or the network device or VLAN is removed). Please refer to
the documentation of your specific Linux distribution in order to find out how
to make such settings persistent by means of an `ifup` hook whenever the interface
comes up. For CentOS/RHEL 8 this can e.g. be achieved by means of an `/sbin/ifup-local
script` (when using `network-scripts` and not NetworkManager). For Debian or Ubuntu,
this typically involves adding `up` lines to `/etc/network/interfaces` or a `/etc/network/if-up.d`
script.
=== Putting things together
Assuming one needs to set both the DSCP bits as well as the PCP for
certain traffic, the above-mentioned mechanisms need to be combined as
follows:
. configure the osmocom program to set the DSCP value
. use the default DSCP -> priority mapping, if possible
. configure an egrees QoS map to map from priority to PCP
If the desired combination of DSCP + PCP cannot be achieved that way,
due to the rather static default kernel mapping table, one needs to go
one step further:
. configure the osmocom program to set the DSCP value
. use packet filter rules to set the priority based on DSCP
. configure an egrees QoS map to map from priority to PCP
include::{srcdir}/chapters/qos-example.adoc[]

View File

@ -4,6 +4,7 @@ EXTRA_DIST = test-usermanual-docinfo.xml \
vty \
test2-vty-reference.xml \
vty-test2 \
chapters \
$(NULL)
# Do not install any of the test pdfs

View File

@ -0,0 +1,3 @@
=== QoS example for example manual
Quite exemplary.