← Interview Prep

Protocol Headers — Field Reference

The wire format of every header you're expected to sketch at a whiteboard: Ethernet, VLAN, ARP, IPv4, IPv6, ICMP, TCP, UDP, MPLS, VXLAN/GRE, and the routing protocols (OSPF, BGP, IS-IS).

Interviewers love "draw the header." The point isn't memorizing every bit — it's knowing the size, the purpose, and the one or two fields that carry real meaning. This page walks the stack bottom-up, encapsulation by encapsulation.

Read a packet outside-in: Ethernet → (VLAN) → IPv4/IPv6 → (MPLS/GRE/VXLAN) → TCP/UDP/ICMP → payload. Each header's "next-protocol" field (EtherType, IP Protocol, IPv6 Next Header, UDP dst port) tells the parser what comes next — that chain is demultiplexing.

Ethernet II frame (L2)

The frame the NIC actually clocks onto the wire. Preamble + SFD (8 bytes) and the inter-frame gap are handled by the PHY and are not part of the frame the driver sees. A frame is 64–1518 bytes (1522 with a VLAN tag); the 64-byte minimum is why short frames get padded.

bytes:        6             6            2         46 - 1500      4
       +-------------+-------------+-----------+---------------+-------+
       | Destination |   Source    | EtherType |    Payload    |  FCS  |
       |     MAC     |     MAC     | / Length  |    (data)     | (CRC) |
       +-------------+-------------+-----------+---------------+-------+
       |<---------------- 64 - 1518 bytes on the wire ------------>|

 Drawn left-to-right by byte order — Ethernet fields don't align to 32-bit
 words, so this is a byte layout, not a bit-field diagram like IPv4/TCP below.
FieldSizePurpose
Destination / Source MAC48 bits eachHardware addresses. First byte's low bits: I/G (0=unicast, 1=multicast/broadcast) and U/L (locally administered).
EtherType16 bitsNext protocol: 0x0800 IPv4, 0x86DD IPv6, 0x0806 ARP, 0x8100 802.1Q, 0x8847 MPLS. Values ≤ 1500 mean "length" (802.3).
Payload46–1500 bytesThe MTU is the upper bound (1500 standard, up to ~9000 for jumbo frames). Under 46 → padded.
FCS32 bitsCRC-32 over the frame; a mismatch is counted as a CRC error and the frame is dropped.

802.1Q VLAN tag

Inserted between Source MAC and EtherType — 4 bytes that push the max frame to 1522. Q-in-Q (802.1ad) stacks two tags (outer S-tag 0x88A8 + inner C-tag).

FieldSizePurpose
TPID16 bitsTag Protocol ID = 0x8100 — what a receiver sees in the EtherType slot to know a tag follows.
PCP3 bitsPriority Code Point — the L2 CoS (802.1p), 8 classes.
DEI1 bitDrop Eligible Indicator (formerly CFI).
VID12 bitsVLAN ID — 0–4095 (0 and 4095 reserved), the reason a switch tops out at ~4094 VLANs.

Jumbo frames & MTU

The standard Ethernet payload MTU is 1500 bytes (frame ≈ 1518, or 1522 with a VLAN tag). A jumbo frame carries a payload larger than 1500 — commonly up to 9000 bytes (many switches cap at 9216). Jumbo frames are not part of the IEEE 802.3 standard; they're a widely supported de-facto extension.

ARP (IPv4 ↔ MAC resolution)

Rides directly in Ethernet (EtherType 0x0806), no IP header. 28 bytes for the IPv4-over-Ethernet case. "Who has 10.0.0.1? Tell 10.0.0.2" is a broadcast request; the reply is unicast.

FieldSizePurpose
Hardware type (HTYPE)16 bits1 = Ethernet.
Protocol type (PTYPE)16 bits0x0800 = IPv4 (same numbering as EtherType).
HLEN / PLEN8 bits eachHardware/protocol address lengths (6 and 4).
Operation (OPER)16 bits1 = request, 2 = reply.
SHA / SPA48 / 32 bitsSender hardware & protocol address.
THA / TPA48 / 32 bitsTarget hardware (unknown in a request) & protocol address.

