diff --git a/docs/manual/config/config_file_reference.rst b/docs/manual/config/config_file_reference.rst index 669bb04e59..54c7180356 100644 --- a/docs/manual/config/config_file_reference.rst +++ b/docs/manual/config/config_file_reference.rst @@ -343,11 +343,11 @@ The default value is: ``10`` Number-with-unit -This element specifies the interval between spontaneous transmissions of participant discovery packets. +This element specifies the interval between spontaneous transmissions of participant discovery packets. The special value "default" corresponds to approximately 80% of the participant lease duration with a maximum of 30s. The unit must be specified explicitly. Recognised units: ns, us, ms, s, min, hr, day. -The default value is: ``30 s`` +The default value is: ``default`` .. _`//CycloneDDS/Domain/Discovery/SPDPMulticastAddress`: @@ -2634,14 +2634,14 @@ The categorisation of tracing output is incomplete and hence most of the verbosi The default value is: ``none`` .. - generated from ddsi_config.h[7f55b8f40b2e7f5984106abb0470128eb3d50017] + generated from ddsi_config.h[1ab75f267e0a5303400a6bbfc80e02a86b4cbdce] generated from ddsi__cfgunits.h[bd22f0c0ed210501d0ecd3b07c992eca549ef5aa] - generated from ddsi__cfgelems.h[771184755c23b94599f2ffd6e8c242dcea7d2658] - generated from ddsi_config.c[1b4f1a011d558f331b8a547fd29ab473d0d926d5] - generated from _confgen.h[1b1d88a85bd851f4e87118505ded33f7b33b0435] + generated from ddsi__cfgelems.h[849a4fe147dfa71c5c3a3a4ccaac458530802c8c] + generated from ddsi_config.c[82930450b615afa033986cf5338869bfdaeaf04d] + generated from _confgen.h[e32eabfc35e9f3a7dcb63b19ed148c0d17c6e5fc] generated from _confgen.c[237308acd53897a34e8c643e16e05a61d73ffd65] generated from generate_rnc.c[b50e4b7ab1d04b2bc1d361a0811247c337b74934] generated from generate_md.c[789b92e422631684352909cfb8bf43f6ceb16a01] generated from generate_rst.c[636ceeed42784e8508dd412b88dfd5f3b44b191b] generated from generate_xsd.c[6b6818d7f17a35d56c376c04ec1410427f34c0f0] - generated from generate_defconfig.c[ee80ba6719e71a457a85f1a638fe52f3756916d5] + generated from generate_defconfig.c[63ca9d8ae2f1ce2e761c9d4c0510a45eb062d830] diff --git a/docs/manual/options.md b/docs/manual/options.md index ec074e41b9..90b11c4461 100644 --- a/docs/manual/options.md +++ b/docs/manual/options.md @@ -221,11 +221,11 @@ The default value is: `10` #### //CycloneDDS/Domain/Discovery/SPDPInterval Number-with-unit -This element specifies the interval between spontaneous transmissions of participant discovery packets. +This element specifies the interval between spontaneous transmissions of participant discovery packets. The special value "default" corresponds to approximately 80% of the participant lease duration with a maximum of 30s. The unit must be specified explicitly. Recognised units: ns, us, ms, s, min, hr, day. -The default value is: `30 s` +The default value is: `default` #### //CycloneDDS/Domain/Discovery/SPDPMulticastAddress @@ -1846,14 +1846,14 @@ While none prevents any message from being written to a DDSI2 log file. The categorisation of tracing output is incomplete and hence most of the verbosity levels and categories are not of much use in the current release. This is an ongoing process and here we describe the target situation rather than the current situation. Currently, the most useful verbosity levels are config, fine and finest. The default value is: `none` - + - - - + + + - + diff --git a/etc/cyclonedds.rnc b/etc/cyclonedds.rnc index a201755f67..9db3b9921d 100644 --- a/etc/cyclonedds.rnc +++ b/etc/cyclonedds.rnc @@ -158,9 +158,9 @@ CycloneDDS configuration""" ] ] }? }? & [ a:documentation [ xml:lang="en" """ -
This element specifies the interval between spontaneous transmissions of participant discovery packets.
+This element specifies the interval between spontaneous transmissions of participant discovery packets. The special value "default" corresponds to approximately 80% of the participant lease duration with a maximum of 30s.
The unit must be specified explicitly. Recognised units: ns, us, ms, s, min, hr, day.
-The default value is: 30 s
The default value is: default
This element specifies the interval between spontaneous " - "transmissions of participant discovery packets.
"), + "transmissions of participant discovery packets. The special " + "value \"default\" corresponds to approximately 80% of the " + "participant lease duration with a maximum of 30s."), UNIT("duration")), STRING("DefaultMulticastAddress", NULL, 1, "auto", MEMBER(defaultMulticastAddressString), diff --git a/src/core/ddsi/src/ddsi_config.c b/src/core/ddsi/src/ddsi_config.c index 71dbf22eaf..1a154135e9 100644 --- a/src/core/ddsi/src/ddsi_config.c +++ b/src/core/ddsi/src/ddsi_config.c @@ -171,7 +171,9 @@ DU(duration_ms_1s); DU(duration_us_1s); DU(duration_100ms_1hr); DU(nop_duration_ms_1hr); +DU(maybe_duration_ms_1hr); PF(duration); +PF(maybe_duration); DUPF(standards_conformance); DUPF(besmode); DUPF(retransmit_merging); @@ -1417,6 +1419,19 @@ static enum update_result uf_duration_gen (struct ddsi_cfgst *cfgst, void *paren return uf_int64_unit (cfgst, cfg_address (cfgst, parent, cfgelem), value, unittab_duration, def_mult, min_ns, max_ns); } +static enum update_result uf_maybe_duration_gen (struct ddsi_cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, const char *value, int64_t def_mult, int64_t min_ns, int64_t max_ns) +{ + struct ddsi_config_maybe_duration * const elem = cfg_address (cfgst, parent, cfgelem); + if (ddsrt_strcasecmp (value, "default") == 0) { + elem->isdefault = 1; + elem->value = 0; + return URES_SUCCESS; + } else { + elem->isdefault = 0; + return uf_int64_unit (cfgst, &elem->value, value, unittab_duration, def_mult, min_ns, max_ns); + } +} + static enum update_result uf_duration_inf (struct ddsi_cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG (int first), const char *value) { if (ddsrt_strcasecmp (value, "inf") == 0) { @@ -1433,6 +1448,11 @@ static enum update_result uf_duration_ms_1hr (struct ddsi_cfgst *cfgst, void *pa return uf_duration_gen (cfgst, parent, cfgelem, value, DDS_MSECS (1), 0, DDS_SECS (3600)); } +static enum update_result uf_maybe_duration_ms_1hr (struct ddsi_cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG (int first), const char *value) +{ + return uf_maybe_duration_gen (cfgst, parent, cfgelem, value, DDS_MSECS (1), 0, DDS_SECS (3600)); +} + static enum update_result uf_nop_duration_ms_1hr (struct ddsi_cfgst *cfgst, UNUSED_ARG(void *parent), UNUSED_ARG(struct cfgelem const * const cfgelem), UNUSED_ARG (int first), const char *value) { int64_t dummy; @@ -1463,6 +1483,17 @@ static void pf_duration (struct ddsi_cfgst *cfgst, void *parent, struct cfgelem pf_int64_unit (cfgst, *elem, sources, unittab_duration, "s"); } +static void pf_maybe_duration (struct ddsi_cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, uint32_t sources) +{ + struct ddsi_config_maybe_duration const * const elem = cfg_address (cfgst, parent, cfgelem); + if (elem->isdefault) + cfg_logelem (cfgst, sources, "default"); + else if (elem->value == DDS_INFINITY) + cfg_logelem (cfgst, sources, "inf"); + else + pf_int64_unit (cfgst, elem->value, sources, unittab_duration, "s"); +} + static enum update_result uf_domainId (struct ddsi_cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG (int first), const char *value) { DDSRT_WARNING_MSVC_OFF(4996); diff --git a/src/core/ddsi/src/ddsi_discovery_spdp.c b/src/core/ddsi/src/ddsi_discovery_spdp.c index b9603d77a2..4fc5b4c6b9 100644 --- a/src/core/ddsi/src/ddsi_discovery_spdp.c +++ b/src/core/ddsi/src/ddsi_discovery_spdp.c @@ -355,8 +355,12 @@ static void ddsi_spdp_directed_xevent_cb (struct ddsi_domaingv *gv, struct ddsi_ PGUID (pp->e.guid), PGUIDPREFIX (arg->dest_proxypp_guid_prefix), DDSI_ENTITYID_PARTICIPANT); // Directed events are used to send SPDP packets to newly discovered peers, and used just once - if (--arg->nrepeats == 0 || gv->config.spdp_interval < DDS_SECS (1) || pp->plist->qos.liveliness.lease_duration < DDS_SECS (1)) + if (--arg->nrepeats == 0 || + pp->plist->qos.liveliness.lease_duration < DDS_SECS (1) || + (!gv->config.spdp_interval.isdefault && gv->config.spdp_interval.value < DDS_SECS (1))) + { ddsi_delete_xevent (ev); + } else { ddsrt_mtime_t tnext = ddsrt_mtime_add_duration (tnow, DDS_SECS (1)); @@ -370,23 +374,28 @@ static void ddsi_spdp_directed_xevent_cb (struct ddsi_domaingv *gv, struct ddsi_ static void resched_spdp_broadcast (struct ddsi_xevent *ev, struct ddsi_participant *pp, ddsrt_mtime_t tnow) { - /* schedule next when 80% of the interval has elapsed, or 2s - before the lease ends, whichever comes first (similar to PMD), - but never wait longer than spdp_interval */ struct ddsi_domaingv * const gv = pp->e.gv; const dds_duration_t mindelta = DDS_MSECS (10); - const dds_duration_t ldur = pp->plist->qos.liveliness.lease_duration; ddsrt_mtime_t tnext; - int64_t intv; + dds_duration_t intv; - if (ldur < 5 * mindelta / 4) - intv = mindelta; - else if (ldur < DDS_SECS (10)) - intv = 4 * ldur / 5; + if (!gv->config.spdp_interval.isdefault) + intv = gv->config.spdp_interval.value; else - intv = ldur - DDS_SECS (2); - if (intv > gv->config.spdp_interval) - intv = gv->config.spdp_interval; + { + // Default interval is 80% of the lease duration with a bit of fiddling around the + // edges (similar to PMD), and with an upper limit + const dds_duration_t ldur = pp->plist->qos.liveliness.lease_duration; + if (ldur < 5 * mindelta / 4) + intv = mindelta; + else if (ldur < DDS_SECS (10)) + intv = 4 * ldur / 5; + else + intv = ldur - DDS_SECS (2); + // Historical maximum interval is 30s, stick to that + if (intv > DDS_SECS (30)) + intv = DDS_SECS (30); + } tnext = ddsrt_mtime_add_duration (tnow, intv); GVTRACE ("xmit spdp "PGUIDFMT" to %"PRIx32":%"PRIx32":%"PRIx32":%x (resched %gs)\n", diff --git a/src/tools/_confgen/_confgen.h b/src/tools/_confgen/_confgen.h index d2423c56c0..cd64e8ae90 100644 --- a/src/tools/_confgen/_confgen.h +++ b/src/tools/_confgen/_confgen.h @@ -39,6 +39,7 @@ void gendef_pf_maybe_memsize (FILE *fp, void *parent, struct cfgelem const * con void gendef_pf_int (FILE *fp, void *parent, struct cfgelem const * const cfgelem); void gendef_pf_uint (FILE *fp, void *parent, struct cfgelem const * const cfgelem); void gendef_pf_duration (FILE *fp, void *parent, struct cfgelem const * const cfgelem); +void gendef_pf_maybe_duration (FILE *fp, void *parent, struct cfgelem const * const cfgelem); void gendef_pf_domainId(FILE *fp, void *parent, struct cfgelem const * const cfgelem); void gendef_pf_participantIndex (FILE *fp, void *parent, struct cfgelem const * const cfgelem); void gendef_pf_boolean (FILE *fp, void *parent, struct cfgelem const * const cfgelem); diff --git a/src/tools/_confgen/generate_defconfig.c b/src/tools/_confgen/generate_defconfig.c index 2746b5c465..1122998307 100644 --- a/src/tools/_confgen/generate_defconfig.c +++ b/src/tools/_confgen/generate_defconfig.c @@ -146,6 +146,12 @@ void gendef_pf_uint (FILE *out, void *parent, struct cfgelem const * const cfgel void gendef_pf_duration (FILE *out, void *parent, struct cfgelem const * const cfgelem) { gendef_pf_int64 (out, parent, cfgelem); } +void gendef_pf_maybe_duration (FILE *out, void *parent, struct cfgelem const * const cfgelem) { + struct ddsi_config_maybe_duration const * const p = cfg_address (parent, cfgelem); + fprintf (out, " cfg->%s.isdefault = %d;\n", cfgelem->membername, p->isdefault); + if (!p->isdefault) + fprintf (out, " cfg->%s.value = INT64_C (%"PRIu64");\n", cfgelem->membername, p->value); +} void gendef_pf_domainId(FILE *out, void *parent, struct cfgelem const * const cfgelem) { (void) out; (void) parent; (void) cfgelem; // skipped on purpose: set explicitly