knowledge

Lecture 5

The Ethernet Frame

An Ethernet frame is the PDU (Protocol Data Unit) of Ethernet.Its payload is typically an IP packet.

Ethernet frames come in two formats: Ethernet v2 and IEEE 802.3.An Ethernet v2 frame has a 14-byte MAC header:the destination address, the source address and the Ethertype.

Preamble7 BSFD1 BDestination6 BSource6 BEthertype2 BPayload46-1500 BFCS4 BMAC headerframe: 64 to 1518 B
An Ethernet v2 frame in transmission order, not to scale.

Preamble. The preamble is 7 bytes of alternating bits.In transmission order, each byte is 10101010.The receiver uses it to synchronize its clock with the sender.

Ethernet transmission is asynchronous: hosts transmit independently, and the channel is idle between frames.The receiver therefore synchronizes again for each frame.

SFD (Start Frame Delimiter). The SFD is the byte after the preamble.In transmission order, it is 10101011: it ends in 11, not 10.These two 1s mark the start of the frame.

The Ethertype names the protocol of the payload.

EthertypePayload
0x0800IPv4
0x0806ARP, used by IPv4
0x86ddIPv6
0x88e5MACsec: an authenticated or encrypted frame
0x88f7PTP (Precision Time Protocol)

Common mistake. The Ethertype does not say whether the data is TCP.TCP travels inside an IP packet, so the Ethertype names IPv4 or IPv6.If the IP packet carries TCP, the IP header says so.

FCS (Frame Check Sequence). The FCS is the frame's last field.The sender computes a CRC (Cyclic Redundancy Check) of the frame and writes this 32-bit value in the FCS.

The receiver recomputes the CRC and compares it with the FCS.If they differ, bit errors corrupted the frame, so the receiver drops it.Ethernet recovers from errors only by dropping frames.

The CRC detects every error of one, two or three bits, and every error burst of at most 32 bits.It also detects most pairs of bursts of at most 17 bits.A random pattern of bit errors goes undetected with a probability of about

2−32≈2.3×10−10.2^{-32} \approx 2.3 \times 10^{-10}.

The MAC header has no length field.The protocol in the payload finds its own length, as IPv4 does with its total length field.

A frame has between 64 and 1518 bytes, counted from the destination address to the FCS.The 64-byte minimum is the minimum frame size of CSMA/CD.If the payload is shorter than 46 bytes, the sender pads it.

Example 1. Padding an ARP request.

An ARP packet has 28 bytes.How many bytes of padding does its frame carry?

The payload needs at least 64−14−4=4664 - 14 - 4 = 46 bytes:the frame minimum, minus the MAC header and the FCS.The sender adds 46−28=1846 - 28 = 18 bytes of padding.

MAC Addresses

A MAC address has 48 bits.An individual address identifies one interface, and a group address identifies a group of interfaces.Individual addresses used to be unique worldwide.

OUI (Organizationally Unique Identifier). The OUI is the first 24 bits.The organization that owns the OUI allocates the last 24 bits.

Two bits of the first byte classify a MAC address.

  • I/G bit (individual/group). The I/G bit is 0 in an individual address and 1 in a group address.
  • U/L bit (universal/local). In an individual address, the U/L bit is 0 if the address is globally administered and 1 if it is locally administered.In a group address, the U/L bit does not count:a group address is always locally administered.

Burnt-in MAC address. A burnt-in MAC address is globally administered.Its manufacturer assigned it, and it is the usual case.

Ethernet sends each byte least significant bit first, by the IEEE 802.3 transmission convention.The written (canonical) form shows each byte most significant bit first, so it inverts the order of the bits inside a byte.

The I/G bit is the least significant bit of the first byte.It is the first bit on the wire, and the 8th bit in the written form.The U/L bit comes second on the wire.

080020710dd400001000U/LI/Gfirst bit on the wireOUI: first 24 bitslast 24 bits
08:00:20:71:0d:d4, with its first byte 0x08 written in binary, most significant bit first.

A MAC address names a group exactly when its first byte is odd.

Randomized address. A randomized address is locally administered.The operating system picks it at random.iOS, Android and Windows 11 use one by default, so the address is no longer a permanent device identifier.

Unicast, Broadcast and Multicast Frames

When A sends a frame to B, A writes its own address as the source and the address of B as the destination.

Unicast frame. A unicast frame goes to one interface.Its destination is an individual address.

Broadcast frame. A broadcast frame goes to every interface of the LAN.Its destination is the broadcast address, ff:ff:ff:ff:ff:ff.

