What is RTPS?
RTPS (Real-Time Publish Subscribe) is the wire protocol that enables DDS implementations to communicate with each other. Defined by OMG, it specifies exactly how messages are formatted and exchanged over the network.
Why RTPS Matters
RTPS is what makes DDS interoperable. Any compliant DDS implementation (HDDS, FastDDS, CycloneDDS, ...) can communicate if they speak the same RTPS version.
RTPS Versions
The years are those of the revision task forces listed in the specification's acknowledgments (DDSI-RTPS 2.5, section 6.3):
| Version | Year |
|---|---|
| 2.0 | 2007 |
| 2.1 | 2008 |
| 2.2 | 2014 |
| 2.3 | 2019 |
| 2.4 | no document revision (the number was skipped) |
| 2.5 | 2020 (published as formal/2022-04-01) |
HDDS announces RTPS 2.4 on the wire and accepts any 2.x peer; behaviour defined by later revisions of the specification (for example the KeyHash rules of 2.5) is implemented where it is needed for interoperability.
Protocol Architecture
Message Structure
Every RTPS message consists of:
+--------------------------------------------------------+
| RTPS Header |
| +----------+----------+----------+-----------------+ |
| | Protocol | Version | Vendor | GuidPrefix | |
| | "RTPS" | 2.4 | HDDS | 12 bytes | |
| +----------+----------+----------+-----------------+ |
+--------------------------------------------------------+
| Submessages |
| +------------------------------------------------+ |
| | Submessage 1 (e.g., DATA) | |
| +------------------------------------------------+ |
| +------------------------------------------------+ |
| | Submessage 2 (e.g., HEARTBEAT) | |
| +------------------------------------------------+ |
| ... |
+--------------------------------------------------------+
Submessage Types
| Submessage | Purpose |
|---|---|
| DATA | Carries user data samples |
| DATA_FRAG | Fragmented data for large samples |
| HEARTBEAT | Announces available sequence numbers |
| ACKNACK | Acknowledges/requests data |
| GAP | Indicates missing sequence numbers |
| INFO_TS | Provides timestamp information |
| INFO_DST | Specifies destination participant |
| INFO_SRC | Specifies source participant |
Discovery Protocol
RTPS defines two discovery protocols:
SPDP (Simple Participant Discovery Protocol)
Discovers other participants in the domain:
- Each participant sends periodic announcements to a well-known multicast address
- Announcements include participant GUID, endpoints, and locators
- Other participants learn about new joiners
SEDP (Simple Endpoint Discovery Protocol)
Discovers endpoints (writers and readers):
- After participant discovery, endpoints are exchanged via unicast
- Each participant learns about remote writers/readers
- Matching (compatible QoS) writers and readers connect
Port Mapping
RTPS uses a deterministic port mapping based on domain ID:
Discovery Multicast Port = 7400 + (250 x domainId)
Discovery Unicast Port = 7410 + (250 x domainId) + (2 x participantId)
User Multicast Port = 7401 + (250 x domainId)
User Unicast Port = 7411 + (250 x domainId) + (2 x participantId)
Example for Domain 0, Participant 0:
| Port Type | Port Number |
|---|---|
| Discovery Multicast | 7400 |
| Discovery Unicast | 7410 |
| User Multicast | 7401 |
| User Unicast | 7411 |
Domain D uses the UDP ports from 7400 + 250 x D to 7649 + 250 x D: 7400-7649 for domain 0, 17900-18149 for domain 42, the domain most Hello World tutorials use. The port table in the Linux guide lists each port.
Data Serialization (CDR)
RTPS uses CDR2 (Common Data Representation) for serialization:
- Platform-independent - Works across different CPU architectures
- Self-describing - Optional type information included
- Efficient - Minimal overhead compared to JSON/XML
CDR2 Serialization of Temperature { sensor_id: "room1", value: 23.5 }
+---------+---------+---------+---------+---------+---------+---------+---------+
| 0x06 | 0x00 | 0x00 | 0x00 | 'r' | 'o' | 'o' | 'm' |
+---------+---------+---------+---------+---------+---------+---------+---------+
| '1' | 0x00 | padding | padding | 0x00 | 0x00 | 0xBC | 0x41 |
+---------+---------+---------+---------+---------+---------+---------+---------+
+- string length -+ +-- "room1" + null --+ +-- 23.5 as f32 (LE) --+
Reliability Protocol
RTPS implements reliability through:
Best-Effort
- Fire and forget
- No acknowledgments
- Lowest latency
Reliable
- HEARTBEAT announces available samples
- ACKNACK requests missing samples
- Retransmission ensures delivery
RTPS vs Other Protocols
| Feature | RTPS | MQTT | AMQP | ZeroMQ |
|---|---|---|---|---|
| Broker | None | Required | Required | Optional |
| Multicast | Yes | No | No | Yes |
| QoS | Rich (22 policies) | 3 levels | Basic | None |
| Discovery | Automatic | Manual | Manual | Manual |
| Real-time | Yes | No | No | Partial |
| Standard | OMG | OASIS | OASIS | None |
Debugging RTPS
Using Wireshark
Wireshark has a built-in RTPS dissector:
- Capture traffic on the UDP ports of your domain (
7400 + 250 x Dto7649 + 250 x D) - Filter:
rtps - Inspect individual submessages
Using hdds_viewer
Our hdds_viewer tool provides:
- Live RTPS traffic capture
- Message decoding with type information
- Topology visualization
- Latency analysis
Next Steps
Now you understand how DDS works under the hood. Let's get HDDS installed:
- Installation Guide - Get HDDS on your system