CAM Memory and TCAM Memory - connorethanjay/CCNP-Enterprise-Preparation GitHub Wiki
CAM Memory
CAM (Content Addressable Memory) is a type of memory used by Cisco Switches which differs from traditional RAM. It is used for high-speed searches to retrieve memory addresses where data can be detected.
- Traditional RAM uses a memory address to retrieve data stored at said memory address.
- CAM in comparison returns the memory address from where the data is stored.
The CAM Table
- CAM operation is limited to returning exact match results as True (0) or False (1).
- This makes it most useful for building tables that rely on exact matches, such as MAC Address tables.
- The CAM table is the primary table for Layer 2 forwarding decisions, since the Switch must find an exact match for the destination MAC address, or it will flood the packet out all ports in the specified VLAN.
- A CAM table is built by recording the source address & inbound port of all frames. As frames arrive on switch ports, the source MAC addresses are learned and recorded into the CAM table.
- In addition to this, the port of arrival and the VLAN are also recorded alongside a timestamp.
- If a learned MAC Address moves to another port, the address and timestamp are rerecorded for the most recent arrival port, and the previous entry is deleted.
- If a learned MAC Address is already present in the correct port on the table and new traffic is received, only it's timestamp is updated.
To view the contents of the CAM table, you can use the command "show mac address-table". In this example I searched for dynamically learned MAC Addresses.
TCAM Memory
-
Ternary Content Addressable Memory is a type of CAM memory that permits a third state other than True / False referred to as "don't care".
-
The don't care state introduces the flexibility in searching which allows TCAM to perform pattern-based searching.
-
TCAM is used for storing IP Addresses where the entire range of IP Addresses can be searched at once.
-
TCAM memory is used to enhance the speed of routing table lookups, forwarding, packet classification (QoS), and ACL command execution. Essentially upper-layer processing information.
-
TCAM uses the term VMR (Value, Mask, Result) for the format of entries.
- Value is the pattern to be matched (ex. IP Addresses, QoS values, etc).
- The "mask" refers to the mask bits associated with the pattern and determines the prefix.
- The "result" is the result or action that occurs where a TCAM lookup returns a hit for the pattern and mask.
Advantages of TCAM over CAM
- TCAM is efficient in routing and ACL execution where partial matches are favored due to it's wildcard support, this is possible due to TCAM having three states rather than two.
- TCAM is selected in most networking devices for activities due to it's flexibility for activities such as searching the routing table and searching ACLs.
Disadvantages of TCAM
- TCAM draws significantly higher power compared to CAM due to how much more intricate it's searching capabilities are.
- TCAM's extra flexibility and capabilities make it harder to develop, which makes it cost more, not only that, but the size of TCAM memory is typically less due to it's power consumption and cost.
- Most traditional Layer 2 Cisco Switches only have CAM for layer 2 switching. Some may have TCAM for QoS but not for Routing. Layer 3 Switches have routing TCAM memory.