RingCentral Linux QoS and Traffic Shaping Configuration
Ver 1.0.0
by Tim McKee, June 12, 2026

The ZIP file contains several files that are required to implement QoS and 
traffic shaping for Linux.   Some file paths may require adjustment based upon
your linux release.  These instructions were developed based upon Mint Linux 
Release Version 22.3.

                     ==============================
                     == Classification using NFT ==
                     ==============================

NFT is used to classify traffic which is destined for RingCentral datacenter 
networks using the service connection port numbers.  Traffic is classified as 
Audio, Video, Signaling, and Other.  Traffic not destined for RingCentral 
datacenter networks is marked as default.  The marks are reflected in the
value of the DSCP field in the IP packet header.

File nftables.nft should be copied to directory '/etc' and will overlay the 
existing file.  The only reason you should edit this file is if you have 
existing special handling and must merge it with the RingCentral rules.  You
should check the syntax if you make any changes using the command:

    nft -c -f /etc/nftables.nft

Once the syntax has checked ok, run this file by typing "/etc/nftables.nft"
and it will begin operations.  The command "nft list ruleset" will show the new
rules and display the match counters.  Any existing connections will be 
classified as default  background traffic.   Any new connections will be marked
correctly.  The connection table can be displayed with the command:

    conntrack -L

A useful variation which does not show the default background traffic 
connections is:

    conntrack -L | grep -v ' mark=1 '


                      ==============================
                      == Traffic Shaping using TC ==
                      ==============================

Traffic marking is great, but if your machine is connected to the Internet
you must do something with the traffic to make sure the priorities you have
marked are honored.  Note that your ISP's customer premise equipment (CPE) by
default will NOT honor the DSCP markings on your traffic.  Not only will it not
prioritize transmission of the realtime traffic over other traffic, it may send
traffic faster than your contracted data rate with your ISP.  The ISP will then
automatically discard the excess traffic, which includes your priority marked
traffic.  This results in very poor voice/video traffic quality and broken or
dropped connections.

The answer to this problem is to restrict your transmission rate to a value
that the ISP equipment will always accept.  Best practice is to use a value of
95% of the contracted or tested data rate.  This leaves a bit of leeway in case
the 'clock' of the ISP does not match the clock of your device.

CRITICAL NOTE: Traffic shaping must be applied to the interface directly 
connected to the upstream ISP.  ALL TRAFFIC must be flowing through the traffic
shaping rules, not just one server.  Violation of this rule will result in 
degraded quality of service.

The file named 'apply-tc-rules.sh' must be edited to identify the interface 
name and contracted or tested WAN speed in either kilobits per second (kbit)
or megabits per second (mbit).  Change the values of wan_device, wan_speed,
and wan_mag to set the applied values upon service startup.  The percentages of
bandwidth allocated to audio, video, signaling, RingCentral other, and default
traffic should be adjusted based upon the traffic expected.

The file named 'remove-tc-rules.sh' must be editied to identify the interface.

You may run the 'apply-tc-rules.sh' script with parameter 1 set to device, 
parameter 2 set to speed, parameter 3 set to speed magnitude (kbit or mbit).
Parameter 4 may be specified as "t" to only run the calculations and display
rule bandwidth results without applying the rules.

Installation

Copy 'apply-tc-rules.sh', 'tc-mon.sh', and 'remove-tc-rules.sh' to directory 
/usr/local/bin (location may change with different linux flavors).  Edit 
file tc.service to reflect a changed directory. (The file tc-mon.sh will 
display current rules and counters on a 1 second interval.)

Copy 'tc.service' to directory /etc/systemd/system (location may change with 
different linux flavors).

Run the following commands to enable autostart and start the service now.

    sudo systemctl daemon-reload
    sudo systemctl enable tc.service
    sudo systemctl start tc.service

