DESERT 3.5.1
Loading...
Searching...
No Matches
packer Class Reference

#include <packer.h>

Inheritance diagram for packer:
Collaboration diagram for packer:

Public Member Functions

 packer (bool)
 
 ~packer ()
 
int command (int, const char *const *)
 
size_t getPayloadBytesLength ()
 
size_t getHdrBytesLength ()
 
size_t getPayloadBinLength ()
 
size_t getHdrBinLength ()
 
std::string packPayload (Packet *)
 
std::string packHdr (Packet *)
 
Packet * unpackPayload (Packet *)
 
Packet * unpackHdr (Packet *)
 
void printMap ()
 

Static Public Member Functions

template<typename T >
static T restoreSignedValue (T _header_field, const uint32_t &_num_compressed_bits)
 
static std::string hexdump_nice (std::string)
 
static std::string hexdump_nice (const char *, size_t)
 
static std::string hexdump (std::string)
 
static std::string hex_bytes (float)
 
static std::string hex_bytes (double)
 
static std::string hex_bytes (const char &, const uint32_t &)
 
static std::string hex_bytes (const int8_t &, const uint32_t &)
 
static std::string hex_bytes (const int16_t &, const uint32_t &)
 
static std::string hex_bytes (const int32_t &, const uint32_t &)
 
static std::string hex_bytes (const int64_t &, const uint32_t &)
 
static std::string hex_bytes (const uint8_t &, const uint32_t &)
 
static std::string hex_bytes (const uint16_t &, const uint32_t &)
 
static std::string hex_bytes (const uint32_t &, const uint32_t &)
 
static std::string hex_bytes (const uint64_t &, const uint32_t &)
 
static std::string hexdump (const char *, size_t)
 
static std::string bindump (std::string)
 
static std::string bindump (const char *, size_t)
 

Protected Member Functions

virtual void init ()
 
virtual size_t packMyHdr (Packet *, unsigned char *, size_t)
 
virtual size_t unpackMyHdr (unsigned char *, size_t, Packet *)
 
virtual void printMyHdrMap ()
 
virtual void printMyHdrFields (Packet *)
 
virtual void printMyHdrField (Packet *, int)
 
size_t getMyHdrBinLength ()
 
size_t get (unsigned char *buffer, size_t offset, void *val, size_t h)
 
size_t put (unsigned char *buffer, size_t offset, void *val, size_t h)
 

Protected Attributes

std::vector< size_t > n_bits
 
int debug_
 

Private Attributes

std::vector< packer * > activePackers
 
size_t payload_length
 
size_t hdr_length
 
bool printAllFields
 
size_t SRC_ID_Bits
 
size_t PKT_ID_Bits
 
size_t FRAME_OFFSET_Bits
 
size_t M_BIT_Bits
 
size_t DUMMY_CONTENT_Bits
 

Detailed Description

Class exploited by the Uwal module to map an NS-Miracle packet into a bit stream, and vice-versa.

Definition at line 56 of file packer.h.

Constructor & Destructor Documentation

◆ packer()

packer::packer ( bool  init_)

Class constructor.

Definition at line 121 of file packer.cpp.

◆ ~packer()

packer::~packer ( )

Class destructor.

Definition at line 159 of file packer.cpp.

Member Function Documentation

◆ bindump() [1/2]

std::string packer::bindump ( const char *  data,
size_t  len 
)
static

Definition at line 1122 of file packer.cpp.

◆ bindump() [2/2]

std::string packer::bindump ( std::string  str)
static

Definition at line 1113 of file packer.cpp.

◆ command()

int packer::command ( int  argc,
const char *const *  argv 
)

Method to map tcl commands into c++ methods.

Parameters
argcnumber of arguments in argv
argvarray of arguments where argv[3] is the tcl command name and argv[4, 5, ...] are the parameters for the corresponding c++ method.

Definition at line 180 of file packer.cpp.

◆ get()

size_t packer::get ( unsigned char *  buffer,
size_t  offset,
void *  val,
size_t  h 
)
protected

Method used to retrieve a given variable from a certain number of bits contained in a buffer of chars.

Parameters
[in]bufferpointer to a buffer of characters.
[in]offsetposition from which to start reading the buffer of characters.
[in,out]valpointer to variable to retrieve (passed as reference).
hthe number of bits to read.
Returns
h, namely the number of read bits.

Definition at line 673 of file packer.cpp.

◆ getHdrBinLength()

size_t packer::getHdrBinLength ( )

Definition at line 228 of file packer.cpp.

◆ getHdrBytesLength()

size_t packer::getHdrBytesLength ( )
inline

Definition at line 88 of file packer.h.

◆ getMyHdrBinLength()

size_t packer::getMyHdrBinLength ( )
protected

Definition at line 661 of file packer.cpp.

◆ getPayloadBinLength()

size_t packer::getPayloadBinLength ( )

Definition at line 216 of file packer.cpp.

◆ getPayloadBytesLength()

size_t packer::getPayloadBytesLength ( )
inline

Definition at line 82 of file packer.h.