Multicast frame. A multicast frame goes to a group of interfaces.Its destination is a multicast address:any group address except the broadcast address.

IPv4, IPv6 and PTP each have their own multicast MAC addresses.The multicast MAC addresses of IPv4 start with 01:00:5e, and those of IPv6 start with 33:33.

Smart switch. A smart switch reads IP group memberships.It builds multicast trees from them.

On a shared medium, such as a WiFi channel or an Ethernet hub, every station receives every frame.The destination address decides which stations keep it.

Shared mediumWiFi channel or Ethernet hubAsenderBdiscardsCdiscardsRouter00:00:c0:3f:6c:a4keepsdst 00:00:c0:3f:6c:a4Switched EthernetAswitchRouter00:00:c0:3f:6c:a4BC
A sends one frame to the router.
DestinationShared mediumSwitched Ethernet
unicastkept only by the destinationsent only where needed, in principle
broadcastkept by all stationsflooded along the spanning tree
multicastkept only by subscribed hostsflooded by simple switches, sent only to subscribers by smart switches
shared mediumAsenderBsubscribedkeepsCsubscribedkeepsDnot subscribeddiscardssrc 08:00:20:71:0d:d4dst 01:00:5e:02:36:cf
A sends one frame to 01:00:5e:02:36:cf on a shared medium.

The spanning tree has no loop, and flooding skips the arrival port, so every host except the sender receives exactly one copy.

S1S2S3S4S5ABCDarrival portinactiveinactive
A broadcast frame from A floods along the spanning tree (arrows).

Example 2. Classifying addresses.

Which of these addresses name one interface?Which did a manufacturer assign?

AddressFirst byteI/GU/LKind
08:00:20:71:0d:d40000100000burnt-in, a Sun machine
00:00:c0:3f:6c:a40000000000burnt-in, a PC
00:00:0c:02:78:360000000000burnt-in, a Cisco router
3a:62:9e:14:c0:7b0011101001individual, locally administered
01:00:5e:02:36:cf000000011–multicast, for IPv4
ff:ff:ff:ff:ff:ff111111111–broadcast

LANs as Broadcast Domains

Broadcast domain. A broadcast domain is the set of interfaces that one broadcast frame reaches.

A LAN is exactly one layer-2 broadcast domain.It is a logical network, not a box, a cable or a technology.

Common mistake. One switch is not always one LAN, and one LAN is not always one medium technology.VLANs split one switch into separate broadcast domains, and a bridge joins an Ethernet segment and a WiFi cell into one LAN.

Virtual LANs

VLAN (Virtual LAN). A VLAN is a LAN defined by configuration.The network manager configures the VLANs of each switch port.The switch treats ports of different VLANs as separate LANs.

VLANs decouple membership in a LAN from physical location.One VLAN can span several switches, and one switch can carry several VLANs.

S1S2S3CDAYXGBEFVLAN 3VLAN 2VLAN 1VLAN 3VLAN 1
Three VLANs on three switches.

Broadcast traffic stays inside one VLAN, and access control can apply per VLAN.Several LANs share the free ports of one switch.A user who moves keeps their LAN without new cabling.

Each VLAN has its own forwarding tables and its own spanning tree.MSTP (Multiple Spanning Tree Protocol) computes these trees.

VLAN tag. A VLAN tag is a 4-byte field after the source address.It holds 0x8100 and the VLAN ID of the frame.IEEE 802.1Q defines this tagged frame format.The tag raises the maximum frame size from 1518 to 1522 bytes.

Destination6 BSource6 B0x8100VLAN IDEthertype2 BPayloadup to 1500 BFCS4 BVLAN tag: 4 B
An 802.1Q-tagged frame in transmission order, not to scale.

Trunk port. A trunk port is a switch port that belongs to several VLANs.

Switches that implement the same VLANs connect through trunk ports.Trunk ports use VLAN tags, so the receiving switch knows the VLAN of each frame.

EL building switchEEports 2-8CSports 9-15Trunkport 16IC building switchTrunkport 1EEports 2, 3, 6CSports 4, 5, 7tagged
The Electrical Engineering (EE) and Computer Science (CS) VLANs span two buildings.

An EE host in IC shares one LAN with the EE hosts in EL, and no LAN with the CS host on the next port.

Example 3. Between two VLANs.

Switch S1 carries VLAN 2, with hosts A and Y, and VLAN 3, with hosts C and D.A has an IP packet for C.Should A send an ARP request for the MAC address of C?Or for its MAC address and its VLAN?

