Vanetza
Loading...
Searching...
No Matches
dcc_information_sharing.hpp
1#ifndef DCC_INFORMATION_SHARING_HPP_GZCSHZLD
2#define DCC_INFORMATION_SHARING_HPP_GZCSHZLD
3
4#include <vanetza/common/clock.hpp>
5#include <vanetza/common/hook.hpp>
6#include <vanetza/common/unit_interval.hpp>
7#include <vanetza/geonet/cbr_aggregator.hpp>
8#include <vanetza/geonet/dcc_field_generator.hpp>
9
10namespace vanetza
11{
12
13class Runtime;
14
15namespace geonet
16{
17
18class LocationTable;
19
20/**
21 * DccInformationSharing realises the DCC_net behaviour for ITS-G5
22 * \see TS 102 636-4-2 V1.1.1
23 *
24 * CBR_target mentioned in TS 102 636-4-2 V1.1.1 is probably the same constant as
25 * NDL_maxChannelUse mentioned in TS 102 687 V1.1.1. However, no value is given:
26 * Table A.3 in TS 102 687 declares them (implicitly through NDL_tmPacketArrivalrate) "n.a.".
27 * Thus, we simply assume CBR_target = NDL_maxChannelUse = NDL_maxChannelLoad.
28 */
30{
31public:
32 /**
33 * Create DCC_net instance
34 *
35 * \param rt Runtime for scheduling periodic update cycles
36 * \param lt Location Table with LocTEX_G5 entries
37 * \param target CBR_target value (usually NDL_maxChannelLoad)
38 * \param delay Delaying first update cycle randomly
39 *
40 * \note Set random delay interval when multiple stations are created at the same time!
41 * Values shall be distributed uniformly across full integer range.
42 */
43 DccInformationSharing(Runtime& rt, const LocationTable& lt, dcc::ChannelLoad target, UnitInterval delay);
44 DccInformationSharing(Runtime& rt, const LocationTable& lt, dcc::ChannelLoad target);
45
46 DccField generate_dcc_field() override;
47
48 /**
49 * Update local CBR measurement
50 *
51 * Local measurement rate is decoupled from processing in DCC_net,
52 * i.e. DccInformationSharing buffers the given value and the latest
53 * measurement value when its internal update cycle runs.
54 *
55 * \param cbr local CBR measurement
56 */
57 void update_local_cbr(dcc::ChannelLoad cbr);
58
59 /**
60 * Set packet TX power
61 *
62 * \param power Packet transmission output power in dBm
63 */
64 void set_tx_power(unsigned power);
65
66private:
67 void trigger();
68
69 Runtime& m_runtime;
70 const LocationTable& m_location_table;
71 const dcc::ChannelLoad m_cbr_target;
72 dcc::ChannelLoad m_cbr_local;
73 unsigned m_tx_power;
74 CbrAggregator m_aggregator;
75 Clock::duration m_trigger_interval;
76 Timestamp m_last_aggregation;
77 Hook<const CbrAggregator&> m_update_hook;
78
79public:
80 /**
81 * on_global_cbr_update is called at each update cycle,
82 * i.e. when a new global CBR has been calculated
83 */
85};
86
87} // namespace geonet
88} // namespace vanetza
89
90#endif /* DCC_INFORMATION_SHARING_HPP_GZCSHZLD */
DccInformationSharing(Runtime &rt, const LocationTable &lt, dcc::ChannelLoad target, UnitInterval delay)
HookRegistry< const CbrAggregator & > on_global_cbr_update
void output_power(unsigned dbm)