diff --git a/implementation/configuration/include/configuration.hpp b/implementation/configuration/include/configuration.hpp index dc445b4c2..1c5dfe51f 100644 --- a/implementation/configuration/include/configuration.hpp +++ b/implementation/configuration/include/configuration.hpp @@ -179,6 +179,8 @@ 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 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 da8cf2e74..3f938f5ea 100644 --- a/implementation/configuration/include/configuration_impl.hpp +++ b/implementation/configuration/include/configuration_impl.hpp @@ -195,6 +195,8 @@ 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 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; @@ -537,6 +539,8 @@ class configuration_impl: ttl_t sd_ttl_; int32_t sd_cyclic_offer_delay_; int32_t sd_request_response_delay_; + std::uint32_t sd_find_initial_debounce_reps_; + std::uint32_t sd_find_initial_debounce_time_; std::uint32_t sd_offer_debounce_time_; std::uint32_t sd_find_debounce_time_; @@ -587,6 +591,8 @@ 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_OFFER_DEBOUNCE_TIME, ET_SERVICE_DISCOVERY_FIND_DEBOUNCE_TIME, ET_SERVICE_DISCOVERY_TTL_FACTOR_OFFERS, @@ -608,7 +614,7 @@ class configuration_impl: ET_SECURITY_AUDIT_MODE, ET_SECURITY_REMOTE_ACCESS, ET_INITIAL_ROUTING_STATE, - ET_MAX = 47 + ET_MAX = 49 }; bool is_configured_[ET_MAX]; diff --git a/implementation/configuration/src/configuration_impl.cpp b/implementation/configuration/src/configuration_impl.cpp index 21c708b60..8b5983cae 100644 --- a/implementation/configuration/src/configuration_impl.cpp +++ b/implementation/configuration/src/configuration_impl.cpp @@ -59,6 +59,8 @@ configuration_impl::configuration_impl(const std::string& _path) : sd_request_response_delay_ {VSOMEIP_SD_DEFAULT_REQUEST_RESPONSE_DELAY}, sd_offer_debounce_time_ {VSOMEIP_SD_DEFAULT_OFFER_DEBOUNCE_TIME}, sd_find_debounce_time_ {VSOMEIP_SD_DEFAULT_FIND_DEBOUNCE_TIME}, + sd_find_initial_debounce_reps_(VSOMEIP_SD_INITIAL_FIND_DEBOUNCE_REPS), + sd_find_initial_debounce_time_(VSOMEIP_SD_INITIAL_FIND_DEBOUNCE_TIME), max_configured_message_size_ {0}, max_local_message_size_ {0}, max_reliable_message_size_ {0}, max_unreliable_message_size_ {0}, buffer_shrink_threshold_ {VSOMEIP_DEFAULT_BUFFER_SHRINK_THRESHOLD}, @@ -154,6 +156,8 @@ 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_offer_debounce_time_ = _other.sd_offer_debounce_time_; sd_find_debounce_time_ = _other.sd_find_debounce_time_; @@ -1800,6 +1804,33 @@ 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 { + its_converter << its_value; + its_converter >> sd_find_initial_debounce_reps_; + 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." @@ -3677,6 +3708,18 @@ 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 { + 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 d07fcb1f7..66c4c28a9 100644 --- a/implementation/service_discovery/include/service_discovery_impl.hpp +++ b/implementation/service_discovery/include/service_discovery_impl.hpp @@ -434,6 +434,12 @@ 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_; + std::chrono::milliseconds find_initial_debounce_time_; + // counter of remaining find initial debounce repetitions + std::uint32_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 3d7642908..c42edbfba 100644 --- a/implementation/service_discovery/src/service_discovery_impl.cpp +++ b/implementation/service_discovery/src/service_discovery_impl.cpp @@ -148,6 +148,12 @@ 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(); + 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; @@ -2879,6 +2885,8 @@ 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); } else { find_debounce_timer_.expires_from_now(find_debounce_time_, ec); } @@ -2886,6 +2894,17 @@ 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,