Six years ago, I nearly got my ISP to upgrade our fibre connection to 1Gbps. As I said at the time: This is a curmudgeonly post which is going to look ridiculously outdated in a few years. What's the point of Gigabit broadband? Well, it's a few years later and Virgin Media have just given me their Gig1 package for £30 per month. Nice! With all the inflation related price rises, it's great to …
The algorithm is super easy:
A stream is defined as something that shares the same Source IP, Target IP, Source port, Target port and protocol, so e.g. “TCP 192.168.0.2:45231 -> 80.0.0.1:443”.
The router counts how many packets each stream had in the last second.
If the bandwith is at its limit and two streams want to send a packet, prioritize the one that had fewer packets in the last second.
This covers all of your bases:
The cool thing is, this algorithm needs extremely little space in RAM and is extremely easy on the CPU too. To store a stream’s data you need 13 bytes for the metadata plus 3 bytes for the package counter, netting 16 bytes per stream. That’s 64 concurrent streams per Kilobyte of used RAM. A megabyte fits 64k streams. You can implement that algorithm on an original Gameboy and it wouldn’t sweat.
Source: I actually spent the first 7 years of my carreer at a company that makes routers and switches and developed the software for them. 128MB RAM was what our mid-range models had, and every single model we had had traffic priorisation.