PFIFO, BFIFO
PFIFO, BFIFO
Section titled “PFIFO, BFIFO”PFIFO (Packet First-In, First-Out) and BFIFO (Byte First-In, First-Out) are the simplest queue types available in RouterOS. Both implement basic FIFO logic where the first packet to arrive is the first packet transmitted. The key difference lies in how they measure queue fullness: PFIFO counts individual packets, while BFIFO tracks total byte size.
These queue types provide no prioritization, no traffic classification, and no quality of service differentiation. Every packet receives equal treatment based solely on arrival order. While this simplicity makes PFIFO and BFIFO easy to configure and predict, it also means they cannot distinguish between latency-sensitive VoIP traffic and bulk downloads.
Overview
Section titled “Overview”PFIFO and BFIFO belong to the most basic category of queue disciplines. They operate on a straightforward principle: packets enter a queue in order and leave in the same order. There is no concept of priority, weighted fairness, or traffic shaping beyond the queue size limit.
The primary use case for these queue types is scenarios where you need simple, predictable behavior without the complexity of more advanced queuing disciplines. They work well for background traffic that can tolerate variable latency or for situations where a downstream device handles all QoS decisions.
Understanding the difference between packet-based and byte-based queuing helps you select the appropriate type for your specific requirements. PFIFO ensures a maximum number of packets wait in queue, while BFIFO ensures a maximum amount of data waits in queue regardless of how many packets comprise that data.
PFIFO (Packet First-In, First-Out)
Section titled “PFIFO (Packet First-In, First-Out)”PFIFO manages queue capacity based on the number of packets waiting for transmission. When a packet arrives, it is placed at the tail of the queue. When bandwidth becomes available, the packet at the head of the queue transmits first. If the queue contains the maximum allowed packets when a new packet arrives, that packet is dropped.
PFIFO Characteristics
Section titled “PFIFO Characteristics”PFIFO offers several distinguishing characteristics that make it suitable for specific use cases. The queue size in packets provides predictable memory usage since each packet consumes a relatively consistent amount of queue control structures. This predictability can be valuable in memory-constrained environments or when you need to guarantee a minimum number of packets can wait during temporary congestion.
The packet-counting approach means small packets and large packets consume equal queue slots. A single 1500-byte packet occupies the same queue position as a 64-byte packet. This behavior can lead to situations where large packets dominate queue capacity, potentially causing head-of-line blocking for latency-sensitive traffic that arrives later.
PFIFO requires minimal CPU overhead since the router only needs to track packet count, not calculate or monitor byte totals. This simplicity translates to lower computational requirements, which can be beneficial on older or resource-limited RouterBOARD devices.
When to Use PFIFO
Section titled “When to Use PFIFO”PFIFO works best in scenarios where you want to limit the maximum number of packets in flight without considering their size. Consider using PFIFO when you have consistent packet sizes (such as VoIP environments with mostly uniform codec outputs), when CPU resources are constrained, or when downstream equipment handles all traffic prioritization.
BFIFO (Byte First-In, First-Out)
Section titled “BFIFO (Byte First-In, First-Out)”BFIFO operates identically to PFIFO in terms of packet ordering but measures queue fullness based on total byte count rather than packet count. When packets enter the queue, they are placed at the tail. When transmission opportunities arise, packets depart from the head in first-in, first-out order. The critical difference is that the queue limit specifies maximum accumulated bytes, not maximum packet count.
BFIFO Characteristics
Section titled “BFIFO Characteristics”Byte-based sizing provides more accurate bandwidth control when packets vary significantly in size. A BFIFO queue with a 1MB limit actually constrains data volume rather than packet count. This behavior prevents a flood of small packets from dominating queue capacity and ensures large packets cannot monopolize available buffer space.
The byte-counting approach means BFIFO can more precisely control actual bandwidth utilization. If you want to limit queued data to approximately 500KB, BFIFO measures this directly. PFIFO would require you to estimate how many packets typically fit in 500KB of data, which varies based on average packet size.
BFIFO requires slightly more computational overhead than PFIFO because the router must track cumulative byte counts. For most modern RouterOS devices, this overhead is negligible, but it becomes a consideration on very old or heavily loaded systems.
When to Use BFIFO
Section titled “When to Use BFIFO”BFIFO is appropriate when you want to limit actual queued data volume rather than packet count. Use BFIFO in environments with highly variable packet sizes where byte-based limits provide more predictable behavior. BFIFO also works well when you are sizing queues based on available memory and want to reserve specific byte amounts for queue buffers.
Comparison: PFIFO vs BFIFO
Section titled “Comparison: PFIFO vs BFIFO”| Aspect | PFIFO | BFIFO |
|---|---|---|
| Queue Measurement | Packet count | Byte count |
| Memory Predictability | Predictable packet structures | Varies with packet size |
| Bandwidth Control | Indirect (via packet limits) | Direct (byte limits) |
| CPU Overhead | Lower | Slightly higher |
| Large Packet Handling | Each packet = 1 slot | Scaled by size |
| Small Packet Handling | Each packet = 1 slot | Scaled by size |
Queue Size Considerations
Section titled “Queue Size Considerations”Setting appropriate queue sizes for PFIFO and BFIFO requires understanding your traffic characteristics and available memory. PFIFO queue sizes are typically specified in number of packets, with values like 10, 50, or 100 packets being common. BFIFO queue sizes are specified in bytes, with values like 100KB, 500KB, or 1MB being typical.
Larger queues allow more packets to wait during bursts of congestion, reducing packet loss at the cost of increased latency. Smaller queues force earlier packet drops but maintain lower latency. The optimal queue size depends on your network’s typical burst duration and the latency sensitivity of your applications.
Configuration
Section titled “Configuration”Both PFIFO and BFIFO queue types are built-in and do not require installation. You reference them by name in your queue configuration.
/queue type add name="PFIFO-100" kind=pfifo fifo-limit=100/queue type add name="BFIFO-500KB" kind=bfifo bfifo-limit=500000FIFO Limit Parameter
Section titled “FIFO Limit Parameter”| Parameter | PFIFO | BFIFO |
|---|---|---|
| Name | fifo-limit | bfifo-limit |
| Unit | Packets | Bytes |
| Purpose | Maximum queued packets | Maximum queued bytes |
The limit parameter controls the maximum queue depth. For PFIFO, this is the maximum number of packets waiting. For BFIFO, this is the maximum total bytes queued.
Limitations
Section titled “Limitations”Neither PFIFO nor BFIFO provides any traffic prioritization capability. All packets receive equal treatment regardless of their content, source, destination, or application requirements. Latency-sensitive traffic such as VoIP or video conferencing experiences the same queuing delays as bulk file transfers.
These queue types cannot classify traffic or apply different treatment to different flows. If you need to prioritize certain traffic or guarantee bandwidth to specific applications or users, consider using PCQ, priority queues, or queue trees with appropriate queue types.
Related Content
Section titled “Related Content”- PCQ Example - Dynamic bandwidth distribution
- Queue Types - All queue type documentation