Neither request works, because VLANs 2 and 3 are separate LANs.An ARP request is a broadcast frame, so it never leaves VLAN 2.The packet must therefore cross a router R.R is the gateway of both VLANs, so A sends the packet to R.

ArrangementConnection of R to the VLANs
separate interfacesR has one interface in each VLAN
trunk linka trunk port of R links to a trunk port of S1
one deviceR is built into S1 and reaches all VLAN ports directly

A uses ARP to resolve the MAC address of R's interface in VLAN 2, and puts the IP packet for C in a frame addressed to R.R picks its interface in VLAN 3 from its forwarding table, and puts the packet in a new frame addressed to C.

With a trunk link, the IP packet crosses the trunk twice, once in each frame.

RrouterS1AYCDtag 2src A, dst Rtag 3src R, dst CVLAN 2VLAN 3
R joins S1 through a trunk link, and host links carry untagged frames.

Bridges

Bridge. A bridge is a switch between different medium technologies.It works at layer 2, so it joins them into one LAN without a router.In the wider sense, every switch is a bridge.

Access point. An access point is a bridge between WiFi and Ethernet.It combines a WiFi base station and a switch.The base station implements the WiFi MAC protocol.The Ethernet backend of the switch is called the distribution system.

A WiFi frame is similar to an Ethernet frame, but its MAC header has more fields.Between a host and its access point, it carries three MAC addresses:source, destination and access point.When A sends a frame to G, the frame carries source A, destination G and access point E.

Ethernet (distribution system)FrouterGserverEaccess pointABWiFiHaccess pointCDWiFi
A frame from A to G (arrows) in one bridged network.

Mesh WiFi. Mesh WiFi replaces the Ethernet backend with WiFi.WiFi relays join the access points and act as switches.

A frame between two relays carries up to four MAC addresses:source, destination, transmitting relay and receiving relay.

A1M1access pointM2relay2M3relayM4access pointB
A frame from A to B over mesh WiFi.
PointSourceDestinationOther addresses
1ABaccess point M1
2ABtransmitting relay M2, receiving relay M3

Example 4. A bridge keeps the addresses.

The web server sends an IP packet to Elaine in each network below.What is the destination MAC address at point 1?Which network uses resources better?

Bridge and range extenderWeb serverM1Ethernet hubPrinter1BridgeM2M3Base stationrange extenderElaineM4Access pointWeb serverM1Ethernet hubPrinter1Access pointM2ElaineM4WiFiWiFiWiFi
Unlabelled links are Ethernet.

The destination MAC address is M4 in both networks.Each network is one large bridged LAN, so the web server resolves the MAC address of Elaine directly.A bridge keeps the source and destination MAC addresses, even when it converts the frame between Ethernet and WiFi.A router instead writes a new MAC header at every hop.

The access-point network uses resources better.In the range-extender network, the base station has no wired link and reaches the bridge over WiFi.All WiFi traffic to the bridge therefore uses WiFi twice:once to reach the base station, and once to reach the bridge.

Wired and Wireless MAC Layers

WiFi's MAC layer shares the radio waves in a local environment.Ethernet's MAC layer was designed to share a cable.It used CSMA/CD, a protocol very similar to the CSMA/CA of WiFi.

Today Ethernet uses full-duplex cables and switches, so it needs no collision detection.Ethernet has become an interconnection layer of local scope.

Switches Versus Routers

Switches, bridges and WiFi base stations join devices within a LAN.IP routers join devices across IP subnets.In every network so far, each IP subnet is exactly one LAN.

SwitchRouter
Setupplug-and-playfollows the IP plan
IP versiondoes not mattermatters
Entriesone per MAC address, exact matchaggregated by prefix
Grows withhostsnetworks

If a network grows too large, switch tables become impractical.Large networks therefore prefer routers.

Historically, routers ran in software and switches in hardware.Today any combination exists.

Example 5. Adding IPv6.

A network of Ethernet switches runs IPv4.Its administrator adds IPv6.Do the switch configurations change?

No, because a switch forwards frames by their MAC addresses.It works the same for IPv4, IPv6 or any other payload.Smart switches are the one exception.

Attacks and Defences on the MAC Layer

MAC addresses travel in cleartext, and many frames are broadcast, especially on a shared medium.Plain Ethernet, at home or at EPFL, authenticates no MAC address.

AttackThe attacker
eavesdroppingreads the MAC payloads of other hosts
free ridinginserts a device into the network without authorization
impersonationuses another host's MAC address, or replays its frames

