#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 } |
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< 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, 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 263 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 99 of file router.hpp.
|
strong |
Reason for packet drop used by drop hook.
Definition at line 84 of file router.hpp.
Definition at line 129 of file router.cpp.
vanetza::geonet::Router::~Router | ( | ) |
Definition at line 162 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 892 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 846 of file router.cpp.
|
private |
|
private |
Create an initialized GeoBroadcast PDU.
request |
Definition at line 1237 of file router.cpp.
|
private |
Create an initialized Single-Hop-Broadcast PDU.
request |
Definition at line 1214 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 1158 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 1182 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 1199 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 760 of file router.cpp.
|
private |
Encaspulate a packet according to security profile.
aid | ITS-AID |
pdu | PDU |
packet | Packet with payload |
Definition at line 1247 of file router.cpp.
|
private |
Executes ITS-G5 media specific procedures Details are described in TS 102 636-4-2.
Definition at line 667 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 652 of file router.cpp.
|
private |
Send all packets in the broadcast forwarding buffer with expired waiting time.
Definition at line 1171 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 1176 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 604 of file router.cpp.
|
inline |
Get the Contention-Based-Forwarding buffer.
Definition at line 217 of file router.hpp.
|
inline |
Get the local position vector. This vector describes the current position of the router.
Definition at line 233 of file router.hpp.
|
inline |
Get the LocationTable. The table holds information about neighbouring ITS-Routers.
Definition at line 225 of file router.hpp.
|
inline |
Get Management Information Base (MIB)
Definition at line 210 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 766 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 363 of file router.cpp.
|
private |
Process BasicHeader at packet indication.
ctx | Context holding data for further parsing |
Definition at line 400 of file router.cpp.
|
private |
Process CommonHeader at packet indication.
ctx | Context holding data for further parsing |
basic | Previously decoded BasicHeader |
Definition at line 426 of file router.cpp.
|
private |
Process ExtendedHeader at packet indication.
ctx | Context holding data for further parsing |
common | Previously decoded CommonHeader |
Definition at line 543 of file router.cpp.
|
private |
Process SecuredMessage at packet indication.
ctx | Context holding data for further parsing |
basic | Previously decoded BasicHeader |
Definition at line 469 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 805 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 716 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 952 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 672 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 694 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 708 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 1015 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 1037 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 980 of file router.cpp.
DataConfirm vanetza::geonet::Router::request | ( | const GacDataRequest & | , |
DownPacketPtr | |||
) |
Definition at line 348 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 277 of file router.cpp.
DataConfirm vanetza::geonet::Router::request | ( | const GucDataRequest & | , |
DownPacketPtr | |||
) |
Definition at line 353 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 219 of file router.cpp.
DataConfirm vanetza::geonet::Router::request | ( | const TsbDataRequest & | , |
DownPacketPtr | |||
) |
Definition at line 358 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 739 of file router.cpp.
|
private |
Reschedule timer for next Beacon transmission.
next | Duration until next transmission |
Definition at line 752 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 197 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 203 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 214 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 192 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 187 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 880 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 864 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 167 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 161 of file router.hpp.
|
private |
Definition at line 542 of file router.hpp.
|
private |
Definition at line 544 of file router.hpp.
|
private |
Definition at line 538 of file router.hpp.
|
private |
Definition at line 549 of file router.hpp.
|
private |
Definition at line 545 of file router.hpp.
|
private |
Definition at line 546 of file router.hpp.
|
private |
Definition at line 541 of file router.hpp.
|
private |
Definition at line 535 of file router.hpp.
|
private |
Definition at line 548 of file router.hpp.
|
private |
Definition at line 547 of file router.hpp.
|
private |
Definition at line 537 of file router.hpp.
|
private |
Definition at line 536 of file router.hpp.
|
private |
Definition at line 539 of file router.hpp.
|
private |
Definition at line 540 of file router.hpp.
|
private |
Definition at line 543 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 155 of file router.hpp.