<p>laforge has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-gsm-manuals/+/23926">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Add new common chapter about QoS, IP DSCP and IEEE 802.1q PCP<br><br>Related: SYS#5427<br>Change-Id: Id344c29eda2a9b3e36376302b425e9db1f6c0f28<br>---<br>M common/chapters/bibliography.adoc<br>A common/chapters/qos-dscp-pcp.adoc<br>2 files changed, 164 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-manuals refs/changes/26/23926/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/common/chapters/bibliography.adoc b/common/chapters/bibliography.adoc</span><br><span>index df69c44..8e08ba3 100644</span><br><span>--- a/common/chapters/bibliography.adoc</span><br><span>+++ b/common/chapters/bibliography.adoc</span><br><span>@@ -176,6 +176,9 @@</span><br><span>   https://tools.ietf.org/html/rfc1350</span><br><span> - [[[ietf-rfc2131]]] IETF RFC 2131: Dynamic Host Configuration Protocol</span><br><span>   https://tools.ietf.org/html/rfc2131</span><br><span style="color: hsl(120, 100%, 40%);">+- [[[ietf-rfc2474]]] IETF RFC 2474: Definition of the Differentiated Services Field (DS Field) in the IPv44</span><br><span style="color: hsl(120, 100%, 40%);">+  and IPv6 Headers</span><br><span style="color: hsl(120, 100%, 40%);">+  https://tools.ietf.org/html/rfc2474</span><br><span> - [[[ietf-rfc2719]]] IETF RFC 2719: Signal Transport over IP</span><br><span>   https://tools.ietf.org/html/rfc2719</span><br><span> - [[[ietf-rfc3331]]] IETF RFC 3331: Message Transfer Part 2 User Adaptation Layer</span><br><span>diff --git a/common/chapters/qos-dscp-pcp.adoc b/common/chapters/qos-dscp-pcp.adoc</span><br><span>new file mode 100644</span><br><span>index 0000000..a9233e3</span><br><span>--- /dev/null</span><br><span>+++ b/common/chapters/qos-dscp-pcp.adoc</span><br><span>@@ -0,0 +1,161 @@</span><br><span style="color: hsl(120, 100%, 40%);">+[[qos-dscp-pcp]]</span><br><span style="color: hsl(120, 100%, 40%);">+== QoS, DCSP/TOS, Prioirty and IEEE 802.1q PCP</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+In many use cases operators want to apply different QoS classes for user plane</span><br><span style="color: hsl(120, 100%, 40%);">+vs. control plane traffic.  IP Routers, Ethernet switches and other network gear</span><br><span style="color: hsl(120, 100%, 40%);">+can then perform intelligent queue management as required for the respective service.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+For example, voice user plane frames need a rather stable and short latency,</span><br><span style="color: hsl(120, 100%, 40%);">+while IP user plane and control plane traffic has less critical latency requirements.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+=== IP Level (DSCP)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+At IP level, different priorities / classes of traffic are expressed</span><br><span style="color: hsl(120, 100%, 40%);">+in accordance to <<ietf-rfc2474>> by the DSCP (Differentiated Services Code</span><br><span style="color: hsl(120, 100%, 40%);">+Point) field of the IP header.  DSCP resembles the upper 6 bits of the</span><br><span style="color: hsl(120, 100%, 40%);">+field formerly known as the TOS bits as per <<ietf-rfc791>>.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+On Linux and other operating systems with BSD-style sockets API, the</span><br><span style="color: hsl(120, 100%, 40%);">+applications can request a specific DSCP value to be used for packets</span><br><span style="color: hsl(120, 100%, 40%);">+generated by those sockets.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Osmocom CNI software such as osmo-bts and osmo-mgw support setting the</span><br><span style="color: hsl(120, 100%, 40%);">+DSCP value via VTY commands, see e.g. the `rtp ip-dscp` setting of the</span><br><span style="color: hsl(120, 100%, 40%);">+`bts` node in osmo-bts.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+=== Packet Priority</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+In the Linux network stack, every packet is represented by `struct</span><br><span style="color: hsl(120, 100%, 40%);">+sk_buff`, which has an associated _priority_.  Furthermore, every socket</span><br><span style="color: hsl(120, 100%, 40%);">+through which applications send data have an associated _socket</span><br><span style="color: hsl(120, 100%, 40%);">+priority_.  Each time a packet is transmitted through a given socket,</span><br><span style="color: hsl(120, 100%, 40%);">+the packet inherits the packet priority from the socket priority.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Furthermore, there is a mapping table that maps DSCP/TOS bits to</span><br><span style="color: hsl(120, 100%, 40%);">+priority.  The sixteen different TOS bit values are mapped to priority</span><br><span style="color: hsl(120, 100%, 40%);">+values as follows:</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+.Linux kernel default DSCP/TOS -> priority mapping</span><br><span style="color: hsl(120, 100%, 40%);">+[options="header",width="50%"]</span><br><span style="color: hsl(120, 100%, 40%);">+|===</span><br><span style="color: hsl(120, 100%, 40%);">+|TOS (binary)|DSCP (binary)|Priority (decimal)</span><br><span style="color: hsl(120, 100%, 40%);">+|xxx0000x|xxx000|0</span><br><span style="color: hsl(120, 100%, 40%);">+|xxx0001x|xxx000|0</span><br><span style="color: hsl(120, 100%, 40%);">+|xxx0010x|xxx001|0</span><br><span style="color: hsl(120, 100%, 40%);">+|xxx0011x|xxx001|0</span><br><span style="color: hsl(120, 100%, 40%);">+|xxx0100x|xxx010|2</span><br><span style="color: hsl(120, 100%, 40%);">+|xxx0101x|xxx010|2</span><br><span style="color: hsl(120, 100%, 40%);">+|xxx0110x|xxx011|2</span><br><span style="color: hsl(120, 100%, 40%);">+|xxx0111x|xxx011|2</span><br><span style="color: hsl(120, 100%, 40%);">+|xxx1000x|xxx100|6</span><br><span style="color: hsl(120, 100%, 40%);">+|xxx1001x|xxx100|6</span><br><span style="color: hsl(120, 100%, 40%);">+|xxx1010x|xxx101|6</span><br><span style="color: hsl(120, 100%, 40%);">+|xxx1011x|xxx101|6</span><br><span style="color: hsl(120, 100%, 40%);">+|xxx1100x|xxx110|4</span><br><span style="color: hsl(120, 100%, 40%);">+|xxx1101x|xxx110|4</span><br><span style="color: hsl(120, 100%, 40%);">+|xxx1110x|xxx111|4</span><br><span style="color: hsl(120, 100%, 40%);">+|xxx1111x|xxx111|4</span><br><span style="color: hsl(120, 100%, 40%);">+|===</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+This table of default DSCP/TOS -> priority bit mappings cannot be</span><br><span style="color: hsl(120, 100%, 40%);">+modified.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+However, the per-packet _priority_ values can be set by various means</span><br><span style="color: hsl(120, 100%, 40%);">+of network policy, including</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+* by packet filter rules (iptables, ip6tables, nftables)</span><br><span style="color: hsl(120, 100%, 40%);">+** if you use `iptables`, using `CLASSIFY --set-class` in the `mangle` table</span><br><span style="color: hsl(120, 100%, 40%);">+** if you use `nftables`, using `meta priority set` in the `mangle` table</span><br><span style="color: hsl(120, 100%, 40%);">+* by the application using the SO_PRIORITY socket option (currently not yet supported by Osmocom CNI)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+=== Ethernet Level (PCP)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+At Ethernet level, different priorities / QoS classes are expressed by</span><br><span style="color: hsl(120, 100%, 40%);">+the so-called PCP (Priority Code Point) field in the IEEE 802.1q (VLAN)</span><br><span style="color: hsl(120, 100%, 40%);">+header.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+NOTE:: This means that PCP functionality requires the use of IEEE 802.q</span><br><span style="color: hsl(120, 100%, 40%);">+VLAN. You cannot use PCP without VLAN</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The Linux kernel assigns IEEE 802.1q PCP bits based on a _mapping_</span><br><span style="color: hsl(120, 100%, 40%);">+between the _priority_ and the PCP value.  Each VLAN network device</span><br><span style="color: hsl(120, 100%, 40%);">+maintains a separate map for both egress (transmit) and ingress</span><br><span style="color: hsl(120, 100%, 40%);">+(receive) path.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The current priority mappings can be inspected via the `/proc`</span><br><span style="color: hsl(120, 100%, 40%);">+filesystem.  For example, if you have a VLAN device `eth0.9` for</span><br><span style="color: hsl(120, 100%, 40%);">+VLAN ID 9 on the net-device `eth0`, you can use the following example:</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+.Example: Inspecting the current egress QoS map</span><br><span style="color: hsl(120, 100%, 40%);">+----</span><br><span style="color: hsl(120, 100%, 40%);">+$ sudo cat /proc/net/vlan/eth0.9<1></span><br><span style="color: hsl(120, 100%, 40%);">+eth0.9  VID: 9   REORDER_HDR: 1  dev->priv_flags: 1021</span><br><span style="color: hsl(120, 100%, 40%);">+         total frames received       123340</span><br><span style="color: hsl(120, 100%, 40%);">+          total bytes received     40668066</span><br><span style="color: hsl(120, 100%, 40%);">+      Broadcast/Multicast Rcvd         1106</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      total frames transmitted        10499</span><br><span style="color: hsl(120, 100%, 40%);">+       total bytes transmitted      1570809</span><br><span style="color: hsl(120, 100%, 40%);">+Device: eth0</span><br><span style="color: hsl(120, 100%, 40%);">+INGRESS priority mappings: 0:0  1:0  2:0  3:0  4:0  5:0  6:0 7:0 <2></span><br><span style="color: hsl(120, 100%, 40%);">+ EGRESS priority mappings: <3></span><br><span style="color: hsl(120, 100%, 40%);">+----</span><br><span style="color: hsl(120, 100%, 40%);">+<1> make sure to specify your specific VLAN interface name here instead of `eth0.9`</span><br><span style="color: hsl(120, 100%, 40%);">+<2> ingress priority mappings (all PCP values mapped to priority 0)</span><br><span style="color: hsl(120, 100%, 40%);">+<3> egress priority mappings (empty)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+As we can see in the above example, there are no egress priority</span><br><span style="color: hsl(120, 100%, 40%);">+mappings yet.  Let's create three new mappings, mapping _priority_</span><br><span style="color: hsl(120, 100%, 40%);">+value 1 to PCP 1, _priority_ 2 to PCP 2, and _priority_ 3 to PCP 3:</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+.Example: Creating three new egress QoS mappings</span><br><span style="color: hsl(120, 100%, 40%);">+----</span><br><span style="color: hsl(120, 100%, 40%);">+$ sudo ip link set dev eth0.9<1> type vlan egress-qos-map 1:1 2:2 3:3 <2></span><br><span style="color: hsl(120, 100%, 40%);">+$ sudo cat /proc/net/vlan/eth0.9 <3></span><br><span style="color: hsl(120, 100%, 40%);">+eth0.9  VID: 9   REORDER_HDR: 1  dev->priv_flags: 1021</span><br><span style="color: hsl(120, 100%, 40%);">+         total frames received       123898</span><br><span style="color: hsl(120, 100%, 40%);">+          total bytes received     40843611</span><br><span style="color: hsl(120, 100%, 40%);">+      Broadcast/Multicast Rcvd         1106</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      total frames transmitted        10517</span><br><span style="color: hsl(120, 100%, 40%);">+       total bytes transmitted      1574357</span><br><span style="color: hsl(120, 100%, 40%);">+Device: eth0</span><br><span style="color: hsl(120, 100%, 40%);">+INGRESS priority mappings: 0:0  1:0  2:0  3:0  4:0  5:0  6:0 7:0</span><br><span style="color: hsl(120, 100%, 40%);">+ EGRESS priority mappings: 1:1 2:2 3:3 <4></span><br><span style="color: hsl(120, 100%, 40%);">+----</span><br><span style="color: hsl(120, 100%, 40%);">+<1> make sure to specify your specific VLAN interface name here instead of `eth0.9`</span><br><span style="color: hsl(120, 100%, 40%);">+<2> command to define three new egress QoS maps</span><br><span style="color: hsl(120, 100%, 40%);">+<3> command to re-display the current status</span><br><span style="color: hsl(120, 100%, 40%);">+<4> three new egress mappings are shown as given in `ip` command</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+NOTE:: The settings of the `ip` command are volatile and only active until</span><br><span style="color: hsl(120, 100%, 40%);">+the next reboot (or the network device or VLAN is removed).  Please refer to</span><br><span style="color: hsl(120, 100%, 40%);">+the documentation of your specific Linux distribution in order to find out how</span><br><span style="color: hsl(120, 100%, 40%);">+to make such settings persistent by means of an `ifup` hook whenever the interface</span><br><span style="color: hsl(120, 100%, 40%);">+comes up.  For CentOS/RHEL 8 this can e.g. be achieved by means of an `/sbin/ifup-local</span><br><span style="color: hsl(120, 100%, 40%);">+script` (when using `network-scripts` and not NetworkManager).  For Debian or Ubuntu,</span><br><span style="color: hsl(120, 100%, 40%);">+this typically involves adding `up` lines to `/etc/network/interfaces` or a `/etc/network/if-up.d`</span><br><span style="color: hsl(120, 100%, 40%);">+script.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+=== Putting things together</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Assuming one needs to set both the DSCP bits as well as the PCP for</span><br><span style="color: hsl(120, 100%, 40%);">+certain traffic, the above-mentioned mechanisms need to be combined as</span><br><span style="color: hsl(120, 100%, 40%);">+follows:</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+. configure the osmocom program to set the DSCP value</span><br><span style="color: hsl(120, 100%, 40%);">+. use the default DSCP -> priority mapping, if possible</span><br><span style="color: hsl(120, 100%, 40%);">+. configure an egrees QoS map to map from priority to PCP</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+If the desired combination of DSCP + PCP cannot be achieved that way,</span><br><span style="color: hsl(120, 100%, 40%);">+due to the rather static default kernel mapping table, one needs to go</span><br><span style="color: hsl(120, 100%, 40%);">+one step further:</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+. configure the osmocom program to set the DSCP value</span><br><span style="color: hsl(120, 100%, 40%);">+. use packet filter rules to set the priority based on DSCP</span><br><span style="color: hsl(120, 100%, 40%);">+. configure an egrees QoS map to map from priority to PCP</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+include::{srcdir}/chapters/qos-example.adoc[]</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-gsm-manuals/+/23926">change 23926</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-gsm-manuals/+/23926"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-gsm-manuals </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Id344c29eda2a9b3e36376302b425e9db1f6c0f28 </div>
<div style="display:none"> Gerrit-Change-Number: 23926 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>