1#ifndef ROUTER_HPP_UKYYCAR0
2#define ROUTER_HPP_UKYYCAR0
4#include <vanetza/common/byte_order.hpp>
5#include <vanetza/common/hook.hpp>
6#include <vanetza/common/its_aid.hpp>
7#include <vanetza/access/ethertype.hpp>
8#include <vanetza/geonet/beacon_header.hpp>
9#include <vanetza/geonet/cbf_packet_buffer.hpp>
10#include <vanetza/geonet/common_header.hpp>
11#include <vanetza/geonet/extended_pdu.hpp>
12#include <vanetza/geonet/gbc_header.hpp>
13#include <vanetza/geonet/gbc_memory.hpp>
14#include <vanetza/geonet/interface.hpp>
15#include <vanetza/geonet/location_table.hpp>
16#include <vanetza/geonet/mib.hpp>
17#include <vanetza/geonet/packet.hpp>
18#include <vanetza/geonet/packet_buffer.hpp>
19#include <vanetza/geonet/pending_packet.hpp>
20#include <vanetza/geonet/pdu.hpp>
21#include <vanetza/geonet/pdu_variant.hpp>
22#include <vanetza/geonet/repeater.hpp>
23#include <vanetza/geonet/sequence_number.hpp>
24#include <vanetza/geonet/shb_header.hpp>
25#include <vanetza/geonet/timestamp.hpp>
26#include <vanetza/units/length.hpp>
27#include <vanetza/units/time.hpp>
28#include <vanetza/security/security_entity.hpp>
29#include <boost/variant.hpp>
52extern const access::EtherType ether_type;
66
67
68
69
70
71
72
76 typedef std::unique_ptr<DataRequest> DataRequestPtr;
77 typedef std::unique_ptr<Pdu> PduPtr;
78 typedef std::unique_ptr<DownPacket> DownPacketPtr;
79 typedef std::unique_ptr<UpPacket> UpPacketPtr;
89 Parse_Extended_Header,
91 Decap_Unsuccessful_Non_Strict,
92 Decap_Unsuccessful_Strict,
95 Security_Entity_Missing,
101 enum class ForwardingStopReason
106 Outside_Destination_Area
113
114
115
116
117
118
119
120
124
125
126
127
128
129
130
131
140
141
142
143
144
145
146
147
148
149
150
154
155
156
160
161
162
166
167
168
169
173
174
175
176
177
181
182
183
184
188
189
190
191
195
196
197
198
202
203
204
205
209
210
211
215
216
217
218
222
223
224
225
226
230
231
232
233
234
238
239
240
241
242
243
244
248
249
250
251
252
256
257
258
259
260
261
265 typedef std::map<UpperProtocol, TransportInterface*> transport_map_t;
268
269
270
274
275
276
280
281
282
286
287
288
292
293
294
295
299
300
301
302
306
307
308
309
313
314
315
316
317
318
319
320
324
325
326
327
328
329
330
331
332
336
337
338
339
340
341
342
346
347
348
349
350
351
352
353
354
355
359
360
364
365
366
370
371
372
373
374
378
379
380
384
385
386
387
388
389
393
394
395
396
397
398
399
403
404
405
406
407
411
412
413
414
415
416
417
421
422
423
424
425
426
427
428
432
433
434
435
436
437
438
442
443
444
445
446
447
448
452
453
454
455
456
457
458
459
463
464
465
466
467
468
469
470
474
475
476
477
478
479
480 units::Duration
timeout_cbf(units::Length distance)
const;
483
484
485
486
487
488
489
490
491
492
496
497
498
499
500
501
502
503
507
508
509
510
511
512
516
517
518
519
520
521
522
523 DownPacketPtr
encap_packet(ItsAid aid, ByteBuffer ssp,
Pdu& pdu, DownPacketPtr packet);
526
527
528
529
530
534
535
536
537
541
542
543
544
545
553 transport_map_t m_transport_ifcs;
561 std::mt19937 m_random_gen;
566
567
568
569
virtual const PositionFix & position_fix()=0
virtual void cancel(const void *scope)=0
void update_rate(Clock::duration interval)
PositionUpdater(Runtime &runtime, PositionProvider &pos, Router &router)
void reset_beacon_timer(Clock::duration next)
Reschedule timer for next Beacon transmission.
const CbfPacketBuffer & get_cbf_buffer() const
Get the Contention-Based-Forwarding buffer.
NextHop area_advanced_forwarding(PendingPacketForwarding &&, const LinkLayer *sender)
Determine next hop for area advanced forwarding See EN 302 636-4-1 v1.3.1 Annex F....
void flush_broadcast_forwarding_buffer()
Send all packets in the broadcast forwarding buffer with expired waiting time.
void indicate_extended(IndicationContext &, const CommonHeader &)
Process ExtendedHeader at packet indication.
const MIB & get_mib() const
Get Management Information Base (MIB).
bool detect_duplicate_packet(const Address &source, SequenceNumber sn)
Detect duplicate packets See EN 302 636-4-1 v1.3.1 Annex A.2.
void pass_down(const dcc::DataRequest &, PduPtr, DownPacketPtr)
Send packet using the information in the DataRequest. The packet is formed using the data in PDU and ...
NextHop greedy_forwarding(PendingPacketForwarding &&)
Determine next hop for greedy forwarding. See EN 302 636-4-1 v1.3.1 Annex E.2.
bool process_extended(const ExtendedPduConstRefs< ShbHeader > &, const UpPacket &, const LinkLayer &ll)
Process ExtendedHeader information. Update router's LocationTable and neighbour relationship....
void pass_up(const DataIndication &, UpPacketPtr)
Pass packet up to the transport layer.
units::Duration timeout_cbf(units::Length distance) const
Determine CBF buffering time for a packet. Complies to EN 302 636-4-1 v1.3.1 Annex E....
void on_beacon_timer_expired()
Send Beacon packet to all neighbours with updated position vector. Only to be called when the beacon ...
void indicate_common(IndicationContext &, const BasicHeader &)
Process CommonHeader at packet indication.
DownPacketPtr encap_packet(ItsAid aid, ByteBuffer ssp, Pdu &pdu, DownPacketPtr packet)
Encaspulate a packet according to security profile.
bool decide_pass_up(bool within_destination, const GeoBroadcastHeader &gbc)
Decide if GBC packet shall be passed up to transport layer.
void set_access_interface(dcc::RequestInterface *ifc)
Register access layer interface.
void set_random_seed(std::uint_fast32_t seed)
Set seed for internal random number generator (RNG) RNG is used e.g. for random Beacon jitter.
units::Duration timeout_cbf(const MacAddress &sender) const
Determine (area) CBF buffering time for a packet from a sender.
NextHop area_contention_based_forwarding(PendingPacketForwarding &&, const MacAddress *sender)
Determine next hop for area contention-based forwarding See EN 302 636-4-1 v1.3.1 Annex F....
std::unique_ptr< ShbPdu > create_shb_pdu(const ShbDataRequest &)
Create an initialized Single-Hop-Broadcast PDU.
void flush_unicast_forwarding_buffer(const Address &addr)
Send all matching packets in the unicast forwarding buffer with expired waiting time.
void detect_duplicate_address(const Address &source, const MacAddress &sender)
Helper method to handle duplicate addresses. If own address collides with the address of a received p...
std::unique_ptr< BeaconPdu > create_beacon_pdu()
Create an initialzed Beacon PDU.
void indicate_basic(IndicationContextBasic &)
Process BasicHeader at packet indication.
void set_dcc_field_generator(DccFieldGenerator *dcc)
Register generator for DCC-MCO fields.
Hook< PacketDropReason > packet_dropped
When a packet is dropped, this Hook is invoked.
bool process_extended(const ExtendedPduConstRefs< TsbHeader > &, const UpPacket &, const LinkLayer &ll)
packet handling of received TSB packet
Hook< ForwardingStopReason > forwarding_stopped
When packet forwarding is stopped, this Hook is invoked.
PacketDropReason
Reason for packet drop used by drop hook.
const LocationTable & get_location_table() const
Get the LocationTable. The table holds information about neighbouring ITS-Routers.
DataConfirm request(const ShbDataRequest &, DownPacketPtr)
Request to send payload per single hop broadcast (SHB). If security is enabled, the message gets enca...
void pass_down(const MacAddress &, PduPtr, DownPacketPtr)
Pass down the packet to the access layer.
void dispatch_repetition(const DataRequestVariant &, DownPacketPtr)
Callback function for dispatching a packet repetition. Invoked by Repeater when a scheduled repetitio...
NextHop non_area_contention_based_forwarding(PendingPacketForwarding &&, const MacAddress *sender)
Determine next hop for non-area contention-based forwarding See EN 302 636-4-1 v1....
bool process_extended(const ExtendedPduConstRefs< GeoBroadcastHeader > &, const UpPacket &, const LinkLayer &ll)
Process ExtendedHeader information. Update router's LocationTable and neighbour relationship....
void indicate(UpPacketPtr, const MacAddress &sender, const MacAddress &destination)
Handle the received packet on network layer. Packet handling involves these steps:
void set_transport_handler(UpperProtocol proto, TransportInterface *ifc)
Register a transport protocol handler.
void reset_beacon_timer()
Reschedule timer for next Beacon transmission Timer will be scheduled according to MIB's Beacon timer...
void update_position(const PositionFix &)
Update router's local position vector.
void execute_media_procedures(CommunicationProfile)
Executes media specific functionalities Details are described in TS 102 636-4-2.
void set_security_entity(security::SecurityEntity *entity)
Register security entity used when itsGnSecurity is enabled.
std::unique_ptr< GbcPdu > create_gbc_pdu(const GbcDataRequest &)
Create an initialized GeoBroadcast PDU.
void set_address(const Address &)
Set Router's own GeoNetworking address.
NextHop forwarding_algorithm_selection(PendingPacketForwarding &&, const LinkLayer *ll=nullptr)
DataConfirm request(const GbcDataRequest &, DownPacketPtr)
Request to send payload per GeoBroadcast (GBC). If security is enabled, the message gets encapsulated...
const LongPositionVector & get_local_position_vector() const
Get the local position vector. This vector describes the current position of the router.
void execute_itsg5_procedures()
Executes ITS-G5 media specific procedures Details are described in TS 102 636-4-2.
bool process_extended(const ExtendedPduConstRefs< BeaconHeader > &, const UpPacket &, const LinkLayer &ll)
Process ExtendedHeader information. Update router's LocationTable and neighbour relationship.
void indicate_secured(IndicationContextBasic &, const BasicHeader &)
Process SecuredMessage at packet indication.
bool outside_sectorial_contention_area(const MacAddress &sender, const MacAddress &forwarder) const
Check if router is outside the sectorial contention area See TS 102 636-4-1 v1.2.3 section E....