Vanetza
 
Loading...
Searching...
No Matches
burst_budget.hpp
1#ifndef BURST_BUDGET_HPP_U5GXDCZN
2#define BURST_BUDGET_HPP_U5GXDCZN
3
4#include <vanetza/common/clock.hpp>
5#include <boost/circular_buffer.hpp>
6#include <chrono>
7#include <cstddef>
8
9namespace vanetza
10{
11
12// forward declaration
13class Runtime;
14
15namespace dcc
16{
17
18/**
19 * BurstBudget: TRC restrictions for DP0 message bursts as per C2C-CC BSP.
20 */
22{
23public:
24 BurstBudget(const Runtime&);
26
27 /**
28 * Get current delay to remain in budget
29 * \return shortest delay not exceeding budget
30 */
31 Clock::duration delay();
32
33 /**
34 * Notify budget of consumption
35 */
36 void notify();
37
38 /**
39 * Set upper limit of messages per burst
40 * \param n burst limit
41 */
42 void burst_messages(std::size_t n);
43
44 /**
45 * Set maximum duration per burst
46 * \param d burst duration
47 */
48 void burst_duration(Clock::duration d);
49
50 /**
51 * Set minimum duration between bursts
52 * \param p burst period
53 */
54 void burst_period(Clock::duration p);
55
56 /**
57 * Get burst interval
58 * \return bust interval
59 */
60 Clock::duration burst_period() const { return m_burst_period; }
61
62private:
63 const Runtime& m_runtime;
64 boost::circular_buffer<Clock::time_point> m_messages;
65 Clock::duration m_burst_duration;
66 Clock::duration m_burst_period;
67};
68
69} // namespace dcc
70} // namespace vanetza
71
72#endif /* BURST_BUDGET_HPP_U5GXDCZN */
73
Clock::duration burst_period() const
void burst_duration(Clock::duration d)
Clock::duration delay()
void burst_messages(std::size_t n)