Priority for VoIP and a cap on backup traffic

John Smith Ltd goes out to the internet through the fibre on eth0 (203.0.113.10/29, wan zone), a contract of 100 Mbit/s download and 20 Mbit/s upload. The VoIP phones (192.168.10.61–.68) register…

Situation

John Smith Ltd goes out to the internet through the fibre on eth0 (203.0.113.10/29, wan zone), a contract of 100 Mbit/s download and 20 Mbit/s upload. The VoIP phones (192.168.10.61–.68) register with the provider’s PBX, 198.51.100.50: SIP signalling on port 5060, RTP audio over udp on the PBX’s ports 10000–20000. Calls go out through the fibre, like everything else.

Every night, and sometimes during the day, the NAS (192.168.10.20) copies its data to an outside backup service with rsync (tcp 873): for as long as the copy lasts the upload is full, and calls in progress break up. During the day the same happens when someone downloads or uploads large files from the web.

You want three things:

  • call signalling always at the top;
  • a cap on the backup, which must never take the whole line;
  • a share of bandwidth always free for the calls’ audio, even when web and backup push as hard as they can.

You do it in Network and uplinks → Quality of Service with two rules on eth0: one for egress (the upload, the real bottleneck) and one for ingress (the download).

Tip A rule goes on the interface the traffic actually leaves through: the queue forms on the line it crosses. If a service leaves through another line (for example the FWA, with a policy route), its ladder goes on that interface, with that line’s speed.

What you need

  • The line’s real speed in both directions. You work a little below the contract, so that the queue forms on the appliance, where Argos decides who goes first, and not on the modem: here 19000 kbit/s egress and 95000 kbit/s ingress.
  • The ports of the traffic to classify, on the remote side: on egress a class takes the packets addressed to those ports, on ingress those that come from those ports. Here 5060 (the PBX’s SIP), 80 and 443 (the web), 873 (the backup service).

How the console reasons

  • Each rule applies to one interface and one direction: the same interface can have one egress rule and one ingress rule, not two in the same direction. The interface is a network card, a VLAN or a PPPoE link (ppp0).
  • A rule is a priority ladder: classes with a name, a guaranteed rate, an optional cap (“Ceil”) and the ports that land in them. The ladder sorts itself by guaranteed rate: the class with the highest guaranteed rate is the one with the highest priority. To put a class at the top, give it the highest guarantee.
  • When the line has spare bandwidth, the classes higher up lend it first; a class with a “Ceil” never goes beyond that value.
  • Traffic that no class names lands in the default class: 256 kbit/s guaranteed and, up to the line speed, whatever bandwidth the other classes leave free. It is the last one on the ladder.
  • A class takes at most 32 ports, counting a range’s ports one by one: 5060,10000-10010 is 12 ports; 10000-20000 is 10001 and the console refuses them with “Max 32 ports per class”.

The last point decides how the audio is protected in this scenario. The PBX’s RTP uses 10001 ports: it does not fit in a class. You do it the other way round: you give a cap to the classes of the heavy traffic (web and backup), so that their sum stays below the line; the bandwidth left over is always available to the default class, where the RTP lands.

Tip If your PBX uses a narrow range for audio (up to 31 ports), put it in the “Voice” class next to 5060: it is the most direct solution, and the audio goes to the top of the ladder together with the signalling.

The plan

Class Guaranteed rate Ceil Ports Egress Ingress
Voice 3000 0 (up to the line) 5060 yes yes
Web 2000 12000 egress, 80000 ingress 80,443 yes yes
Backup 1000 4000 873 yes no
(default) 256 the line everything else, RTP included — —

Values in kbit/s. On egress web and backup together do not exceed 16000 kbit/s: out of 19000 there are always about 3000 kbit/s left for the default class, some thirty simultaneous G.711 calls. On ingress the web stops at 80000 out of 95000: 15000 are left.

Steps

The egress rule

  1. Open Network and uplinks → Quality of Service and press the “+” button on the right of the list’s bar (“Add shaping rule”). “Quality of Service / New rule” opens.

  2. Fill in the top part:

    • “Direction”: “Egress”;
    • “Interface”: eth0 (WAN);
    • “Description”: Fibre, 20 Mbit/s upload;
    • “Line speed (kbit/s)”: 19000;
    • “Enabled”: on.
  3. The “Priority ladder” block of a new rule already has one class, “Voice”, with 5000 kbit/s guaranteed and no ports. Click it: in the “Edit class” dialog leave “Name” Voice and fill in “Guaranteed rate (kbit/s)” 3000, “Ceil (kbit/s)” 0, “Egress ports” 5060, then press “Save”.

    The dialog of a class of the priority ladderThe dialog of a class of the priority ladder
    The dialog of a class of the priority ladder
  4. Press “Add priority” on the right of the ladder’s header. In the “Add priority” dialog fill in “Name” Web, “Guaranteed rate (kbit/s)” 2000, “Ceil (kbit/s)” 12000, “Egress ports” 80,443 and press “Add”.

  5. “Add priority” again: “Name” Backup, “Guaranteed rate (kbit/s)” 1000, “Ceil (kbit/s)” 4000, “Egress ports” 873 → “Add”.

  6. Check the ladder: “Voice” is at the top with the “Priority” label, then “Web” and “Backup”. The bars show the guaranteed rate. To correct a class, click it: the “Edit class” dialog has “Save” to keep the change and “Remove class”. A class joins the rule, or a change takes effect, only when you save the rule.

  7. Press “Create rule” at the bottom right. The rule reaches the kernel at once (no need to apply the firewall) and “Rule applied” appears.

    The egress rule on eth0 with the three classesThe egress rule on eth0 with the three classes
    The egress rule on eth0 with the three classes

