Vanetza
 
Loading...
Searching...
No Matches
vanetza::geonet::PacketBuffer Class Reference

#include <packet_buffer.hpp>

Public Types

typedef std::unique_ptr< packet_buffer::Datadata_ptr
 

Public Member Functions

 PacketBuffer (std::size_t capacity)
 
bool push (data_ptr packet, Clock::time_point t)
 
void flush (Clock::time_point t)
 

Private Types

typedef packet_buffer::Expiry expiry_type
 
typedef std::tuple< expiry_type, data_ptr > node_type
 

Private Member Functions

std::size_t free () const
 
std::size_t capacity () const
 
void push (expiry_type &&expiry, data_ptr packet)
 
bool drop_head ()
 
void drop_expired (Clock::time_point t)
 
bool drop (std::size_t bytes)
 

Private Attributes

std::list< node_type > m_nodes
 
std::size_t m_capacity
 
std::size_t m_stored
 

Detailed Description

PacketBuffer with bounded capacity, packet expiry and head-drop

Definition at line 64 of file packet_buffer.hpp.

Member Typedef Documentation

◆ data_ptr

typedef std::unique_ptr<packet_buffer::Data> vanetza::geonet::PacketBuffer::data_ptr

Definition at line 67 of file packet_buffer.hpp.

◆ expiry_type

◆ node_type

typedef std::tuple<expiry_type, data_ptr> vanetza::geonet::PacketBuffer::node_type
private

Definition at line 92 of file packet_buffer.hpp.

Constructor & Destructor Documentation

◆ PacketBuffer()

vanetza::geonet::PacketBuffer::PacketBuffer ( std::size_t  capacity)

Create PacketBuffer with given capacity

Parameters
capacityBuffer can store this many bytes

Definition at line 25 of file packet_buffer.cpp.

Member Function Documentation

◆ capacity()

std::size_t vanetza::geonet::PacketBuffer::capacity ( ) const
inlineprivate

Definition at line 95 of file packet_buffer.hpp.

◆ drop()

bool vanetza::geonet::PacketBuffer::drop ( std::size_t  bytes)
private

Drop as many packets as required to store given number of bytes. Packets at the head of the list are dropped first.

Parameters
bytesrequire #bytes free capacity
Returns
true if there is enough capacity left for #bytes

Definition at line 86 of file packet_buffer.cpp.

◆ drop_expired()

void vanetza::geonet::PacketBuffer::drop_expired ( Clock::time_point  t)
private

Drop all packets with expired timestamp

Parameters
tcurrent time

Definition at line 73 of file packet_buffer.cpp.

◆ drop_head()

bool vanetza::geonet::PacketBuffer::drop_head ( )
private

Drop current head element

Returns
true if head element was dropped

Definition at line 63 of file packet_buffer.cpp.

◆ flush()

void vanetza::geonet::PacketBuffer::flush ( Clock::time_point  t)

Flush packets from buffer. Expired packets are dropped.

Note
Some packets might remain in buffer (re-added during flushing)
Parameters
tCurrent time

Definition at line 46 of file packet_buffer.cpp.

◆ free()

std::size_t vanetza::geonet::PacketBuffer::free ( ) const
inlineprivate

Definition at line 94 of file packet_buffer.hpp.

◆ push() [1/2]

bool vanetza::geonet::PacketBuffer::push ( data_ptr  packet,
Clock::time_point  t 
)

Push one packet into buffer

Parameters
packetPacket data
tCurrent time
Returns
true if packet has been pushed successfully

Definition at line 30 of file packet_buffer.cpp.

◆ push() [2/2]

void vanetza::geonet::PacketBuffer::push ( expiry_type &&  expiry,
data_ptr  packet 
)
private

Push one new element into buffer list

Note
capacity is not checked by this method, has to be done manually
Parameters
expiryExpiry data
packetPacket data

Member Data Documentation

◆ m_capacity

std::size_t vanetza::geonet::PacketBuffer::m_capacity
private

Definition at line 126 of file packet_buffer.hpp.

◆ m_nodes

std::list<node_type> vanetza::geonet::PacketBuffer::m_nodes
private

Definition at line 125 of file packet_buffer.hpp.

◆ m_stored

std::size_t vanetza::geonet::PacketBuffer::m_stored
private

Definition at line 127 of file packet_buffer.hpp.


The documentation for this class was generated from the following files: