Now when a sample is received, the SampleInfo_t contains a referece to the DataWriter that sent the sample. This reference is encoded in the SampleInfo_t.publication_handle. With the publication_handle you can get the information on the DataWriter that wrote the data by calling the operation get_matched_publication_data on the DataReader which accepts the SampleInfo_t.ublication_handle and fills a PublicationBuiltinTopicData with that informaton. There you can fiend the GUID of the participant that wrote the sample in the field PublicationBuiltinTopicData.participant_key.
Therefore one possible approch is to save the information on the locators of the discovered participants associating the information with the Participant GUID. Then when a sample is received you use the InstanceHandle_t to get to the GUID as shown in the Java pseudo-code below:
dataReader.take_next_sample(data, info);
System.out.println("Receive data from DataWriter...");
dataReader.get_matched_publication_data(publicationData, info.publication_handle);
// publicationData.participant_key contains GUID of the Participant that wrote the sample
// Locate the Participant using publicationData.participant_key and access its locators
Yes, this is possible. But it requires a few steps which I describe below.
The IP address, in fact all the addresses that can be used to reach a DDS DomainParticipant are propagated by the DomainParticipant itself via discovery and available in in the ParticipantBuiltinTopicData which can be accessed reading the "DCPSParticipants" builtin Topic as described in the HOWTO tiltled "Detect the presence of DomainParticipants, DataWriters and DataReaders in the DDS Domain".
Each discovered participant is uniquely identified via a GUID which is available in the field
ParticipantBuiltinTopicData.key
. The IP address(es) of the DomainParticipant can be found inParticipantBuiltinTopicData.metatraffic_unicast_locators
.Now when a sample is received, the
SampleInfo_t
contains a referece to theDataWriter
that sent the sample. This reference is encoded in theSampleInfo_t.publication_handle
. With thepublication_handle
you can get the information on theDataWriter
that wrote the data by calling the operationget_matched_publication_data
on theDataReader
which accepts theSampleInfo_t.ublication_handle
and fills aPublicationBuiltinTopicData
with that informaton. There you can fiend the GUID of the participant that wrote the sample in the fieldPublicationBuiltinTopicData.participant_key
.Therefore one possible approch is to save the information on the locators of the discovered participants associating the information with the Participant GUID. Then when a sample is received you use the InstanceHandle_t to get to the GUID as shown in the Java pseudo-code below:
I uploaded to the File Exchange an example of how to do this in Java. It is the file MonitorInformationOnSampleWriter.java.
Gerardo
Thank you once again Gerado for a very detailed answer!
can you provide code snippet for the same in rti6 in c++
Updated Link:
Detect the presence of DomainParticipants, DataWriters and DataReaders in the DDS Domain
https://community.rti.com/howto/detect-presence-domainparticipants-datawriters-and-datareaders-dds-domain