Before you can set up either sort of queue, you must tell PF where to place the parent queue. The parent queue is attached to a network interface, generally the Internet-facing interface. Queue rules go in /etc/pf.conf between the scrub and NAT rules. Not all of the components are necessary, but here's the full ugly syntax:
1 altq on 2 interfacename 3 queue-type bandwidth 4 bandwidth qlimit 5 qlimit tbrsize 6 tbrsize 7 queue { 8 queue2, 9 queue3}
All altq parent queue definitions start with the 1 altq keyword. You then state the 2 interface that this queue is attached to. Each interface can have no more than one parent queue.
Then state the 3 queue type you've chosen. You must state the total amount of 4 bandwidth in the parent queue. PF recognizes the following case-sensitive bandwidth labels.
b | bits per second |
Kb | kilobits per second |
Mb | megabits per second |
Gb | gigabits per second |
The 5 qlimit parameter gives the number of packets to hold in the queue. This defaults to 50, which is suitable for almost all cases. You can decide to not include the qlimit value.
The 6 tbrsize, or Token Bucket Regulator size, dictates how quickly packets can be removed from the queue (transmitted). This parameter is optional, and defaults to the wire speed. You're better off using the bandwidth option to regulate bandwidth, as the effective usage of tbrsize is to control if packets are transmitted based on device driver interrupts or the kernel clock. On any vaguely modern system, either comes extremely quickly.
We then identify this as the 7 parent queue, and list the child queues 8 queue2 and 9 queue3.