libtins  4.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Types | Public Member Functions | List of all members
Tins::TCPIP::DataTracker Class Reference

#include <data_tracker.h>

Public Types

typedef std::vector< uint8_t > payload_type
typedef std::map< uint32_t,

Public Member Functions

 DataTracker ()
 DataTracker (uint32_t seq_number)
 Constructs an instance using the given sequence number as the initial one. More...
bool process_payload (uint32_t seq, payload_type payload)
 Processes the given payload. More...
void advance_sequence (uint32_t seq)
 Skip forward to a sequence number. More...
uint32_t sequence_number () const
void sequence_number (uint32_t seq)
const payload_typepayload () const
payload_typepayload ()
const buffered_payload_typebuffered_payload () const
buffered_payload_typebuffered_payload ()
uint32_t total_buffered_bytes () const

Detailed Description

Stores and tracks data in a TCP stream, reassembling segments, handling out of order packets, etc.

Member Typedef Documentation

The type used to store the buffered payload

typedef std::vector<uint8_t> Tins::TCPIP::DataTracker::payload_type

The type used to store the payload

Constructor & Destructor Documentation

Tins::TCPIP::DataTracker::DataTracker ( )

Default constructs an instance

Tins::TCPIP::DataTracker::DataTracker ( uint32_t  seq_number)

Constructs an instance using the given sequence number as the initial one.

seq_numberThe sequence number to use

Member Function Documentation

void Tins::TCPIP::DataTracker::advance_sequence ( uint32_t  seq)

Skip forward to a sequence number.

This allows to recover from packetloss, if we just do not see all packets of an original stream. This recovery can only sensibly triggered from the application layer.

The method does nothing, if the sequence number is smaller or equal to the current number.

This method is particularly useful to call from an out of order callback, if the application wants to skip forward to this out of order block. The application will then get the normal data callback!

The method cleans the buffer from all no longer needed fragments.

IMPORTANT: If you call this method with a sequence number that is not exactly a TCP fragment boundary, the flow will never recover from this.

seqThe seqeunce number to skip to.
const buffered_payload_type& Tins::TCPIP::DataTracker::buffered_payload ( ) const

Retrieves the buffered payload (const)

buffered_payload_type& Tins::TCPIP::DataTracker::buffered_payload ( )

Retrieves the buffered payload

const payload_type& Tins::TCPIP::DataTracker::payload ( ) const

Retrieves the available payload (const)

payload_type& Tins::TCPIP::DataTracker::payload ( )

Retrieves the available payload

bool Tins::TCPIP::DataTracker::process_payload ( uint32_t  seq,
payload_type  payload 

Processes the given payload.

This will buffer the given data on the payload buffer or store it on the buffered payload map, depending the sequence number given.

This method returns true iff any data was added to the payload buffer. That is if this method returns true, then the size of the payload will be greater than what it was before calling the function.

seq The payload's sequence number payload The payload to process

true iff any data was added to the payload buffer
uint32_t Tins::TCPIP::DataTracker::sequence_number ( ) const

Retrieves the current sequence number

void Tins::TCPIP::DataTracker::sequence_number ( uint32_t  seq)

Sets the current sequence number

uint32_t Tins::TCPIP::DataTracker::total_buffered_bytes ( ) const

Retrieves the total amount of buffered bytes

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