diff --git a/documentation/vsomeipConfiguration.md b/documentation/vsomeipConfiguration.md index 75f2b698b..84c597e86 100644 --- a/documentation/vsomeipConfiguration.md +++ b/documentation/vsomeipConfiguration.md @@ -624,8 +624,9 @@ The general filter rules are: - **request_response_delay** - Minimum delay of a unicast message to a multicast message for provided services and eventgroups. (ignored by vsomeip) - **offer_debounce_time** - Time which the stack collects new service offers before they enter the repetition phase. This can be used to reduce the number of sent messages during startup. The default setting is `500ms`. - **find_debounce_time** - Time which the stack collects non local service requests before sending find messages. The default setting is `500ms`. - - **max_remote_subscribers** - Maximum possible number of different remote subscribers. Additional remote -subscribers will not be acknowledged. + - **max_remote_subscribers** - Maximum possible number of different remote subscribers. Additional remote subscribers will not be acknowledged. + - **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_.
Service Discovery configuration diff --git a/implementation/configuration/include/configuration.hpp b/implementation/configuration/include/configuration.hpp index 1c5dfe51f..6b37339c2 100644 --- a/implementation/configuration/include/configuration.hpp +++ b/implementation/configuration/include/configuration.hpp @@ -179,7 +179,7 @@ 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 std::uint32_t get_sd_find_initial_debounce_reps() 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_offer_debounce_time() const = 0; virtual std::uint32_t get_sd_find_debounce_time() const = 0; diff --git a/implementation/configuration/include/configuration_impl.hpp b/implementation/configuration/include/configuration_impl.hpp index e4061092f..53848ec5a 100644 --- a/implementation/configuration/include/configuration_impl.hpp +++ b/implementation/configuration/include/configuration_impl.hpp @@ -195,7 +195,7 @@ 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 std::uint32_t get_sd_find_initial_debounce_reps() 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_offer_debounce_time() const; VSOMEIP_EXPORT std::uint32_t get_sd_find_debounce_time() const; diff --git a/implementation/configuration/src/configuration_impl.cpp b/implementation/configuration/src/configuration_impl.cpp index 0b8f6e52a..de6f53a38 100644 --- a/implementation/configuration/src/configuration_impl.cpp +++ b/implementation/configuration/src/configuration_impl.cpp @@ -1809,8 +1809,16 @@ void configuration_impl::load_service_discovery( 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 >> sd_find_initial_debounce_reps_; + 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") { @@ -3699,7 +3707,7 @@ int32_t configuration_impl::get_sd_request_response_delay() const { return sd_request_response_delay_; } -std::uint32_t configuration_impl::get_sd_find_initial_debounce_reps() const { +uint8_t configuration_impl::get_sd_find_initial_debounce_reps() const { return sd_find_initial_debounce_reps_; } diff --git a/implementation/service_discovery/include/service_discovery_impl.hpp b/implementation/service_discovery/include/service_discovery_impl.hpp index 66c4c28a9..32b7f5475 100644 --- a/implementation/service_discovery/include/service_discovery_impl.hpp +++ b/implementation/service_discovery/include/service_discovery_impl.hpp @@ -434,11 +434,10 @@ class service_discovery_impl: public service_discovery, std::mutex collected_offers_mutex_; services_t collected_offers_; - // configurable debounce time for a configuarble number of inital debounce repetitions - std::uint32_t find_initial_debounce_reps_; + // interval between debounces during the initial debounce phase of the finds std::chrono::milliseconds find_initial_debounce_time_; - // counter of remaining find initial debounce repetitions - std::uint32_t remaining_find_initial_debounce_reps_; + // 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_; diff --git a/implementation/service_discovery/src/service_discovery_impl.cpp b/implementation/service_discovery/src/service_discovery_impl.cpp index 1a25c86e1..a033a0e7a 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,8 +150,7 @@ 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_ = 0; - find_initial_debounce_reps_ = configuration_->get_sd_find_initial_debounce_reps(); + 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()); offer_debounce_time_ = std::chrono::milliseconds( @@ -2885,6 +2886,7 @@ service_discovery_impl::start_find_debounce_timer(bool _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); } @@ -2892,17 +2894,6 @@ service_discovery_impl::start_find_debounce_timer(bool _first_start) { VSOMEIP_ERROR<< "service_discovery_impl::start_find_debounce_timer " "setting expiry time of timer failed: " << ec.message(); } - - if (_first_start) { - // Reset the number of remaining initial debounce cycles for find - remaining_find_initial_debounce_reps_ = find_initial_debounce_reps_; - } else { - if (remaining_find_initial_debounce_reps_ > 0) { - // Decrement the number of remaining initial debounce cycles for find - remaining_find_initial_debounce_reps_--; - } - } - find_debounce_timer_.async_wait( std::bind( &service_discovery_impl::on_find_debounce_timer_expired,