From 2ee1a2f34d4c4f9f491371f73cd41977bf360851 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Wed, 28 Apr 2021 11:20:00 +0200 Subject: Add new common chapter about QoS, IP DSCP and IEEE 802.1q PCP Related: SYS#5427 Change-Id: Id344c29eda2a9b3e36376302b425e9db1f6c0f28 --- common/chapters/bibliography.adoc | 6 ++ common/chapters/glossary.adoc | 8 ++ common/chapters/qos-dscp-pcp.adoc | 161 ++++++++++++++++++++++++++++++++++++++ tests/Makefile.am | 1 + tests/chapters/qos-example.adoc | 3 + 5 files changed, 179 insertions(+) create mode 100644 common/chapters/qos-dscp-pcp.adoc create mode 100644 tests/chapters/qos-example.adoc diff --git a/common/chapters/bibliography.adoc b/common/chapters/bibliography.adoc index 11152c5..06b1fb4 100644 --- a/common/chapters/bibliography.adoc +++ b/common/chapters/bibliography.adoc @@ -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 diff --git a/common/chapters/glossary.adoc b/common/chapters/glossary.adoc index 23c7273..20794a1 100644 --- a/common/chapters/glossary.adoc +++ b/common/chapters/glossary.adoc @@ -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_ <> 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_ <>) 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_ <>) TFTP:: Trivial File Transfer Protocol; (_IETF RFC 1350_ <>) +TOS:: + Type Of Service; bit-field in IPv4 header, now re-used as DSCP (_IETF RFC 791_ <>) VLR:: Visitor Location Register; volatile storage of attached subscribers in the MSC diff --git a/common/chapters/qos-dscp-pcp.adoc b/common/chapters/qos-dscp-pcp.adoc new file mode 100644 index 0000000..3f97941 --- /dev/null +++ b/common/chapters/qos-dscp-pcp.adoc @@ -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 <> 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 <>. + +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[] diff --git a/tests/Makefile.am b/tests/Makefile.am index 1be6308..784f61f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 diff --git a/tests/chapters/qos-example.adoc b/tests/chapters/qos-example.adoc new file mode 100644 index 0000000..d398243 --- /dev/null +++ b/tests/chapters/qos-example.adoc @@ -0,0 +1,3 @@ +=== QoS example for example manual + +Quite exemplary. -- cgit v1.2.3