Architecture¶
How the six crates of the stack fit together: what each one owns, what it must not acquire, the seams between them, and who owns each timer. Each crate’s own design is described separately, under Each crate’s architecture.
A table, figure, clause or requirement cited on this page always names its document and edition.
The organising idea¶
ISO 14229 is not one standard but a series, and it is already layered. The stack follows
that series with one crate per document, so “does this belong here?” is answered by
asking which document specifies the behaviour. ISO 14229-1 is the one exception: it is
split into its wire format, uds_protocol, and its application behaviour,
uds_services.
The result is reuse. A session layer that reads no clock and calls no transport serves CAN, DoIP, K-line and simulation alike; a service dispatcher that knows how to fetch a data identifier has nothing to say about IP. Only the crates that name a transport are bound to one.
The stack today. Solid edges are calls; dashed edges are the message
vocabulary, which uds_services and uds_on_ip read messages with.¶
The crates¶
Crate |
Standard |
Owns |
|---|---|---|
|
ISO 14229-1:2020 clauses 7 and 10 to 15 |
The encoding and decoding of every diagnostic service message. |
|
ISO 14229-2:2021 |
The session layer: the |
|
ISO 14229-1:2020, everything but the message format |
The point where an application meets the stack: per-service handler traits, the dispatch and negative-response rules of ISO 14229-1:2020 clause 8.7, the typed client calls and the client’s timing policy, and the driver that holds the session layer and calls a transport. |
|
ISO 14229-5:2022 |
The UDSonIP binding: the |
|
ISO 13400-2:2019 |
DoIP: framing, the TCP and UDP sockets, routing activation, alive check, vehicle
identification and the |
|
none: the C ABI of |
A server for firmware written in C: an application serving every staged service
from layers of C tables and handlers, the record and operation-status protocols
those handlers answer through, |
Each also has something it must not acquire, and that is the more useful half:
uds_protocolstays a codec: no dispatch, no policy, no session state.uds_sessionnever learns which transport it runs over, and never reads a clock. ISO 14229-2:2021 9.1.2 splitstP_Client’s reload parameters four ways by whether the transport offersT_DataSOM.ind; the session layer holds a default and an enhanced pair, and its caller decides which values those are.uds_servicesdeclares the transport seam and implements no transport. Nothing on that seam is DoIP-shaped, so a CAN binding implements the same methods.uds_on_ipnever learns what a service is. It reads three things of a message: whether a positive response answersDiagnosticSessionControlorECUReset, a request’s suppressPosRspMsgIndicationBit, and the response-pending negative response. Those are ISO 14229-5:2022 clause 8 and transport rules keyed on a service, not service semantics.simple_doipnever learns what a UDS message means. A diagnostic message’s payload is an opaque byte string to it.uds_cnever implements a standard. Every rule it serves by is a protocol crate’s: it states the firmware’s tables through the service traits ofuds_servicesand carries the firmware’s sockets undersimple_doip’s entity, and decides only what the C contract leaves to it.
automotive-wire-codec, outside this repository, provides the zero-copy no_std codec
traits uds_protocol, simple_doip and uds_services are built on.
The six crates release in lockstep to crates.io: one version for the stack, published bottom-up in dependency order.
When and what¶
Several questions about where a behaviour belongs have the same answer:
ISO 14229-5 decides *when*. ISO 13400-2 performs *what*.
Reconnect and repeat routing activation (ISO 14229-5:2022 REQ 7.8, REQ 7.10): before diagnostic communication continues,
uds_on_ipsequences it andsimple_doipperforms it. The routing activation request is ISO 13400-2’s, and a tester sends it, so only a tester reconnects.Close after a positive response (ISO 14229-5:2022 REQ 7.9, REQ 7.11):
uds_on_ipdecides andsimple_doipcloses. Closing a TCP connection is an ISO 13400-2 mechanism; the rule that a close follows this particular response is ISO 14229-5’s. REQ 7.11’s close follows every positiveECUResetresponse; REQ 7.9’s follows a positiveDiagnosticSessionControlresponse only where the server leaves the software it is running. That fact is the server’s own, souds_servicesstates it anduds_on_ipdecides what follows.Periodic responses (ISO 14229-5:2022 REQ 7.7, REQ 7.16): payload type
0x8004, which ISO 13400-2:2019 does not define, souds_on_ipinterprets it andsimple_doipcarries it unread. A tester built onuds_on_ipreceives one. A server cannot yet send one: neitherUdsTransportnorDiagnosticEntitylets a sender choose a payload type.
The rule also says what must not happen. uds_services never decides when a connection
closes, because knowing that ISO 14229-5:2022 REQ 7.9 or REQ 7.11 requires a close is
ISO 14229-5 knowledge. simple_doip never recognises a service identifier to decide for
itself. A crate that must know whether to act has acquired the requirement, whether or
not it also performs it.
The seams¶
A seam is declared by the crate that calls through it, so the implementor depends on the declarer and a caller never depends on its callee’s choice of binding. The connection seam is the one exception.
Transport seam: ``uds_services`` to a binding. uds_services declares
UdsTransport and TransportEvent; uds_on_ip implements them over DoIP. An event
borrows the driver’s buffer, never the transport, so a server can answer the request it
has just received. ClientTransport adds close for the client role alone; a server
is reconnected to and never reconnects, so the seam carries no reconnect.
Connection seam: ``uds_on_ip`` to ``simple_doip``. The sockets are ISO 13400-2’s, so
simple_doip::service declares this seam, with no I/O in it: DiagnosticEntity, a
whole entity behind one event stream, for a server; for a client,
DiagnosticConnection, one connection as a tester uses it, and TesterConnection,
one it can also replace (reconnect) and end (close). This seam is declared by the
callee, because uds_on_ip already consumes simple_doip’s addressing and the edge
cannot run the other way.
``uds_session`` is vocabulary, not a seam. uds_on_ip names uds_session’s
addressing, SResult, Timestamp and Reloads, and calls none of its behaviour.
uds_services holds the session layer by value, supplies its inputs and drains its
actions.
The seams in detail, and the design of the two bindings, are in each crate’s architecture.
Timing ownership¶
Every timer has one owner, the crate that runs it. Where its value is policy rather than a fixed parameter, the table also says who sets it.
Timer |
Owner |
Values, and notes |
|---|---|---|
|
|
One per logical channel, physical and functional alike (ISO 14229-2:2021 REQ 5.26,
Table 7). Starts on |
|
|
One per physical and per functional channel (ISO 14229-2:2021 REQ 5.26, Table 7).
The minimum spacing before the next request when none is required.
|
|
|
One |
|
|
Session timers, kept with the others rather than with the service that is slow. The session layer reports their expiry and does not answer it; see below. |
|
|
ISO 14229-2:2021 types it a performance requirement on the server’s application, not a timer to run. |
Request repeats |
|
ISO 14229-2:2021 9.7 Table 9 has the client repeat a request whose response window
expired or whose transmission failed, at most twice. |
Response-pending extensions |
|
|
|
|
How long a tester waits for a request’s acknowledgement (ISO 13400-2:2019
Table 12), set with |
Connect and routing activation |
|
|
DoIP connection and announcement timers |
|
|
Who sends response-pending. A server that will not answer within tP2_Server sends a
response-pending negative response before it expires, which gives it tP2*_Server.
uds_session runs the timer and reports the coming expiry as an overrun, ahead of it by
the lead of UDSS_LLR_0186; ISO 14229-2:2021 states no session layer action, so the
session layer sends nothing itself. uds_services runs the handler alongside the event
loop, so the report arrives while the handler works; it decides whether a
response-pending is admissible, builds it and submits it through the session layer.
uds_on_ip sends it like any other T_Data.req.
Standards and crates¶
The standards’ layers and the crate boundaries do not line up one-to-one:
ISO 14229-1:2020 is two crates:
uds_protocolis its wire format, anduds_serviceseverything else in it.ISO 14229-5:2022 specifies an application profile above the session layer and a transport mapping below it.
uds_on_ipimplements both, and sits wholly below the session layer in the call order.The session layer’s service user is the ISO 14229-1 layer, which is
uds_services; that crate is also the driver that supplies the session layer’s time and drains its outputs.
The Cargo graph follows the seams rather than either picture. uds_on_ip depends on
uds_services, whose seam it implements, while uds_services calls it, and no crate
names a binding. The graph therefore has no cycle and needs no feature gate to avoid one.
Cargo dependencies. An arrow points from a crate to a crate that depends on
it, so left to right is publication order. Every edge is unconditional, and
uds_c is the one leaf.¶
What a transport swap replaces¶
A binding is not a layer swapped within the stack. It is a complete path from A_Data
to the wire, attached below the shared driver, so swapping replaces the binding together
with its transport while the driver, session, message and service crates stay. For
application code the swap point is the transport = parameter of uds_services’
uds_server! and uds_client! macros.
The DoIP binding as built, and a CAN binding as it would attach (dashed).¶
The diagnostic conversation is portable; connection setup is not. DoIP has TCP
connections, routing activation, vehicle identification and alive check, and CAN has none
of them, so establishing the link is the application’s, through the binding’s own API.
uds_on_can and an ISO 15765-2 crate do not exist; they show where one would attach.
Each crate’s architecture¶
Crate |
Where its design is described |
|---|---|
|
|
|
|
|
|
|
Requirements, and its README |
|
its README |
|
its README and crate documentation, and |