Kea 2.7.6
|
Represents a list of packets with a sequential and random access to list elements. More...
#include <packet_storage.h>
Public Types | |
typedef boost::shared_ptr< T > | PacketPtr |
A type which represents the pointer to a packet. | |
Public Member Functions | |
PacketStorage () | |
Constructor. | |
void | append (const PacketPtr &packet) |
Appends the new packet object to the collection. | |
void | clear (const uint64_t num=0) |
Removes packets from the storage. | |
bool | empty () const |
Checks if the storage has no packets. | |
PacketPtr | getNext () |
Returns next packet from the storage. | |
PacketPtr | getRandom () |
Returns random packet from the storage. | |
uint64_t | size () const |
Returns number of packets in the storage. | |
Represents a list of packets with a sequential and random access to list elements.
The main purpose of this class is to support sending Renew and Release messages from perfdhcp. The Renew and Release messages are sent for existing leases only. Therefore, the typical use case for this class is that it holds a list of Reply messages sent by the server in response to Request messages. The Request messages hold addresses and/or IPv6 prefixes acquired so they can be used to identify existing leases. When perfdhcp needs to send Renew or Release message, it will access one of the elements on this list and will create the Renew or Release message based on its content. Once the element (packet) is returned it is also deleted from the list, so as it is not used again. This class provide either sequential access to the packets or random access. The random access algorithm is much slower but at least it allows to simulate more real scenario when the renewing or releasing client is random.
Pkt4 | or Pkt6 class, which represents DHCPv4 or DHCPv6 message respectively. |
Definition at line 42 of file packet_storage.h.
boost::shared_ptr<T> isc::perfdhcp::PacketStorage< T >::PacketPtr |
A type which represents the pointer to a packet.
Definition at line 45 of file packet_storage.h.
|
inline |
Constructor.
Definition at line 56 of file packet_storage.h.
|
inline |
Appends the new packet object to the collection.
packet | A pointer to an object representing a packet. |
Definition at line 61 of file packet_storage.h.
|
inline |
Removes packets from the storage.
It is possible to specify a number of packets to be removed from a storage. Packets are removed from the beginning of the storage. If specified number is greater than the size of the storage, all packets are removed.
num | A number of packets to be removed. If omitted, all packets will be removed. |
Definition at line 77 of file packet_storage.h.
References isc::perfdhcp::PacketStorage< T >::size().
|
inline |
Checks if the storage has no packets.
Definition at line 91 of file packet_storage.h.
Referenced by isc::perfdhcp::PacketStorage< T >::getRandom().
|
inline |
Returns next packet from the storage.
This function returns packets sequentially (in the same order in which they have been appended). The returned packet is instantly removed from the storage.
Definition at line 102 of file packet_storage.h.
|
inline |
Returns random packet from the storage.
This function picks random packet from the storage and returns it. It is way slower than the getNext
function because it has to iterate over all existing entries from the beginning of the storage to the random packet's position. Therefore, care should be taken when using this function to access elements when storage is large.
Definition at line 122 of file packet_storage.h.
References isc::perfdhcp::PacketStorage< T >::empty(), and isc::perfdhcp::PacketStorage< T >::size().
|
inline |
Returns number of packets in the storage.
Definition at line 138 of file packet_storage.h.
Referenced by isc::perfdhcp::PacketStorage< T >::clear(), and isc::perfdhcp::PacketStorage< T >::getRandom().