Switching: how a frame crosses a switch
The Ethernet frame a switch reads, how it learns where every device lives, the three things it can do with a frame, why collisions vanished, and how to read the interface counters when a port misbehaves.
On this page
A switch does one thing, and it does it a few hundred million times a second: read the first twelve bytes of a frame, look them up in a table, and push the frame out one port. Everything else a switch has ever been sold with — VLANs, spanning tree, port security, quality of service — is a rule bolted onto that single decision. This article is about the decision itself, and about the table that makes it possible.
The map
Read this first when short on time. Every branch is a section below.
The Ethernet frame, in the order the switch reads it
A switch's whole world is the layer 2 frame, and the fields are laid out so that the two it needs most arrive first.
Three details earn their place:
- Destination comes before source. That ordering exists so a switch (or a cut-through switch especially) can start deciding as early as possible.
- The type field says what is inside, so the receiving host knows whether to hand the payload to IPv4, IPv6 or ARP. It is also how a VLAN tag announces itself: type
0x8100means "a four-byte tag follows, and the real type is after that". - The FCS is a checksum over the whole frame. A switch that finds it wrong discards the frame and increments a counter — which is why CRC errors on a port point at a physical problem, not a configuration one.
Three kinds of destination address
| Kind | Looks like | Switch behaviour |
|---|---|---|
| Unicast | Any address with the low bit of the first byte clear | Forward out one port, or flood if unknown |
| Broadcast | ff:ff:ff:ff:ff:ff | Flood out every port in the VLAN |
| Multicast | Low bit of the first byte set, e.g. 01:00:5e:... | Flood by default, or forward selectively if snooping is on |
The rule is a single bit: the least significant bit of the first byte. Clear means one destination, set means many. Broadcast is simply the multicast address where every bit is set.
Learning: the table builds itself
A switch is never configured with where anything is. It works it out by watching, and the mechanism is one sentence long: when a frame arrives, record its source MAC address against the port it arrived on.
That is the whole algorithm. It works because every device that wants to receive traffic must first send something — an ARP request, a DHCP discover, anything — and that something carries its address in the source field.
sequenceDiagram autonumber participant A as PC-A on Fa0/1 participant S as Switch participant B as PC-B on Fa0/2 A->>S: frame, src aaaa, dst bbbb Note over S: learns aaaa is on Fa0/1 S->>B: bbbb unknown, so flood to every other port B-->>S: reply, src bbbb, dst aaaa Note over S: learns bbbb is on Fa0/2 S-->>A: aaaa is known, send out Fa0/1 only
The table itself is small and has four columns:
Switch# show mac address-table
Mac Address Table
-------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
10 0050.56aa.1111 DYNAMIC Gi1/0/1
10 0050.56aa.2222 DYNAMIC Gi1/0/2
10 000c.29bb.3333 DYNAMIC Gi1/0/24
20 0050.56cc.4444 STATIC Gi1/0/8
Total Mac Addresses for this criterion: 4Note that VLAN is part of the key, not just extra information. The same MAC address can legitimately appear in two VLANs, and lookups are always scoped to the VLAN the frame arrived in.
Entries are dynamic — learned, and aged out after 300 seconds of silence by default. Ageing matters: it lets a laptop move from one port to another without leaving a stale entry that black-holes its traffic forever. A move is usually handled faster than that, because the moment the device sends a frame from its new port the switch simply overwrites the entry.
The uplink port is the interesting one. On an access switch, the uplink to the rest of the network accumulates every MAC address in the building, because every frame from outside arrives through it. Seeing hundreds of addresses on one port and one address on each of the others is exactly what a healthy access switch looks like.
The MAC table has a fixed size — often 8,000 to 32,000 entries. Flooding it with fake source addresses forces the switch to evict real entries and flood everything, which is a MAC flooding attack: it turns a switch into a hub so an attacker can read traffic. Port security exists precisely to cap how many addresses a port may learn.
- Virtualisation multiplies MAC addresses: one physical port carrying twenty virtual machines presents twenty source addresses, which is why server-facing ports need higher port-security limits than desk ports.
clear mac address-table dynamicis the standard first move when a device has moved and traffic is going to the wrong place; the table rebuilds within seconds.- Data centre fabrics replace learning with a control plane — EVPN distributes MAC addresses via BGP rather than flooding to discover them — because flooding does not scale to tens of thousands of hosts.
Three things a switch can do with a frame
Once the destination has been looked up, exactly one of three outcomes follows.
flowchart TD
F["Frame arrives on port X<br/>learn its source MAC"] --> B{"Destination?"}
B -->|Broadcast or multicast| FL["Flood out every port<br/>in the VLAN except X"]
B -->|Unicast, not in table| FL
B -->|Unicast, in table on port Y| C{"Y equals X?"}
C -->|No| FW["Forward out port Y only"]
C -->|Yes| DR["Filter: drop the frame"]
Forward is the normal case and the reason switches exist. Traffic between two ports does not touch any other port, so twelve conversations can run at full speed simultaneously.
Flood covers three situations: a broadcast, a multicast the switch has no better information about, and an unknown unicast — a destination not yet in the table. The frame goes out every port in the VLAN except the one it arrived on. That exception is not a detail; without it every frame would be echoed back to its sender.
Filter happens when the destination is known to be on the same port the frame arrived on. Both devices are reachable through one port, so they can hear each other directly and the switch drops the frame rather than sending it back.
Persistent unknown unicast flooding for a device that is clearly active usually means the switch is learning the device's address in one direction only — asymmetric routing, an ageing timer shorter than the ARP timer on the router, or a topology change repeatedly clearing the table. Comparing the MAC ageing time with the router's ARP timeout resolves it more often than not.
Collision domains, broadcast domains, and why hubs died
Original Ethernet was a single shared cable. Only one device could transmit at a time, so hosts used CSMA/CD: listen before transmitting, and if two transmit at once, detect the collision, stop, wait a random interval, retry. It worked, and it degraded badly under load, because the busier the network the more likely a collision.
A hub extended that shared medium into a star shape without changing anything: all ports remained one collision domain. A switch changed it completely. Each port is its own segment, each link is point-to-point, and once both ends run full duplex — transmitting on one pair while receiving on another — collisions become physically impossible. CSMA/CD is disabled on a full-duplex link because there is nothing to arbitrate.
| Hub, 8 ports | Switch, 8 ports | Router, 8 ports | |
|---|---|---|---|
| Collision domains | 1 | 8 | 8 |
| Broadcast domains | 1 | 1 per VLAN | 8 |
| Simultaneous conversations | 1 | 4 pairs at line rate | 4 pairs |
| Bandwidth per port | shared | dedicated | dedicated |
The practical consequence today: a collision counter above zero on a modern switch port is a fault, not normal wear. It means something on that link is running half duplex, which almost always means autonegotiation was disabled on one end only.
Broadcast domains are the other half of the story. A switch floods broadcasts everywhere, so a flat switched network is one broadcast domain no matter how many switches it contains. Every ARP request, every DHCP discover and every piece of chatty discovery protocol reaches every host. That works fine for fifty devices and becomes a real cost at five hundred, which is the argument that leads directly to VLANs.
What happens inside the box
A switch has to decide how much of a frame to read before it starts transmitting it, and the choice is a straight trade between latency and correctness.
| Method | Waits for | Latency | Corrupt frames |
|---|---|---|---|
| Store and forward | The entire frame, then checks the FCS | Higher, and varies with frame size | Discarded |
| Cut-through | The first 6 bytes, the destination MAC | Lowest, and fixed | Forwarded |
| Fragment-free | The first 64 bytes | Between the two | Runts caught, later corruption not |
Cisco Catalyst switches use store and forward, and the reason is not caution alone: a switch cannot apply quality of service, inspect for security or convert between different port speeds without holding the whole frame. Cut-through survives in specialised low-latency hardware — trading systems and high-performance computing, where a few microseconds are worth forwarding the occasional corrupt frame for.
Buffers and drops
When two ports both send to one output port, or a 10 Gbps port feeds a 1 Gbps port, frames must queue. Switches hold them in buffer memory, and when the buffer for a port fills, further frames are dropped — output drops in the counters.
This is worth naming clearly because the instinct is to blame the link. Output drops on an uninterrupted gigabit port are not a cabling fault; they are the switch telling you that more traffic wanted to leave that port than it could carry, even if the average utilisation looks low. Bursts happen on a millisecond timescale that five-minute averages hide completely.
- Incast is this problem at scale: forty servers answering one request simultaneously overwhelm the switch buffer facing the requester, and the resulting drops stall TCP. It is a known pain point in distributed storage systems.
- Arista and Cisco Nexus switches publish their buffer sizes as a selling point, because for some workloads buffer depth matters more than port speed.
- Speed mismatch — a 10 Gbps server talking to a 1 Gbps client through a switch — guarantees buffering, which is why the client feels slow while every link shows plenty of spare capacity.
Reading a port when something is wrong
Most switch troubleshooting is one command and knowing what its numbers mean.
Switch# show interfaces status
Port Name Status Vlan Duplex Speed Type
Gi1/0/1 Reception PC connected 10 a-full a-1000 10/100/1000BaseTX
Gi1/0/2 notconnect 10 auto auto 10/100/1000BaseTX
Gi1/0/3 Old printer connected 10 a-half a-100 10/100/1000BaseTX
Gi1/0/4 Camera err-disabled 30 auto auto 10/100/1000BaseTX
Gi1/0/24 Uplink to DIST-1 connected trunk full 1000 1000BaseSX| Status | Means | Next step |
|---|---|---|
connected | Link is up and the port is forwarding | Look at counters if performance is the complaint |
notconnect | No link detected | Cable, far-end device powered off, wrong port |
err-disabled | The switch shut the port down itself | show interfaces status err-disabled for the reason |
disabled | Somebody typed shutdown | no shutdown |
The a- prefix on duplex and speed means the value was autonegotiated. a-half on a modern device, as on Gi1/0/3 above, is a warning sign worth chasing.
The counters that mean something
| Counter | What it indicates |
|---|---|
| CRC / FCS errors | Frames arriving corrupted. Cable, connector, interference, or a failing transceiver. |
| Runts | Frames under 64 bytes. Usually collisions, so a duplex problem. |
| Giants | Frames over 1518 bytes. Often a jumbo-frame or VLAN-tag mismatch rather than a fault. |
| Late collisions | A collision after 64 bytes. On a proper link this is impossible, so it is a duplex mismatch or a cable over 100 m. |
| Input errors | The total of the above. A rising number with a stable link means a physical problem. |
| Output drops | Congestion on the outbound queue, not a fault in the link itself. |
Counters are cumulative since the last reboot or the last clear counters. Five thousand CRC errors mean nothing without knowing whether they accumulated over two years or two minutes. Always clear the counters, wait, and look again — the rate is the diagnosis, not the total.
The err-disabled state deserves its own note. A switch disables a port on its own when it detects something it has been told is unacceptable: a port-security violation, a spanning-tree BPDU arriving where it should not, link flapping, or an EtherChannel misconfiguration. The port stays down until you bounce it or an errdisable recovery timer expires. It is not a failure, it is a deliberate response — so the first question is always which condition triggered it.
Switch# show interfaces GigabitEthernet1/0/4 status err-disabled
Switch# show errdisable recovery
Switch(config)# errdisable recovery cause psecure-violation
Switch(config)# errdisable recovery interval 300- CAM table
- Content-addressable memory: the hardware that makes a MAC address lookup a single-cycle operation rather than a search. Used as a synonym for the MAC address table.
- Unknown unicast flooding
- Sending a unicast frame out every port because its destination is not in the table.
- err-disabled
- A port administratively shut down by the switch itself in response to a detected violation.
- Line rate
- Forwarding at the full speed of the port with no loss, for the smallest frame size. A switch that can do this on every port simultaneously is called non-blocking.
Recap
- A switch reads the destination MAC address, looks it up, and forwards out one port; everything else is a rule attached to that decision.
- The Ethernet frame puts destination before source so the lookup can begin after six bytes.
- The type field identifies the payload and is also how an 802.1Q VLAN tag announces itself.
- Switches learn from the source address of arriving frames, never from the destination.
- The MAC table is keyed by VLAN and address, and entries age out after 300 seconds by default.
- Three outcomes exist: forward to one port, flood to all others, or filter and drop.
- Flooding covers broadcasts, unresolved multicast and unknown unicast, and never sends back out the arrival port.
- Each switch port is its own collision domain, so on a full-duplex link collisions are impossible and any collision counter is a fault.
- A switched network is one broadcast domain until VLANs divide it.
- Cisco switches use store and forward, which is required for quality of service, security inspection and speed conversion.
- Output drops mean congestion in a buffer, not a broken link, and bursts hide inside five-minute averages.
- Late collisions mean a duplex mismatch, CRC errors mean a physical problem, and counters only make sense as a rate.
Questions
Say the answer out loud before opening it.
How does a switch build its MAC address table?
By reading the source MAC address of every frame that arrives and recording it against the port it came in on.
- Learning is always from the source field, never the destination.
- Entries are keyed by VLAN as well as address, so the same MAC can appear twice legitimately.
- Dynamic entries age out after 300 seconds of silence by default.
This works because any device that expects to receive traffic must first transmit something — ARP, DHCP or a routing protocol hello — which carries its address in the source field.
What are the three actions a switch can take on a frame?
Forward it out one port, flood it out every port except the arrival port, or filter it and drop it.
- Forward happens when the destination is a known unicast on a different port.
- Flood happens for broadcasts, unresolved multicast, and unknown unicast destinations.
- Filter happens when the destination is known to be reachable out the same port the frame arrived on.
The never-send-back-out-the-arrival-port rule is what keeps flooding from echoing frames to their own sender and is a precondition for spanning tree working at all.
What is unknown unicast flooding and why is persistent flooding a problem?
It is sending a unicast frame out every port because the destination is not in the table; persistent flooding wastes bandwidth on every port and lets every device see traffic meant for one.
- Brief flooding is normal while the table is being learned.
- Continuous flooding for an active device usually means the switch never sees frames from that device, so it never learns it.
- Common causes are asymmetric routing, a MAC ageing timer shorter than the router's ARP timer, and repeated topology changes clearing the table.
Deliberately induced, it is the goal of a MAC flooding attack, which fills the table with bogus entries so the switch floods everything and an attacker can capture it.
How many collision domains and broadcast domains does a 24-port switch have?
Twenty-four collision domains, one per port, and one broadcast domain per VLAN.
- Every port is a separate point-to-point link, so simultaneous transmissions on different ports cannot collide.
- With no VLANs configured, all 24 ports are in VLAN 1 and form a single broadcast domain.
- Configuring four VLANs gives four broadcast domains and still 24 collision domains.
Because full duplex removes collisions entirely, the collision-domain count is mostly a way of contrasting a switch with the hub it replaced.
Why is CSMA/CD irrelevant on a modern switched network?
Because each link is point-to-point and full duplex, so transmission and reception happen on separate pairs and nothing can collide.
- CSMA/CD existed to arbitrate a shared medium, which a switch port is not.
- Full-duplex interfaces disable it entirely.
- It only reappears when a link accidentally runs half duplex, which is a fault to fix rather than a mode to support.
Wireless is the modern shared medium and uses CSMA/CA instead, avoiding collisions in advance rather than detecting them, because a radio cannot listen while transmitting.
What is the difference between store-and-forward and cut-through switching?
Store-and-forward reads the entire frame and verifies its checksum before forwarding; cut-through starts forwarding as soon as it has read the destination address.
- Store-and-forward discards corrupt frames, adds latency proportional to frame size, and is required for quality of service and speed conversion.
- Cut-through has fixed, very low latency but propagates corrupt frames.
- Fragment-free is a compromise that reads the first 64 bytes, catching collision fragments.
Cisco Catalyst switches are store-and-forward; cut-through survives in specialised low-latency hardware where microseconds are worth more than the occasional bad frame.
A port shows late collisions. What does that tell you?
Almost certainly a duplex mismatch, and occasionally a cable longer than 100 metres.
- A late collision is one detected after the first 64 bytes, which cannot happen on a correctly built link.
- The half-duplex end counts late collisions; the full-duplex end counts CRC errors and runts.
- The link stays up and only fails under load, so monitoring often shows nothing.
The fix is to make both ends match — modern practice is autonegotiation on both — and hardcoding one side only is what creates the problem in the first place.
What does err-disabled mean and how do you clear it?
The switch shut the port down itself in response to a condition it was configured to treat as a violation.
- Common causes are port-security violations, BPDU guard triggering, link flapping and EtherChannel misconfiguration.
show interfaces status err-disablednames the specific cause.- Clearing it means
shutdownthenno shutdown, or configuringerrdisable recoveryfor that cause with an interval.
Automatic recovery is convenient but hides the underlying problem, so it is usually enabled only for causes that are expected to be transient.
What causes output drops on a port, and is it a fault?
Congestion: more traffic wanted to leave the port than it could carry, so the buffer filled and frames were discarded. It is not a fault in the link.
- Typical causes are many ports sending to one, or a fast port feeding a slower one.
- Bursts happen on a millisecond scale that five-minute utilisation averages hide entirely.
- The fixes are more bandwidth, quality of service to choose what gets dropped, or deeper buffers.
At scale this is the incast problem, where many servers answer one request at once and overwhelm the buffer facing the requester, stalling TCP for whole round trips.
Why does a switch's uplink port show hundreds of MAC addresses?
Because every frame from every device beyond that link arrives through it, so the switch learns all of those source addresses against that one port.
- Access ports typically show one address, or a handful when a phone and a PC share a port.
- Server ports running virtual machines show one address per virtual NIC.
- This is why port security limits are set per port role rather than globally.
The distribution of addresses across ports is a quick sanity check on a topology: an access port with fifty addresses is either a hidden switch or a hypervisor nobody documented.
What does the type field in an Ethernet frame do?
It says what protocol the payload belongs to, so the receiver hands it to the right stack.
- 0x0800 is IPv4, 0x86DD is IPv6, 0x0806 is ARP.
- 0x8100 means an 802.1Q VLAN tag follows, with the real type after it.
- Values below 1536 mean the field is a length instead, from the older frame format.
The VLAN case is why tagged frames are four bytes longer than untagged ones, and why a device that does not understand tagging reports them as giants.
Why is the MAC address table cleared on a topology change?
Because a change in the spanning-tree topology means traffic may now reach devices through different ports, so existing entries could be wrong.
- Keeping stale entries would black-hole traffic until they aged out, which could be five minutes.
- Spanning tree signals the change and switches shorten the ageing time or flush the table.
- The cost is a burst of flooding while the table rebuilds.
This is why a flapping access port that has not been configured with PortFast is disruptive far beyond its own link: each transition triggers topology-change handling across the switched network.
How do you tell whether a performance complaint is a switch problem?
Clear the counters on the ports in the path, generate the traffic that is slow, and look at what increments.
- Rising CRC errors or runts point at the physical layer — cable, connector, transceiver.
- Rising late collisions point at a duplex mismatch.
- Rising output drops point at congestion, which is a capacity or queuing question rather than a fault.
- Nothing incrementing points away from the switch entirely.
The clearing step is what makes this work: totals accumulated since the last reboot tell you almost nothing, whereas a rate over a known interval is a measurement.
Two devices are plugged into the same switch and cannot reach each other, but both reach the internet. What would you check?
Whether they are in the same VLAN, and whether anything is filtering between them.
show interfaces statusshows the VLAN of each access port immediately.- Different VLANs means the traffic needs routing, and the router may not permit it.
- Protected ports or a private VLAN configuration would also block port-to-port traffic while allowing the uplink.
Reaching the internet while not reaching each other is the useful clue: it proves both ports work and the uplink path is fine, so the difference has to be a policy applied between them.
Why does the switch never send a frame back out the port it arrived on?
Because the sender is on that port, so returning the frame would at best waste bandwidth and at worst create a loop.
- It applies to flooding, which goes to all ports except the arrival port.
- It also underpins the filter action, where a known destination on the arrival port causes a drop.
- Without the rule, a broadcast would circulate indefinitely even on a single switch.
The rule alone is not enough once there are multiple switches with redundant links, which is exactly the gap spanning tree fills.