LibreQoS/README.md

129 lines
5.8 KiB
Markdown
Raw Normal View History

2020-10-02 10:44:48 -05:00
# LibreQoS
2020-10-07 10:26:52 -05:00
LibreQoS is a python application that allows you to apply fq_codel traffic shaping on hundreds of customers. <a href="https://www.bufferbloat.net/projects/codel/wiki/">Fq_codel</a> is a Free and Open Source Active Queue Management algorithm that reduces bufferbloat, and can improve the quality of customer connections significantly. LibreQoS features the ability to import devices from LibreNMS and UNMS at runtime using API calls. It then apples hundreds of filter rules to direct customer traffic through individual fq_codel instances within an <a href="https://linux.die.net/man/8/tc-htb">HTB</a> (HTB+fq_codel). By utilizing <a href="https://tldp.org/HOWTO/Adv-Routing-HOWTO/lartc.adv-filter.hashing.html">hashing filters</a>, thousands of rules can be applied with minimal impact on traffic throughput or CPU use. This is alpha software, please do not deploy in production without thorough testing.
2020-10-07 09:48:41 -05:00
## Features
2020-10-05 14:34:54 -05:00
* HTB + fq_codel
* Experimental support for CAKE (Common Applications Kept Enhanced)
2020-10-06 08:37:39 -05:00
* TC filters divided into groups with hashing filters to significantly increase efficiency and minimize resource use
2020-10-07 05:18:12 -05:00
* VM running LibreQoS with 2500 IP rules uses just 1.5GB RAM total
2020-10-07 05:06:46 -05:00
* Basic statistics (Top 10 CPEs experiencing packet loss)
2020-10-07 09:48:41 -05:00
## Integration
2020-10-05 14:34:54 -05:00
* LibreNMS device import
* UNMS/UCRM device import
2020-10-07 09:48:41 -05:00
## Requirements
2020-10-02 11:33:45 -05:00
* Edge and Core routers with MTU 1500 on links between them
2020-10-07 10:24:15 -05:00
* If you use MPLS, you would terminate MPLS traffic at the core router. LibreQoS cannot decapsulate MPLS on its own.
2020-10-02 11:29:16 -05:00
* OSPF primary link (low cost) through the server running LibreQoS
2020-10-05 20:16:48 -05:00
* OSPF backup link
2020-10-02 12:06:06 -05:00
![Diagram](docs/diagram.png?raw=true "Diagram")
2020-10-07 09:48:41 -05:00
### Server Requirements
2020-10-02 11:29:16 -05:00
* VM or physical server
2020-10-02 11:35:03 -05:00
* One management network interface
* Two dedicated network interface cards, preferably SFP+ capable
2020-10-02 10:55:22 -05:00
* Python 3
2020-10-07 10:24:15 -05:00
* pip install ipaddress
* Recent Linux kernel. Ubuntu Server 20.04.1+ recommended
2020-10-07 09:48:41 -05:00
### VM Performance
#### Memory use
2020-10-07 09:47:35 -05:00
On ProxMox VMs you need to do <a href="https://www.reddit.com/r/Proxmox/comments/asakcb/problem_with_ram_cache/">some tweaks</a> to allow freed up memory to be reclaimed by the hypervisor. Generally memory use should be under 2GB if you have less than 2000 hosts. If for any reason memory exceeds what it should be, try
2020-10-06 08:55:10 -05:00
```
sudo sh -c 'echo 1 >/proc/sys/vm/drop_caches'
```
2020-10-07 09:48:41 -05:00
#### Disable Offloading in Guest VM
2020-10-07 09:47:35 -05:00
Performance can greatly benefit from disabling certain hardware offloading inside the guest VM. If you're using a system that uses Netplan (e.g. Ubuntu) to configure the network then you can use a Netplan post-up script to configure offloading. You create a script in the following directory with a name prefixed by a number to indicate load order e.g. /etc/networkd-dispatcher/routable.d/40-offloading-config - which is executable and owned by root. e.g. To switch off TCP Segment Offloading on eth0:
```
#!/bin/sh
/sbin/ethtool -K eth0 tso off
```
2020-10-07 09:48:41 -05:00
### Add a bridge between in/out interface NICs
2020-10-05 14:34:54 -05:00
* Add linux interface bridge br0 to the two dedicated interfaces
* For example on Ubuntu Server 20.04 which uses NetPlan, you would add the following to the .yaml file in /etc/netplan/
```
bridges:
br0:
interfaces:
- eth4
- eth5
```
2020-10-07 09:48:41 -05:00
## Run LibreQoS
2020-10-05 14:49:51 -05:00
* Modify setting parameters in ispConfig.py to suit your environment
2020-10-05 14:34:54 -05:00
* Run:
```
sudo python3 ./LibreQoS.py
```
2020-10-07 09:48:41 -05:00
## Statistics
2020-10-07 05:06:46 -05:00
Basic statistics are now available by running
```
python3 ./stats.py
```
after successful execution of ./LibreQoS.py or ./scheduled.py
2020-10-07 09:48:41 -05:00
## Running as a service
2020-10-05 14:34:54 -05:00
You can use the scheduled.py file to set the time of day you want the shapers to be refreshed at after the initial run.
On linux distributions that use systemd, such as Ubuntu, add the following to /etc/systemd/system/LibreQoS.service
```
[Unit]
After=network.service
[Service]
WorkingDirectory=/home/$USER/LibreQoSDirectory
ExecStart=/usr/bin/python3 /home/$USER/LibreQoSDirectory/scheduled.py
Restart=always
[Install]
WantedBy=default.target
```
Then run
```
sudo systemctl start LibreQoS.service
```
2020-10-07 09:48:41 -05:00
## Real World Performance
2020-10-05 16:17:46 -05:00
This customer is using a Ubiquiti LTU-LR CPE with QoS shaping applied at 215Mbps down and 30Mbps up.
<img src="docs/customerExample.jpg" width="500">
2020-10-05 16:16:26 -05:00
2020-10-07 09:48:41 -05:00
## Server Spec Recommendations
2020-10-02 12:25:11 -05:00
* For up to 1Gbps
* 4+ CPU cores
2020-10-06 09:06:26 -05:00
* 4GB RAM
2020-10-02 16:25:23 -05:00
* 32GB Disk Space
* Passmark score of 13,000 or more (AMD Ryzen 5 2600 or better)
* For up to 2Gbps
* 6+ CPU cores
2020-10-06 09:06:26 -05:00
* 6GB RAM
2020-10-02 12:25:11 -05:00
* 32GB Disk Space
* Passmark score of 17,000 or more (AMD Ryzen 5 3600 or better)
* For up to 5Gbps
* 8+ CPU cores
2020-10-06 09:06:26 -05:00
* 8GB RAM
2020-10-02 12:25:11 -05:00
* 32GB Disk Space
* Passmark score of 23,000 or more (AMD Ryzen 7 3800X or better)
* For up to 10Gbps
* 16+ CPU cores
2020-10-06 09:06:26 -05:00
* 16GB RAM
2020-10-02 12:25:11 -05:00
* 32GB Disk Space
* Passmark score of 38,000 or more (AMD Ryzen 9 3950X or better)
2020-10-02 16:25:23 -05:00
https://www.cpubenchmark.net/high_end_cpus.html
2020-10-02 12:25:11 -05:00
2020-10-07 09:48:41 -05:00
## Special Thanks
2020-10-07 05:18:45 -05:00
Thank you to the hundreds of contributors to the fq_codel and cake projects. Thank you to Phil Sutter, Bert Hubert, Gregory Maxwell, Remco van Mook, Martijn van Oosterhout, Paul B Schroeder, and Jasper Spaans for contributing to the guides and documentation listed below.
2020-10-02 10:59:58 -05:00
2020-10-07 09:48:41 -05:00
## References
2020-10-02 11:33:45 -05:00
* https://tldp.org/HOWTO/Adv-Routing-HOWTO/lartc.adv-filter.hashing.html
* http://linux-ip.net/gl/tc-filters/tc-filters.html
2020-10-07 09:48:41 -05:00
## License
2020-10-02 11:01:17 -05:00
Copyright (C) 2020 Robert Chacón
2020-10-02 10:44:48 -05:00
LibreQoS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
2020-10-02 10:48:37 -05:00
LibreQoS is distributed in the hope that it will be useful,
2020-10-02 10:44:48 -05:00
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LibreQoS. If not, see <http://www.gnu.org/licenses/>.