diff options
authorHarald Welte <laforge@osmocom.org>2021-04-28 11:20:00 +0200
committerHarald Welte <laforge@osmocom.org>2021-04-28 12:11:53 +0200
commit2ee1a2f34d4c4f9f491371f73cd41977bf360851 (patch)
parente87733176f6e8ea7daac3d4ce7d11dd8f265449b (diff)
Add new common chapter about QoS, IP DSCP and IEEE 802.1q PCP
5 files changed, 179 insertions, 0 deletions
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
+- [[[ieee-802.1q]]] IEEE 802.1Q: Bridges and Bridged Networks
+ https://ieeexplore.ieee.org/document/6991462
- [[[ietf-rfc768]]] IETF RFC 768: User Datagram Protocol
- [[[ietf-rfc791]]] IETF RFC 791: Internet Protocol
@@ -178,6 +181,9 @@
- [[[ietf-rfc2131]]] IETF RFC 2131: Dynamic Host Configuration Protocol
+- [[[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
- [[[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::
Direction of messages / signals from the network core towards the
mobile phone
+ Diffrentiated Services Code Point (_IETF RFC 2474_ <<ietf-rfc2474>>
Digital Signal Processor
@@ -264,6 +266,8 @@ PC::
Point Code; an address in MTP
Paging Channel on downlink Um interface; used by network to page an MS
+ Priority Code Point (_IEEE 802.1Q_ <<ieee-802.11>>)
Packet Control Unit; used to manage Layer 2 of the GPRS radio interface
@@ -354,6 +358,8 @@ TCP::
Transmission Control Protocol; (_IETF RFC 793_ <<ietf-rfc793>>)
Trivial File Transfer Protocol; (_IETF RFC 1350_ <<ietf-rfc1350>>)
+ Type Of Service; bit-field in IPv4 header, now re-used as DSCP (_IETF RFC 791_ <<ietf-rfc791)
Transceiver; element of a BTS serving a single carrier
@@ -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
+ Virtual LAN in the context of Ethernet (_IEEE 802.1Q_ <<ieee-802.1q>>)
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/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
+|TOS (binary)|DSCP (binary)|Priority (decimal)
+This table of default DSCP/TOS -> priority bit mappings cannot be
+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)
+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`
+=== 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
+. 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
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 \
# 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.