diff --git a/etc/cyclonedds.rnc b/etc/cyclonedds.rnc index cdc59d7..03c6bf5 100644 --- a/etc/cyclonedds.rnc +++ b/etc/cyclonedds.rnc @@ -223,7 +223,7 @@ CycloneDDS configuration""" ] ] & [ a:documentation [ xml:lang="en" """
This element specifies the size of DDSI sample fragments generated by Cyclone DDS. Samples larger than FragmentSize are fragmented into fragments of FragmentSize bytes each, except the last one, which may be smaller. The DDSI spec mandates a minimum fragment size of 1025 bytes, but Cyclone DDS will do whatever size is requested, accepting fragments of which the size is at least the minimum of 1025 and FragmentSize.
The unit must be specified explicitly. Recognised units: B (bytes), kB & KiB (210 bytes), MB & MiB (220 bytes), GB & GiB (230 bytes).
-The default value is: "1280 B".
""" ] ] +The default value is: "1344 B".
""" ] ] element FragmentSize { memsize }? diff --git a/etc/cyclonedds.xsd b/etc/cyclonedds.xsd index 801dd9a..aa4ad02 100644 --- a/etc/cyclonedds.xsd +++ b/etc/cyclonedds.xsd @@ -375,7 +375,7 @@ CycloneDDS configurationThis element specifies the size of DDSI sample fragments generated " "by Cyclone DDS. Samples larger than FragmentSize are fragmented into " diff --git a/src/core/ddsi/include/dds/ddsi/q_config.h b/src/core/ddsi/include/dds/ddsi/q_config.h index 3c78e28..e2ddf37 100644 --- a/src/core/ddsi/include/dds/ddsi/q_config.h +++ b/src/core/ddsi/include/dds/ddsi/q_config.h @@ -262,8 +262,8 @@ struct config unsigned delivery_queue_maxsamples; + uint16_t fragment_size; uint32_t max_msg_size; - uint32_t fragment_size; int publish_uc_locators; /* Publish discovery unicast locators */ int enable_uc_locators; /* If false, don't even try to create a unicast socket */ diff --git a/src/core/ddsi/src/q_config.c b/src/core/ddsi/src/q_config.c index 1581f23..d00f2c9 100644 --- a/src/core/ddsi/src/q_config.c +++ b/src/core/ddsi/src/q_config.c @@ -164,6 +164,7 @@ DU(natint_255); DUPF(participantIndex); DU(dyn_port); DUPF(memsize); +DUPF(memsize16); DU(duration_inf); DU(duration_ms_1hr); DU(duration_ms_1s); @@ -1092,8 +1093,26 @@ static enum update_result uf_memsize (struct cfgst *cfgst, void *parent, struct static void pf_memsize (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, uint32_t sources) { - int const * const elem = cfg_address (cfgst, parent, cfgelem); - pf_int64_unit (cfgst, *elem, sources, unittab_memsize, "B"); + uint32_t const * const elem = cfg_address (cfgst, parent, cfgelem); + pf_int64_unit (cfgst, (int64_t) *elem, sources, unittab_memsize, "B"); +} + +static enum update_result uf_memsize16 (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG (int first), const char *value) +{ + int64_t size = 0; + if (uf_natint64_unit (cfgst, &size, value, unittab_memsize, 1, 0, UINT16_MAX) != URES_SUCCESS) + return URES_ERROR; + else { + uint16_t * const elem = cfg_address (cfgst, parent, cfgelem); + *elem = (uint16_t) size; + return URES_SUCCESS; + } +} + +static void pf_memsize16 (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, uint32_t sources) +{ + uint16_t const * const elem = cfg_address (cfgst, parent, cfgelem); + pf_int64_unit (cfgst, (int64_t) *elem, sources, unittab_memsize, "B"); } static enum update_result uf_tracingOutputFileName (struct cfgst *cfgst, UNUSED_ARG (void *parent), UNUSED_ARG (struct cfgelem const * const cfgelem), UNUSED_ARG (int first), const char *value) diff --git a/src/core/ddsi/src/q_transmit.c b/src/core/ddsi/src/q_transmit.c index 90fd213..24b8779 100644 --- a/src/core/ddsi/src/q_transmit.c +++ b/src/core/ddsi/src/q_transmit.c @@ -541,7 +541,7 @@ dds_return_t create_fragment_message (struct writer *wr, seqno_t seq, const stru ASSERT_MUTEX_HELD (&wr->e.lock); - if (fragnum * gv->config.fragment_size >= size && size > 0) + if (fragnum * (uint32_t) gv->config.fragment_size >= size && size > 0) { /* This is the first chance to detect an attempt at retransmitting an non-existent fragment, which a malicious (or buggy) remote @@ -617,20 +617,20 @@ dds_return_t create_fragment_message (struct writer *wr, seqno_t seq, const stru frag->fragmentStartingNum = fragnum + 1; frag->fragmentsInSubmessage = 1; - frag->fragmentSize = (unsigned short) gv->config.fragment_size; - frag->sampleSize = (uint32_t)size; - fragstart = fragnum * gv->config.fragment_size; #if MULTIPLE_FRAGS_IN_SUBMSG /* ugly hack for testing only */ if (fragstart + gv->config.fragment_size < ddsi_serdata_size (serdata) && fragstart + 2 * gv->config.fragment_size >= ddsi_serdata_size (serdata)) frag->fragmentsInSubmessage++; ret = frag->fragmentsInSubmessage; #endif + frag->fragmentSize = gv->config.fragment_size; + frag->sampleSize = (uint32_t) size; - fraglen = gv->config.fragment_size * frag->fragmentsInSubmessage; + fragstart = fragnum * (uint32_t) gv->config.fragment_size; + fraglen = (uint32_t) gv->config.fragment_size * (uint32_t) frag->fragmentsInSubmessage; if (fragstart + fraglen > size) - fraglen = (uint32_t)(size - fragstart); + fraglen = (uint32_t) (size - fragstart); ddcmn->octetsToInlineQos = (unsigned short) ((char*) (frag+1) - ((char*) &ddcmn->octetsToInlineQos + 2)); if (wr->reliable && (!isnew || fragstart + fraglen == ddsi_serdata_size (serdata)))