The ingress rule

  1. Press “+” in the list’s bar again.

  2. Fill in: “Direction” “Ingress”, “Interface” eth0 (WAN), “Description” Fibre, 100 Mbit/s download, “Line speed (kbit/s)” 95000, “Enabled” on.

  3. Prepare the classes. On ingress the ports field is called “Remote service ports”: they are the ones the traffic comes from.

    • Click the “Voice” class already there and fill in “Guaranteed rate (kbit/s)” 3000, “Ceil (kbit/s)” 0, “Remote service ports” 5060 → “Save”;
    • with “Add priority”: “Name” Web, “Guaranteed rate (kbit/s)” 2000, “Ceil (kbit/s)” 80000, “Remote service ports” 80,443 → “Add”.

    The backup is not needed on ingress: of the NAS’s copy, only the receipt acknowledgements come back as download.

  4. Press “Create rule”. “Rule applied” appears.

The list now shows two rows for eth0, “Egress · 3 classes · 3000 kbit/s · Fibre, 20 Mbit/s upload” and “Ingress · 2 classes · …”, each with “Enabled”.

If the fibre is on PPPoE

With the fibre on PPPoE (link ppp0 on eth0.10, see FTTH fibre over PPPoE on VLAN 10) the two rules go on the link: in “Interface” choose ppp0 (WAN), not eth0. The rest does not change. A rule on a PPPoE link is built at every session, as soon as pppd brings it up; while the session is down the rule’s card in System status → Status says “Waiting for the PPPoE session”, and that is not an error.

For the technician Each rule is an HTB queue: a root class at the line speed, the default class 1:10 (256 kbit/s, HTB priority 7) and the ladder’s classes 1:11, 1:12… in the ladder’s order, with priority 0, 1, 2… Each port is a u32 filter that matches the destination port (egress) or source port (ingress) of the IP packet, TCP or UDP alike. Ingress is redirected into a dedicated ifb interface (argos-ifbN), which shapes as egress what comes in: at most 16 interfaces can have an ingress rule. The same commands go into the hooks of /etc/network/interfaces, so the ladder comes back at every reboot; for a PPPoE link pppd’s hook /etc/ppp/ip-up.d/argos-shaping runs them at every session. On egress the queue sees the packets after the masquerade: the destination port does not change.

Verification

  1. Open System status → Status. There is a card for each rule, headed “eth0 · WAN · Egress” and “eth0 · WAN · Ingress”, with the rule’s description. Each class has a bar, the bytes sent since the rule was applied and, if there are any, the “Dropped” packets; traffic without a class is “Unclassified”.

    The egress rule's card on the Status pageThe egress rule's card on the Status page
    The egress rule's card on the Status page
  2. Start a copy from the NAS (or wait for the nightly one) and watch the egress card: the “Backup” bar grows, and its “Dropped” go up when the copy presses against the cap: it is the backup that is slowed down, not the rest.

  3. During the copy make a test call of a few minutes, to a mobile phone too: the audio must stay clean both ways.

  4. At the same time open a website or run a speed test from a PC: the web slows down but works, because it has its guarantee and its cap.

  5. If you want to see the active SIP connections, Events and diagnostics → Diagnostics → Connection tracking has the ready-made filter “VoIP (SIP, udp 5060)”.

If something goes wrong

What you see What it means What to do
“Max 32 ports per class” The class’s ports, counted one by one, are more than 32. Narrow the list; for a wide range such as the RTP see “How the console reasons”.
“Ports must look like 5060,10000-10010” The ports’ format is wrong. Numbers and ranges separated by commas, with no leading zeros.
“The guaranteed rates, plus the default class’s 256 kbit/s, exceed the line speed” The sum of the guarantees is larger than the line. Reduce the guaranteed rates or correct the line speed.
“Ceil cannot exceed the line speed” / “Ceil must be 0 (off) or >= rate” The cap is above the line or below the class’s guarantee. Correct the “Ceil”.
“A rule for this direction already exists on this interface” Each interface has at most one rule per direction. Edit the existing rule.
“At most 16 interfaces can shape incoming traffic” The limit on ingress rules. Switch off or delete an ingress rule you do not need.
“Applying the rule failed — …” The kernel refused a step; the text says which. Correct it and save again; the next attempt also retries the removals left behind.
On Status “Not active in the kernel”, and in the “Attention” strip “Traffic priority on eth0 is not active in the kernel: save its QoS rule again” The queue has disappeared from the interface, for example after a manual restart of networking. Open the rule: the form says “This rule is not active in the kernel: ‘Save rule’ builds it again as it is.”, and “Save rule” is enabled even without a change. Press it.
The audio still breaks up during the backup The line speed you gave is higher than the real one: the queue forms in the modem, where Argos does not decide. Lower “Line speed (kbit/s)” by 5–10 % and save.
The audio breaks up only when the web is full The caps of web and backup added together leave little for the default class, or there is other heavy traffic without a class. Lower the “Ceil” of “Web”, or give a capped class to the traffic you find in the “Unclassified” bar.
Calls work but the phones’ registration stays on the old line after a switch It is not QoS: it is connection tracking. See After a line change the phones stay on the old one.
LET’S TALK INFRASTRUCTURE

Control starts with a conversation.

Tell us about your infrastructure. Let’s start with what you actually need.

Talk to an engineer