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>
46 class RequestInterface;
52extern const access::EtherType ether_type;
54class DccFieldGenerator;
55class IndicationContext;
56class IndicationContextBasic;
58class TransportInterface;
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
99 enum class ForwardingStopReason
104 Outside_Destination_Area
119 DataConfirm
request(
const ShbDataRequest&, DownPacketPtr);
130 DataConfirm
request(
const GbcDataRequest&, DownPacketPtr);
133 DataConfirm
request(
const GucDataRequest&, DownPacketPtr);
134 DataConfirm
request(
const GacDataRequest&, DownPacketPtr);
135 DataConfirm
request(
const TsbDataRequest&, DownPacketPtr);
263 typedef std::map<UpperProtocol, TransportInterface*> transport_map_t;
468 units::Duration
timeout_cbf(units::Length distance)
const;
510 DownPacketPtr
encap_packet(ItsAid aid,
Pdu& pdu, DownPacketPtr packet);
540 transport_map_t m_transport_ifcs;
548 std::mt19937 m_random_gen;
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.
NextHop greedy_forwarding(PendingPacketForwarding &&)
Determine next hop for greedy forwarding. See EN 302 636-4-1 v1.3.1 Annex E.2.
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.
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.
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.
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....
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.
DownPacketPtr encap_packet(ItsAid aid, Pdu &pdu, DownPacketPtr packet)
Encaspulate a packet according to security profile.
void set_address(const Address &)
Set Router's own GeoNetworking address.
NextHop forwarding_algorithm_selection(PendingPacketForwarding &&, const LinkLayer *ll=nullptr)
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....