◆ hex_bytes() [1/11]

std::string packer::hex_bytes ( const char &  value,
const uint32_t &  len_bits 
)
static

Definition at line 786 of file packer.cpp.

◆ hex_bytes() [2/11]

std::string packer::hex_bytes ( const int16_t &  value,
const uint32_t &  len_bits 
)
static

Definition at line 840 of file packer.cpp.

◆ hex_bytes() [3/11]

std::string packer::hex_bytes ( const int32_t &  value,
const uint32_t &  len_bits 
)
static

Definition at line 871 of file packer.cpp.

◆ hex_bytes() [4/11]

std::string packer::hex_bytes ( const int64_t &  value,
const uint32_t &  len_bits 
)
static

Definition at line 909 of file packer.cpp.

◆ hex_bytes() [5/11]

std::string packer::hex_bytes ( const int8_t &  value,
const uint32_t &  len_bits 
)
static

Definition at line 813 of file packer.cpp.

◆ hex_bytes() [6/11]

std::string packer::hex_bytes ( const uint16_t &  value,
const uint32_t &  len_bits 
)
static

Definition at line 990 of file packer.cpp.

◆ hex_bytes() [7/11]

std::string packer::hex_bytes ( const uint32_t &  value,
const uint32_t &  len_bits 
)
static

Definition at line 1021 of file packer.cpp.

◆ hex_bytes() [8/11]

std::string packer::hex_bytes ( const uint64_t &  value,
const uint32_t &  len_bits 
)
static

Definition at line 1059 of file packer.cpp.

◆ hex_bytes() [9/11]

std::string packer::hex_bytes ( const uint8_t &  value,
const uint32_t &  len_bits 
)
static

Definition at line 963 of file packer.cpp.

◆ hex_bytes() [10/11]

std::string packer::hex_bytes ( double  value)
static

Definition at line 769 of file packer.cpp.

◆ hex_bytes() [11/11]

std::string packer::hex_bytes ( float  value)
static

Definition at line 752 of file packer.cpp.

◆ hexdump() [1/2]

std::string packer::hexdump ( const char *  data,
size_t  len 
)
static

Definition at line 735 of file packer.cpp.

◆ hexdump() [2/2]

std::string packer::hexdump ( std::string  str)
static

Definition at line 727 of file packer.cpp.

◆ hexdump_nice() [1/2]

std::string packer::hexdump_nice ( const char *  data,
size_t  len 
)
static

Definition at line 706 of file packer.cpp.

◆ hexdump_nice() [2/2]

std::string packer::hexdump_nice ( std::string  str)
static

Function used for log and debug purposes (in order to print binary strings, even if they contain special characters)

Parameters
strthe binary string to print
Returns
str_out the string to print (special characters are reported in hex form)

Definition at line 697 of file packer.cpp.

◆ init()

void packer::init ( )
protectedvirtual

◆ packHdr()

std::string packer::packHdr ( Packet *  p)

Definition at line 234 of file packer.cpp.

◆ packMyHdr()

size_t packer::packMyHdr ( Packet *  p,
unsigned char *  buf,
size_t  offset 
)
protectedvirtual

◆ packPayload()

std::string packer::packPayload ( Packet *  p)

Method to map an NS-Miracle packet into a legal modem payload (i.e., a string of binary characters) when one among the following protocol stack is in use (see UWMPhy_modem::stack):

  • STACK1, that includes:
    • UWCBR/UWUDP/UWStaticRouting/UWIP/UWMLL/ALOHA/MFSK_WHOI_MM,or subsets of it;
    • UWCBR/UWUDP/UWStaticRouting/UWIP/UWMLL/ALOHA-CSMA/MFSK_WHOI_MM,or subsets of it;
    • UWVBR/UWUDP/UWStaticRouting/UWIP/UWMLL/ALOHA/MFSK_WHOI_MM,or subsets of it;
    • UWVBR/UWUDP/UWStaticRouting/UWIP/UWMLL/ALOHA-CSMA/MFSK_WHOI_MM,or subsets of it.
  • STACK2, that includes:
    • UWCBR/UWUDP/UWSUN/UWIP/UWMLL/ALOHA/MFSK_WHOI_MM,or subsets of it;
    • UWVBR/UWUDP/UWSUN/UWIP/UWMLL/ALOHA-CSMA/MFSK_WHOI_MM,or subsets of it.

NOTE: With the currently implemented map:

  • we do not guarentee to support ARP message exchanges at the MLL layer (i.e., we suggest to manually set the ARP tables in the tcl files)
See also
packer_IM::pack1
packer_IM::pack2
Parameters
ppointer to the NS-Miracle packet that must be mapped into a modem payload.
Returns
res, a binary string to be sent acoustically as payload of the next modem packet to transmit.

Definition at line 292 of file packer.cpp.

◆ printMap()

void packer::printMap ( )

Definition at line 506 of file packer.cpp.

◆ printMyHdrField()

void packer::printMyHdrField ( Packet *  p,
int  field 
)
protectedvirtual

Definition at line 617 of file packer.cpp.

