#include <cbf_packet_buffer.hpp>
|
using | timer_bimap = boost::bimaps::bimap< boost::bimaps::multiset_of< Timer >, boost::bimaps::unordered_set_of< Identifier, std::hash< Identifier > >, boost::bimaps::with_info< std::list< CbfPacket >::iterator > > |
|
CbfPacketBuffer facilitates implementation of contention based forwarding
Definition at line 84 of file cbf_packet_buffer.hpp.
◆ Identifier
using vanetza::geonet::CbfPacketBuffer::Identifier = CbfPacketIdentifier |
◆ timer_bimap
using vanetza::geonet::CbfPacketBuffer::timer_bimap = boost::bimaps::bimap< boost::bimaps::multiset_of<Timer>, boost::bimaps::unordered_set_of<Identifier, std::hash<Identifier> >, boost::bimaps::with_info<std::list<CbfPacket>::iterator> > |
|
private |
◆ TimerCallback
using vanetza::geonet::CbfPacketBuffer::TimerCallback = std::function<void(PendingPacket<GbcPdu>&&)> |
◆ CbfPacketBuffer()
vanetza::geonet::CbfPacketBuffer::CbfPacketBuffer |
( |
Runtime & |
rt, |
|
|
TimerCallback |
cb, |
|
|
std::unique_ptr< CbfCounter > |
cnt, |
|
|
std::size_t |
bytes |
|
) |
| |
Create CBF packet buffer with bounded capacity
- Parameters
-
rt | Runtime instance used for internal timers |
cb | Callback invoked for each packet on expiry |
cnt | CBF counter implementation |
bytes | Buffer can hold at most this number of bytes |
Definition at line 51 of file cbf_packet_buffer.cpp.
◆ ~CbfPacketBuffer()
vanetza::geonet::CbfPacketBuffer::~CbfPacketBuffer |
( |
| ) |
|
◆ add()
void vanetza::geonet::CbfPacketBuffer::add |
( |
CbfPacket && |
packet, |
|
|
Clock::duration |
timeout |
|
) |
| |
Enqueue a packet and start an associated timer expiring after timeout
- Parameters
-
packet | Buffer this packet |
timeout | CBF timer expiration for this packet |
Definition at line 92 of file cbf_packet_buffer.cpp.
◆ counter()
std::size_t vanetza::geonet::CbfPacketBuffer::counter |
( |
const Identifier & |
packet | ) |
const |
Get counter associated with given packet
- Note
- packet counter is incremented at each timer update
- Parameters
-
- Returns
- 0 if packet has never been buffered before
Definition at line 168 of file cbf_packet_buffer.cpp.
◆ fetch()
boost::optional< CbfPacket > vanetza::geonet::CbfPacketBuffer::fetch |
( |
const Identifier & |
id | ) |
|
Fetch a packet from buffer.
Associated timer is automatically stopped and packet removed from buffer. Packet lifetime is reduced by queueing time at return.
- Parameters
-
- Returns
- packet if found in buffer
Definition at line 139 of file cbf_packet_buffer.cpp.
◆ find()
const CbfPacket * vanetza::geonet::CbfPacketBuffer::find |
( |
const Identifier & |
id | ) |
const |
Find packet in buffer.
- Parameters
-
- Returns
- read-only pointer to packet, nullptr if not found
Definition at line 161 of file cbf_packet_buffer.cpp.
◆ flush()
void vanetza::geonet::CbfPacketBuffer::flush |
( |
| ) |
|
|
private |
◆ reduce_lifetime()
bool vanetza::geonet::CbfPacketBuffer::reduce_lifetime |
( |
const Timer & |
timer, |
|
|
CbfPacket & |
packet |
|
) |
| const |
|
private |
Reduce packet lifetime by queueing time
- Parameters
-
timer | contains queueing start time |
packet | associated packet |
- Returns
- true if packet remains valid, false if end of lifetime is reached
Definition at line 199 of file cbf_packet_buffer.cpp.
◆ remove()
bool vanetza::geonet::CbfPacketBuffer::remove |
( |
const Identifier & |
id | ) |
|
Try to remove a packet from buffer.
- Parameters
-
- Returns
- true if packet existed before removal
Definition at line 63 of file cbf_packet_buffer.cpp.
◆ remove_timer()
void vanetza::geonet::CbfPacketBuffer::remove_timer |
( |
typename timer_bimap::left_map::iterator |
timer_it | ) |
|
|
private |
◆ schedule_timer()
void vanetza::geonet::CbfPacketBuffer::schedule_timer |
( |
| ) |
|
|
private |
◆ update()
void vanetza::geonet::CbfPacketBuffer::update |
( |
const Identifier & |
id, |
|
|
Clock::duration |
timeout |
|
) |
| |
Update associated packet timer
- Parameters
-
id | packet identification |
timeout | CBF timer expiration |
Definition at line 126 of file cbf_packet_buffer.cpp.
◆ m_capacity_bytes
const std::size_t vanetza::geonet::CbfPacketBuffer::m_capacity_bytes |
|
private |
◆ m_counter
std::unique_ptr<CbfCounter> vanetza::geonet::CbfPacketBuffer::m_counter |
|
private |
◆ m_packets
std::list<CbfPacket> vanetza::geonet::CbfPacketBuffer::m_packets |
|
private |
◆ m_runtime
Runtime& vanetza::geonet::CbfPacketBuffer::m_runtime |
|
private |
◆ m_stored_bytes
std::size_t vanetza::geonet::CbfPacketBuffer::m_stored_bytes |
|
private |
◆ m_timer_callback
TimerCallback vanetza::geonet::CbfPacketBuffer::m_timer_callback |
|
private |
◆ m_timers
timer_bimap vanetza::geonet::CbfPacketBuffer::m_timers |
|
private |
The documentation for this class was generated from the following files: