In short
DoIP wraps UDS in an 8-byte header and sends it over TCP port 13400. A tester finds vehicles with a UDP vehicle identification request, opens TCP, activates routing with its logical address, then sends UDS requests addressed to an ECU's logical address. The UDS bytes themselves do not change.
Best for: Engineers moving diagnostics or flashing from CAN to Ethernet, and anyone building a DoIP tester
UDS does not care how its bytes travel. On CAN, ISO-TP splits them into 8- or 64-byte frames. On Ethernet, DoIP (Diagnostics over IP, ISO 13400) puts them in TCP packets, so a large software image moves far faster than over CAN. 22 F1 90 is still 22 F1 90; what changes is the addressing and the connection set-up around it.
The 8-byte header
Every DoIP message starts with the same header:
| Bytes | Field | Notes |
|---|---|---|
| 1 | Protocol version | 0x02 for ISO 13400-2:2012, 0x03 for 2019; 0xFF in vehicle identification requests |
| 1 | Inverse protocol version | Bitwise NOT of the version, a cheap check that this is DoIP |
| 2 | Payload type | What the message is |
| 4 | Payload length | Bytes after the header |
The payload types you need:
| Type | Message | Transport |
|---|---|---|
0x0001 | Vehicle identification request | UDP |
0x0004 | Vehicle announcement / identification response | UDP |
0x0005 | Routing activation request | TCP |
0x0006 | Routing activation response | TCP |
0x0007, 0x0008 | Alive check request and response | TCP |
0x8001 | Diagnostic message (carries UDS) | TCP |
0x8002 | Diagnostic message positive acknowledgement | TCP |
0x8003 | Diagnostic message negative acknowledgement | TCP |
0x0000 | Generic header negative acknowledgement | Both |
Both UDP and TCP use port 13400; DoIP over TLS uses TCP port 3496.
import struct
DOIP_PORT = 13400
def doip(payload_type, payload=b"", version=0x02):
"""Generic DoIP header: version, inverted version, payload type, payload length."""
return struct.pack(">BBHI", version, version ^ 0xFF, payload_type, len(payload)) + payload
def parse(data):
version, inverse, payload_type, length = struct.unpack(">BBHI", data[:8])
if version ^ inverse != 0xFF:
raise ValueError("inverse version does not match")
return payload_type, data[8:8 + length]
print(doip(0x0001, version=0xFF).hex(" ")) # vehicle identification request
print(doip(0x0005, struct.pack(">HB4x", 0x0E00, 0x00)).hex(" ")) # routing activation request
print(doip(0x8001, struct.pack(">HH", 0x0E00, 0x1000) + bytes([0x22, 0xF1, 0x90])).hex(" ")) # UDS 22 F1 90
Output:
ff 00 00 01 00 00 00 00
02 fd 00 05 00 00 00 07 0e 00 00 00 00 00 00
02 fd 80 01 00 00 00 07 0e 00 10 00 22 f1 90
The last line is a complete DoIP message: header, source address 0E00, target address 1000, and the UDS request 22 F1 90.
Logical addresses
CAN diagnostics address ECUs by CAN ID. DoIP uses 2-byte logical addresses instead:
| Range | Use |
|---|---|
0x0E00–0x0FFF | External test equipment (the tester) |
0x0001–0x0DFF, 0x1000–0x7FFF | Vehicle manufacturer specific: ECUs and gateways |
A typical tester uses 0x0E00. The vehicle's DoIP edge node, usually the central gateway, owns the IP address; ECUs behind it, on CAN or Ethernet, are reached by their logical address, and the gateway translates.
Step 1: find the vehicle
A tester broadcasts a vehicle identification request over UDP. Each DoIP entity answers with its VIN, logical address, EID and GID (6 bytes each) and a "further action required" byte. Vehicles also announce themselves on their own after start-up.
import socket
def discover(broadcast="255.255.255.255", port=DOIP_PORT, timeout=1.0):
"""Send a vehicle identification request and collect the announcements: (ip, VIN, logical address)."""
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock:
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
sock.settimeout(timeout)
sock.sendto(doip(0x0001, version=0xFF), (broadcast, port))
found = []
try:
while True:
data, (ip, _) = sock.recvfrom(1024)
payload_type, body = parse(data)
if payload_type == 0x0004:
found.append((ip, body[:17].decode("ascii"), int.from_bytes(body[17:19], "big")))
except socket.timeout:
return found
Step 2: activate routing, then talk UDS
Diagnostics run over TCP. Before the edge node forwards anything, the tester sends a routing activation request with its own logical address and an activation type (0x00 default, 0x01 for WWH-OBD). Response code 0x10 means routing is active. Other codes refuse it: 0x00 unknown source address, 0x01 all sockets in use, 0x04 missing authentication, 0x06 unsupported activation type.
Then each UDS request travels as a diagnostic message: source address, target address, UDS bytes. The edge node first acknowledges it with 0x8002, then the ECU's answer comes back as another 0x8001. A 0x8003 NACK means DoIP could not deliver it: 0x03 unknown target address, 0x06 target unreachable, 0x04 message too large.
def receive(sock):
header = _exactly(sock, 8)
length = int.from_bytes(header[4:8], "big")
return parse(header + _exactly(sock, length))
def _exactly(sock, count):
data = b""
while len(data) < count:
chunk = sock.recv(count - len(data))
if not chunk:
raise ConnectionError("DoIP entity closed the connection")
data += chunk
return data
def uds_request(ip, ecu_address, request, tester=0x0E00, port=DOIP_PORT):
"""Activate routing, send one UDS request and return the UDS response bytes."""
with socket.create_connection((ip, port), timeout=2) as sock:
sock.sendall(doip(0x0005, struct.pack(">HB4x", tester, 0x00)))
payload_type, body = receive(sock)
if payload_type != 0x0006 or body[4] != 0x10:
raise RuntimeError(f"routing activation refused: {body.hex(' ')}")
sock.sendall(doip(0x8001, struct.pack(">HH", tester, ecu_address) + request))
while True:
payload_type, body = receive(sock)
if payload_type == 0x8003:
raise RuntimeError(f"diagnostic message NACK, code 0x{body[4]:02X}")
if payload_type == 0x8001:
response = body[4:]
if response[:1] == b"\x7f" and response[2:3] == b"\x78":
continue # response pending
return response
# 0x8002: positive ACK from the DoIP entity; the UDS answer follows
for ip, vin, address in discover():
print(f"{ip} VIN {vin} logical address 0x{address:04X}")
print(uds_request(ip, address, bytes([0x22, 0xF1, 0x90])).hex(" "))
Output from a test run against a simulated DoIP entity on localhost, which first answers 7F 22 78 (response pending) and then the VIN:
127.0.0.1 VIN WVWZZZ1JZXW000001 logical address 0x1000
62 f1 90 57 56 57 5a 5a 5a 31 4a 5a 58 57 30 30 30 30 30 31
The UDS response is the same 62 F1 90 + VIN that the UDS over CAN guide gets over ISO-TP. Everything you know about UDS sessions, security access, DTCs and flashing carries over unchanged.
Ready-made library
For more than a few requests, use python-doipclient. It handles discovery, routing activation, alive checks and TLS:
from doipclient import DoIPClient
address, announcement = DoIPClient.await_vehicle_announcement()
client = DoIPClient(address[0], announcement.logical_address)
print(client.request_entity_status())
Its DoIPClientUDSConnector plugs the connection into the udsoncan library, so the same UDS client code works over CAN and DoIP. Its default tester address is 0x0E00 and its default protocol version is 0x02.
Connecting to a vehicle
Inside the vehicle, automotive Ethernet uses single-pair physical layers such as 100BASE-T1, which a laptop cannot plug into directly. At the OBD-II connector, ISO 13400 defines a separate pin-out for standard 100BASE-TX Ethernet. The common layout uses pins 3 and 11 for one pair, 12 and 13 for the other, and pin 8 as the activation line: the tester applies a voltage to pin 8 to tell the vehicle to switch its Ethernet diagnostic port on. Without that, the port stays silent. Then:
- Connect with a DoIP cable or adapter that drives pin 8.
- Get an IP address. Some vehicles run DHCP; others need a static address in their subnet, which you can find by watching for the vehicle announcement in Wireshark.
- Send the vehicle identification request, or wait for the announcement.
- Open TCP 13400 and activate routing.
Wireshark decodes DoIP and the UDS inside it, which makes it the first tool to open when something does not answer.
Frequently asked questions
What is DoIP in automotive?
Diagnostics over Internet Protocol, standardised in ISO 13400. It carries UDS requests and responses over TCP/IP instead of CAN, using an 8-byte header, logical addresses for ECUs, and port 13400.
What port does DoIP use?
13400, for both UDP (vehicle discovery) and TCP (diagnostic messages). DoIP secured with TLS uses TCP port 3496.
What is routing activation in DoIP?
The first message a tester sends on a new TCP connection. It registers the tester's logical address with the vehicle's DoIP edge node. Only after a response with code 0x10 does the node forward diagnostic messages to ECUs.
Is UDS over DoIP different from UDS over CAN?
The UDS services and bytes are identical. Only the transport changes: DoIP addresses ECUs with logical addresses and sends whole messages over TCP, where CAN uses CAN IDs and ISO-TP segmentation.
References
DBC Utility
One desktop app for DBC files and CAN recordings.
One-time $34 · Windows & Linux · Files stay on your computer