Files
MicrOBU/obu-firmware/external/vanetza-idf/vanetza/geonet/cbr_aggregator.hpp
T
Ashin Walpola d107534eb2 Keep vanetza-idf in obu-firmware, so a plain clone builds the firmware
obu-firmware builds against the vanetza-idf C-ITS library, which until now
came from the colleague's microbu-esp32c5 tree beside the repository and was
not tracked here, so a clone of this repository could not build the firmware
it ships. The library alone is now part of obu-firmware, as
obu-firmware/external/vanetza-idf: their external/vanetza-idf at commit
cf4b99f, unchanged (9775 files; see its PROVENANCE.md). CMake takes it from
there by default; -DVANETZA_IDF_DIR still points the build elsewhere.

The rest of the colleague's tree (their own VAM firmware, PKI tooling,
station-link Python tools, the V2X2MAP bridge) stays out of this repository
and gitignored; nothing is pushed to their repository. NOTES.md, docs/06,
TODO.md and the pcap verifier's usage line point at the new location.
2026-09-24 10:56:05 +02:00

76 lines
2.0 KiB
C++

#ifndef CBR_AGGREGATOR_HPP_VUGJW6BW
#define CBR_AGGREGATOR_HPP_VUGJW6BW
#include <vanetza/dcc/channel_load.hpp>
#include <vanetza/geonet/timestamp.hpp>
#include <array>
namespace vanetza
{
namespace geonet
{
class LocationTable;
/**
* CbrAggregator realises the CBR_G aggregation, originally specified by TS 102 636-4-2 V1.1.1
* section 5.2.2 and carried forward by TS 103 836-4-2 V2.1.1 clause 5.3 (Release 2; the
* five-step algorithm here, including using the previous cycle's local CBR in the final
* max(), matches the current text exactly).
*
* Since this algorithm relies mainly on location table entries it is placed in the geonet module.
*/
class CbrAggregator
{
public:
using ChannelLoad = dcc::ChannelLoad;
CbrAggregator();
/**
* Get local channel busy ratio, i.e. CBR_L_0_Hop
* \return CBR
*/
ChannelLoad get_local_cbr() const { return m_local_cbr[0]; }
/**
* Get one-hop channel busy ratio, i.e. CBR_L_1_Hop
* \return CBR
*/
ChannelLoad get_one_hop_cbr() const { return m_one_hop_cbr; }
/**
* Get two-hop channel busy ratio, i.e. CBR_L_2_Hop
* \return CBR
*/
ChannelLoad get_two_hop_cbr() const { return m_two_hop_cbr; }
/**
* Get global channel busy ratio
* \return CBR
*/
ChannelLoad get_global_cbr() const { return m_global_cbr; }
/**
* Aggregate {1,2}-hop CBRs from received CBR values stored in location table
* \parame local most recent local CBR measurement CBR_L_0_Hop
* \param lt location table containing LocTEX_G5 entries
* \param cbr_lifetime reject entries older than T_cbr
* \param cbr_target reference value
*/
void aggregate(ChannelLoad cbr_local, const LocationTable& lt, Timestamp cbr_lifetime, ChannelLoad cbr_target);
private:
std::array<ChannelLoad, 2> m_local_cbr;
ChannelLoad m_one_hop_cbr;
ChannelLoad m_two_hop_cbr;
ChannelLoad m_global_cbr;
};
} // namespace geonet
} // namespace vanetza
#endif /* CBR_AGGREGATOR_HPP_VUGJW6BW */