Increasing UDPv4 buffer size

4 posts / 0 new
Last post
Offline
Last seen: 11 years 2 months ago
Joined: 04/09/2013
Posts: 13
Increasing UDPv4 buffer size

I am getting UDP errors due to high traffic. I am trying to increase the buffer size but the error I am getting:

NDDS_Transport_Support_set_builtin_transport_property:ERROR participant has already been enabled.
See included code:

/* To customize participant QoS, use
DDSTheParticipantFactory->get_default_participant_qos() */
DDSTheParticipantFactory->get_default_participant_qos(factory_qos);
factory_qos.entity_factory.autoenable_created_entities = DDS_BOOLEAN_FALSE;

mainPub_participant = DDSTheParticipantFactory->create_participant(
domainId, factory_qos/*DDS_PARTICIPANT_QOS_DEFAULT*/,
NULL /* listener */, DDS_STATUS_MASK_NONE);
if (mainPub_participant == NULL)
{
printf("\n mainPub_participant create_participant error\n");
return 1;
}

////////////////////////////////////////////////////////
///Create participant as disabled for now
if( mainPub_participant->get_qos(publisher_qos)!= DDS_RETCODE_OK )
{
printf("mainPub_participant->get_qos ERROR\n");
}
publisher_qos.entity_factory.autoenable_created_entities = DDS_BOOLEAN_FALSE;
if (mainPub_participant->set_qos(publisher_qos) != DDS_RETCODE_OK) {
printf("mainPub_participant->get_qos ERROR\n");
}

///////////////////////////////////////////////////////////////////////
///Increase transport layer buffer size
NDDS_Transport_UDPv4_Property_t property = NDDS_TRANSPORT_UDPV4_PROPERTY_DEFAULT;

if( NDDSTransportSupport::get_builtin_transport_property(mainPub_participant,DDS_TRANSPORTBUILTIN_UDPv4,
(struct NDDS_Transport_Property_t&)property) != DDS_RETCODE_OK)
{
printf("**Error: get builtin transport property\n");
}

// Make your desired changes here
// For example, to increase the UDPv4 max msg size to 64K:
property.parent.message_size_max = 65535;
property.recv_socket_buffer_size = 65535;
property.send_socket_buffer_size = 65535;

if (NDDSTransportSupport::set_builtin_transport_property(mainPub_participant, DDS_TRANSPORTBUILTIN_UDPv4,
(struct NDDS_Transport_Property_t&)property) != DDS_RETCODE_OK)
{
printf("***Error: set builtin transport property\n");
}

mainPublisher = mainPub_participant->create_publisher(
DDS_PUBLISHER_QOS_DEFAULT, NULL /* listener */, DDS_STATUS_MASK_NONE);
if (mainPublisher == NULL) {
printf("mainPublisher create_publisher error\n");
return 1;
}

Organization:
rip
rip's picture
Offline
Last seen: 3 days 18 hours ago
Joined: 04/06/2012
Posts: 324

Hi,

You've read the factory qos into a local variable, changed the behavior, but didn't put it back into the factory.  You're missing a call to set the qos.

Regards,

rip

Offline
Last seen: 11 years 2 months ago
Joined: 04/09/2013
Posts: 13

Ok I included the DDSTheParticipantFactory->set_qos(factory_qos) function call As shown in the code below
but now I am having trouble re-enableing the participant. First I create all the writers and then I call mainPublisher->enable();
mainPublisher->enable();
and get the error:
DDS_Publisher_enable:ERROR: parent participant is not enabled
DDS_Publisher_enable:ERROR: parent participant is not enabled

int createMainParticipant(int domainId)
{
struct DDS_DomainParticipantFactoryQos factory_qos;
DDS_DomainParticipantQos publisher_qos; /////////////////////////////////////////////////////////////////////////
///Overwrite the default Create Factory participant as disabled for now
DDSTheParticipantFactory->get_qos(factory_qos);
factory_qos.entity_factory.autoenable_created_entities = DDS_BOOLEAN_FALSE;
DDSTheParticipantFactory->set_qos(factory_qos);

mainPub_participant = DDSTheParticipantFactory->create_participant(
domainId, DDS_PARTICIPANT_QOS_DEFAULT,
NULL /* listener */, DDS_STATUS_MASK_NONE);
if (mainPub_participant == NULL)
{
printf("\n mainPub_participant create_participant error\n");
return 1;
}

///////////////////////////////////////////////////////////////////////
///Increase transport layer buffer size
NDDS_Transport_UDPv4_Property_t property = NDDS_TRANSPORT_UDPV4_PROPERTY_DEFAULT;

if( NDDSTransportSupport::get_builtin_transport_property(mainPub_participant,DDS_TRANSPORTBUILTIN_UDPv4,
(struct NDDS_Transport_Property_t&)property) != DDS_RETCODE_OK)
{
printf("**Error: get builtin transport property\n");
}

//////////////////////////////////////////////////////////////////
/// increase the UDPv4 max msg size to 64K:
property.parent.message_size_max = 20480;//65535;
property.recv_socket_buffer_size = 20480;//65535;
property.send_socket_buffer_size = 20480;//65535;

if (NDDSTransportSupport::set_builtin_transport_property(mainPub_participant, DDS_TRANSPORTBUILTIN_UDPv4,
(struct NDDS_Transport_Property_t&)property) != DDS_RETCODE_OK)
{
printf("***Error: set builtin transport property\n");
}

mainPublisher = mainPub_participant->create_publisher(
DDS_PUBLISHER_QOS_DEFAULT, NULL /* listener */, DDS_STATUS_MASK_NONE);
if (mainPublisher == NULL) {
printf("mainPublisher create_publisher error\n");
return 1;
}
printf("mainPublisher Created successfully\n");

rose's picture
Offline
Last seen: 3 years 4 months ago
Joined: 08/22/2011
Posts: 148

You also need to enable the DomainParticipant before you start to write data:

if (mainPub_participant->enable() != DDS_RETCODE_OK) { ... handle error ... }

Thank you,
Rose