Skip to content
Tutorials Center
My learning

Topics

Lesson 15 of 79 ยท Data Link Layer

Ethernet and Frames

Learn the Ethernet frame format, MAC addresses, the 64-byte minimum frame, Fast, Gigabit and 10G variants and full duplex, and build a frame in Python.

Almost every wired network you will ever plug into speaks Ethernet. It was designed in the 1970s for a shared coaxial cable and has since grown from 10 megabits per second to 400 gigabits and beyond, yet the thing that crosses the wire is still recognisably the same: a frame with a destination address, a source address, a type, some data and a checksum. That stability is why a 1990s laptop and a modern data-center switch can still be connected.

In the previous lessons you saw how framing and error detection work in general and how stations share a medium with medium access control. Ethernet is the concrete answer that won. In this lesson you will take an Ethernet frame apart field by field, learn what a MAC address really is, see why a frame can never be shorter than 64 bytes, and build and parse frames in Python.

What Ethernet is

Ethernet is a family of standards, published by the IEEE as 802.3, that covers the physical layer and the lower half of the data link layer (the MAC sublayer). Above it sits the logical link layer that hands packets, usually IP packets, to the frame builder.

The original design was a bus: every station was attached to one long cable, and they took turns with CSMA/CD (listen first, detect collisions, back off at random). Today almost nothing shares a cable. Each device is wired with a point-to-point link to a port on a switch, and the two ends can send at the same time. The frame format survived all that, which is why this lesson spends most of its time on it.

The frame format

An Ethernet II frame, the version used by IP networks, looks like this on the wire:

flowchart LR
    A["Preamble<br/>7 bytes"] --> B["SFD<br/>1 byte"] --> C["Destination MAC<br/>6 bytes"] --> D["Source MAC<br/>6 bytes"] --> E["EtherType<br/>2 bytes"] --> F["Payload<br/>46 to 1500 bytes"] --> G["FCS<br/>4 bytes"]

The fields of an Ethernet II frame. The preamble and start frame delimiter (SFD) are added by the hardware and are not counted as part of the frame.

Field Size Purpose
Preamble 7 bytes A pattern of alternating 1 and 0 bits that lets the receiver lock its clock to the sender (see line coding).
SFD 1 byte 10101011: the last two 1 bits say "the frame starts now".
Destination MAC 6 bytes Who the frame is for.
Source MAC 6 bytes Who sent it.
EtherType 2 bytes Which protocol is in the payload.
Payload 46 to 1,500 bytes The data, usually an IP packet.
FCS 4 bytes Frame check sequence: a 32-bit CRC.

Between two frames the sender must stay silent for the inter-frame gap, 96 bit times (12 bytes). Together with the preamble and SFD, every frame therefore costs 20 bytes of "air time" beyond its own 18 bytes of header and trailer, which matters when you compute efficiency later.

EtherType

The two-byte type field tells the receiver which protocol to hand the payload to, just like the protocol field of IP does one layer up. The values you will meet most:

EtherType Protocol
0x0800 IPv4
0x0806 ARP
0x86DD IPv6
0x8100 802.1Q VLAN tag

Values of 1,500 or below mean something else: in the older IEEE 802.3 format that same field is a length. Because no EtherType was assigned below 1,536 (0x0600), a receiver can tell the two formats apart.

The frame check sequence

The FCS is the CRC-32 of everything from the destination address through the end of the payload. The sender appends it, the receiver recomputes it, and a mismatch means the frame is silently discarded. Ethernet does not ask for a retransmission: recovering from loss is the job of higher layers such as TCP. A frame that fails the CRC check was almost certainly damaged on the wire, so a rising count of CRC errors on a switch port usually points to a bad cable, connector or interface.

MAC addresses

Every Ethernet interface has a 48-bit MAC address (media access control address), written as six bytes in hexadecimal, such as 3c:22:fb:12:9a:07. It identifies an interface on the local network segment. Unlike an IP address it says nothing about where the device is: it is assigned by the manufacturer and travels with the hardware.

