LABS · PROTOCOLS · NET PATH

Ethernet and 802.1Q: the frame, VLANs and the trunk

Every packet travels inside an Ethernet frame. See its fields byte by byte, how a switch decides where to send it, how it gets an 802.1Q tag to cross a trunk and why one VLAN doesn't see another's traffic.

Level: beginner · 12 minutes

Interactive simulation

The animation needs JavaScript. The full lesson is written out below.

Download the capture and open it in Wireshark to keep exploring.

What Ethernet is

Ethernet (IEEE 802.3) is the technology of wired local networks: it defines the cable, the signal and the frame format. Every network card has a 48-bit MAC address. The frame carries the packet from one device to the next within the same local network; at every hop a new frame is built.

A VLAN (IEEE 802.1Q) splits a switch into several independent local networks: each VLAN is its own broadcast domain. So that several VLANs can share the cable between two switches, the trunk marks each frame with a 4-byte tag saying which VLAN it belongs to.

The fields of the Ethernet II frame

FieldSizeWhat it's for
Preamble and SFD8 bytesSynchronize the receiver. The card strips them: they don't appear in the capture.
Destination MAC6 bytesWhich card the frame goes to. ff:ff:ff:ff:ff:ff is broadcast.
Source MAC6 bytesWhich card sends it. The switch uses it to learn.
802.1Q tag4 bytes (optional)Only on trunks: TPID 0x8100 and the VLAN number.
EtherType2 bytesWhat's inside: 0x0800 IPv4, 0x86DD IPv6, 0x0806 ARP.
Data46 to 1500 bytesThe packet. If it's shorter, it's padded to 46.
FCS4 bytesCRC-32 to detect errors. If it doesn't match, the frame is dropped.

Without the preamble, a frame is 64 to 1518 bytes; with the 802.1Q tag, up to 1522. The 1500 bytes of data are Ethernet's MTU.

How it works: from one access port to the other, through the trunk

Six steps: the untagged frame, the tag on the trunk, delivery on the other end, the unicast reply, the native VLAN and the configuration.

  1. The Ethernet frame leaves the laptop

    To talk to Marta (192.168.10.25, same network), the laptop needs her MAC and sends an ARP Request. The Ethernet II frame carries the destination MAC (broadcast), the source MAC, EtherType 0x0806 and the 28 bytes of ARP plus 18 of padding: 60 bytes, plus the 4-byte FCS the capture doesn't show. Gi1/0/1 is an access port in VLAN 10: SW1 learns the laptop's MAC in that VLAN.

  2. SW1 tags it on the trunk

    A broadcast is copied out every port in its VLAN, and only its VLAN: Sofía's PC (VLAN 40) doesn't get it. Trunk Gi1/0/48 carries several VLANs, so SW1 inserts an 802.1Q tag after the source MAC: TPID 0x8100 and the TCI with priority 0, DEI 0 and VLAN 10. The frame grows from 60 to 64 bytes and SW1 recalculates the FCS.

  3. SW2 removes the tag

    SW2 reads VID 10, learns the laptop's MAC in VLAN 10 behind the trunk and copies the broadcast only out VLAN 10 ports. Before delivering it, it removes the tag: Marta gets the same 60 bytes the laptop sent. Diego, in VLAN 40, doesn't see it either.

  4. The reply comes back over the trunk

    Marta replies with an ARP Reply to the laptop's MAC. SW2 learns Marta's MAC on Gi1/0/5, tags the frame with VID 10 and sends it only over the trunk, because the laptop is behind it. SW1 learns Marta's MAC on Gi1/0/48, removes the tag and delivers it only out Gi1/0/1. A unicast frame to a known destination isn't flooded.

  5. Native VLAN: untagged frames

    SW1 pings SW2 from its management interface, the VLAN 99 SVI. Since 99 is the trunk's native VLAN, the frame crosses untagged and SW2 assigns it to VLAN 99. Both ends must use the same native VLAN; otherwise untagged frames end up in the wrong VLAN. For security, the native VLAN shouldn't be VLAN 1 or a VLAN with users.

  6. How the trunk is configured

    Gi1/0/48 is a static trunk (switchport mode trunk) that doesn't negotiate with DTP (switchport nonegotiate), uses VLAN 99 as native and only allows VLANs 10, 40 and 99. User ports are access ports: switchport mode access and switchport access vlan 10 or 40. SW2 has the same configuration on its Gi1/0/48.

The MAC address

It's 48 bits written in hexadecimal: 00:00:5e:00:53:10, or 0000.5e00.5310 in Cisco IOS. The first 3 bytes are the OUI, the vendor identifier; the vendor assigns the last 3.

  • Unicast: the least significant bit of the first byte is 0. It goes to a single card.
  • Multicast: that bit is 1, as in 01:00:5e:… (IPv4 multicast). It goes to a group.
  • Broadcast: all 48 bits set to 1, ff:ff:ff:ff:ff:ff. It goes to every device in the VLAN.
  • The second bit of the first byte set to 1 marks a locally administered MAC, like the random MACs of phones and laptops.

