MADARA  3.4.1
madara::transport::FragmentMessageHeader Class Reference

Defines a fragmentation header which allows for multi-part messages that are only applied once all fragments are received. More...

#include <Fragmentation.h>

Inheritance diagram for madara::transport::FragmentMessageHeader:
madara::transport::MessageHeader

Public Member Functions

 FragmentMessageHeader ()
 Constructor. More...
 
virtual ~FragmentMessageHeader ()
 Destructor. More...
 
virtual uint32_t encoded_size (void) const override
 Returns the size of the encoded MessageHeader class, which may be different from sizeof (MessageHeader) because of compiler optimizations for word boundaries. More...
 
virtual bool equals (const MessageHeader &other) override
 Compares the fields of this instance to another instance. More...
 
void operator= (MessageHeader &header)
 Assignment operator for regular message header. More...
 
virtual const char * read (const char *buffer, int64_t &buffer_remaining) override
 Reads a MessageHeader instance from a buffer and updates the amount of buffer room remaining. More...
 
virtual std::string to_string (void) override
 Converts the structure into a human-readable string. More...
 
virtual char * write (char *buffer, int64_t &buffer_remaining) override
 Writes a MessageHeader instance to a buffer and updates the amount of buffer room remaining. More...
 

Static Public Member Functions

static bool fragment_message_header_test (const char *buffer)
 Tests the buffer for a reduced message identifier. More...
 
static uint64_t get_size (const char *buffer)
 Returns the size field of the header. More...
 
static uint32_t get_updates (const char *buffer)
 Returns the number of updates indicated in the header. More...
 
static bool message_header_test (const char *buffer)
 Tests the buffer for a normal message identifier. More...
 
static uint32_t static_encoded_size (void)
 Returns the size of the encoded MessageHeader class, which may be different from sizeof (MessageHeader) because of compiler optimizations for word boundaries. More...
 

Public Attributes

uint64_t clock
 the clock of the sender when the message was generated More...
 
char domain [32]
 the domain that this message is intended for More...
 
char madara_id [8]
 the identifier of this transport (MADARA_IDENTIFIER) More...
 
char originator [64]
 the originator of the message (host:port) More...
 
uint32_t quality
 the quality of the message sender More...
 
uint64_t size
 the size of this header plus the updates More...
 
uint64_t timestamp
 the timestamp of the sender when the message was generated More...
 
uint64_t total_size
 
