From 0fdb37bd11a0d71c26606ca4e76bbf4d787ed88d Mon Sep 17 00:00:00 2001 From: Raphael Riebl Date: Thu, 4 Jul 2024 10:34:56 +0200 Subject: [PATCH] geonet: configurable initial beacon delay --- vanetza/geonet/mib.cpp | 2 +- vanetza/geonet/mib.hpp | 2 +- vanetza/geonet/router.cpp | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/vanetza/geonet/mib.cpp b/vanetza/geonet/mib.cpp index 1c96b092d..6355d66a6 100644 --- a/vanetza/geonet/mib.cpp +++ b/vanetza/geonet/mib.cpp @@ -50,7 +50,7 @@ ManagementInformationBase::ManagementInformationBase() : itsGnDefaultTrafficClass(false, false, 0), vanetzaDefaultSeed(0xc0114c2c), vanetzaCbfMaxCounter(1), - vanetzaDeferInitialBeacon(false), + vanetzaDeferInitialBeacon(Clock::duration::zero()), vanetzaDisableBeaconing(false), vanetzaMultiHopDuplicateAddressDetection(false), vanetzaFadingCbfCounter(false), diff --git a/vanetza/geonet/mib.hpp b/vanetza/geonet/mib.hpp index 99e293a37..00c48cf23 100644 --- a/vanetza/geonet/mib.hpp +++ b/vanetza/geonet/mib.hpp @@ -94,7 +94,7 @@ struct ManagementInformationBase TrafficClass itsGnDefaultTrafficClass; std::uint32_t vanetzaDefaultSeed; /*< default seed for internal random number generator */ std::size_t vanetzaCbfMaxCounter; /*< maximum counter value used for Advanced routing */ - bool vanetzaDeferInitialBeacon; /*< defer first beacon up to itsGnBeaconServiceRetransmitTimer */ + Clock::duration vanetzaDeferInitialBeacon; /*< defer first beacon by given duration */ bool vanetzaDisableBeaconing; /*< disable transmission of beacons entirely */ bool vanetzaMultiHopDuplicateAddressDetection; /*< execute DAD for multi-hop packets */ bool vanetzaFadingCbfCounter; /*< use fading counters for CBF packet buffer */ diff --git a/vanetza/geonet/router.cpp b/vanetza/geonet/router.cpp index 6e87262f7..e1e557571 100644 --- a/vanetza/geonet/router.cpp +++ b/vanetza/geonet/router.cpp @@ -145,14 +145,14 @@ Router::Router(Runtime& rt, const MIB& mib) : m_random_gen(mib.vanetzaDefaultSeed) { if (!m_mib.vanetzaDisableBeaconing) { - if (!m_mib.vanetzaDeferInitialBeacon) { + if (m_mib.vanetzaDeferInitialBeacon > Clock::duration::zero()) { + // defer initial Beacon transmission by given duration plus jitter + std::uniform_real_distribution dist_jitter(0.0, 1.0); + const auto jitter = clock_cast(dist_jitter(m_random_gen) * m_mib.itsGnBeaconServiceMaxJitter); + reset_beacon_timer(m_mib.vanetzaDeferInitialBeacon + jitter); + } else { // send Beacon immediately after start-up at next runtime trigger invocation reset_beacon_timer(Clock::duration::zero()); - } else { - // defer initial Beacon transmission slightly - std::uniform_real_distribution dist(0.0, 1.0); - const auto first_beacon = dist(m_random_gen) * m_mib.itsGnBeaconServiceRetransmitTimer; - reset_beacon_timer(clock_cast(first_beacon)); } }