2

I am trying to understand TCAMs and I have stumbled upon this: Ternary CAMs, Wikipedia

The addresses are stored using "don't care" for the host part of the address, so looking up the destination address in the CAM immediately retrieves the correct routing entry; both the masking and comparison are done by the CAM hardware.

This paragraph is ambigous to me. Is masking taking place with TCAMs so that the result is a network address which gets compared to the network address in the routing table or not?

Because not having to calculate the network address at all while routing would be an awesome property of TCAMs.

2

This paragraph is ambigous to me. Is masking taking place with TCAMs so that the result is a network address which gets compared to the network address in the routing table or not?

No, not exactly. There is not a regular masking operation taking place. There is no software querying the CAM/TCAM at forwarding time. While usual memory is designed to be queried by a 'memory address' (pointer), CAM/TCAM is a kind of memory circuit (hardware) designed to lookup by content. It does in hardware what a hash table does in software: an associative array.

The point is: TCAM can be programmed with a network prefix entry. For instance, you can insert a /24 prefix into TCAM by marking last 8 bits as "DON'T CARE".

With plain binary CAM, you can't insert IP prefix, you can only insert full IP address (or MAC addresses) as lookup key.

"What I wanted to know is whether TCAMs need to calculate a network address before searching for a matching entry in their routing table."

No. TCAM circuitry can DIRECTLY lookup keys against entries built with 0s and 1s and Xs (X=don't care). For instance, you could insert entry=1.0.0.X then you can lookup key=1.0.0.1. The TCAM circuitry will find and return the matching 1.0.0.X entry (plus its associated information) without doing the "formal" masking you seem to be picturing. However, TCAM lookup does a kind of masking to distinguish between "care bits" and "don't care bits"

  • "1. So you say masking is taking place but technically the TCAMs don't need to calculate the network address?" Well, when you load a an address with 'dont care bits' in the TCAM, can you view it as preloading the TCAM com precalculated network address? – Everton Jan 8 '16 at 14:28
  • Are you saying that masking is taking place when new entries are being added to the the routing tables but not when packets are being routed? – rosix Jan 8 '16 at 14:28
  • "Are you saying that masking is taking place when new entries are being added to the the routing tables but not when packets are being routed?" No, the masking is part of both the TCAM entry and of the lookup mechanism. For example 1.0.0.0/24 entry would be inserted as 1.0.0.X (X=don't care bits). Now if you would lookup destination ip 1.0.0.1 against the TCAM hardware, it would find the 1.0.0.X entry and return the associated result (possibly some index for searching further information in regular memory). TCAM masking is used to simulate a network-prefix-based lookup. – Everton Jan 8 '16 at 14:36
  • I thought that masking was the process of performing a binary AND operation on an ip address and a network mask in order to calculate the network address. What you are describing is not masking but simply looking up an entry in a table. – rosix Jan 8 '16 at 14:47
  • 1
    @rosix "What I wanted to know is whether TCAMs need to calculate a network address before searching for a matching entry in their routing table." No. TCAM circuitry can DIRECTLY lookup keys against entries built with 0s and 1s and Xs (X=don't care). For instance, you could insert entry=1.0.0.X then you can lookup key=1.0.0.1. The TCAM circuitry will find and return the matching 1.0.0.X entry (plus its associated information) without doing the "formal" masking you seem to be picturing. However, TCAM lookup does a kind of masking to distinguish between "care bits" and "don't care bits" . – Everton Jan 20 '16 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.