MAC addresses and frames

How does data find one machine among many on the same network?

A MAC address: 48 bits, written as six pairs of hex digits3C22FB4A910Ea block given to the makerone card, set by the makerBuilt into every network card.Means something only inside one network.An Ethernet frame (not to scale)Destination MAC6 bytesSource MAC6 bytesType2 bytesData46 to 1,500 bytesCheck4 bytesa switch reads thisEvery network card has a MAC address, and every frame starts with the MAC it is going to.Ethernet carries data in frames. A frame is the data with a short header in front: who it is for, who sent it andwhat kind of data it holds. A check value at the end lets the receiver detect damage and drop the frame.A switch reads only the destination MAC to choose the port a frame leaves by. How it learns which MAC ison which port is the next page.

Every network card has a 48-bit MAC address. Ethernet sends data in frames, and each frame begins with the destination MAC.

MAC address learning

A switch learns where each address lives from the frames it sees

A · port 1B · port 2C · port 3D · port 4FrameFrom the source, it…For the destination, it…1 A → Blearns A is on port 1B unknown: floods to 2, 3, 42 B → Alearns B is on port 2A known: sends to port 1 only3 C → Alearns C is on port 3A known: sends to port 1 only4 A → DA already knownD unknown: floods to 2, 3, 4MAC table after four frames:A → 1 B → 2 C → 3A switch learns where each address lives from the source of every frame, and floods only when it does not know.Learning costs nothing: the source MAC is in every frame. A destination already in the table goes out one port; anunknown one is flooded out of every port but the one it came in on. Entries age out after 300 seconds of silence,so a device that moves is relearned on its new port with its next frame.

A switch records each frame’s source MAC against its port, forwards known destinations, and floods unknown ones.

MAC address learning · Going deeper · 1 of 2

Forward, filter or flood

The frame’s destinationWhat the switch doesWhyA MAC in the table, on another portforward out that one portit knows where the host isA MAC in the table, on the same portfilter: drop itthe host already heard itA MAC not in the tableflood out every other portunknown unicastFF:FF:FF:FF:FF:FFflood out every other portbroadcastA multicast MAC (01:00:5E…)flood, unless IGMP snoopingsnooping sends only to membersSwitch# show mac address-table dynamicVlan  Mac Address     Type     Ports  10  0050.56a1.0007 DYNAMIC  Gi1/0/7  10  3c22.fb10.9e41 DYNAMIC  Gi1/0/12Cisco writes MACs as three groups offour hex digits. The table is per VLAN.Ageing: mac address-table aging-time.Forward, filter or flood: a switch makes one of three decisions for every frame.A full MAC table (thousands of fake addresses from a MAC flooding attack) turns every frame into unknown unicast, sothe switch floods everything like a hub. Port security, in lesson 14, caps how many addresses one port may learn.

Known destinations are forwarded or filtered. Unknown unicast, broadcast and multicast are flooded out of every other port in the VLAN.

MAC address learning · Going deeper · 2 of 2

Cut-through starts after the address; store-and-forward checks the whole frame

One 1518-byte frame arriving at 1 Gbps, and when each method starts sending it on0 µs2 µs4 µs6 µs8 µs10 µs12 µs14 µsFrame arriving12.1 µsStore-and-forwardwaits for the FCS, checks it12.1 µsFragment-freewaits for the first 64 bytes512 nsCut-throughstarts after the destination MAC112 nsCut-through starts sending once it has read the address; store-and-forward waits to check the whole frame.At 1 Gbps a full frame takes 12.1 µs to arrive, so store-and-forward adds that much at every switch, and dropscorrupt frames on the spot. Cut-through saves the wait but passes corrupt frames on, to be dropped further along.Most campus switches store and forward; low-latency data-centre and trading switches cut through.

Store-and-forward waits 12.1 µs for a full frame at 1 Gbps and drops bad ones; cut-through starts in about 112 ns.

Duplex and speed

A duplex mismatch keeps the link up and quietly ruins it

Port Aset to full duplexPort Bfell back to half duplextime →sends whenever it likesB is sending when A’s framearrives: “late collision”, B stopsA receives B’s cut-off frames:CRC errors and runtsA duplex mismatch keeps the link up and quietly ruins it: light traffic works, real load collapses.Full duplex sends and receives at once on separate pairs; half duplex takes turns and backs off when it hears acollision (CSMA/CD). If one end is fixed at full and the other auto-negotiates, the other falls back to half. Fix it bysetting both ends to auto, or both to the same fixed speed and duplex. Collisions on a switch port are a red flag.

With one end at full and the other at half duplex, one side logs late collisions and the other CRC errors and runts.

Duplex and speed · Going deeper

Reading interface counters and states

Switch# show interfaces gi1/0/7GigabitEthernet1/0/7 is up, line protocol is up  Full-duplex, 1000Mb/s, media type is 10/100/1000BaseTX  5 minute input rate 412000 bits/sec, 61 packets/sec     1843 runts, 0 giants, 0 throttles     2210 input errors, 2207 CRC, 0 frame, 0 overrun     0 collisions, 0 late collision, 0 deferredup / uplayer 1 and layer 2 workingup / downcable fine, layer 2 failingdown / downno cable, no light, far end offadministratively downsomeone typed shutdownerr-disabledthe switch shut it: a violationInterface counters tell you which layer is failing before you touch a cable.Rising CRC errors and runts on a full-duplex port point to a bad cable, a dirty optic or a duplex mismatch at the far end.Giants are frames over the MTU. Late collisions only happen on a half-duplex port and mean a mismatch or a cable too long.Clear the counters, wait, and look again: an old count tells you nothing about now.

CRC errors and runts point to cabling or a mismatch, giants to an MTU problem, and late collisions to half duplex. err-disabled means the switch shut the port.

CDP and LLDP

Every device tells its neighbours who it is and which port they share

SW1R1 · Gi0/0/1Gi1/0/24AP-LobbyIP phoneSW1# show cdp neighborsDevice ID   Local Intrfce  Holdtme  Capability  Platform  Port IDR1          Gig 1/0/24     152      R B S I     ISR4331   Gig 0/0/1AP-Lobby    Gig 1/0/1      128      T B I       C9120AXI  Gig 0SEP0A1B2C3  Gig 1/0/5      139      H P M       IP Phone  Port 1Holdtme counts down from 180 seconds and resets with every announcement, sent each 60.Capability: R router, S switch, T trans-bridge (AP), H host, P phone, I IGMP, B source-route bridge.show cdp neighbors detail adds each neighbour’s IP address and software version.CDP and LLDP make every device tell its neighbours who it is and which port they share.They are how you check a network diagram against reality: SW1 port 24 really does go to R1’s Gi0/0/1. CDP is Cisco’sown and on by default; LLDP is the IEEE standard (802.1AB), sends every 30 seconds and holds for 120, and LLDP-MEDtells phones their voice VLAN and power. Both announce details an attacker would like, so turn them off on user ports.

CDP (Cisco) and LLDP (IEEE 802.1AB) list each neighbour, its platform and the ports at both ends of the link.

Lesson complete

You finished “Ethernet and switching”

Nicely done.

Open in a new tab