Skip to content

Commit da3667f

Browse files
transport updates
1 parent fc30aee commit da3667f

2 files changed

Lines changed: 118 additions & 1 deletion

File tree

specification/transport/can/can.tex

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,53 @@ \subsection{CAN ID field}
255255
client if request, server if response. \\
256256
\end{CyphalSimpleTable}
257257

258+
\subsubsection{Format selection}\label{sec:transport_can_format_selection}
259+
260+
The two message formats differ not only in the CAN ID bit layout but also in the payload carried on the wire.
261+
The v1.1 16-bit format carries a full session-layer message including its session-layer header;
262+
the v1.0 legacy 13-bit format carries only the raw application payload without any session-layer wrapping,
263+
which is what makes it wire-compatible with Cyphal/CAN v1.0 nodes that predate the session layer.
264+
265+
A sender shall use the v1.0 legacy 13-bit format for a message transfer if and only if both of the following hold:
266+
(a) the subject-ID lies in the pinned range $[0, 8191]$, and
267+
(b) the message is a best-effort publication.
268+
In all other cases -- auto-allocated subject-IDs, the broadcast subject, gossip shards, reliable messages,
269+
gossip messages, service discovery, and RPC -- the sender shall use the v1.1 16-bit format.
270+
271+
When transmitting on a pinned subject using the 13-bit format, the sender shall strip the session-layer
272+
header from the outgoing message before enqueuing the frame, so that only the raw application payload
273+
appears on the wire. This is what makes a 13-bit frame parseable by Cyphal/CAN v1.0 nodes,
274+
which are unaware of the session layer.
275+
276+
When receiving a 13-bit-format frame on a subscribed pinned subject, the receiver shall reconstruct a
277+
session-layer header consistent with the matching pinned topic and prepend it to the received payload
278+
before forwarding the message to the session layer. The reconstructed header shall declare the message as
279+
best-effort and shall carry a message tag drawn from a monotonically increasing per-subscription counter,
280+
so that session-layer duplicate suppression continues to function.
281+
The reconstructed message shall be otherwise indistinguishable from an equivalent message originated by
282+
a v1.1 node on the same pinned topic.
283+
284+
\begin{remark}
285+
This rule confines every v1.1-specific feature to the 16-bit format, which v1.0 receivers unconditionally
286+
discard at the bit~7 check. A message reaching a v1.0 receiver is therefore always in a form that the
287+
receiver can parse: a plain application payload on a pinned subject-ID.
288+
\end{remark}
289+
290+
\subsubsection{Unicast transfers}\label{sec:transport_can_unicast}
291+
292+
Cyphal/CAN does not define a dedicated CAN ID layout for unicast delivery.
293+
A unicast transfer shall be represented as an RPC-service \emph{request} to the reserved service-ID $511$
294+
addressed to the destination node.
295+
The session layer treats service-ID $511$ as an opaque unicast channel;
296+
no service response is issued at the transport layer, and higher-layer reply semantics, if any,
297+
are carried in subsequent unicast requests in the opposite direction.
298+
299+
The sender shall maintain a $128$-element array of transfer-ID counters indexed by the destination node-ID,
300+
and increment the entry corresponding to the destination of each outgoing unicast transfer.
301+
This ensures that the receiver observes a monotonic transfer-ID stream on every $(\text{source}, \text{destination})$
302+
pair, so that the standard transfer-ID timeout check
303+
(section~\ref{sec:transport_can_transfer_id_timeout}) applies without modification.
304+
258305
\subsubsection{Transfer priority}
259306

260307
Valid values for transfer priority range from 0 to 7, inclusively,
@@ -421,6 +468,33 @@ \subsubsection{Transfer CRC}\label{sec:transport_can_transfer_crc}
421468
The transfer CRC function is \textbf{CRC-16/CCITT-FALSE}:
422469
polynomial $0x1021$, initial value $0xFFFF$, no input or output reflection, no final XOR.
423470

