Get IP Address of DataWriter/Publisher on RTI DDS?

陌路散爱 提交于 2019-12-11 02:08:21

问题


I am using RTI DDS 5.2.3.17 and would like to get the IP address of the DataWriter/Publisher 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?


回答1:


Accessing the IP address of a DataWriter is not possible in a standardized way. However, the RTI Context implementation by default uses the IP address as part of every Entity's Globally Unique Identifier (GUID).

You can find more information about GUIDs and how to access them in the RTI Knowledge Base article Accessing the GUID of Connext DDS Entities. Normally, the IP address is captured in the first 4 bytes of the GUID, indicated by rtps_host_id in the DDS_GUID_t diagram.

You did not explain your situation in too much detail, but if you happen to have data available coming from the DataWriter, you could also leverage the SampleInfo that comes with the data. It has a field called source_guid.

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.




回答2:


The DataWriter GUID is not a reliable way to get the IP address of the DomainParticipant. More recent versions of Connext DDS no longer construct the GUID_t from the IP address or the host ID.

A right way is to look at the ParticipantBultinTopicData of the DomainParticipant that owns that DataWriter. The field default_unicast_locators contains the IP addresses of the DomainParticipant.

You can get the ParticipantBultinTopicData of the DomainParticipant that owns the DataWriter that wrote a sample from theSampleInfo. To do this call get_matched_publication_participant_data() on the DataReader passing the publication_handle that is found in the SampleInfo.

Note that the above gets you the IP addresses (Locators) of the DomainParticipant that owns the DataWriter. It is possible for a DataWriter to override those and provide a different set (normally a subset). This probably does not matter if you just want to provide logging. But if you wanted to see if the DataWriter uses a different set of Locators you can also get those from the unicast_locators field in the PublicationBuiltinTopicData which you can also get from the SampleInfo calling get_matched_publication_data().



来源:https://stackoverflow.com/questions/49610680/get-ip-address-of-datawriter-publisher-on-rti-dds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!