The physical layer gives CAN a wired-AND bus where a dominant 0 beats a recessive 1. The protocol is built entirely on that one property. A frame starts with an identifier that doubles as its priority, carries 0 to 8 bytes, protects them with a 15-bit CRC, and ends with an acknowledge slot that every receiver writes into. When any node sees something wrong it destroys the frame for everyone with an error flag, and counters decide whether a node that keeps causing errors is allowed to stay on the bus. This page goes through the base and extended data frames field by field, builds real frames bit by bit, then the remote, error and overload frames, fault confinement, and the three higher-layer protocols you meet most: CANopen, J1939 and ISO-TP.
Standards: ISO 11898-1 (data link layer) [1], Bosch CAN 2.0 A/B [2]. The wire itself (transceiver, levels, bit timing, circuits) is on CAN Physical Layer; CAN FD has its own page.
| Layer | Defined in | Who implements it | What it does |
|---|---|---|---|
| Application / higher layer | CANopen (CiA 301), SAE J1939, ISO 15765-2 (ISO-TP), UDS | Software stack | Gives identifiers and bytes a meaning: node addresses, parameter groups, segmentation of long messages, diagnostics. |
| Logical link control (LLC) | ISO 11898-1 | CAN controller + driver | Acceptance filtering, overload notification, recovery management (automatic retransmission). |
| Medium access control (MAC) | ISO 11898-1 | CAN controller (hardware) | Framing, arbitration, bit stuffing, CRC, ACK, error detection and signalling, fault confinement. |
| Physical coding (PCS) | ISO 11898-1 | CAN controller (hardware) | Bit encoding (NRZ), bit timing, synchronisation, sampling. |
| Physical medium (PMA/MDI) | ISO 11898-2 | Transceiver, cable, termination | Dominant/recessive levels on CANH/CANL. See CAN Physical Layer. |
| Frame | Sent by | Purpose | On the wire |
|---|---|---|---|
| Data frame | Any node with something to send | Carries 0–8 bytes under an identifier | SOF · arbitration · control · data · CRC · ACK · EOF (§03–§05) |
| Remote frame | A node asking for data | Requests the data frame with the same identifier | Like a data frame with RTR recessive and no data field (§08) |
| Error frame | Any node that detects an error | Destroys the current frame for every node so it is retransmitted | Error flag (6 bits, overlapping flags 6–12) + 8-bit recessive delimiter (§09) |
| Overload frame | A node that sees a dominant bit in the intermission, or needs time | Delays the next frame | Overload flag (6 dominant) + 8-bit recessive delimiter (§10) |
| Interframe space | — | Separates a data or remote frame from what came before | 3-bit intermission, then bus idle; plus 8-bit suspend transmission for error-passive transmitters (§10) |
| Field | Bits | Value | Purpose |
|---|---|---|---|
| SOF | 1 | d | Start of frame. Its recessive-to-dominant edge hard-synchronises every node. |
| Identifier | 11 | ID10…ID0 | Names the content and sets priority (lower value wins arbitration). MSB first. The top 7 bits must not all be recessive (7F0h–7FFh are not allowed). |
| RTR | 1 | d / r | Remote transmission request: dominant in a data frame, recessive in a remote frame. Last bit of the arbitration field. |
| IDE | 1 | d | Identifier extension: dominant means base format. |
| r0 | 1 | d | Reserved, sent dominant. (In CAN FD this position became FDF.) |
| DLC | 4 | 0–8 | Data length code. Values 9–15 are allowed on the wire in classical CAN but still mean 8 bytes. |
| Data | 0–64 | — | Payload, byte 0 first, each byte MSB first. |
| CRC sequence | 15 | — | CRC-15, polynomial \(x^{15}+x^{14}+x^{10}+x^{8}+x^{7}+x^{4}+x^{3}+1\) (4599h), over the unstuffed bits from SOF to the end of the data. |
| CRC delimiter | 1 | r | Gives the receivers a recessive bit before they must drive ACK. |
| ACK slot | 1 | r → d | Sent recessive by the transmitter; every node that received the frame with a correct CRC overwrites it dominant. |
| ACK delimiter | 1 | r | Recessive. |
| EOF | 7 | r | End of frame. Fixed form, not stuffed; a dominant bit here is a form error (except the last bit, see §10). |
| Intermission | 3 | r | Part of the interframe space. No node may start a frame here. |
Unstuffed, a base data frame is \(44 + 8n\) bits plus the 3-bit intermission, where \(n\) is the number of data bytes: 111 bits for 8 bytes. Stuffing adds up to \(\lfloor(34 + 8n - 1)/4\rfloor\) bits (§06).
| Field | Bits | Value | Purpose |
|---|---|---|---|
| SOF | 1 | d | As in base format. |
| Base identifier (ID28…ID18) | 11 | — | The 11 most significant bits of the 29-bit identifier. |
| SRR | 1 | r | Substitute remote request: sits where a base frame has RTR, always recessive. |
| IDE | 1 | r | Recessive: this is an extended frame. Still inside the arbitration field. |
| Identifier extension (ID17…ID0) | 18 | — | The 18 least significant bits. |
| RTR | 1 | d / r | Data or remote frame. End of the 32-bit arbitration field. |
| r1 · r0 | 1 · 1 | d · d | Reserved, sent dominant. |
| DLC … EOF | — | — | Identical to the base format. |
Why SRR is recessive. When a base frame and an extended frame with the same top 11 identifier bits start together, they agree through ID18. At the next bit the base data frame sends RTR dominant and the extended frame sends SRR recessive, so the base frame wins. If the base frame is a remote frame (RTR recessive) they tie again, and IDE decides: dominant in the base frame. So a base frame always beats an extended frame with the same base identifier, and the two formats can share a bus.
Unstuffed, an extended data frame is \(64 + 8n\) bits plus intermission: 131 bits for 8 bytes, against 111 for base format. Only the top 11 bits are compared against a base frame's identifier; the remaining 18 only arbitrate among extended frames.
Pick the format and type, then edit the identifier and data. The builder computes the CRC-15 and inserts stuff bits exactly as a CAN controller does. TXD is node A's controller output, CANH/CANL are the bus, RXD is node B's transceiver output. Stuff bits are marked s (violet); the ACK slot (amber) is the one bit node A sends recessive and node B drives dominant.
Switch to Extended and enter 18FEF100 (a J1939 message, §13) to see SRR and IDE recessive inside the arbitration field and the 18-bit extension after them.
| Contenders (starting together) | Decided at | Winner | Why |
|---|---|---|---|
| Base 100h vs base 101h | ID0 | 100h | Lower identifier: its first differing bit is dominant. |
| Base data 123h vs base remote 123h | RTR | Data frame | RTR dominant beats recessive; the requester gets its answer in the same slot. |
| Base data 123h vs extended 048C0000h (base part 123h) | RTR / SRR | Base | Base RTR dominant vs extended SRR recessive. |
| Base remote 123h vs extended, same base part | IDE | Base | RTR and SRR are both recessive; base IDE is dominant. |
| Two nodes sending the identical frame | — | Both | They never disagree, so both "win". Two nodes must never send different data under one identifier: they would disagree in the data field, where a disagreement is a bit error, not lost arbitration. |
Arbitration is bitwise and non-destructive: a node that sends recessive and reads dominant inside the arbitration field stops transmitting and becomes a receiver of the winning frame, and no bus time is lost. Outside the arbitration field (and the ACK slot) the same mismatch is a bit error. The waveform of three nodes arbitrating is on CAN Physical Layer.
Acknowledge. Every node that received the frame without error, whether or not its acceptance filter wants the frame, drives the ACK slot dominant. The transmitter only learns that at least one node got it, not which one. If no node acknowledges (for example the transmitter is alone on the bus, or every other node runs at a different bit rate), the transmitter flags an ACK error and retries indefinitely, raising its TEC until it goes error-passive (§12).
A node that detects an error sends an error flag, starting at the next bit (for a CRC error, at the bit after the ACK delimiter). An error-active node's flag is 6 dominant bits. That breaks the stuff rule, so every other node detects a stuff, form or bit error and sends its own flag: the flags overlap, and the bus sees between 6 and 12 dominant bits. Each node then sends recessive, waits until it reads the bus recessive, and sends 7 more recessive bits: the 8-bit error delimiter. After the 3-bit intermission the transmitter retries automatically. An error-passive node's flag is 6 recessive bits, which the other nodes cannot see, so a node with a bad record cannot destroy other nodes' frames.
| Error | Detected by | Where | Condition | Error flag starts |
|---|---|---|---|---|
| Bit error | Transmitter | Any bit it sends, except the arbitration field and ACK slot | Bit read back differs from bit sent | Next bit |
| Stuff error | Every node | SOF to end of CRC sequence | Six consecutive identical bits | Next bit |
| CRC error | Receivers | CRC sequence | Computed CRC differs from received CRC | Bit after the ACK delimiter |
| Form error | Every node | CRC delimiter, ACK delimiter, EOF, error and overload delimiters | Dominant bit in a fixed recessive field (receivers ignore the last bit of EOF) | Next bit |
| ACK error | Transmitter | ACK slot | Reads recessive: nobody acknowledged | Next bit |
| Event | TEC | REC |
|---|---|---|
| Receiver detects an error | — | +1 |
| Receiver sees a dominant bit right after sending its error flag (it was the first to notice) | — | +8 |
| Transmitter sends an error flag (exceptions: error-passive ACK error; stuff error on a recessive stuff bit in arbitration) | +8 | — |
| Bit error while sending an active error flag or overload flag | +8 | +8 |
| 14 consecutive dominant bits after an error flag (then each further 8) | +8 | +8 |
| Frame transmitted successfully (ACK received, no error to end of EOF) | −1 | — |
| Frame received successfully | — | −1 (if REC > 127: set to 119–127) |
Because a transmitter's error costs 8 and a success earns back 1, a node keeps its standing as long as fewer than about one frame in eight fails. A node that is the cause of errors (a broken transmitter, a wrong bit rate) climbs quickly; nodes that merely observe them climb slowly.
| State | Entered when | Error flag it sends | Other effects |
|---|---|---|---|
| Error active | TEC ≤ 127 and REC ≤ 127 | 6 dominant: destroys the frame for all | Normal operation. |
| Error passive | TEC > 127 or REC > 127 | 6 recessive: invisible unless it is the transmitter | 8-bit suspend transmission after each frame it sends. |
| Bus off | TEC > 255 | None: the node may not drive the bus | Leaves after 128 occurrences of 11 consecutive recessive bits (many controllers also need software to request recovery); counters reset to 0. |
The data link layer only moves an identifier and up to 8 bytes. Every real network adds a convention for what the identifiers mean and how to carry more than 8 bytes. Three dominate: CANopen in industrial automation and robotics, SAE J1939 in trucks, buses and off-highway machines, and ISO-TP (ISO 15765-2) for diagnostics in cars.
CANopen (CiA 301) uses base-format frames. The 11-bit identifier, called the COB-ID, is a 4-bit function code followed by a 7-bit node ID (1–127). The function code sets the priority: network management first, process data next, configuration and heartbeats last. Each node exposes an object dictionary (index 16 bits, sub-index 8 bits): PDOs carry real-time process data mapped from dictionary entries with no protocol overhead, and SDOs read or write any dictionary entry with a confirmed request/response.
| Object | COB-ID | Direction | Use |
|---|---|---|---|
| NMT | 000h | Master → all | Start, stop, reset nodes |
| SYNC | 080h | Producer → all | Sampling and actuation trigger for synchronous PDOs |
| EMCY | 080h + node | Node → all | Emergency error code |
| TIME | 100h | Producer → all | Time of day |
| TPDO1–4 | 180h / 280h / 380h / 480h + node | Node → network | Process data out of the node |
| RPDO1–4 | 200h / 300h / 400h / 500h + node | Network → node | Process data into the node |
| SDO response / request | 580h / 600h + node | Server → client / client → server | Object dictionary access |
| Heartbeat (NMT error control) | 700h + node | Node → all | Node state, periodically |
J1939 uses extended frames at 250 or 500 kbit/s. The 29-bit identifier is three priority bits, an 18-bit parameter group number (PGN) that says what the data is, and the 8-bit source address of the sender. When the PDU format byte (PF) is below 240 (PDU1), the PDU specific byte (PS) is a destination address and is not part of the PGN; at 240 and above (PDU2) the message is broadcast and PS extends the PGN. Messages longer than 8 bytes use the transport protocol: a connection-management frame (TP.CM, PGN 60416), either broadcast (BAM) or with RTS/CTS handshaking, followed by numbered data-transfer frames (TP.DT, PGN 60160) of 7 bytes each.
Try 18FEF100 (vehicle speed, CCVS), 18FECA00 (active diagnostic codes, DM1), 18EAFF00 (request to all) or 1CECFF00 (transport protocol, BAM).
ISO 15765-2 is the transport layer under UDS diagnostics. The first one or two bytes of each frame are a protocol control information (PCI) field whose high nibble gives the frame type. A message of up to 7 bytes goes in one single frame. A longer one starts with a first frame carrying the 12-bit total length and 6 data bytes; the receiver answers with a flow control frame giving the block size (how many frames before the next flow control, 0 = all) and STmin (minimum gap between frames); the sender then sends consecutive frames of 7 data bytes with a 4-bit sequence number that wraps 1…F, 0, 1….
| Type | PCI (hex nibbles) | Data bytes | Meaning |
|---|---|---|---|
| Single frame (SF) | 0L | 1–7 | L = length |
| First frame (FF) | 1L LL | 6 | LLL = total length, 8–4095 |
| Consecutive frame (CF) | 2N | ≤ 7 | N = sequence number |
| Flow control (FC) | 3S BS ST | — | S: 0 continue, 1 wait, 2 overflow · BS block size · ST STmin |
The base frame, at the bit after ID18/ID0: base RTR is dominant, extended SRR is recessive.
SOF, the 11 identifier bits, RTR, IDE, r0 and DLC are 19 dominant bits in a row. A recessive stuff bit goes in after every fifth: after dominant bits 5, 10 and 15, so the run on the wire is 00000 1 00000 1 00000 1 0000 followed by the CRC.
Every node that received the frame with a correct CRC, whether or not it wants the frame. The transmitter sends it recessive and checks that someone overwrote it.
The first node sends 6. The others may notice only when the 6th identical bit arrives (a stuff error) and then send their own 6, so the flags overlap by 0 to 5 bits: 6 to 12 in total.
At the bit after the ACK delimiter. It must first let the CRC and ACK delimiters pass so it does not corrupt the ACK of nodes that received correctly; its flag then appears in EOF, where the other nodes see a form error.
Every attempt ends with an ACK error: TEC +8. After 16 attempts TEC = 128 and it goes error-passive. From then on the ACK-error exception applies (a passive transmitter does not count an ACK error), so it stays error-passive instead of going bus-off.
Priority 6, PF FEh = 254 (PDU2, broadcast), PS F1h, so PGN = FEF1h = 65265 (cruise control / vehicle speed, CCVS), source address 00h (engine).
A first frame carrying 6 bytes, then 14 bytes in two consecutive frames (7 + 7): three frames from the sender plus one flow control frame from the receiver.