This ACL rule count calculator shows how many hardware TCAM entries an access list needs. Port ranges such as 1024-65535 cannot be stored as a range in ternary memory, so they expand into several value and mask entries; two ranges in one rule multiply. Enter your rules, set the TCAM size, and see the total, with and without range-operator hardware.
Result
The result updates automatically as you change any input.
Formula and worked steps
Formulas used
- A port range is split into the fewest aligned power-of-two blocks (value/mask entries): 1024-65535 needs 6, 1-1023 needs 10, a single port or any needs 1
- Entries per rule = source port blocks x destination port blocks x address combinations
- With range-operator hardware a range costs one range operation and the rule needs one entry per port item
- IPv6 entries use more TCAM slots on many platforms (editable factor)
- TCAM layout, entry width, expansion thresholds and the number of range operators differ between platforms and software releases. Use your platform's scale guide for the TCAM size and the IPv6 slot cost.
- On some platforms a range that expands to only a few entries (for example five or fewer on Cisco Nexus 7000 by default) is expanded even when range operators are free.
- Address combinations is the number of source and destination prefix pairs in the rule; enter 1 if the rule has one source and one destination prefix.
What is ACL rule expansion?
Access control lists on switches and routers are often matched in hardware by ternary content-addressable memory (TCAM). A TCAM entry stores a value and a mask for each field, so it can match exact values and prefixes of bits, which is ideal for IP prefixes. It cannot store an arbitrary numeric range. A rule such as “permit TCP from any to any with source ports 1024 to 65535” must be converted into one or more prefix-style entries, and the number of entries can be large.
Converting a range into entries
A 16-bit port range is split into the smallest set of aligned power-of-two blocks. 1024 to 65535 needs six: 1024-2047, 2048-4095, 4096-8191, 8192-16383, 16384-32767 and 32768-65535. 1 to 1023 needs ten, since 1, 2-3, 4-7 and so on up to 512-1023 are separate blocks. A single port or the whole range needs one. Ranges that start and end on block boundaries are cheap, while a range such as 1 to 65534 needs 30 entries.
Multiplication
If the rule has a range for both the source port and the destination port, the entries multiply: 6 source blocks times 6 destination blocks is 36 entries for one rule. A rule with several address prefix combinations multiplies again. A hundred-line ACL can therefore need thousands of entries, and the effect is only visible when the TCAM fills and the switch refuses new rules or falls back to software.
Range operators
Many platforms have a limited pool of logical operation units, also called Layer 4 operators or range checkers. A rule with a range uses one of these instead of expanding, and takes only one TCAM entry. The pool is small, for example 32 source and 32 destination comparisons on some Catalyst models, and is shared by all ACLs. When it runs out, ranges are expanded in software into equivalent entries, which is the situation this calculator estimates.
How the ACL rule count calculator works
Formulas
Each rule line has a name, source ports, destination ports and a count of address combinations. A port field can be any, a single port, a range, or a list separated by semicolons. For each field the tool counts the minimum aligned blocks, multiplies source blocks by destination blocks by address combinations, and sums over all rules. For range-operator hardware it counts one entry per port item and one range operation per range. IPv6 entries are multiplied by the slot factor you set.
Worked example
The starting rules are a web rule (any to 80 and 443: 2 entries), a high-port rule (1024 to 65535 to any: 6 entries), an ephemeral-both-ways rule (1024-65535 to 1024-65535: 36 entries) and a management rule (any to port 22 with 4 address combinations: 4 entries). The total is 48 entries, 1.2% of a 4,096-entry TCAM. With range operators it drops to 8 entries using 3 range operations. One more rule with the range 1 to 65534 on both sides would add 900 entries, almost 22% of the whole table.
Software and hardware evaluation
Hardware ACLs are evaluated at line rate regardless of length, but are limited by TCAM capacity. Software ACLs on a router CPU are evaluated in order, so each packet is compared with rules one by one until a match, and long lists reduce throughput. The right approach for software lists is to put the most frequently matched rules first and to summarise networks; for hardware lists, count entries. Some platforms also divide TCAM between features such as ACLs, QoS and routing, so the free space may be less than the total.
Why it matters for network engineers
TCAM exhaustion is a nasty failure: a new ACL line fails to install, an existing ACL stops being enforced in hardware, or traffic is punted to the CPU. Counting entries before a change avoids that. It also changes how you write rules. Aligning port ranges to power-of-two boundaries, using well-known port lists instead of broad ranges and using object groups wisely can cut entries by an order of magnitude. Large policy sets also affect firewall performance; see the firewall sizing calculator for the traffic side of the same decision.
Best practices and common mistakes
Prefer eq or a short list of ports to ranges where the real set of services is small. Where you need a broad range, align it to a block: 49152 to 65535 is one entry, whereas 49000 to 65535 is many. Merge rules that differ only by a prefix when the prefixes can be summarised, using the same method as the route summarization calculator. Check the platform’s TCAM utilisation after every change and keep headroom.
Common mistakes are counting rules rather than entries, forgetting that IPv6 entries take more space, and treating a vendor’s range-operator count as unlimited. Another is not allowing for other features that share the TCAM. Do not assume that two platforms behave alike: expansion thresholds and operator counts differ and change between software releases. The same scarcity of hardware table space affects routing as well, which you can estimate with the FIB size calculator.
Rewriting rules to save entries
If the total is too high, rewrite the worst rules first: replace a broad range with the short list of ports that are really used, split an unaligned range into aligned blocks you control, or remove rules that never match.
Verifying on the device
After applying an ACL, check the platform’s command for TCAM or hardware resource utilisation, and the number of entries per ACL, if it is shown. Compare it with this calculation: a big difference means that the platform expands differently, for example because of an expansion threshold or an IPv6 width factor, and you should update the inputs for the next change.
FAQs
Why do port ranges use more TCAM entries?
TCAM matches values and bit masks, not numeric ranges, so a range must be split into aligned power-of-two blocks. 1024-65535, for example, needs 6 entries and 1-1023 needs 10.
What is a logical operation unit?
It is a hardware register that evaluates a range or comparison, so the rule uses one TCAM entry instead of many. The number is limited and shared across ACLs, and when it runs out the ranges are expanded.
How many TCAM entries does an ACL need?
Multiply the number of blocks in the source port range, the destination port range and the address combinations for each rule, then add the rules together. A plain rule with single ports uses one entry.
Do IPv6 ACLs use more TCAM?
On many platforms yes: IPv6 entries are wider and take two or more slots. The calculator has an editable slot factor, so enter the value from your platform’s scale guide.
Next, try the firewall sizing calculator, the route summarization calculator and fib-size-calculator, or browse all Network Security & Overhead calculators and the full list of network calculators.