What a switch does with each frame

  • Learns: records the source MAC, the port and the VLAN the frame came in on.
  • Forwards: if it knows the destination MAC in that VLAN, it sends the frame only out that port.
  • Filters: if the destination is on the same port the frame came in on, it drops it.
  • Floods: if the destination is broadcast, multicast or an unknown MAC, it copies it out every port in that VLAN except the incoming one.
  • Ages: removes a MAC after 300 seconds without traffic (default).

The 802.1Q tag

FieldBitsValue in the simulation
TPID160x8100: signals that the frame is tagged
PCP30: best effort (voice usually uses 5)
DEI10: not eligible for dropping
VID1210: VLAN USUARIOS (valid from 1 to 4094)

The tag sits between the source MAC and the EtherType, so the switch recalculates the FCS when it adds and removes it. End devices almost never see it: access ports deliver untagged frames. The typical exception is the IP phone, which tags its voice VLAN.

Access ports and trunks

Access portTrunk
VLANsOne, plus an optional voice VLANSeveral
802.1Q tagNoYes, except the native VLAN
ConnectsPCs, printers, IP phonesSwitches, routers (router-on-a-stick), APs with several SSIDs, hypervisors
Commandsswitchport mode access · switchport access vlan 10switchport mode trunk · switchport trunk allowed vlan 10,40,99

See it on Cisco IOS XE

CommandWhat it shows
show vlan briefThe VLANs and each one's access ports.
show interfaces trunkThe trunks, their native VLAN and the allowed and active VLANs.
show interfaces Gi1/0/1 switchportThe port mode (access or trunk), its VLAN and the voice VLAN.
show mac address-table dynamic vlan 10The MACs the switch learned in VLAN 10 and their port.
show interfaces Gi1/0/48Input errors, CRC, collisions, duplex and speed.
show cdp neighbors detailThe neighbor on the other end of the trunk, its port and its native VLAN.

What happens when it fails

  • Different native VLAN on each end: untagged frames change VLAN. CDP warns with %CDP-4-NATIVE_VLAN_MISMATCH.
  • A VLAN missing from the allowed list: its devices can't see each other across switches, even though they work fine within each switch.
  • Different mode on each end (access on one, trunk on the other): the link carries one VLAN or none. Check it with show interfaces trunk.
  • Port in the wrong VLAN: the device gets an IP from another network or none. show vlan brief shows where each port is.
  • Duplex or speed mismatch: errors, late collisions and CRCs in show interfaces (topic 1.1).
  • Double-tagging VLAN hopping: an attacker in the native VLAN can reach another VLAN. That's why the native VLAN shouldn't be VLAN 1 or have users.

Frequently asked questions

What's the difference between a frame and a packet?

The frame is the layer 2 PDU: it carries the source and destination MACs and the FCS, and lives for a single hop. The packet is the layer 3 PDU (IP): it travels end to end inside a new frame at every hop.

Why doesn't VLAN 40 get the broadcast?

Each VLAN is a different broadcast domain. The switch only copies the frame out ports in its VLAN; to get from one VLAN to another you need a router or a layer 3 switch.

How big is the 802.1Q tag?

4 bytes: 2 for the TPID (0x8100) and 2 for the TCI, with 3 priority bits, 1 DEI bit and 12 bits of VLAN ID.

What is the native VLAN?

The VLAN whose frames cross the trunk untagged. By default it's VLAN 1; you change it with switchport trunk native vlan and it must match on both ends.

What is ISL?

Cisco's old proprietary trunking protocol, which encapsulated the whole frame. Current Catalyst switches only use 802.1Q.

Key takeaways

  • The Ethernet II frame carries destination MAC, source MAC, EtherType, data (46 to 1500 bytes) and FCS.
  • The switch learns from the source MAC and forwards by the destination MAC; it floods broadcasts and unknown destinations.
  • Each VLAN is a broadcast domain: VLAN 40 doesn't see VLAN 10's frames.
  • On the trunk, 802.1Q inserts 4 bytes (TPID 0x8100 and the VID); the native VLAN crosses untagged.
  • On Cisco IOS you verify it with show vlan brief, show interfaces trunk and show mac address-table.

NEXT STEP

From this lesson to the Canadá Logística network

In the CCNA 2.0 Course you configure Canadá Logística's VLANs, trunks and access ports, with EtherChannel and LACP between switches, in Packet Tracer or CML. We'll let you know when it opens.

Upcoming labs

Sources

Lesson prepared with AI assistance and checked against the sources cited. The bytes of every packet are generated according to the standard and verified with an independent tool.