TransportMulticastMappingQoS Programmatically

4 posts / 0 new
Last post
Offline
Last seen: 5 years 11 months ago
Joined: 01/07/2015
Posts: 5
TransportMulticastMappingQoS Programmatically

Hi,

I need to create a DomaniParticipant with TransportMulticastMappingQoS set programmaticaly (C++), but unfortunately I've found no such code in RTI examples area.

According to Users Manual, I shoud fill a DDS_TransportMulticastMappingQosPolicy struct which is defined in dds_c_infrastructure.h like:

struct DDS_TransportMulticastMappingQosPolicy {
    /*e \dref_TransportMulticastMappingQosPolicy_value
     */
    struct DDS_TransportMulticastMappingSeq value;

    DDSCPP_VARIABLE_LENGTH_VALUE_TYPE_SUPPORT(DDS_TransportMulticastMappingQosPolicy)
};

Where:

DDS_SEQUENCE(DDS_TransportMulticastMappingSeq, struct DDS_TransportMulticastMapping_t);

And:

struct DDS_TransportMulticastMapping_t {
    /*e \dref_TransportMulticastMapping_t_addresses
    */
    char* addresses;

    /*e \dref_TransportMulticastMapping_t_topic_expression
    */
    char* topic_expression;

    /*e \dref_TransportMulticastMapping_t_mapping_function
    */
    struct DDS_TransportMulticastMappingFunction_t mapping_function;

    DDSCPP_VARIABLE_LENGTH_VALUE_TYPE_SUPPORT(DDS_TransportMulticastMapping_t)
};

 

I am plannig to use a Multicast QoS topic map similar to:

Topic Name (topic_expression field above)        Multicast Add (addresses field above)    Port  (???)

------------------------------------------------------------------------------------------------------------------------------------------------

      "ind.any.*"                                                          "224.0.0.1"                                   600

      "nor.sys.*"                                                           "224.0.0.2"                                  601

      "ade.sys.*"                                                          "224.0.0.3"                                  602

 

Does anyone have a piece of code that  implemments this TransportMulticastMappingQoS for a C++ compiler?

How to add a port number to IP addresses expressions? (I could not find it out in Section 8.5.8.1 of Users Manual) Is it like "IP:PORT" definition?

Thanks in advance!

Julio.

gianpiero's picture
Offline
Last seen: 11 months 1 week ago
Joined: 06/02/2010
Posts: 177

Hello Julio,

You are right. We don't have examples for that. And we should: hopefully we will have them up soon.

Let me see if I can help you with some code snippets.

Before doing anything get the participant QoS and set two lists of adresses: One for topics starting with F and one for topic starting with B:

DDS_DomainParticipantQos participantQos;
// Get the default participant QoS
DDSTheParticipantFactory->get_default_participant_qos(participantQos);

// Init the qos.. 
DDS_TransportMulticastMappingQosPolicy_initialize(&participantQos.multicast_mapping);
// .. and the sequence... 
DDS_TransportMulticastMappingSeq_initialize(&participantQos.multicast_mapping.value);
// .. with two elements 
DDS_TransportMulticastMappingSeq_ensure_length(&participantQos.multicast_mapping.value, 2,2);

// get the reference to the first element in the sequence ..
v = DDS_TransportMulticastMappingSeq_get_reference(&participantQos.multicast_mapping.value, 0);
//  .. and set the list of addresses .. 
v->addresses = DDS_String_dup("239.255.100.123,239.255.100.124");
// .. for topic starting with B 
v->topic_expression = DDS_String_dup("B*");

// get the reference to the second element in the sequence ..
v = DDS_TransportMulticastMappingSeq_get_reference(&participantQos.multicast_mapping.value, 1);
// .. and set the list of addresses ..  
v->addresses = DDS_String_dup("[239.255.100.200,239.255.100.220]");
// .. for topic startign with F 
v->topic_expression = DDS_String_dup("F*"); 

 

At this point create your participant using the participantQoS you just initialized. 

The dataReader qos, by default has datareaderQos.multicast.value = DDS_AUTOMATIC_TRANSPORT_MULTICAST_QOS.

If datareaderQos.multicast.value is set to DDS_AUTOMATIC_TRANSPORT_MULTICAST_QOS (default) and the DDS_TransportMulticastQosPolicy::value has at least one element with an empty address, then the address will be obtained from DDS_TransportMulticastMappingQosPolicy!

// get the default data reader Qos
subscriber->get_default_datareader_qos(datareaderQos);

// change the  
DDS_TransportMulticastSettingsSeq_initialize(&datareaderQos.multicast.value);
DDS_TransportMulticastSettingsSeq_ensure_length(&datareaderQos.multicast.value,1,1);

tmp = DDS_TransportMulticastSettingsSeq_get_reference(&datareaderQos.multicast.value, 0);
tmp->receive_address = DDS_String_dup("");
tmp->receive_port = 3456;

reader = subscriber->create_datareader(
        topic, datareaderQos, NULL,
        DDS_STATUS_MASK_NONE);
if (reader == NULL) {
        RTITestLog_exception(METHOD_NAME, &RTI_LOG_GET_FAILURE_s,
                 "create_datareader");
        goto done;
} 

 

 Does it make more sense now? 

I hope the code snippets will help you for now. Try it and feel free to post here for more info or help.

Best,
  Gianpiero

 

Offline
Last seen: 5 years 11 months ago
Joined: 01/07/2015
Posts: 5

Hi gianpiero,

Thanks for your response !!!!

I still have two questions with regard to your post:

1) In Participant QoS is there a way to define a set of MUTICAST ADDRESS+PORT(s) in Multicast Map or just sets of MULTICAST ADRESSES as your code shows?

2) The 2nd part of your post, when you set "tmp" variable you are actually changing datareaderQos ? Do we have to set datareaderQos in orther to have Multicast Map Participant QoS working ? I thought that we just needed to set Participant QoS in both sides (Publisher and Subscriber)...

 

Thanks again!

Julio.

 

 

 

gianpiero's picture
Offline
Last seen: 11 months 1 week ago
Joined: 06/02/2010
Posts: 177

Hello Julio, 

Reguarding your first (1) question: I believe there is not way to set the port in the Multicast Map.

Reguarding your second (2) question: TODAY in order for the datareader to use the multicast address that is specified in the participant QoS, you have to specify an empty receive_address in the datareader multicast QoS. But we are addressing this issue for the next release (for future reference the issue number is CORE-6054). 

I hope this helps you out. 

Regards,
  Gianpiero