The address has structure:

  • The first three bytes are the OUI (organizationally unique identifier), assigned by the IEEE to a manufacturer. The last three bytes are chosen by that manufacturer, so addresses are meant to be globally unique.
  • Bit 0 of the first byte (the lowest bit) is the individual/group bit. 0 means unicast (one interface); 1 means multicast (a group).
  • Bit 1 of the first byte is the universal/local bit. 0 is a burned-in, globally administered address; 1 means the address was set locally, which is what virtual machines, containers and phones doing "random MAC addresses" use.
  • ff:ff:ff:ff:ff:ff is the broadcast address: every station on the segment accepts the frame.

An interface accepts a frame if the destination is its own MAC address, the broadcast address, or a multicast group it has joined. In promiscuous mode it accepts everything, which is how packet sniffers work (see packet capture).

Python Build, parse and damage an Ethernet frame

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The 5-byte payload was padded with zeros up to 46 bytes, so the frame is exactly 64 bytes. The next section explains why that number is not arbitrary.

Looking up and changing a MAC address

You can read your interface's MAC address with a command: ipconfig /all (look for "Physical Address") or getmac on Windows, ip link (or ifconfig on older systems) on Linux and ifconfig or networksetup on macOS. The first three bytes identify the maker through the public OUI registry, for example CC:46:D6 is assigned to Cisco, 3C:D9:2B to Hewlett Packard and 00:9A:CD to Huawei.

MAC cloning (or spoofing) means telling the operating system or router to use a different address than the burned-in one. There are good reasons: an ISP that registered your old router's MAC and refuses a new one, a replacement device that must take over an identity, or privacy (phones now use random MACs per Wi-Fi network). There are bad reasons too, such as dodging a MAC filter or impersonating another device. This is why MAC addresses should never be your only security control.

Strengths and limits of MAC addresses, summed up:

  • Uniqueness and compatibility. Addresses are meant to be globally unique, and they work the same on every Ethernet and Wi-Fi device, so a frame can reach any station on the segment, and multicast and broadcast addresses are built in.
  • Hardware-dependent and local. The address is tied to the interface, so replacing a network card changes it, and it only has meaning inside one local network. Routers rewrite the MAC header at every hop, so it never identifies a host across the Internet.
  • No inherent security. Anyone can read MACs from frames and anyone can change their own. A MAC address is an identifier, not a credential.
  • Inefficiency. A flat 48-bit address has no hierarchy, so switches must remember every address they see. That is why large networks are divided into subnets, where IP routing does the scaling.
Python Reading an OUI and flagging random (locally administered) MACs

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Minimum and maximum frame size

The maximum payload of 1,500 bytes is the Ethernet MTU. It was a compromise of the early hardware: big enough to be efficient, small enough that one station could not hog a shared cable or fill expensive memory. Adding the header (14 bytes) and FCS (4 bytes) gives a maximum frame of 1,518 bytes, or 1,522 with an 802.1Q VLAN tag. Data centers often use jumbo frames of about 9,000 bytes to cut per-frame overhead, but every device on the path must agree.

The minimum matters just as much, and it comes straight from collision detection. On a shared cable, a sender can only detect that its frame collided with someone else's while it is still transmitting. The worst case is a station at one end of the cable that starts sending, the signal almost reaches the far end, and a station there starts too. The collision signal then needs a full trip back. So the frame must last at least one round-trip time of the longest allowed network. That duration was fixed at 512 bit times (the slot time), which is 64 bytes: 6 + 6 + 2 + 46 + 4.

If an application sends less than 46 bytes of data, the sender pads the payload. The receiver cannot tell padding from data on its own, so IP uses its own length field to find where the real packet ends (the lesson on the IPv4 packet covers total length).

Python Slot time, frame time and efficiency

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

