| NACK Code | Hex | Meaning | Cause |
|---|---|---|---|
| Reserved | 0x00 | Reserved | — |
| Invalid source address | 0x02 | SA not registered/activated | Routing activation not performed |
| Unknown target address | 0x03 | TA logical address not in routing table | Wrong ECU address; ECU offline |
| Message too large | 0x04 | Payload exceeds buffer | Reduce UDS request size |
| Out of memory | 0x05 | ECU cannot process | Too many concurrent sessions |
| Target unreachable | 0x06 | ECU not responding | CAN bus off; ECU not powered; wrong SA |
| Unknown network | 0x07 | Target network not known | CAN bus identifier not configured |
| Transport protocol error | 0x08 | CAN TP error on target CAN bus | CAN frame loss; timing violation |
DoIP Diagnostic Message NACK Codes
UDS Session Management over DoIP
import socket, struct, time
class DoipUdsClient:
def __init__(self, ecu_ip: str, tester_la: int = 0xE000, ecu_la: int = 0x0001):
self.ecu_ip = ecu_ip
self.tester_la = tester_la
self.ecu_la = ecu_la
self.sock = None
def connect(self) -> bool:
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.settimeout(5.0)
try:
self.sock.connect((self.ecu_ip, 13400))
except ConnectionRefusedError:
return False
# Send RoutingActivationRequest
payload = struct.pack(">HBI", self.tester_la, 0x00, 0)
hdr = struct.pack(">BBHI", 0x02, 0xFD, 0x0005, len(payload))
self.sock.sendall(hdr + payload)
resp = self.sock.recv(256)
if len(resp) < 9: return False
act_code = resp[8] # 0x10 = routing activation accepted
return act_code == 0x10
def send_uds(self, uds_data: bytes) -> bytes:
payload = struct.pack(">HH", self.tester_la, self.ecu_la) + uds_data
hdr = struct.pack(">BBHI", 0x02, 0xFD, 0x8001, len(payload))
self.sock.sendall(hdr + payload)
# Wait for DiagnosticMessage response (skip ACK 0x8002)
while True:
resp = self.sock.recv(65536)
ptype = struct.unpack(">H", resp[2:4])[0]
if ptype == 0x8001: # DiagnosticMessage (actual UDS response)
return resp[12:] # skip 8-byte DoIP header + 4-byte SA/TA
# else: 0x8002 ACK — ignore, wait for next
def send_tester_present(self):
uds_tp = bytes([0x3E, 0x80]) # TesterPresent suppressPosRspMsgIndicationBit
self.send_uds(uds_tp)
# Usage:
# client = DoipUdsClient("169.254.1.100")
# client.connect()
# vin_resp = client.send_uds(bytes([0x22, 0xF1, 0x90])) # Read VINParallel Multi-ECU Diagnostics
import threading, socket
# Parallel DoIP sessions: connect to multiple ECUs simultaneously
# One TCP connection per ECU; run diagnostic in parallel threads
ECU_LIST = [
{"name": "Engine", "ip": "169.254.20.10", "la": 0x0010},
{"name": "Transmission","ip": "169.254.20.11", "la": 0x0011},
{"name": "Brake", "ip": "169.254.10.20", "la": 0x0020},
{"name": "Steering", "ip": "169.254.10.21", "la": 0x0021},
]
results = {}
lock = threading.Lock()
def flash_ecu(ecu: dict):
client = DoipUdsClient(ecu["ip"], ecu_la=ecu["la"])
if not client.connect():
with lock: results[ecu["name"]] = "CONNECT_FAILED"
return
# Start programming session, flash, verify...
sw_version = client.send_uds(bytes([0x22, 0xF1, 0x89])) # Read SW version
with lock:
results[ecu["name"]] = sw_version.hex()
# Start all ECUs simultaneously
threads = [threading.Thread(target=flash_ecu, args=(e,)) for e in ECU_LIST]
for t in threads: t.start()
for t in threads: t.join()
print("Results:", results)
# Total flash time ≈ single ECU time (all in parallel)
# vs CAN sequential: 4× single ECU timeSummary
Parallel multi-ECU diagnostics over DoIP is one of the most significant operational improvements over CAN-based diagnostics: an EOL factory flash of 4 ECUs can happen simultaneously over separate TCP connections, reducing total flash time from 4× to 1× the single-ECU time. The TesterPresent keepalive over DoIP uses the same UDS 0x3E 0x80 message as CAN, but is sent inside a DoIP DiagnosticMessage frame — the S3 server timer (5 s) still applies. NACK code 0x06 (target unreachable) is the most common field diagnostic failure; it means the DoIP gateway reached the target ECU's CAN bus but received no response — typically indicating the target ECU is not in the expected session state or has reset.
🔬 Deep Dive — Core Concepts Expanded
This section builds on the foundational concepts covered above with additional technical depth, edge cases, and configuration nuances that separate competent engineers from experts. When working on production ECU projects, the details covered here are the ones most commonly responsible for integration delays and late-phase defects.
Key principles to reinforce:
- Configuration over coding: In AUTOSAR and automotive middleware environments, correctness is largely determined by ARXML configuration, not application code. A correctly implemented algorithm can produce wrong results due to a single misconfigured parameter.
- Traceability as a first-class concern: Every configuration decision should be traceable to a requirement, safety goal, or architecture decision. Undocumented configuration choices are a common source of regression defects when ECUs are updated.
- Cross-module dependencies: In tightly integrated automotive software stacks, changing one module's configuration often requires corresponding updates in dependent modules. Always perform a dependency impact analysis before submitting configuration changes.
🏭 How This Topic Appears in Production Projects
- Project integration phase: The concepts covered in this lesson are most commonly encountered during ECU integration testing — when multiple software components from different teams are combined for the first time. Issues that were invisible in unit tests frequently surface at this stage.
- Supplier/OEM interface: This is a topic that frequently appears in technical discussions between Tier-1 ECU suppliers and OEM system integrators. Engineers who can speak fluently about these details earn credibility and are often brought into critical design review meetings.
- Automotive tool ecosystem: Vector CANoe/CANalyzer, dSPACE tools, and ETAS INCA are the standard tools used to validate and measure the correct behaviour of the systems described in this lesson. Familiarity with these tools alongside the conceptual knowledge dramatically accelerates debugging in real projects.
⚠️ Common Mistakes and How to Avoid Them
- Assuming default configuration is correct: Automotive software tools ship with default configurations that are designed to compile and link, not to meet project-specific requirements. Every configuration parameter needs to be consciously set. 'It compiled' is not the same as 'it is correctly configured'.
- Skipping documentation of configuration rationale: In a 3-year ECU project with team turnover, undocumented configuration choices become tribal knowledge that disappears when engineers leave. Document why a parameter is set to a specific value, not just what it is set to.
- Testing only the happy path: Automotive ECUs must behave correctly under fault conditions, voltage variations, and communication errors. Always test the error handling paths as rigorously as the nominal operation. Many production escapes originate in untested error branches.
- Version mismatches between teams: In a multi-team project, the BSW team, SWC team, and system integration team may use different versions of the same ARXML file. Version management of all ARXML files in a shared repository is mandatory, not optional.
📊 Industry Note
Engineers who master both the theoretical concepts and the practical toolchain skills covered in this course are among the most sought-after professionals in the automotive software industry. The combination of AUTOSAR standards knowledge, safety engineering understanding, and hands-on configuration experience commands premium salaries at OEMs and Tier-1 suppliers globally.