diff --git a/documentation/vsomeipUserGuide b/documentation/vsomeipUserGuide index 4c1f9842e..b3b3b00c9 100644 --- a/documentation/vsomeipUserGuide +++ b/documentation/vsomeipUserGuide @@ -1185,6 +1185,27 @@ Minimum delay of a unicast message to a multicast message for provided services and eventgroups. + +** `find_initial_debounce_reps` ++ +Number of initial debounces using find_initial_debounce_time. This can be +used to modify the number of sent messages during initial part of startup +(valid values: _0 - 2^8-1_). The default setting is _0_. ++ + +** `find_initial_debounce_time` ++ +Time which the stack collects new service requests before they enter the +repetition phase. This can be used to modify the number of +sent messages during initial part of startup. The default setting is _200ms_. ++ + +** `find_debounce_time` ++ +Time which the stack collects new service requests before they enter the +repetition phase. This can be used to reduce the number of +sent messages during startup. The default setting is _500ms_. ++ + ** `offer_debounce_time` + Time which the stack collects new service offers before they enter the diff --git a/implementation/configuration/include/configuration.hpp b/implementation/configuration/include/configuration.hpp index 8b32a0c99..5ebb49c69 100644 --- a/implementation/configuration/include/configuration.hpp +++ b/implementation/configuration/include/configuration.hpp @@ -175,6 +175,9 @@ class configuration { virtual ttl_t get_sd_ttl() const = 0; virtual int32_t get_sd_cyclic_offer_delay() const = 0; virtual int32_t get_sd_request_response_delay() const = 0; + virtual uint8_t get_sd_find_initial_debounce_reps() const = 0; + virtual std::uint32_t get_sd_find_initial_debounce_time() const = 0; + virtual std::uint32_t get_sd_find_debounce_time() const = 0; virtual std::uint32_t get_sd_offer_debounce_time() const = 0; // Trace configuration diff --git a/implementation/configuration/include/configuration_impl.hpp b/implementation/configuration/include/configuration_impl.hpp index f30e0ecf5..2f95e1687 100644 --- a/implementation/configuration/include/configuration_impl.hpp +++ b/implementation/configuration/include/configuration_impl.hpp @@ -193,6 +193,9 @@ class configuration_impl: VSOMEIP_EXPORT ttl_t get_sd_ttl() const; VSOMEIP_EXPORT int32_t get_sd_cyclic_offer_delay() const; VSOMEIP_EXPORT int32_t get_sd_request_response_delay() const; + VSOMEIP_EXPORT uint8_t get_sd_find_initial_debounce_reps() const; + VSOMEIP_EXPORT std::uint32_t get_sd_find_initial_debounce_time() const; + VSOMEIP_EXPORT std::uint32_t get_sd_find_debounce_time() const; VSOMEIP_EXPORT std::uint32_t get_sd_offer_debounce_time() const; // Trace configuration @@ -530,6 +533,9 @@ class configuration_impl: ttl_t sd_ttl_; int32_t sd_cyclic_offer_delay_; int32_t sd_request_response_delay_; + uint8_t sd_find_initial_debounce_reps_; + std::uint32_t sd_find_initial_debounce_time_; + std::uint32_t sd_find_debounce_time_; std::uint32_t sd_offer_debounce_time_; std::map > magic_cookies_; @@ -579,6 +585,9 @@ class configuration_impl: ET_WATCHDOG_ALLOWED_MISSING_PONGS, ET_TRACING_ENABLE, ET_TRACING_SD_ENABLE, + ET_SERVICE_DISCOVERY_FIND_INITIAL_DEBOUNCE_REPS, + ET_SERVICE_DISCOVERY_FIND_INITIAL_DEBOUNCE_TIME, + ET_SERVICE_DISCOVERY_FIND_DEBOUNCE_TIME, ET_SERVICE_DISCOVERY_OFFER_DEBOUNCE_TIME, ET_SERVICE_DISCOVERY_TTL_FACTOR_OFFERS, ET_SERVICE_DISCOVERY_TTL_FACTOR_SUBSCRIPTIONS, @@ -598,7 +607,7 @@ class configuration_impl: ET_PARTITIONS, ET_SECURITY_AUDIT_MODE, ET_SECURITY_REMOTE_ACCESS, - ET_MAX = 45 + ET_MAX = 48 }; bool is_configured_[ET_MAX]; diff --git a/implementation/configuration/src/configuration_impl.cpp b/implementation/configuration/src/configuration_impl.cpp index 380b29060..d86a335ea 100644 --- a/implementation/configuration/src/configuration_impl.cpp +++ b/implementation/configuration/src/configuration_impl.cpp @@ -67,6 +67,9 @@ configuration_impl::configuration_impl(const std::string &_path) sd_ttl_(VSOMEIP_SD_DEFAULT_TTL), sd_cyclic_offer_delay_(VSOMEIP_SD_DEFAULT_CYCLIC_OFFER_DELAY), sd_request_response_delay_(VSOMEIP_SD_DEFAULT_REQUEST_RESPONSE_DELAY), + sd_find_initial_debounce_reps_(VSOMEIP_SD_INITIAL_FIND_DEBOUNCE_REPS), + sd_find_initial_debounce_time_(VSOMEIP_SD_INITIAL_FIND_DEBOUNCE_TIME), + sd_find_debounce_time_(VSOMEIP_SD_DEFAULT_FIND_DEBOUNCE_TIME), sd_offer_debounce_time_(VSOMEIP_SD_DEFAULT_OFFER_DEBOUNCE_TIME), max_configured_message_size_(0), max_local_message_size_(0), @@ -180,6 +183,9 @@ configuration_impl::configuration_impl(const configuration_impl &_other) sd_ttl_ = _other.sd_ttl_; sd_cyclic_offer_delay_= _other.sd_cyclic_offer_delay_; sd_request_response_delay_= _other.sd_request_response_delay_; + sd_find_initial_debounce_reps_ = _other.sd_find_initial_debounce_reps_; + sd_find_initial_debounce_time_ = _other.sd_find_initial_debounce_time_; + sd_find_debounce_time_ = _other.sd_find_debounce_time_; sd_offer_debounce_time_ = _other.sd_offer_debounce_time_; trace_ = std::make_shared(*_other.trace_.get()); @@ -1832,6 +1838,41 @@ void configuration_impl::load_service_discovery( its_converter >> sd_request_response_delay_; is_configured_[ET_SERVICE_DISCOVERY_REQUEST_RESPONSE_DELAY] = true; } + } else if (its_key == "find_initial_debounce_reps") { + if (!is_overlay_ && is_configured_[ET_SERVICE_DISCOVERY_FIND_INITIAL_DEBOUNCE_REPS]) { + VSOMEIP_WARNING << "Multiple definitions for service_discovery.find_initial_debounce_reps." + " Ignoring definition from " << _element.name_; + } else { + int tmp; + its_converter << its_value; + its_converter >> tmp; + if (tmp == static_cast(tmp)) { + sd_find_initial_debounce_reps_ = static_cast(tmp); + } + else { + VSOMEIP_WARNING << "Invalid value for service_discovery.find_initial_debounce_reps: " << tmp; + sd_find_initial_debounce_reps_ = std::numeric_limits::max(); + } + is_configured_[ET_SERVICE_DISCOVERY_FIND_INITIAL_DEBOUNCE_REPS] = true; + } + } else if (its_key == "find_initial_debounce_time") { + if (!is_overlay_ && is_configured_[ET_SERVICE_DISCOVERY_FIND_INITIAL_DEBOUNCE_TIME]) { + VSOMEIP_WARNING << "Multiple definitions for service_discovery.find_initial_debounce_time." + " Ignoring definition from " << _element.name_; + } else { + its_converter << its_value; + its_converter >> sd_find_initial_debounce_time_; + is_configured_[ET_SERVICE_DISCOVERY_FIND_INITIAL_DEBOUNCE_TIME] = true; + } + } else if (its_key == "find_debounce_time") { + if (!is_overlay_ && is_configured_[ET_SERVICE_DISCOVERY_FIND_DEBOUNCE_TIME]) { + VSOMEIP_WARNING << "Multiple definitions for service_discovery.find_debounce_time." + " Ignoring definition from " << _element.name_; + } else { + its_converter << its_value; + its_converter >> sd_find_debounce_time_; + is_configured_[ET_SERVICE_DISCOVERY_FIND_DEBOUNCE_TIME] = true; + } } else if (its_key == "offer_debounce_time") { if (is_configured_[ET_SERVICE_DISCOVERY_OFFER_DEBOUNCE_TIME]) { VSOMEIP_WARNING << "Multiple definitions for service_discovery.offer_debounce." @@ -3676,6 +3717,18 @@ int32_t configuration_impl::get_sd_request_response_delay() const { return sd_request_response_delay_; } +uint8_t configuration_impl::get_sd_find_initial_debounce_reps() const { + return sd_find_initial_debounce_reps_; +} + +std::uint32_t configuration_impl::get_sd_find_initial_debounce_time() const { + return sd_find_initial_debounce_time_; +} + +std::uint32_t configuration_impl::get_sd_find_debounce_time() const { + return sd_find_debounce_time_; +} + std::uint32_t configuration_impl::get_sd_offer_debounce_time() const { return sd_offer_debounce_time_; } diff --git a/implementation/service_discovery/include/defines.hpp b/implementation/service_discovery/include/defines.hpp index b7642f122..2f92012ec 100644 --- a/implementation/service_discovery/include/defines.hpp +++ b/implementation/service_discovery/include/defines.hpp @@ -47,6 +47,7 @@ #define VSOMEIP_SD_DEFAULT_REQUEST_RESPONSE_DELAY 2000 #define VSOMEIP_SD_DEFAULT_OFFER_DEBOUNCE_TIME 500 #define VSOMEIP_SD_DEFAULT_FIND_DEBOUNCE_TIME 500 - +#define VSOMEIP_SD_INITIAL_FIND_DEBOUNCE_TIME 200 +#define VSOMEIP_SD_INITIAL_FIND_DEBOUNCE_REPS 0 #endif // VSOMEIP_SD_DEFINES_HPP diff --git a/implementation/service_discovery/include/service_discovery_impl.hpp b/implementation/service_discovery/include/service_discovery_impl.hpp index 200627ccf..05a92c9ca 100644 --- a/implementation/service_discovery/include/service_discovery_impl.hpp +++ b/implementation/service_discovery/include/service_discovery_impl.hpp @@ -418,6 +418,11 @@ class service_discovery_impl: public service_discovery, std::mutex collected_offers_mutex_; services_t collected_offers_; + // interval between debounces during the initial debounce phase of the finds + std::chrono::milliseconds find_initial_debounce_time_; + // tracks number of remaining debounces for the initial debounce phase of the finds + uint8_t remaining_find_initial_debounce_reps_; + std::chrono::milliseconds find_debounce_time_; std::mutex find_debounce_timer_mutex_; boost::asio::steady_timer find_debounce_timer_; diff --git a/implementation/service_discovery/src/service_discovery_impl.cpp b/implementation/service_discovery/src/service_discovery_impl.cpp index c38804575..810dc2246 100644 --- a/implementation/service_discovery/src/service_discovery_impl.cpp +++ b/implementation/service_discovery/src/service_discovery_impl.cpp @@ -68,6 +68,8 @@ service_discovery_impl::service_discovery_impl( repetitions_max_(VSOMEIP_SD_DEFAULT_REPETITIONS_MAX), cyclic_offer_delay_(VSOMEIP_SD_DEFAULT_CYCLIC_OFFER_DELAY), offer_debounce_timer_(_host->get_io()), + find_initial_debounce_time_(VSOMEIP_SD_INITIAL_FIND_DEBOUNCE_TIME), + remaining_find_initial_debounce_reps_(VSOMEIP_SD_INITIAL_FIND_DEBOUNCE_REPS), find_debounce_time_(VSOMEIP_SD_DEFAULT_FIND_DEBOUNCE_TIME), find_debounce_timer_(_host->get_io()), main_phase_timer_(_host->get_io()), @@ -148,6 +150,11 @@ service_discovery_impl::init() { repetitions_max_ = configuration_->get_sd_repetitions_max(); cyclic_offer_delay_ = std::chrono::milliseconds( configuration_->get_sd_cyclic_offer_delay()); + remaining_find_initial_debounce_reps_ = configuration_->get_sd_find_initial_debounce_reps(); + find_initial_debounce_time_ = std::chrono::milliseconds( + configuration_->get_sd_find_initial_debounce_time()); + find_debounce_time_ = std::chrono::milliseconds( + configuration_->get_sd_find_debounce_time()); offer_debounce_time_ = std::chrono::milliseconds( configuration_->get_sd_offer_debounce_time()); ttl_timer_runtime_ = cyclic_offer_delay_ / 2; @@ -2826,6 +2833,9 @@ service_discovery_impl::start_find_debounce_timer(bool _first_start) { boost::system::error_code ec; if (_first_start) { find_debounce_timer_.expires_from_now(initial_delay_, ec); + } else if (remaining_find_initial_debounce_reps_ > 0) { + find_debounce_timer_.expires_from_now(find_initial_debounce_time_, ec); + --remaining_find_initial_debounce_reps_; } else { find_debounce_timer_.expires_from_now(find_debounce_time_, ec); }