You can see why the idea of a shared cable breaks down above 100 Mbit/s: at 1 Gbit/s the slot time is half a microsecond, which would restrict the cable to about 50 metres. Gigabit half duplex used a trick called carrier extension to lengthen short frames, but in practice nobody uses it.

Speeds, media and full duplex

Ethernet names follow a pattern: speed, signalling, medium.

Name Speed Medium
10BASE-T 10 Mbit/s Twisted pair, up to 100 m
100BASE-TX (Fast Ethernet) 100 Mbit/s Cat 5 twisted pair, up to 100 m
1000BASE-T (Gigabit Ethernet) 1 Gbit/s Cat 5e or better, all four pairs, 100 m
1000BASE-SX / LX 1 Gbit/s Multimode / single-mode fiber
10GBASE-T 10 Gbit/s Cat 6A, up to 100 m
10GBASE-SR / LR 10 Gbit/s Fiber, about 300 m to 10 km
25, 40, 100, 400 GbE up to 400 Gbit/s Fiber or direct-attach copper, mostly in data centers

Every one of these uses the same frame. What changes is the physical signalling, which is why a switch can bridge a 100 Mbit/s port and a 10 Gbit/s port by simply storing and forwarding frames. Adjacent devices run auto-negotiation to agree on the best speed and duplex mode both ends support.

Full duplex

A twisted-pair link has separate wire pairs for each direction (10BASE-T and 100BASE-TX use one pair to send and one to receive). With only two devices on the link and a switch in the middle, there is nothing to collide with. In full duplex mode both ends send and receive at once and CSMA/CD is switched off: no collision detection, no slot time limit, double the total capacity. Gigabit and faster links are always full duplex. Older half-duplex links, such as those through a hub, still use CSMA/CD.

A duplex mismatch, where one end is fixed at full duplex and the other auto-negotiates down to half, gives a famous symptom: the link comes up, but throughput is poor, with late collisions on one side and CRC errors on the other.

When you design or troubleshoot, remember that Ethernet delivers frames on a best-effort basis. It detects damage with the FCS but never repairs it, and it never tells the sender about a loss.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What is the smallest legal Ethernet frame, counted from the destination MAC address through the FCS?

    The 46-byte minimum payload plus 14 bytes of header and 4 bytes of FCS makes 64 bytes. The preamble and SFD are not counted.
  2. 2. Which MAC address is the Ethernet broadcast address?

    All 48 bits set to 1 means every station on the segment accepts the frame. The 01:00:5e prefix belongs to IPv4 multicast.
  3. 3. The first byte of a MAC address is 0x03. What does that tell you?

    0x03 is 00000011 in binary. The lowest bit (1) marks a group/multicast address and the next bit (1) marks it as locally administered.
  4. 4. Why does full duplex Ethernet not need CSMA/CD?

    With a dedicated link between a host and a switch port, and separate paths for each direction, nothing can collide, so collision detection is switched off.
  5. 5. What does a receiving station do with a frame whose FCS does not match?

    Ethernet detects errors but does not repair or report them. Recovery, if needed, is left to higher layers such as TCP.

Summary

  • An Ethernet II frame is destination MAC, source MAC, EtherType, a 46 to 1,500 byte payload and a 4-byte CRC-32 FCS, preceded on the wire by a preamble and SFD.
  • A MAC address is 48 bits: an OUI plus a manufacturer-assigned part, with a multicast bit and a locally-administered bit in the first byte. ff:ff:ff:ff:ff:ff is broadcast.
  • The 64-byte minimum comes from the 512-bit slot time needed for collision detection; short payloads are padded.
  • Ethernet speeds from 10 Mbit/s to 400 Gbit/s share one frame format. Modern links are full duplex and do not use CSMA/CD.
  • The FCS only detects damage; Ethernet never retransmits.

Next, see how a switch learns which MAC address lives on which port.