ISO-TP transport: interview questions
10 ISO-TP transport questions embedded interviewers ask, each with a model answer. What problem does ISO-TP solve, and where does it sit between CAN and UDS?…
What problem does ISO-TP solve, and where does it sit between CAN and UDS?
A classic CAN frame carries at most 8 bytes, and diagnostic messages are longer: a VIN response is 20 bytes, a list of trouble codes can be 200, a firmware block several kilobytes. ISO-TP (ISO 15765-2, called CanTp in AUTOSAR) cuts a long message into frames at the sender, puts it back together at the receiver, lets a slow receiver hold the sender back, and notices a missing frame.
It sits between the CAN driver and the diagnostic protocol:
| Layer | In a car |
|---|---|
| Application | UDS (ISO 14229-1), OBD |
| Transport and network | ISO-TP (ISO 15765-2) |
| Data link and physical | CAN (ISO 11898) |
Its promise to the layer above is narrow: a message of up to 4095 bytes (more since the 2016 edition) arrives complete and in order, or the user is told that it did not. It does not retransmit. A lost frame ends the whole message, and the application decides what happens next, which for UDS is the tester asking again.
It is deliberately small: four frame types, three parameters (flow status, block size, STmin) and a handful of timers.
What are the four ISO-TP frame types, and how is each recognised?
By the high nibble of the first byte, the protocol control information (PCI):
| High nibble | Frame | Rest of the PCI | Carries |
|---|---|---|---|
0 | Single frame | low nibble: length, 1 to 7 | the whole message, up to 7 bytes |
1 | First frame | low nibble and next byte: 12-bit length | the first 6 bytes |
2 | Consecutive frame | low nibble: sequence number | up to 7 bytes |
3 | Flow control | low nibble: flow status, then block size and STmin | nothing |
A message of 7 bytes or fewer goes in one single frame with no handshake, and most diagnostic requests are that short. A longer one is a first frame from the sender, a flow control frame from the receiver, then consecutive frames:
tester 7E0 03 22 F1 90 CC CC CC CC single frame: 3 bytes
ECU 7E8 10 14 62 F1 90 54 45 31 first frame: 20 bytes in all, 6 here
tester 7E0 30 00 00 CC CC CC CC CC flow control: continue
ECU 7E8 21 42 43 4D 34 34 36 52 consecutive frame 1
ECU 7E8 22 45 30 30 30 30 34 32 consecutive frame 2
The flow control frame travels in the opposite direction to the data, on the receiver's own identifier. That is the detail people forget when they draw it.
How does a first frame encode the message length, and what changes above 4095 bytes?
The low nibble of the first byte and the whole second byte form a 12-bit length. 10 14 is 0x014, 20 bytes. Twelve bits give the classic limit of 4095.
Two points to state exactly:
- The length is the whole message's, not what this frame carries. The receiver uses it to decide whether it has a buffer that large, and to know when the last consecutive frame has arrived. The last frame is usually part-filled, and the receiver takes only the bytes the length still needs.
- A first frame with a length under 8 is malformed (that message belongs in a single frame) and is ignored.
Above 4095 bytes, the 2016 edition adds an escape: a first frame whose 12-bit length is 0 carries a 32-bit length in the next four bytes. So the frame begins 10 00 and then four length bytes, and the first data bytes follow them. Firmware downloads on CAN FD use this.
A receiver that cannot take the announced length answers with a flow control frame of status overflow, before any data has moved.
What are the three flow status values in a flow control frame, and what must the sender do on each?
| Value | Name | The sender must |
|---|---|---|
0 | ContinueToSend | take the block size and STmin from this frame and start sending |
1 | Wait | keep waiting and restart its timeout; another flow control frame will follow |
2 | Overflow | abandon the message: the receiver has no room for the announced length |
Values 3 to F are reserved, and the sender abandons the message.
Details that come up in conformance testing:
- Overflow is only legal as the answer to a first frame. A receiver says at once that it can never take a message this long.
- Wait may be repeated, but not for ever. The sender counts wait frames against a limit, N_WFTmax, and gives up when it is exceeded. With the limit configured as 0, the receiver may not send wait frames at all.
- After each block of
BSconsecutive frames, the sender stops and waits for another flow control frame. That frame may carry different values of block size and STmin, so a sender must take them from the latest frame rather than store them once per message. - Block size 0 means "send everything that is left; no more flow control frames".
How is the STmin byte encoded, and what should a sender do with a reserved value?
| Byte | Meaning |
|---|---|
00 to 7F | 0 to 127 milliseconds |
F1 to F9 | 100 to 900 microseconds |
80 to F0, FA to FF | reserved |
A sender that receives a reserved value treats it as 7F, 127 ms, the longest valid time. Guessing shorter could overrun the receiver; the longest value is always safe.
STmin is the minimum gap between the end of one consecutive frame and the start of the next, and the sender enforces it. A sender may wait longer than STmin and never shorter, so one with a 1 ms tick that is asked for 300 µs rounds up to its next tick, or uses a hardware timer if the project needs the throughput.
The trap in the encoding is assuming the byte is always milliseconds. Code that treats F1 as 241 ms still works, only very slowly, so the bug survives testing and shows up as a programming session that takes ten times as long as it should.
How does the consecutive-frame sequence number work, and what does a receiver do on a wrong one?
The sequence number is the low nibble of each consecutive frame's first byte. The first frame counts as number 0, so the first consecutive frame is 21. The numbers run 1, 2 ... 15, then wrap to 0 and carry on: 2F is followed by 20, not by 21.
A receiver keeps the number it expects next. If a consecutive frame arrives with any other number, it ends the reception and passes nothing up. It does not try to reorder frames, and it does not ask for the missing one, because ISO-TP has no retransmission.
Four bits cannot say how many frames were lost, only that the sequence broke. A loss of exactly sixteen frames would look correct, which is one reason the total length from the first frame and the N_Cr timeout are both checked as well.
The usual bug is in the wrap: starting the counter at 0 after the first frame, or wrapping from 15 to 1. Both pass any test whose messages are shorter than about 110 bytes.
What is the difference between normal, extended and mixed addressing in ISO-TP?
CAN identifiers name messages, not nodes, so ISO-TP needs a convention for "this tester to that ECU".
| Scheme | How the address is carried | Where you meet it |
|---|---|---|
| Normal | a pair of 11-bit identifiers per ECU, one for each direction | most passenger cars: 0x7E0 request, 0x7E8 response |
| Normal fixed | 29-bit identifiers 0x18DA<target><source> (physical) and 0x18DB<target><source> (functional) | trucks and buses, beside J1939 |
| Extended | the first data byte is the target address | gateways, some older platforms |
| Mixed | the first data byte is an address extension, for a network behind a gateway | sub-networks such as LIN nodes reached through CAN |
With normal addressing all 8 data bytes belong to ISO-TP. With extended and mixed addressing the first byte is taken, the PCI moves to the second byte, and every frame carries one byte less: 6 in a single frame, 5 in a first frame, 6 in a consecutive frame.
For an implementation this means the frame's payload capacity and the PCI's offset are parameters of the connection, not the constants 8 and 0.
What is the difference between physical and functional addressing, and why can a functional request not be multi-frame?
Physical addressing is one tester to one ECU, on that ECU's own request identifier. Any message length is allowed.
Functional addressing is one tester to every ECU at once, on a shared identifier (0x7DF in the OBD scheme). Each ECU that supports the request answers on its own response identifier.
A functional request must fit in a single frame. Segmentation needs flow control, and flow control is a conversation between two nodes: after a first frame the sender waits for one receiver to say continue, with one block size and one STmin. Thirty ECUs cannot each answer the same first frame.
The responses are not limited in the same way. Each ECU answers physically, so a response to a functional request may be segmented, with the tester sending a flow control frame to each ECU.
Functional addressing is used for what every ECU should hear: TesterPresent with the response suppressed, a session change for the whole vehicle, switching off DTC storage before reprogramming.
What happens when a new first frame or single frame arrives in the middle of a reception?
The reception in progress is ended, and the new frame is handled as the start of a new message. A single frame is processed as a complete message; a first frame starts a new reception. The half-received message is dropped and never reaches the application.
The rule behind the standard's table of unexpected frames is that a new message always wins over an old one, and a damaged message is dropped whole. Without it, a tester that restarted in the middle of a transfer would be locked out until the ECU's N_Cr timeout expired.
The other rows worth knowing:
| While | Arrives | A correct receiver |
|---|---|---|
| idle | consecutive frame | ignores it |
| idle, not sending | flow control | ignores it |
| receiving | consecutive frame with the wrong sequence number | ends the reception |
| receiving | nothing for N_Cr | ends the reception |
| any | a frame whose PCI claims more bytes than the frame holds | ignores it |
A receiver should also check that the new frame is on the same connection. With several testers or several addresses, each connection has its own reception state, and a frame on one does not disturb another.
How does ISO-TP change on CAN FD?
CAN FD frames hold up to 64 bytes, and ISO 15765-2:2016 extends the PCI to use them:
- Single frame: in a frame longer than 8 bytes, the first byte is
00and the length is in the second byte, so one frame carries up to 62 bytes. A 20-byte VIN response becomes a single frame with no flow control. - First frame: a 12-bit length of 0 is an escape to a 32-bit length in the next four bytes, for messages beyond 4095 bytes.
- Consecutive frame: up to 63 bytes each.
- Padding is mandatory. CAN FD has no frame length of 9, 10 or 11 bytes (only 12, 16, 20, 24, 32, 48 and 64), so a frame is padded up to the next valid length.
The state machine, the flow control frame and the timers are unchanged. An implementation written with the frame's capacity as a parameter handles both.
The practical effect is throughput. A consecutive frame carries nine times as much, and the data phase runs at a higher bit rate, which is why CAN FD cut reprogramming times so sharply.