CAM Table – In-Depth Explanation
1. What is a CAM Table?
CAM stands for Content Addressable Memory.
The CAM Table is a high-speed hardware memory in Ethernet switches, mapping MAC addresses to switch ports and VLANs.
Purpose: Enables ultra-fast lookups for Layer 2 frame forwarding—crucial for efficient switch performance.
2. Role in Network Switches
Layer 2 switches use the CAM table to make real-time forwarding decisions for Ethernet frames. The switch checks the destination MAC in the CAM table to know which port to use—preventing unnecessary flooding and maximizing performance.
3. Difference Between CAM Table and MAC Address Table
CAM Table | MAC Address Table |
---|---|
Hardware memory for fast lookup | Logical/CLI view for admins |
Implemented using actual CAM chips | Displayed by "show mac address-table" |
Focus on physical memory/lookup | Focus on logical data structure |
Same underlying function as MAC table, but “CAM” highlights hardware aspect | Admin perspective (OS/CLI/monitoring) |
Note: In practice, "CAM table" and "MAC address table" are used interchangeably. "CAM" focuses on the hardware lookup; "MAC table" is the software/CLI representation.
4. How CAM Works in Switches
- CAM retrieves data by content, not by address (unlike RAM).
- Switches perform parallel hardware searches, resulting in nanosecond-scale MAC lookups.
- Example: Frame with destination MAC
00:11:22:33:44:55
arrives. CAM instantly finds the associated port in hardware.
5. CAM Table Structure and Entries
Field | Description |
---|---|
MAC Address | 48-bit hardware address |
Port | Switch interface (e.g., Gi0/1) |
VLAN | VLAN ID (e.g., 10) |
Type | Dynamic or Static |
Example Entry:
MAC: 00:11:22:33:44:55 | Port: Gi0/2 | VLAN: 10 | Type: Dynamic
6. CAM Table Learning Process
- Dynamic: Switch learns MACs from source addresses of incoming frames.
- Static: Admins can manually assign MAC-to-port mappings.
Example:
Host A sends a frame from Gi0/1 (VLAN 20) with MAC AA-BB-CC-DD-EE-FF.
Switch adds: AA-BB-CC-DD-EE-FF | Gi0/1 | VLAN 20 | Dynamic
7. CAM Table Size and Limits
Switches have a finite CAM table size (e.g., 8,192 or 16,384 entries).
Overflow causes switch to flood unknown MACs—degrading network performance and creating security risks.
8. CAM Table Aging and Timeout
- Aging Timer: Each dynamic entry ages out if no frames are seen from the MAC for a period (typically 300 seconds).
- Static entries: Never age out and must be manually removed.
9. CAM Table Overflow and Security Implications
MAC Flooding Attack: Attacker floods the switch with frames from thousands of fake MACs, filling the CAM table.
Consequence: Switch starts flooding frames, allowing attacker to sniff traffic on the network.
- Mitigations:
- Port Security: Limit the number of MACs per port.
- DHCP Snooping: Prevent rogue DHCP servers.
- Dynamic ARP Inspection: Prevent ARP spoofing.
switch(config-if)# switchport port-security maximum 2
10. Viewing CAM Table Entries
show mac address-table show mac-address-table
Sample Output:
VLAN MAC Address Type Ports ---- --------------- ------- ----- 10 00-11-22-33-44-55 DYNAMIC Gi0/2 20 AA-BB-CC-DD-EE-FF STATIC Gi0/1
11. CAM Table vs. TCAM (Ternary CAM)
CAM Table | TCAM Table |
---|---|
Matches binary values only (0/1) | Matches 0, 1, or "don't care" (X) |
Used for MAC address lookups (Layer 2) | Used for ACLs, QoS, Layer 2/3/4 lookups |
Simpler and faster for fixed field matching | More flexible for advanced searches (e.g., IP+port+protocol) |
Example: CAM: Exact match for MAC forwarding.
TCAM: Match on IP, protocol, and port for an access list.
12. CAM Table Role in Frame Forwarding
- When a frame arrives: Switch looks up destination MAC in CAM table.
- If found: Forwards to associated port.
- If not found: Floods to all ports in VLAN except source port.
13. Troubleshooting CAM Table Issues
Issue | Possible Cause | Resolution |
---|---|---|
CAM Table Overflow | Attack or too many devices | Implement port security; monitor logs |
MAC Flapping | Device moving or network loop | Check cabling, spanning-tree, port security |
Stale Entries | Device offline, aging timer too high | Adjust aging time, remove static entries |
Use show mac address-table
to identify MACs that are flapping, too many dynamic entries, or missing static MACs.
14. Example Scenario
Two devices, A and B, connected to Gi0/1 and Gi0/2 in VLAN 10:
Device A sends a frame with source MAC 00-11-22-33-44-AA → Switch learns: 00-11-22-33-44-AA | Gi0/1 | VLAN 10 | Dynamic
Device B replies, switch learns: 00-11-22-33-44-BB | Gi0/2 | VLAN 10 | Dynamic
After this, frames destined for either device are forwarded directly to their port, not flooded.
But, if an attacker floods the switch with fake MACs, CAM table may overflow—leading to network-wide flooding and exposure of sensitive data.
15. When and Where to Use CAM Table Knowledge
- Switch operation: Essential for understanding L2 forwarding.
- Security: Mitigate MAC flooding attacks and unauthorized access.
- Troubleshooting: Diagnose connectivity, loops, or table overflow.
- Optimization: Manage table size in large environments.
📑 Summary Table
Aspect | CAM Table Role or Value |
---|---|
Purpose | High-speed MAC-to-port lookup in hardware |
Learned entries | Dynamically or statically |
Table size | Limited by switch hardware |
Aging | Removes inactive dynamic entries |
Security risks | Flooding attacks, MAC flapping |
Mitigation | Port security, DHCP snooping |
Troubleshooting | show mac address-table, check for overflows |