What is the purpose of the different GUID and Sequence_Number fields in DDS_SampleInfo?

The DDS_SampleInfo associated with each sample contains the fields original_publication_virtual_guid and original_publication_virtual_sequence_number. This pair forms the SampleIdentity which uniquely identifies each individual sample. When a DataWriter uses write_w_params(), it can explicitly set the identity field contained in the DDS_WriteParams_t structure. This is useful when a DataWriter wants to send data as if it was a different one, i.e., when relaying data in an intermediate service. This is why these values are “virtual”: because the sample may be relayed by intermediate services.

Infrastructure services like RTI Persistence Service and RTI Routing Service use the fields source_guid and publication_sequence_number to identify their endpoints, and the fields original_publication_virtual_guid and original_publication_virtual_sequence_number to identify the Publisher author of the sample. In this case, the GUID/sequence_number of the DataWriter that physically writes the sample is different from the GUID/sequence_number of its original source. Persistence Service does it by default and Routing Service can be configured to do it by setting <publish_with_original_info> to true. Both identities are preserved so any application can access the physical as well as the virtual identity for any sample.

The fields source_guid and related_source_guid are used on a request/reply scenario in which a reply has to be sent only to the Requester that issued the related request. In this case, the Requester's DataWriter will send a request setting the source_guid to an unique value. This value must be the same value even after the Requester restarts. The Replier's DataReader will get the request's source_guid from the DDS_SampleInfo and it will send it as the related_source_guid of the reply using the Replier's DataWriter. This is handled internally by DDS and the application doesn’t have to take care of it.

The DDS_SampleInfo GUID fields source_guid, related_source_guid, and related_subscription_guid map to the DDS_WriteParams_t fields source_guid, related_source_guid and related_reader_guid. The values of each of them can be set in the application.

The original_publication_virtual_guid field is accessible either via QoS or within the application. Any value set in the application overrides the QoS.

The related_original_publication_virtual_guid field is not exposed in the DataWriter.