unsigned char ttl
 time to live (number of rebroadcasts to perform after original send More...
 
uint32_t type
 the type of message More...
 
uint32_t update_number
 
uint32_t updates
 the number of knowledge variable updates in the message More...
 

Detailed Description

Defines a fragmentation header which allows for multi-part messages that are only applied once all fragments are received.

Format:

[0] [64 bit unsigned size]
[8] [8 byte transport id] (prefixed with 'KFRG')
[16] [32 byte domain name]
[48] [64 byte originator (generally host:port)]
[112] [32 bit unsigned type]
2 = MULTIASSIGN (most common type)
[116] [32 bit unsigned num updates]
[120] [32 bit unsigned quality (type of priority)]
[124] [64 bit unsigned Lamport clock]
[132] [64 bit unsigned wall clock timestamp]
[140] [8 bit unsigned ttl–for rebroadcasts]
[141] [32 bit update number out of num updates]
[145] [64 bit total size of full packet]
[153] [knowledge updates start here in the buffer]

Definition at line 50 of file Fragmentation.h.

Constructor & Destructor Documentation

◆ FragmentMessageHeader()

madara::transport::FragmentMessageHeader::FragmentMessageHeader ( )

Constructor.

Definition at line 11 of file Fragmentation.cpp.

◆ ~FragmentMessageHeader()

madara::transport::FragmentMessageHeader::~FragmentMessageHeader ( )
virtual

Destructor.

Definition at line 21 of file Fragmentation.cpp.

Member Function Documentation

◆ encoded_size()

uint32_t madara::transport::FragmentMessageHeader::encoded_size ( void  ) const
overridevirtual

Returns the size of the encoded MessageHeader class, which may be different from sizeof (MessageHeader) because of compiler optimizations for word boundaries.

Reimplemented from madara::transport::MessageHeader.

Definition at line 23 of file Fragmentation.cpp.

◆ equals()

bool madara::transport::FragmentMessageHeader::equals ( const MessageHeader other)
overridevirtual

Compares the fields of this instance to another instance.

Parameters
otherthe other instance to compare against
Returns
true if equal, false otherwise

Reimplemented from madara::transport::MessageHeader.

Definition at line 506 of file Fragmentation.cpp.

◆ fragment_message_header_test()

static bool madara::transport::FragmentMessageHeader::fragment_message_header_test ( const char *  buffer)
inlinestatic

Tests the buffer for a reduced message identifier.

Returns
true if identifier indicates reduced message header

Definition at line 120 of file Fragmentation.h.

◆ get_size()

uint64_t madara::transport::MessageHeader::get_size ( const char *  buffer)
staticinherited

Returns the size field of the header.

Returns
size field of the encoded buffer

Definition at line 429 of file MessageHeader.cpp.

◆ get_updates()

uint32_t madara::transport::FragmentMessageHeader::get_updates ( const char *  buffer)
static

Returns the number of updates indicated in the header.

Returns
updates of the encoded buffer

Definition at line 39 of file Fragmentation.cpp.

◆ message_header_test()

static bool madara::transport::MessageHeader::message_header_test ( const char *  buffer)
inlinestaticinherited

Tests the buffer for a normal message identifier.

Returns
true if identifier indicates reduced message header

Definition at line 129 of file MessageHeader.h.

◆ operator=()

void madara::transport::FragmentMessageHeader::operator= ( MessageHeader header)

Assignment operator for regular message header.

Definition at line 824 of file Fragmentation.cpp.

◆ read()

const char * madara::transport::FragmentMessageHeader::read ( const char *  buffer,
int64_t &  buffer_remaining 
)
overridevirtual

Reads a MessageHeader instance from a buffer and updates the amount of buffer room remaining.

Parameters
bufferthe readable buffer where data is stored
buffer_remainingthe count of bytes remaining in the buffer to read
Returns
current buffer position for next read

Reimplemented from madara::transport::MessageHeader.

Definition at line 57 of file Fragmentation.cpp.

◆ static_encoded_size()

uint32_t madara::transport::FragmentMessageHeader::static_encoded_size ( void  )
static

Returns the size of the encoded MessageHeader class, which may be different from sizeof (MessageHeader) because of compiler optimizations for word boundaries.

Definition at line 31 of file Fragmentation.cpp.

◆ to_string()

std::string madara::transport::FragmentMessageHeader::to_string ( void  )
overridevirtual

Converts the structure into a human-readable string.

Returns
the stringified version of Fragmentation

Reimplemented from madara::transport::MessageHeader.

Definition at line 46 of file Fragmentation.cpp.

◆ write()

char * madara::transport::FragmentMessageHeader::write ( char *  buffer,
int64_t &  buffer_remaining 
)
overridevirtual

Writes a MessageHeader instance to a buffer and updates the amount of buffer room remaining.

Parameters
bufferthe readable buffer where data is stored
buffer_remainingthe count of bytes remaining in the buffer to read
Returns
current buffer position for next write

Reimplemented from madara::transport::MessageHeader.

Definition at line 285 of file Fragmentation.cpp.

Member Data Documentation

◆ clock

uint64_t madara::transport::MessageHeader::clock
inherited

the clock of the sender when the message was generated

Definition at line 188 of file MessageHeader.h.

◆ domain

char madara::transport::MessageHeader::domain[32]
inherited
Initial value:
= {
'\0','\0','\0','\0','\0','\0','\0','\0',
'\0','\0','\0','\0','\0','\0','\0','\0',
'\0','\0','\0','\0','\0','\0','\0','\0',
'\0','\0','\0','\0','\0','\0','\0','\0'
}

the domain that this message is intended for

Definition at line 149 of file MessageHeader.h.

◆ madara_id

char madara::transport::MessageHeader::madara_id[8]
inherited
Initial value:
= {
'\0','\0','\0','\0','\0','\0','\0','\0'
}

the identifier of this transport (MADARA_IDENTIFIER)

Definition at line 142 of file MessageHeader.h.

◆ originator

char madara::transport::MessageHeader::originator[64]
inherited
Initial value:
= {
'\0','\0','\0','\0','\0','\0','\0','\0',
'\0','\0','\0','\0','\0','\0','\0','\0',
'\0','\0','\0','\0','\0','\0','\0','\0',
'\0','\0','\0','\0','\0','\0','\0','\0',
'\0','\0','\0','\0','\0','\0','\0','\0',
'\0','\0','\0','\0','\0','\0','\0','\0',
'\0','\0','\0','\0','\0','\0','\0','\0',
'\0','\0','\0','\0','\0','\0','\0','\0'
}

the originator of the message (host:port)

Definition at line 159 of file MessageHeader.h.

◆ quality

uint32_t madara::transport::MessageHeader::quality
inherited

the quality of the message sender

Definition at line 183 of file MessageHeader.h.

◆ size

uint64_t madara::transport::MessageHeader::size
inherited

the size of this header plus the updates

Definition at line 137 of file MessageHeader.h.

◆ timestamp

uint64_t madara::transport::MessageHeader::timestamp
inherited

the timestamp of the sender when the message was generated

Definition at line 193 of file MessageHeader.h.

◆ total_size

uint64_t madara::transport::FragmentMessageHeader::total_size

Definition at line 132 of file Fragmentation.h.

◆ ttl

unsigned char madara::transport::MessageHeader::ttl
inherited

time to live (number of rebroadcasts to perform after original send

Definition at line 198 of file MessageHeader.h.

◆ type

uint32_t madara::transport::MessageHeader::type
inherited

the type of message

See also
madara::transport::Messages enum

Definition at line 173 of file MessageHeader.h.

◆ update_number

uint32_t madara::transport::FragmentMessageHeader::update_number

Definition at line 131 of file Fragmentation.h.

◆ updates

uint32_t madara::transport::MessageHeader::updates
inherited

the number of knowledge variable updates in the message

Definition at line 178 of file MessageHeader.h.


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