Access control. Access control admits only users who show credentials.It prevents free riding.

Access controlPasswordWiFi standard
sharedthe same for all usersWPA2-Personal, WPA3-Personal
per-userpersonal to each userWPA2-Enterprise, WPA3-Enterprise

Authenticity. Authenticity proves the source address with cryptography.It prevents impersonation.It is easier when access control is per-user.

Confidentiality. Confidentiality encrypts the payload of each frame.It prevents eavesdropping.Every switch must read the MAC addresses, so they stay in cleartext.

Session key. A session key is a secret key for one connection.A host and its base station or switch derive it when the host joins.They use it to authenticate and encrypt their frames.

Home WiFi uses a shared password but does not authenticate users.Up to WPA2-PSK, anyone who knows the password can derive the session key of another user from their handshake, and so impersonate that user.WPA3 generates secrets per session, so the password alone is not enough and impersonation is harder.

EPFL WiFi uses per-user access control, and it authenticates and encrypts frames.All three attacks are impossible there in principle.

IEEE 802.1X and MACsec

IEEE 802.1X. IEEE 802.1X is the standard for access control to a LAN.A WiFi base station or an Ethernet switch admits a host only after an authentication server accepts its credentials.

The authentication server is typically a RADIUS server.The host and the server set up a TLS (Transport Layer Security) tunnel.Inside it, an inner protocol checks the host's credentials.The base station or switch relays the tunnel but cannot read it.

HostBase station or switchRADIUS serverthe host asks to joinit contacts the servere.g. PEAP or TunnelTLSe.g. MSCHAPv2the server admits the hostboth derive session keysauthenticated, encryptedrequestrequestTLS tunnelcredentialsacceptkey handshakeframes
IEEE 802.1X admission, time running down.

The base station or switch binds the session keys to the host's MAC address.

MACsec (IEEE 802.1AE). MACsec authenticates and encrypts frames.It uses the session keys of the host and its base station or switch.

A MACsec frame has Ethertype 0x88e5.Its encrypted payload holds the original Ethertype, the VLAN tag and the original payload.

SecTAG (Security Tag). The SecTAG is the 16-byte MACsec header.It follows the Ethertype.

ICV (Integrity Check Value). The ICV is a 16-byte authentication tag.The sender computes it with the session key over every field from the destination address to the payload.A forged source address therefore fails the check.

Destination6 BSource6 BEthertype2 BSecTAG16 BPayloadincl. Ethertype, VLAN tagICV16 BFCS4 Bencryptedauthenticated by the ICV
A MACsec frame in transmission order, not to scale.

Example 6. The EPFL WiFi profile.

A Mac connected to the EPFL WiFi shows these settings.What role does each one play?

SettingRole
Wi-Fi (epfl) under 802.1Xper-user access control
EAP-PEAP (MSCHAPv2)a PEAP tunnel, with MSCHAPv2 inside
PEAP and TTLSthe accepted TLS tunnels
WPA2authenticates and encrypts the frames
DigiCert Global Root G2the root of the server's certificate
radius.epfl.chthe authentication server

The trusted certificate and server stop a fake base station from collecting the credentials.

Example 7. Bart shares his access.

Bart, an EPFL student, connects his PC to the EPFL WiFi.Lisa has no EPFL account.She plugs into the Ethernet port of his PC.Can Lisa reach the internet if Bart's PC acts as a bridge?As a NAT?

Bart's PC as a bridgeLisaM3Bart's PCM2M11Base stationdrops themBart's PC as a NATLisaM3Bart's PCM2M11Base stationaccepts themWiFisrc M3WiFisrc M1one LANLAN 1LAN 2
Red marks the frames that the base station drops.

The base station accepts only authenticated frames, and it bound Bart's session key to his MAC address, M1.

As a bridge, Bart's PC keeps Lisa's source MAC address, M3.The base station therefore drops her frames, even if Bart's PC authenticates them with his key.An IP address in Bart's subnet does not help, because the check happens at layer 2.

As a NAT, Bart's PC is a layer-3 device that splits the network into two LANs.It sends Lisa's packets in its own frames, from M1, so Lisa uses the campus network without an account.

The same holds if Bart sits behind his own NAT box, because that NAT box authenticated to the EPFL WiFi.EPFL then sees Bart and Lisa as programs with different port numbers on that NAT box.

A guest VM on an authenticated laptop works the same way.Its VMware or UTM hypervisor runs its own NAT, so the VM reaches the WiFi without authenticating again.