Wiki DE Start in the browser

Wiki › Basics

Ethernet and MAC addresses

How frames are addressed in the local network, how a switch learns where to send them, and what happens when a MAC address appears twice.

Layer
2 (Sicherung)
Standard
IEEE 802.3
See an example
See demo

The Ethernet frame

Ethernet carries data in the local network in frames. Every frame starts with the destination and the source MAC address, followed by the EtherType, which says what is inside. At the end is the checksum FCS (CRC-32): the receiver recomputes it and drops the frame if it does not match. Before the frame the network card sends preamble and SFD (layer 1) so the receiver can find the clock.

Ethernet IIFrame · IEEE 802.3
Preamble7 bytes
SFD1 bytes
Destination MAC6 bytes02:00:00:00:04:00
Source MAC6 bytes02:00:00:00:01:00
EtherType2 bytes0x0800
Payload46–1500 bytes140 Byte
FCS4 bytes0x9facebdb
Gap (IFG)12 bytes
Left to right, in the order the bytes are sent. Grey dashed: never part of a capture (layer 1 or line framing). Point at a field for an explanation.
FieldLengthExample valueMeaning
Preamble (layer 1)7 bytes10101010 × 7Seven bytes 10101010: the receiver synchronises its clock. Part of the physical layer.
SFD (layer 1)1 bytes10101011Start frame delimiter 10101011: the frame starts now.
Destination MAC6 bytes02:00:00:00:04:00To whom? FF:FF:FF:FF:FF:FF is broadcast, a first byte with the lowest bit set is multicast.
Source MAC6 bytes02:00:00:00:01:00From whom? The MAC address of the sending interface; the switch learns it.
EtherType2 bytes0x0800What is inside: 0x0800 IPv4, 0x86DD IPv6, 0x0806 ARP, 0x8100 VLAN tag, 0x8864 PPPoE. Values from 0x0600 are types, smaller ones a length (IEEE 802.3).
Payload46–1500 bytes140 ByteThe layer-3 packet, 46 to 1500 bytes (MTU). If it is shorter, the sender pads with zeros so the frame including FCS is 64 bytes long.
FCS4 bytes0x9facebdbFrame check sequence: CRC-32 over the whole frame from the destination MAC. If it does not match, the receiver drops the frame.
Gap (IFG) (layer 1)12 bytesAt least 12 bytes of silence before the next frame (interframe gap). Part of the physical layer.
Values: Real frame from the demo “DNS, TCP and HTTP” (no. 36, 158 bytes), exactly as the packet list in leyoNET shows it.

A frame is at least 64 and at most 1518 bytes long. The sender pads shorter packets. More on VLAN tag, LLC and Wi-Fi frames: Structure of frames and packets.

A MAC address has 48 bits, written as six hexadecimal pairs. On a real device the first three bytes name the manufacturer. leyoNET assigns “locally administered” addresses (02:…) derived from the device number, so every project stays reproducible.

How a switch learns

A switch remembers for every sender on which port it has seen it: the MAC table, also called SAT (source address table): the switch learns from the source address. A frame to a known address goes only to that port. If the address is unknown or a broadcast, the switch sends it to all other ports (flooding). Entries expire after a few minutes.

Duplicate MAC addresses

If two devices have the same MAC, the switch sees the same address alternately on two ports and rewrites its table each time. Replies end up at the wrong device. In practice this happens with cloned virtual machines. The demo “Duplicate MAC address” shows it; the switch reports “MAC flapping”.

How to do it in leyoNET

The same text as in the app’s help (F1 key).

Switching

A switch records each frame's source MAC and port (MAC table, also called SAT for “source address table”). If it knows the destination it forwards only there, otherwise to all ports (flooding). Broadcasts such as ARP always go to every port in the same VLAN. If two devices share a MAC address, the switch learns it alternately on two ports («MAC flapping»): frames reach the wrong device and the switch console reports «MAC moves».

See an example

  • Demo “Duplicate MAC address” in leyoNETDemo “Duplicate MAC address” in leyoNET
    Duplicate MAC address

    Three computers on a switch; the notebook has the same MAC address as PC 2.

    PC 1 pings PC 2 while the notebook pings PC 1. The switch learns the MAC alternately on two ports and reports «MAC moves»; replies reach the wrong device and pings are lost.

    Watch live Project file

“Watch live” opens the network in leyoNET, the simulation runs in a loop. In the app you find it under File → Demo networks, with a step-by-step tour.

Practise

  • ★★☆☆☆ Small LAN with a switch · 4 goals · Worksheet (German)
  • ★☆☆☆☆ Capture packets · 2 goals · Worksheet (German)

In leyoNET under Tools → Exercise catalogue. Every exercise checks itself.

What leyoNET simplifies

ProtocolLayerSimplification in the simulation
Ethernet II, 802.1Q2With FCS (CRC-32) and padding to 64 bytes; preamble, SFD and gap only as information on layer 1; no jumbo frames

Standards

  • IEEE 802.3 – IEEE Standard for Ethernet (current edition: IEEE 802.3-2022)

Read on

Found a mistake or have an idea? Source of this page on GitHub.