IPv6 has no ARP — it uses NDP (Neighbor Solicitation/Advertisement) carried inside ICMPv6.

IPv4 header (L3)

20 bytes without options, up to 60 with them. EtherType 0x0800.

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-------+-------+---------------+-------------------------------+
|Version|  IHL  |    DSCP  |ECN |         Total Length          |
+-------+-------+---------------+-----+-------------------------+
|         Identification         |Flags|    Fragment Offset     |
+---------------+---------------+-----+-------------------------+
|      TTL      |    Protocol   |        Header Checksum        |
+---------------+---------------+-------------------------------+
|                     Source IP Address                         |
+---------------------------------------------------------------+
|                  Destination IP Address                       |
+---------------------------------------------------------------+
|                    Options (0–40 bytes)                       |
+---------------------------------------------------------------+
FieldSizePurpose
Version4 bits= 4.
IHL4 bitsHeader length in 32-bit words (5 = 20 bytes, max 15 = 60).
DSCP + ECN6 + 2 bitsThe old ToS byte: DSCP is the QoS class; ECN signals congestion without dropping.
Total Length16 bitsHeader + data, so a datagram maxes at 65,535 bytes.
Identification16 bitsGroups fragments of one original datagram.
Flags3 bitsReserved(0), DF (Don't Fragment — the bit PMTUD relies on), MF (More Fragments).
Fragment Offset13 bitsPosition of this fragment in 8-byte units.
TTL8 bitsHop count; decremented each router, 0 → dropped + ICMP Time Exceeded (how traceroute works).
Protocol8 bitsNext header: 6 TCP, 17 UDP, 1 ICMP, 89 OSPF, 47 GRE, 4 IP-in-IP, 112 VRRP.
Header Checksum16 bitsHeader only — recomputed at every hop because TTL changes.
Source / Destination IP32 bits eachThe addresses NAT rewrites.
Options0–40 bytesRare: Record Route, Timestamp, source routing.

IPv6 header (L3)

A fixed 40 bytes — deliberately simpler than IPv4: no header checksum, no in-network fragmentation, no options in the base header (they move to extension headers). EtherType 0x86DD.

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-------+---------------+---------------------------------------+
|Version| Traffic Class |             Flow Label                |
+-------+---------------+-------------------+-------------------+
|         Payload Length          |  Next Header  |  Hop Limit  |
+---------------------------------+---------------+-------------+
|                                                               |
+                    Source Address (128 bits)                  +
|                                                               |
+---------------------------------------------------------------+
|                                                               |
+                 Destination Address (128 bits)                +
|                                                               |
+---------------------------------------------------------------+
FieldSizePurpose
Version4 bits= 6.
Traffic Class8 bitsDSCP + ECN, same role as IPv4's ToS byte.
Flow Label20 bitsTags a flow so routers can keep it on one path (ECMP hashing) without deep inspection.
Payload Length16 bitsLength of everything after the 40-byte base header (extension headers + L4).
Next Header8 bitsSame numbering as IPv4 Protocol; also chains extension headers. ICMPv6 = 58.
Hop Limit8 bitsThe renamed TTL.
Source / Destination128 bits each16-byte addresses — the whole reason IPv6 exists.

Extension headers

Optional headers are daisy-chained via Next Header between the base header and L4, each pointing at the next. Order matters. The ones to know:

ICMP / ICMPv6

Control & error signaling. ICMP rides in IPv4 (protocol 1); ICMPv6 in IPv6 (Next Header 58) and also carries NDP and MLD. Minimal header — the meaning is in Type/Code.

FieldSizePurpose
Type8 bitsICMPv4: 8/0 echo req/reply, 3 dest unreachable, 11 time exceeded, 5 redirect. ICMPv6: 128/129 echo, 133–137 NDP (RS/RA/NS/NA/Redirect).
Code8 bitsSub-type, e.g. type 3 / code 4 = "fragmentation needed & DF set" — the PMTUD message.
Checksum16 bitsICMPv6 checksum covers an IPv6 pseudo-header (ICMPv4's does not).
Rest of header32 bitsType-specific: Identifier + Sequence for echo, next-hop MTU for "frag needed", etc.

TCP segment header (L4)

20 bytes without options, up to 60 with them. IP protocol 6. The 4-tuple (src IP, src port, dst IP, dst port) identifies a connection.

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-------------------------------+-------------------------------+
|          Source Port          |       Destination Port        |
+-------------------------------+-------------------------------+
|                        Sequence Number                        |
+---------------------------------------------------------------+
|                     Acknowledgment Number                     |
+-------+-----------+-----------+-------------------------------+
|Offset | Reserved  |  Flags    |            Window             |
+-------+-----------+-----------+-------------------------------+
|           Checksum            |         Urgent Pointer        |
+-------------------------------+-------------------------------+
|                     Options (0–40 bytes)                      |
+---------------------------------------------------------------+
FieldSizePurpose
Source / Destination Port16 bits eachEndpoint demultiplexing.
Sequence Number32 bitsByte offset of the first data byte (ISN on the SYN).
Acknowledgment Number32 bitsNext byte expected — cumulative. Valid only when ACK set.
Data Offset4 bitsHeader length in 32-bit words (hence the 60-byte cap).
FlagsSYN ACK FIN RST PSH URG + ECE CWR (ECN) + NS.
Window16 bitsReceiver's free buffer — flow control (scaled by the Window Scale option).
Checksum16 bitsCovers header + data + a pseudo-header with the IPs — why NAT must recompute it.
Urgent Pointer16 bitsOffset of urgent data when URG set (rare).
Options0–40 bytesMSS, Window Scale, SACK-permitted/SACK, Timestamps.

Full mechanics: TCP — Theory & Mechanisms.

UDP datagram header (L4)

Just 8 bytes — no state, no reliability. IP protocol 17. The base for DNS, DHCP, VoIP, VXLAN, and QUIC/HTTP-3.

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-------------------------------+-------------------------------+
|          Source Port          |       Destination Port        |
+-------------------------------+-------------------------------+
|            Length             |           Checksum            |
+-------------------------------+-------------------------------+
FieldSizePurpose
Source / Destination Port16 bits eachDemultiplexing; dst port also selects the app protocol (53 DNS, 67/68 DHCP, 4789 VXLAN).
Length16 bitsHeader + data (minimum 8).
Checksum16 bitsOptional in IPv4 (0 = none), mandatory in IPv6; covers a pseudo-header.

MPLS label (the "2.5" shim)

Sits between L2 and L3 (EtherType 0x8847 unicast / 0x8848 multicast). A 4-byte shim, and labels stack — the bottom one carries the S bit. Transit LSRs forward on the top label alone and never look at L3.

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-----------------------------------------------+-----+-+-------+
|                 Label (20 bits)               | TC  |S|  TTL  |
+-----------------------------------------------+-----+-+-------+
FieldSizePurpose
Label20 bitsThe forwarding index (swapped hop by hop). 0–15 reserved (3 = implicit-null → PHP).
TC / EXP3 bitsTraffic Class (QoS), formerly "EXP".
S1 bitBottom-of-Stack — set on the last label before the payload.
TTL8 bitsOwn hop counter; uniform vs pipe mode controls whether it's copied to/from IP TTL.

A typical VPN packet carries two labels: outer = transport (LDP/RSVP/SR, to the egress PE), inner = service (VPN/VC, identifies the customer VRF or pseudowire). More: MPLS — Theory.

Overlay encapsulations — VXLAN & GRE

VXLAN (MAC-in-UDP)

Wraps a full L2 frame in UDP (dst port 4789) for L2-over-L3 fabrics/EVPN. 8-byte header; total overhead ~50 bytes (outer Eth+IP+UDP+VXLAN), which is why fabrics raise the MTU.

FieldSizePurpose
Flags8 bitsThe I bit must be 1 → VNI is valid.
Reserved24 + 8 bitsUnused.
VNI24 bitsVXLAN Network Identifier — ~16M segments vs 4094 VLANs (the scale win).

GRE

Generic point-to-point tunnel, IP protocol 47. Minimal 4-byte header, plus optional fields.

FieldSizePurpose
Flags + Version16 bitsC (checksum present), K (key present), S (sequence present), version.
Protocol Type16 bitsEtherType of the payload (e.g. 0x0800 IPv4, 0x6558 for NVGRE/Ethernet).
Key / Sequence32 bits each (opt.)Optional tunnel key (multiplexing) and sequence number.

Routing protocol headers

Where each control-plane protocol actually rides — a favorite trap ("what transport does OSPF use?").

ProtocolRuns onNeighbor / transport
OSPFIP protocol 89Multicast 224.0.0.5/6 (v2), no TCP/UDP; own reliable flooding.
IS-ISDirectly on L2 (CLNS)No IP at all — PDUs in the frame; multicast MAC 0180.C200.0014/15.
BGPTCP/179Unicast TCP session to a configured peer — the only IGP/EGP that's connection-oriented.
RIPUDP/520Multicast 224.0.0.9 (v2).
EIGRPIP protocol 88Multicast 224.0.0.10; RTP for reliability.
LDPUDP/646 discovery, TCP/646 sessionHello over multicast, label exchange over TCP.
VRRPIP protocol 112Multicast 224.0.0.18.

OSPFv2 common header (24 bytes)

Every OSPF packet (Hello, DBD, LSR, LSU, LSAck) starts with this; the Type field selects which.

FieldSizePurpose
Version8 bits= 2.
Type8 bits1 Hello, 2 DB Description, 3 LS Request, 4 LS Update, 5 LS Ack.
Packet Length16 bitsIncluding this header.
Router ID32 bitsOriginating router.
Area ID32 bitsThe area this packet belongs to.
Checksum16 bitsWhole packet.
AuType + Authentication16 + 64 bitsAuth scheme (null/simple/crypto) + data.

BGP message header (19 bytes)

Fixed header in front of every BGP message on the TCP session.

FieldSizePurpose
Marker16 bytesAll ones — historically for auth/sync, now a framing delimiter.
Length16 bitsTotal message length, 19–4096 (or 65535 with extended-message support).
Type8 bits1 OPEN, 2 UPDATE, 3 NOTIFICATION, 4 KEEPALIVE, 5 ROUTE-REFRESH.

The UPDATE carries the substance: withdrawn routes, path attributes (AS_PATH, NEXT_HOP, LOCAL_PREF, MED, communities), and NLRI. MP-BGP moves NLRI into MP_REACH/UNREACH_NLRI attributes (AFI/SAFI) to carry IPv6, VPNv4/v6, and EVPN. See BGP — Theory and MP-BGP.

IS-IS header

No IP — the PDU sits straight in the L2 frame. Fixed common header then TLVs.

FieldSizePurpose
Intradomain Routing Protocol Discriminator8 bits= 0x83 — marks an IS-IS PDU.
Length Indicator8 bitsLength of the fixed header.
Version / Protocol ID Extension8 bits= 1.
ID Length8 bitsSystem-ID length (0 → default 6 bytes).
PDU Type5 bitsHello (L1/L2/P2P), LSP, CSNP, PSNP.
Max Area Addresses8 bitsThen everything else is TLVs — the extensibility that let IS-IS carry IPv6 and SR with no new PDU.

Detail: IS-IS — Theory.

One-glance size cheat sheet

HeaderSizeNext-protocol field → value
Ethernet II14 B (+4 VLAN, +4 FCS)EtherType → 0x0800 / 0x86DD / 0x0806 / 0x8847
IPv420–60 BProtocol → 6 / 17 / 1 / 89 / 47
IPv640 B fixedNext Header → 6 / 17 / 58 / 43 (+ ext. headers)
TCP20–60 BDst port → application
UDP8 BDst port → application
ICMP / ICMPv68 B (+ data)Type/Code
MPLS label4 B each (stackable)S bit → then IP or another label
VXLAN8 B (UDP 4789)VNI → inner Ethernet frame
GRE4–16 B (IP proto 47)Protocol Type → payload EtherType

Likely follow-up questions

Related: Life of a Packet · TCP Theory · MPLS Theory · BGP Theory.