Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add and expose settings for SD find debounce as config options #716

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions documentation/vsomeipUserGuide
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions implementation/configuration/include/configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion implementation/configuration/include/configuration_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<std::string, std::set<uint16_t> > magic_cookies_;
Expand Down Expand Up @@ -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,
Expand All @@ -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];
Expand Down
53 changes: 53 additions & 0 deletions implementation/configuration/src/configuration_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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<trace>(*_other.trace_.get());
Expand Down Expand Up @@ -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<std::uint8_t>(tmp)) {
sd_find_initial_debounce_reps_ = static_cast<std::uint8_t>(tmp);
}
else {
VSOMEIP_WARNING << "Invalid value for service_discovery.find_initial_debounce_reps: " << tmp;
sd_find_initial_debounce_reps_ = std::numeric_limits<std::uint8_t>::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."
Expand Down Expand Up @@ -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_;
}
Expand Down
3 changes: 2 additions & 1 deletion implementation/service_discovery/include/defines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down
10 changes: 10 additions & 0 deletions implementation/service_discovery/src/service_discovery_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down