◆ printMyHdrFields()

void packer::printMyHdrFields ( Packet *  p)
protectedvirtual

◆ printMyHdrMap()

void packer::printMyHdrMap ( )
protectedvirtual

◆ put()

size_t packer::put ( unsigned char *  buffer,
size_t  offset,
void *  val,
size_t  h 
)
protected

Method used to map in a certain number of bits, contained in a buffer of chars, a given variable.

Parameters
[in]bufferpointer to a buffer of characters.
[in]offsetposition from which to start writing to the buffer of characters.
[in,out]valpointer to the variable to map (passed as reference).
hthe number of bits to use for the mapping.
Returns
h, namely the number of written bits.

Definition at line 685 of file packer.cpp.

◆ restoreSignedValue()

template<typename T >
static T packer::restoreSignedValue ( _header_field,
const uint32_t &  _num_compressed_bits 
)
inlinestatic

Definition at line 174 of file packer.h.

◆ unpackHdr()

Packet * packer::unpackHdr ( Packet *  p)

Definition at line 412 of file packer.cpp.

◆ unpackMyHdr()

size_t packer::unpackMyHdr ( unsigned char *  buf,
size_t  offset,
Packet *  p 
)
protectedvirtual

◆ unpackPayload()

Packet * packer::unpackPayload ( Packet *  p)

Method to de-map a legal modem payload (i.e., a string of binary characters) into an NS-Miracle packet, when one among the following protocol stack is in use (see UWMPhy_modem::stack):

  • STACK1, that includes: UWCBR/UWUDP/UWStaticRouting/UWIP/UWMLL/ALOHA/S2C_EvoLogics,or subsets of it UWCBR/UWUDP/UWStaticRouting/UWIP/UWMLL/ALOHA-CSMA/S2C_EvoLogics,or subsets of it UWVBR/UWUDP/UWStaticRouting/UWIP/UWMLL/ALOHA/S2C_EvoLogics,or subsets of it UWVBR/UWUDP/UWStaticRouting/UWIP/UWMLL/ALOHA-CSMA/S2C_EvoLogics,or subsets of it
  • STACK2, that includes: UWCBR/UWUDP/UWSUN/UWIP/UWMLL/ALOHA/S2C_EvoLogics,or subsets of it UWCBR/UWUDP/UWSUN/UWIP/UWMLL/ALOHA-CSMA/S2C_EvoLogics,or subsets of it UWVBR/UWUDP/UWSUN/UWIP/UWMLL/ALOHA/S2C_EvoLogics,or subsets of it UWVBR/UWUDP/UWSUN/UWIP/UWMLL/ALOHA-CSMA/S2C_EvoLogics,or subsets of it
See also
packer_IM::pack
packer_IM::unpack1
packer_IM::unpack2
Parameters
sthe node ID from which the last received packet arrives.
dthe node ID to which the last received packet is sent.
srcthe payload of the last packet received from the modem.
Returns
p the NS-Miracle packet recovered from the information contained in s, d and src.

Definition at line 433 of file packer.cpp.

Member Data Documentation

◆ activePackers

std::vector<packer *> packer::activePackers
private

Vector of elements containing the pointers to the active packers (i.e., the derived classed of packer actually in charge of pack and unpack packets.

These are set by the tcl user through the command "addPacker". See packer::command).

Definition at line 271 of file packer.h.

◆ debug_

int packer::debug_
protected

Flag to enable debug messages.

Definition at line 227 of file packer.h.

◆ DUMMY_CONTENT_Bits

size_t packer::DUMMY_CONTENT_Bits
private

Bit length of the Mbit_ field to be put in the header stream of bits.

Definition at line 296 of file packer.h.

◆ FRAME_OFFSET_Bits

size_t packer::FRAME_OFFSET_Bits
private

Bit length of the pktID_ field to be put in the header stream of bits.

Definition at line 292 of file packer.h.

◆ hdr_length

size_t packer::hdr_length
private

The minimum number of elements that a buffer of char must have in order to store the header fields of the AL.

See also
: hdr-uwal.h

Definition at line 282 of file packer.h.

◆ M_BIT_Bits

size_t packer::M_BIT_Bits
private

Bit length of the frameID_ field to be put in the header stream of bits.

Definition at line 294 of file packer.h.

◆ n_bits

std::vector<size_t> packer::n_bits
protected

Vector of elements containing the indication of the number of bits to consider for each header field.

Definition at line 224 of file packer.h.

◆ payload_length

size_t packer::payload_length
private

The minimum number of elements that a buffer of char must have in order to store the fields to be coded by the activePackers into a string of bytes.

Definition at line 277 of file packer.h.

◆ PKT_ID_Bits

size_t packer::PKT_ID_Bits
private

Bit length of the srcID_ field to be put in the header stream of bits.

Definition at line 290 of file packer.h.

◆ printAllFields

bool packer::printAllFields
private

Definition at line 286 of file packer.h.

◆ SRC_ID_Bits

size_t packer::SRC_ID_Bits
private

Definition at line 288 of file packer.h.


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