471+
\subsubsection{Transfer-ID timeout}\label{sec:transport_can_transfer_id_timeout}
472+
473+
The \emph{transfer-ID timeout} governs the duration over which a receiver retains the last-admitted
474+
transfer-ID of a reassembly session for duplicate suppression. A start-of-transfer frame whose transfer-ID
475+
matches the last-admitted value within the timeout window is discarded as a duplicate;
476+
after the timeout elapses, the next admission is accepted unconditionally.
477+
The recommended default value is $2$ seconds.
478+
479+
The timeout applies to the following session kinds:
480+
\begin{itemize}
481+
\item Message (subject) sessions, in both the v1.1 16-bit and the v1.0 legacy 13-bit formats.
482+
\item Service request sessions, including the unicast channel defined in
483+
section~\ref{sec:transport_can_unicast}.
484+
\end{itemize}
485+
486+
A transfer-ID timeout of \emph{zero} shall be used for service \emph{response} sessions.
487+
The transfer-ID of a service response is not generated by the server -- it is echoed from the request being
488+
answered. Because the transfer-ID field is only five bits wide, the client may legitimately re-use the same
489+
transfer-ID value for two different requests to the same server within a short interval as its counter wraps;
490+
with a nonzero timeout, the later matching response would be rejected as a duplicate of the earlier one.
491+
Setting the timeout to zero disables transport-level duplicate suppression on response sessions,
492+
leaving the receiving application to correlate responses with outstanding requests by other
493+
means\footnote{%
494+
See \href{https://github.com/OpenCyphal/libcanard/issues/247}{OpenCyphal/libcanard issue~247}
495+
for the original discussion.
496+
}.
497+
424498
\subsection{Examples}
425499

426500
\begin{remark}[breakable]

specification/transport/transport.tex

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,26 @@ \chapter{Transport layer}\label{sec:transport}
22

33
\section{Function}
44

5-
TODO: DEFINE THE CORE TRANSPORT CONTRACT PER cy.
5+
A Cyphal \emph{transport} provides unreliable, unordered, deduplicated delivery of integrity-checked messages
6+
between Cyphal nodes. A message is either delivered intact or not delivered at all; the transport performs
7+
neither retransmission nor ordering recovery. Reliable delivery, ordering, and session semantics, where required,
8+
are provided by higher layers on top of this minimal contract.
9+
10+
A transport shall provide two delivery modes:
11+
\begin{description}
12+
\item[Multicast] Delivery to the group of subscribers on a \emph{subject}, identified by a numerical
13+
\emph{subject-ID}\footnote{In IP networks this analogous to multicast groups.}.
14+
\item[Unicast] Delivery to a single \emph{remote node}, identified by its \emph{node-ID}.
15+
\end{description}
16+
17+
Messages may be of arbitrary size not larger than 4 gibibytes.
18+
A transport shall perform segmentation and reassembly transparently to the higher layers,
19+
so that a received message is always delivered as a single unit.
20+
A transport may offer redundant interfaces for fault tolerance, with transparent failover,
21+
which is invisible to the higher layers.
22+
23+
Participant discovery is provided implicitly as a side effect of joining the broadcast subject defined in
24+
section~\ref{sec:transport_subject_id_ranges}; no separate discovery protocol is required.
625

726
\section{Definitions}
827

@@ -150,5 +169,29 @@ \subsection{Redundancy}
150169
Specific examples include time synchronization algorithms or diagnostic probes.
151170
}.
152171

172+
\subsection{Subject-ID ranges}\label{sec:transport_subject_id_ranges}
173+
174+
Subject-ID values range from zero up to a transport-specific maximum and are partitioned as follows:
175+
176+
\begin{description}
177+
\item[{$[0,\, 8191]$ -- pinned subjects}] Statically-assigned subject-IDs.
178+
This range is the only one used by Cyphal/CAN v1.0 and is retained as the primary path for interoperation
179+
with v1.0 nodes.
180+
181+
\item[{$[8192,\, 8191{+}M]$ -- auto-allocated subjects}] Subject-IDs assigned dynamically by the session layer,
182+
where $M$ is a transport-specific prime \emph{modulus} satisfying $M \bmod 4 = 3$.
183+
184+
\item[Maximum value -- broadcast subject] Used by the session layer for low-rate broadcast traffic such as
185+
topic allocation gossip and service discovery scouts.
186+
187+
\item[Remaining values -- gossip shards] Subject-IDs strictly between $(8191{+}M)$ and the broadcast subject
188+
are used as sharded subjects for background gossip propagation.
189+
\end{description}
190+
191+
On the broadcast subject and on the gossip shard subjects, the transport is permitted to relax two requirements:
192+
(a) deduplication is not mandatory, and (b) support for messages exceeding a single transport frame is not required.
193+
The session layer tolerates occasional duplication on these subjects and constrains its own protocol messages
194+
to fit within a single transport frame.
195+
153196
% Please keep \clearpage in front of every section to enforce clear separation!
154197
\clearpage\input{transport/can/can.tex}

0 commit comments

Comments
 (0)