Home Learning Paths ECU Lab Assessments Interview Preparation Arena Pricing Log In Sign Up

DoIP: ISO 13400-2 Diagnostics over Internet Protocol

AttributeValueNotes
StandardISO 13400-2:2019DoIP replaces ISO 15765-2 (CAN TP) for Ethernet ECUs
TransportUDP (discovery) + TCP (data)UDP port 13400 for VIN/entity discovery; TCP port 13400 for UDS tunnelling
TLSTLS 1.3 mandatory for remote accessIn-vehicle (bench) can use plaintext; remote OTA/offboard MUST be TLS encrypted
ECU addressingLogical address (2 bytes)e.g., 0x0001 = ECU 1; 0xE000 = tester; carried in DoIP header
Max UDS payloadLimited by TCP MTUEffectively unlimited; no 4095-byte CAN TP restriction
Bandwidth vs CAN100 Mbit/s vs 0.5 Mbit/s200× faster for flash reprogramming; multi-ECU parallel flash possible

DoIP Transport: UDP Discovery + TCP Data

DoIP Connection Flow
  Phase 1: UDP Vehicle Discovery (optional; for tester to find ECU IP)
  Tester                              ECU (DoIP Gateway)
    │── UDP bcast/mcast 13400 ──────►│ VehicleIdentificationRequest
    │◄── UDP unicast 13400 ──────────│ VehicleIdentificationResponse
    │                                 │  (VIN, EID, GID, IP address)

  Phase 2: TCP Connection + Routing Activation (mandatory)
  Tester                              ECU
    │── TCP SYN → port 13400 ────────►│ TCP connection
    │◄── TCP SYN-ACK ────────────────│
    │── RoutingActivationRequest ────►│ (SA=tester logical addr, type=0x00)
    │◄── RoutingActivationResponse ──│ (0x10=success; 0x11=denied)

  Phase 3: UDS Tunnelled over DoIP
  Tester                              ECU
    │── DoIP DiagnosticMessage ──────►│ SA=0xE000 TA=0x0001 UDS=[0x22 0xF1 0x90]
    │◄── DoIP DiagnosticMessageAck ──│ (acknowledgement; not UDS response)
    │◄── DoIP DiagnosticMessage ─────│ SA=0x0001 TA=0xE000 UDS=[0x62 0xF1 0x90 VIN...]

  TCP keepalive: tester sends DoIP 0x0006 (Alive Check) every 500ms
  Idle timeout: ECU closes TCP connection after 5 s without activity

UDS over DoIP: Header Format

Pythondoip_frame.py
import struct

# DoIP Generic Header: 8 bytes
# Version(1) + InvVersion(1) + PayloadType(2) + PayloadLength(4)
DOIP_VERSION = 0x02   # ISO 13400-2:2019

PAYLOAD_TYPES = {
    0x0001: "VehicleIdentificationRequest",
    0x0004: "VehicleIdentificationResponse",
    0x0005: "RoutingActivationRequest",
    0x0006: "RoutingActivationResponse",
    0x8001: "DiagnosticMessage",
    0x8002: "DiagnosticMessagePositiveAck",
    0x8003: "DiagnosticMessageNegativeAck",
}

def build_doip_header(payload_type: int, payload: bytes) -> bytes:
    version = DOIP_VERSION
    inv_version = version ^ 0xFF
    return struct.pack(">BBHI", version, inv_version, payload_type, len(payload))

def build_routing_activation_request(source_addr: int) -> bytes:
    payload = struct.pack(">HBL", source_addr, 0x00, 0)  # SA, type=default, reserved
    return build_doip_header(0x0005, payload) + payload

def build_diagnostic_message(src_addr: int, tgt_addr: int, uds_data: bytes) -> bytes:
    payload = struct.pack(">HH", src_addr, tgt_addr) + uds_data
    return build_doip_header(0x8001, payload) + payload

# Example: send UDS ReadDataByIdentifier 0x22 for VIN (DID 0xF190)
routing_act = build_routing_activation_request(0xE000)   # tester SA
uds_request = bytes([0x22, 0xF1, 0x90])                  # 0x22 = RDBI, DID=0xF190
diag_msg    = build_diagnostic_message(0xE000, 0x0001, uds_request)

print(f"Routing activation: {routing_act.hex()}")
print(f"Diagnostic message: {diag_msg.hex()}")

Summary

DoIP tunnels UDS payloads over TCP, providing the same diagnostic functionality as CAN-based ISO 15765-2 but at 100–1000× the bandwidth. The most impactful use case is flash reprogramming: a 50 MB ECU firmware update takes ~15 minutes over CAN (500 kbit/s), ~5 seconds over 100BASE-T1 DoIP. The routing activation step is mandatory before any UDS requests — without it, the ECU's DoIP entity rejects all DiagnosticMessage frames with negative acknowledgement code 0x06 (unknown source address). TLS 1.3 is mandatory for any remote (offboard) diagnostic session per ISO 21434 cybersecurity requirements.

🔬 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

  1. 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'.
  2. 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.
  3. 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.
  4. 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.

← PreviousHands-On: SOME/IP Service ImplementationNext →Vehicle Identification & DoIP Routing