Vanetza
 
Loading...
Searching...
No Matches
limeric.hpp
1#ifndef LIMERIC_HPP_OPCJEHBN
2#define LIMERIC_HPP_OPCJEHBN
3
4#include <vanetza/common/clock.hpp>
5#include <vanetza/common/hook.hpp>
6#include <vanetza/common/unit_interval.hpp>
7#include <vanetza/dcc/channel_load.hpp>
8#include <vanetza/dcc/duty_cycle_permit.hpp>
9#include <boost/circular_buffer.hpp>
10#include <boost/optional/optional.hpp>
11#include <chrono>
12
13namespace vanetza
14{
15
16// forward declaration
17class Runtime;
18
19namespace dcc
20{
21
22/**
23 * LIMERIC adapted to ETSI ITS
24 *
25 * This implementation follows TS 102 687 v1.2.1 section 5.4
26 * Optionally, the dual-alpha convergence proposed in [1] can be enabled.
27 *
28 * [1] Ignacio Soto, Oscar Amador, Manuel Uruena, Maria Calderon
29 * "Strengths and Weaknesses of the ETSI Adaptive DCC Algorithm: A Proposal for Improvement"
30 * DOI: 10.1109/LCOMM.2019.2906178
31 */
33{
34public:
35 /**
36 * Limeric paremeters as given by TS 102 687 v1.2.1, Table 3
37 */
39 {
40 UnitInterval alpha { 0.016 }; /*< also named alpha_low if dual-alpha is enabled */
41 UnitInterval beta { 0.0012 };
42 UnitInterval delta_max { 0.03 }; /*< upper bound permitted duty cycle */
43 UnitInterval delta_min { 0.0006 }; /*< lower bound permitted duty cycle */
44 double g_plus_max = 0.0005;
45 double g_minus_max = -0.00025;
46 ChannelLoad cbr_target { 0.68 };
47 Clock::duration cbr_interval = std::chrono::milliseconds(100); /*< algorithm is scheduled every second interval */
48 };
49
51 {
52 UnitInterval alternate_alpha { 0.1 }; /*< called alpha_high in [1] */
53 UnitInterval threshold { 0.00001 }; /* heuristically determined threshold for switching between alphas */
54 };
55
57 Limeric(Runtime&, const Parameters&);
58 ~Limeric();
59
60 /**
61 * Report new channel load measurement
62 * \param cl channel load measurement
63 */
65
66 /**
67 * Get current averaged CBR.
68 * \note The result incorporates previous measurements as well as the averaged CBR during last periodic update.
69 * \return averaged CBR
70 */
72
73 /**
74 * Get permitted duty cycle as calculated by the last periodic update
75 * \return permitted duty cycle
76 */
77 UnitInterval permitted_duty_cycle() const override { return m_duty_cycle; }
78
79 /**
80 * Called every time the permitted duty cycle is updated
81 * \param this instance itself
82 * \param time point for which algorithm update has been scheduled
83 */
85
86 /**
87 * Configure dual-alpha convergence
88 * \param params dual-alpha parameters, boost::none disables dual-alpha convergence
89 */
90 void configure_dual_alpha(const boost::optional<DualAlphaParameters>& params);
91
92private:
93 void calculate(Clock::time_point);
94 void schedule();
95 UnitInterval calculate_duty_cycle() const;
96
97 Runtime& m_runtime;
98 Parameters m_params;
99 boost::optional<DualAlphaParameters> m_dual_alpha;
100 ChannelLoad m_channel_load; /*< moving average channel load */
101 UnitInterval m_duty_cycle;
102 boost::circular_buffer<ChannelLoad> m_cbr;
103 Hook<const Limeric*, Clock::time_point> m_duty_cycle_change;
104};
105
106} // namespace dcc
107} // namespace vanetza
108
109#endif /* LIMERIC_HPP_OPCJEHBN */
110
void update_cbr(ChannelLoad)
Definition: limeric.cpp:40
void configure_dual_alpha(const boost::optional< DualAlphaParameters > &params)
Definition: limeric.cpp:94
ChannelLoad average_cbr() const
Definition: limeric.cpp:31
UnitInterval permitted_duty_cycle() const override
Definition: limeric.hpp:77
HookRegistry< const Limeric *, Clock::time_point > on_duty_cycle_change
Definition: limeric.hpp:84