Skip to content

Commit

Permalink
geonet: configurable initial beacon delay
Browse files Browse the repository at this point in the history
  • Loading branch information
riebl committed Jul 4, 2024
1 parent 067c01a commit 0fdb37b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion vanetza/geonet/mib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion vanetza/geonet/mib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
12 changes: 6 additions & 6 deletions vanetza/geonet/router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> 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<double> dist(0.0, 1.0);
const auto first_beacon = dist(m_random_gen) * m_mib.itsGnBeaconServiceRetransmitTimer;
reset_beacon_timer(clock_cast(first_beacon));
}
}

Expand Down

0 comments on commit 0fdb37b

Please sign in to comment.