Search code examples
ippublish-subscribedatareaderdata-distribution-service

Get IP Address of DataReader/Subscriber on RTI DDS?


I am using RTI DDS 5.2.3.17 and would like to get the IP address of the remote DataReader/Subscriber that I am sending messages to, to add to some log messages.

How would I go about doing this I am having some trouble in just forming the logic of what to do?


Solution

  • The mechanism described for your question here, using the SampleInfo, will not work for obtaining the IP address of DataReaders

    Depending on the situation, the easiest approach would probably be to install a listener on your DataWriter and inspect the last_subscription_handle parameter when the DataWriterListener’s on_publication_matched() callback is invoked. As explained in the RTI Knowledge Base article Accessing the GUID of Connext DDS Entities, the instance handle is essentially another GUID for you to inspect.

    If you have many readers that you need to keep track of, it might be easier to subscribe to the BuiltinTopics used for discovery, as explained in that same KB article. That is more work though.

    Again, all of this is assuming you are looking for the IPv4 address. Also note that this is not a publicly exposed mechanism, so things might change in the future. And all of this breaks at the moment that your application explicitly sets its GUID.