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.
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.
| Ethertype | Payload |
|---|---|
0x0800 | IPv4 |
0x0806 | ARP, used by IPv4 |
0x86dd | IPv6 |
0x88e5 | MACsec: an authenticated or encrypted frame |
0x88f7 | PTP (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
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 bytes:the frame minimum, minus the MAC header and the FCS.The sender adds 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.
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.
| Destination | Shared medium | Switched Ethernet |
|---|---|---|
| unicast | kept only by the destination | sent only where needed, in principle |
| broadcast | kept by all stations | flooded along the spanning tree |
| multicast | kept only by subscribed hosts | flooded by simple switches, sent only to subscribers by smart switches |
The spanning tree has no loop, and flooding skips the arrival port, so every host except the sender receives exactly one copy.
Example 2. Classifying addresses.
Which of these addresses name one interface?Which did a manufacturer assign?
| Address | First byte | I/G | U/L | Kind |
|---|---|---|---|---|
08:00:20:71:0d:d4 | 00001000 | 0 | 0 | burnt-in, a Sun machine |
00:00:c0:3f:6c:a4 | 00000000 | 0 | 0 | burnt-in, a PC |
00:00:0c:02:78:36 | 00000000 | 0 | 0 | burnt-in, a Cisco router |
3a:62:9e:14:c0:7b | 00111010 | 0 | 1 | individual, locally administered |
01:00:5e:02:36:cf | 00000001 | 1 | – | multicast, for IPv4 |
ff:ff:ff:ff:ff:ff | 11111111 | 1 | – | 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.
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.
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.
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.
| Arrangement | Connection of R to the VLANs |
|---|---|
| separate interfaces | R has one interface in each VLAN |
| trunk link | a trunk port of R links to a trunk port of S1 |
| one device | R 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.
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.
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.
| Point | Source | Destination | Other addresses |
|---|---|---|---|
| 1 | A | B | access point M1 |
| 2 | A | B | transmitting 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?
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.
| Switch | Router | |
|---|---|---|
| Setup | plug-and-play | follows the IP plan |
| IP version | does not matter | matters |
| Entries | one per MAC address, exact match | aggregated by prefix |
| Grows with | hosts | networks |
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.
| Attack | The attacker |
|---|---|
| eavesdropping | reads the MAC payloads of other hosts |
| free riding | inserts a device into the network without authorization |
| impersonation | uses another host's MAC address, or replays its frames |
Access control. Access control admits only users who show credentials.It prevents free riding.
| Access control | Password | WiFi standard |
|---|---|---|
| shared | the same for all users | WPA2-Personal, WPA3-Personal |
| per-user | personal to each user | WPA2-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.
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.
Example 6. The EPFL WiFi profile.
A Mac connected to the EPFL WiFi shows these settings.What role does each one play?
| Setting | Role |
|---|---|
Wi-Fi (epfl) under 802.1X | per-user access control |
EAP-PEAP (MSCHAPv2) | a PEAP tunnel, with MSCHAPv2 inside |
PEAP and TTLS | the accepted TLS tunnels |
WPA2 | authenticates and encrypts the frames |
DigiCert Global Root G2 | the root of the server's certificate |
radius.epfl.ch | the 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?
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.