#include <router.hpp>
Public Types | |
enum class | PacketDropReason { Parse_Basic_Header , Parse_Common_Header , Parse_Secured_Header , Parse_Extended_Header , ITS_Protocol_Version , Decap_Unsuccessful_Non_Strict , Decap_Unsuccessful_Strict , Hop_Limit , Payload_Size , Security_Entity_Missing , Packet_Size , Internal_Error } |
Reason for packet drop used by drop hook. More... | |
enum class | ForwardingStopReason { Hop_Limit , Source_PDR , Sender_PDR , Outside_Destination_Area } |
typedef std::unique_ptr< DataRequest > | DataRequestPtr |
typedef std::unique_ptr< Pdu > | PduPtr |
typedef std::unique_ptr< DownPacket > | DownPacketPtr |
typedef std::unique_ptr< UpPacket > | UpPacketPtr |
using | PendingPacketForwarding = PendingPacket<GbcPdu, const MacAddress&> |
Public Member Functions | |
Router (Runtime &, const MIB &) | |
DataConfirm | request (const ShbDataRequest &, DownPacketPtr) |
Request to send payload per single hop broadcast (SHB). If security is enabled, the message gets encapsulated in a security envelope. Returns whether data was valid to be sent. | |
DataConfirm | request (const GbcDataRequest &, DownPacketPtr) |
Request to send payload per GeoBroadcast (GBC). If security is enabled, the message gets encapsulated in a security envelope. Returns whether data was valid to be sent. | |
DataConfirm | request (const GucDataRequest &, DownPacketPtr) |
DataConfirm | request (const GacDataRequest &, DownPacketPtr) |
DataConfirm | request (const TsbDataRequest &, DownPacketPtr) |
void | indicate (UpPacketPtr, const MacAddress &sender, const MacAddress &destination) |
Handle the received packet on network layer. Packet handling involves these steps: | |
void | update_position (const PositionFix &) |
Update router's local position vector. | |
void | set_transport_handler (UpperProtocol proto, TransportInterface *ifc) |
Register a transport protocol handler. | |
void | set_security_entity (security::SecurityEntity *entity) |
Register security entity used when itsGnSecurity is enabled. | |
void | set_access_interface (dcc::RequestInterface *ifc) |
Register access layer interface. | |
void | set_dcc_field_generator (DccFieldGenerator *dcc) |
Register generator for DCC-MCO fields. | |
void | set_address (const Address &) |
Set Router's own GeoNetworking address. | |
const MIB & | get_mib () const |
Get Management Information Base (MIB) | |
const CbfPacketBuffer & | get_cbf_buffer () const |
Get the Contention-Based-Forwarding buffer. | |
const LocationTable & | get_location_table () const |
Get the LocationTable. The table holds information about neighbouring ITS-Routers. | |
const LongPositionVector & | get_local_position_vector () const |
Get the local position vector. This vector describes the current position of the router. | |
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.4 and figure E.2 for details. | |
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 | forwarding_algorithm_selection (PendingPacketForwarding &&, const LinkLayer *ll=nullptr) |
Public Attributes | |
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. |
Private Types | |
typedef std::map< UpperProtocol, TransportInterface * > | transport_map_t |
Private Member Functions | |
void | on_beacon_timer_expired () |
Send Beacon packet to all neighbours with updated position vector. Only to be called when the beacon timer expires. | |
void | reset_beacon_timer () |
Reschedule timer for next Beacon transmission Timer will be scheduled according to MIB's Beacon timer settings. | |
void | reset_beacon_timer (Clock::duration next) |
Reschedule timer for next Beacon transmission. | |
void | indicate_basic (IndicationContextBasic &) |
Process BasicHeader at packet indication. | |
void | indicate_common (IndicationContext &, const BasicHeader &) |
Process CommonHeader at packet indication. | |
void | indicate_extended (IndicationContext &, const CommonHeader &) |
Process ExtendedHeader at packet indication. | |
void | indicate_secured (IndicationContextBasic &, const BasicHeader &) |
Process SecuredMessage at packet indication. | |
bool | process_extended (const ExtendedPduConstRefs< BeaconHeader > &, const UpPacket &, const LinkLayer &ll) |
Process ExtendedHeader information. Update router's LocationTable and neighbour relationship. | |
bool | process_extended (const ExtendedPduConstRefs< ShbHeader > &, const UpPacket &, const LinkLayer &ll) |
Process ExtendedHeader information. Update router's LocationTable and neighbour relationship. Pass packet up to transport layer for further processing. | |
bool | process_extended (const ExtendedPduConstRefs< TsbHeader > &, const UpPacket &, const LinkLayer &ll) |
packet handling of received TSB packet | |
bool | process_extended (const ExtendedPduConstRefs< GeoBroadcastHeader > &, const UpPacket &, const LinkLayer &ll) |
Process ExtendedHeader information. Update router's LocationTable and neighbour relationship. Pass packet up to transport layer for further processing. Forward packets. | |
void | flush_broadcast_forwarding_buffer () |
Send all packets in the broadcast forwarding buffer with expired waiting time. | |
void | flush_unicast_forwarding_buffer (const Address &addr) |
Send all matching packets in the unicast forwarding buffer with expired waiting time. | |
void | execute_media_procedures (CommunicationProfile) |
Executes media specific functionalities Details are described in TS 102 636-4-2. | |
void | execute_itsg5_procedures () |
Executes ITS-G5 media specific procedures Details are described in TS 102 636-4-2. | |
void | pass_down (const MacAddress &, PduPtr, DownPacketPtr) |
Pass down the packet to the access layer. | |
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 payload. | |
void | pass_up (const DataIndication &, UpPacketPtr) |
Pass packet up to the transport layer. | |
bool | decide_pass_up (bool within_destination, const GeoBroadcastHeader &gbc) |
Decide if GBC packet shall be passed up to transport layer. | |
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 packet Router's address is set to a new random address. | |
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. | |
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.3.1 Annex E.3. | |
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.3. | |
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.3 (non-area CBF, eq. E.1) and F.3 (area CBF, eq. F.1) | |
units::Duration | timeout_cbf (const MacAddress &sender) const |
Determine (area) CBF buffering time for a packet from a sender. | |
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.4. | |
void | dispatch_repetition (const DataRequestVariant &, DownPacketPtr) |
Callback function for dispatching a packet repetition. Invoked by Repeater when a scheduled repetition is due. | |
DownPacketPtr | encap_packet (ItsAid aid, ByteBuffer ssp, Pdu &pdu, DownPacketPtr packet) |
Encaspulate a packet according to security profile. | |
std::unique_ptr< ShbPdu > | create_shb_pdu (const ShbDataRequest &) |
Create an initialized Single-Hop-Broadcast PDU. | |
std::unique_ptr< BeaconPdu > | create_beacon_pdu () |
Create an initialzed Beacon PDU. | |
std::unique_ptr< GbcPdu > | create_gbc_pdu (const GbcDataRequest &) |
Create an initialized GeoBroadcast PDU. |
Router is the central entity for GeoNet communication
Incoming and outgoing GeoNet packets are handled by the router. It may even dispatch own packets (beacons) if necessary.
This implementation follows EN 302 636-4-1 v1.3.1
Definition at line 73 of file router.hpp.
typedef std::unique_ptr<DataRequest> vanetza::geonet::Router::DataRequestPtr |
Definition at line 76 of file router.hpp.
typedef std::unique_ptr<DownPacket> vanetza::geonet::Router::DownPacketPtr |
Definition at line 78 of file router.hpp.
typedef std::unique_ptr<Pdu> vanetza::geonet::Router::PduPtr |
Definition at line 77 of file router.hpp.
using vanetza::geonet::Router::PendingPacketForwarding = PendingPacket<GbcPdu, const MacAddress&> |
Definition at line 81 of file router.hpp.
|
private |
Definition at line 265 of file router.hpp.
typedef std::unique_ptr<UpPacket> vanetza::geonet::Router::UpPacketPtr |
Definition at line 79 of file router.hpp.
|
strong |
Definition at line 101 of file router.hpp.
|
strong |
Reason for packet drop used by drop hook.
Definition at line 84 of file router.hpp.
Definition at line 132 of file router.cpp.
vanetza::geonet::Router::~Router | ( | ) |
Definition at line 165 of file router.cpp.
|
private |
Determine next hop for area advanced forwarding See EN 302 636-4-1 v1.3.1 Annex F.4.
pdu | |
payload | |
ll | optional link-layer control info (if not source operations) |
Definition at line 890 of file router.cpp.
|
private |
Determine next hop for area contention-based forwarding See EN 302 636-4-1 v1.3.1 Annex F.3.
pdu | |
payload | |
sender | optional sender MAC address (if not first hop) |
Definition at line 844 of file router.cpp.
|
private |
|
private |
Create an initialized GeoBroadcast PDU.
request |
Definition at line 1331 of file router.cpp.
|
private |
Create an initialized Single-Hop-Broadcast PDU.
request |
Definition at line 1308 of file router.cpp.
|
private |
Decide if GBC packet shall be passed up to transport layer.
within_destination | is router located within destination area |
gbc | GeoBroadcast header |
Definition at line 1252 of file router.cpp.
|
private |
Helper method to handle duplicate addresses. If own address collides with the address of a received packet Router's address is set to a new random address.
source | address of source (from packet header) |
sender | address of sender (link layer) |
Definition at line 1276 of file router.cpp.
|
private |
Detect duplicate packets See EN 302 636-4-1 v1.3.1 Annex A.2.
source | source address |
sn | sequence number |
Definition at line 1293 of file router.cpp.
|
private |
Callback function for dispatching a packet repetition. Invoked by Repeater when a scheduled repetition is due.
request | |
payload |
Definition at line 758 of file router.cpp.
|
private |
Encaspulate a packet according to security profile.
aid | ITS-AID |
ssp | Service Specific Permissions |
pdu | PDU |
packet | Packet with payload |
Definition at line 1341 of file router.cpp.
|
private |
Executes ITS-G5 media specific procedures Details are described in TS 102 636-4-2.
Definition at line 661 of file router.cpp.
|
private |
Executes media specific functionalities Details are described in TS 102 636-4-2.
profile | e.g. ITS-G5 |
Definition at line 645 of file router.cpp.
|
private |
Send all packets in the broadcast forwarding buffer with expired waiting time.
Definition at line 1265 of file router.cpp.
|
private |
Send all matching packets in the unicast forwarding buffer with expired waiting time.
addr | unicast packets for this address |
Definition at line 1270 of file router.cpp.
NextHop vanetza::geonet::Router::forwarding_algorithm_selection | ( | PendingPacketForwarding && | packet, |
const LinkLayer * | ll = nullptr ) |
Forwarding algorithm selection procedure as given by Annex D
pdu | GeoNetworking PDU |
payload | packet payload |
ll | link-layer control info (unavailable for source operations) |
Definition at line 597 of file router.cpp.
|
inline |
Get the Contention-Based-Forwarding buffer.
Definition at line 219 of file router.hpp.
|
inline |
Get the local position vector. This vector describes the current position of the router.
Definition at line 235 of file router.hpp.
|
inline |
Get the LocationTable. The table holds information about neighbouring ITS-Routers.
Definition at line 227 of file router.hpp.
|
inline |
Get Management Information Base (MIB)
Definition at line 212 of file router.hpp.
|
private |
Determine next hop for greedy forwarding. See EN 302 636-4-1 v1.3.1 Annex E.2.
pdu | |
payload |
Definition at line 764 of file router.cpp.
void vanetza::geonet::Router::indicate | ( | UpPacketPtr | packet, |
const MacAddress & | sender, | ||
const MacAddress & | destination ) |
Handle the received packet on network layer. Packet handling involves these steps:
packet | received packet from access layer |
sender | MAC address of sender |
destination | MAC address of destination (might be broadcast) |
Definition at line 374 of file router.cpp.
|
private |
Process BasicHeader at packet indication.
ctx | Context holding data for further parsing |
Definition at line 399 of file router.cpp.
|
private |
Process CommonHeader at packet indication.
ctx | Context holding data for further parsing |
basic | Previously decoded BasicHeader |
Definition at line 424 of file router.cpp.
|
private |
Process ExtendedHeader at packet indication.
ctx | Context holding data for further parsing |
common | Previously decoded CommonHeader |
Definition at line 526 of file router.cpp.
|
private |
Process SecuredMessage at packet indication.
ctx | Context holding data for further parsing |
basic | Previously decoded BasicHeader |
Definition at line 467 of file router.cpp.
|
private |
Determine next hop for non-area contention-based forwarding See EN 302 636-4-1 v1.3.1 Annex E.3.
pdu | |
payload | |
sender | optional sender MAC address (if not first hop) |
Definition at line 803 of file router.cpp.
|
private |
Send Beacon packet to all neighbours with updated position vector. Only to be called when the beacon timer expires.
Definition at line 710 of file router.cpp.
bool vanetza::geonet::Router::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.4 and figure E.2 for details.
sender | |
forwarder |
Definition at line 950 of file router.cpp.
|
private |
Send packet using the information in the DataRequest. The packet is formed using the data in PDU and payload.
request | containing transmission parameters |
pdu | header information |
payload | Packet payload |
Definition at line 666 of file router.cpp.
|
private |
Pass down the packet to the access layer.
addr | MAC address of destination |
pdu | header information |
payload | Packet payload |
Definition at line 688 of file router.cpp.
|
private |
Pass packet up to the transport layer.
ind | containing network information |
packet | payload to be passed up to the next layer |
Definition at line 702 of file router.cpp.
|
private |
Process ExtendedHeader information. Update router's LocationTable and neighbour relationship.
pdu | containing the ExtendedHeader |
packet | received packet |
ll | link-layer control info |
Definition at line 1109 of file router.cpp.
|
private |
Process ExtendedHeader information. Update router's LocationTable and neighbour relationship. Pass packet up to transport layer for further processing. Forward packets.
pdu | containing the ExtendedHeader |
packet | received packet |
ll | link-layer control info |
Definition at line 1131 of file router.cpp.
|
private |
Process ExtendedHeader information. Update router's LocationTable and neighbour relationship. Pass packet up to transport layer for further processing.
pdu | containing the ExtendedHeader |
packet | received packet |
ll | link-layer control info |
Definition at line 978 of file router.cpp.
|
private |
packet handling of received TSB packet
pdu | PDU with TSB header |
packet | received packet |
ll | link-layer control info |
Definition at line 1013 of file router.cpp.
DataConfirm vanetza::geonet::Router::request | ( | const GacDataRequest & | , |
DownPacketPtr | ) |
Definition at line 359 of file router.cpp.
DataConfirm vanetza::geonet::Router::request | ( | const GbcDataRequest & | request, |
DownPacketPtr | payload ) |
Request to send payload per GeoBroadcast (GBC). If security is enabled, the message gets encapsulated in a security envelope. Returns whether data was valid to be sent.
request | |
payload | from upper layers |
Definition at line 284 of file router.cpp.
DataConfirm vanetza::geonet::Router::request | ( | const GucDataRequest & | , |
DownPacketPtr | ) |
Definition at line 364 of file router.cpp.
DataConfirm vanetza::geonet::Router::request | ( | const ShbDataRequest & | request, |
DownPacketPtr | payload ) |
Request to send payload per single hop broadcast (SHB). If security is enabled, the message gets encapsulated in a security envelope. Returns whether data was valid to be sent.
request | |
payload | from upper layers |
Definition at line 222 of file router.cpp.
DataConfirm vanetza::geonet::Router::request | ( | const TsbDataRequest & | , |
DownPacketPtr | ) |
Definition at line 369 of file router.cpp.
|
private |
Reschedule timer for next Beacon transmission Timer will be scheduled according to MIB's Beacon timer settings.
Definition at line 737 of file router.cpp.
|
private |
Reschedule timer for next Beacon transmission.
next | Duration until next transmission |
Definition at line 750 of file router.cpp.
void vanetza::geonet::Router::set_access_interface | ( | dcc::RequestInterface * | ifc | ) |
Register access layer interface.
ifc | interface used for passing packets down to access layer |
Definition at line 200 of file router.cpp.
void vanetza::geonet::Router::set_address | ( | const Address & | addr | ) |
void vanetza::geonet::Router::set_dcc_field_generator | ( | DccFieldGenerator * | dcc | ) |
Register generator for DCC-MCO fields.
dcc | DCC-MCO field generator or nullptr for disabling feature |
Definition at line 206 of file router.cpp.
void vanetza::geonet::Router::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.
seed | reset RNG's state to this seed |
Definition at line 217 of file router.cpp.
void vanetza::geonet::Router::set_security_entity | ( | security::SecurityEntity * | entity | ) |
Register security entity used when itsGnSecurity is enabled.
entity | security entity |
Definition at line 195 of file router.cpp.
void vanetza::geonet::Router::set_transport_handler | ( | UpperProtocol | proto, |
TransportInterface * | ifc ) |
Register a transport protocol handler.
proto | register handler for this upper protocol |
ifc | use this interface or disable handling if nullptr |
Definition at line 190 of file router.cpp.
|
private |
Determine (area) CBF buffering time for a packet from a sender.
This is a shortcut for a re-curring pattern in Annex F.3 and F.4: 1) sender position is looked up in location table 2) position accuracy of sender is validated (if it is found) 3) progress is then distance between sender and local router
sender | MAC address of sender |
Definition at line 878 of file router.cpp.
|
private |
Determine CBF buffering time for a packet. Complies to EN 302 636-4-1 v1.3.1 Annex E.3 (non-area CBF, eq. E.1) and F.3 (area CBF, eq. F.1)
dist | distance or progress (interpretation depends on non-area vs. area CBF) |
Definition at line 862 of file router.cpp.
void vanetza::geonet::Router::update_position | ( | const PositionFix & | position_fix | ) |
Update router's local position vector.
fix | current position fix |
Definition at line 170 of file router.cpp.
Hook<ForwardingStopReason> vanetza::geonet::Router::forwarding_stopped |
When packet forwarding is stopped, this Hook is invoked.
ForwardingStopReason | why Router decided not to forward packet |
Definition at line 163 of file router.hpp.
|
private |
Definition at line 555 of file router.hpp.
|
private |
Definition at line 557 of file router.hpp.
|
private |
Definition at line 551 of file router.hpp.
|
private |
Definition at line 562 of file router.hpp.
|
private |
Definition at line 558 of file router.hpp.
|
private |
Definition at line 559 of file router.hpp.
|
private |
Definition at line 554 of file router.hpp.
|
private |
Definition at line 548 of file router.hpp.
|
private |
Definition at line 561 of file router.hpp.
|
private |
Definition at line 560 of file router.hpp.
|
private |
Definition at line 550 of file router.hpp.
|
private |
Definition at line 549 of file router.hpp.
|
private |
Definition at line 552 of file router.hpp.
|
private |
Definition at line 553 of file router.hpp.
|
private |
Definition at line 556 of file router.hpp.
Hook<PacketDropReason> vanetza::geonet::Router::packet_dropped |
When a packet is dropped, this Hook is invoked.
PacketDropReason | why Router decided to drop packet |
Definition at line 157 of file router.hpp.