DESERT 4.0.0
packer Class Reference

#include <packer.h>

Inheritance diagram for packer:
Inheritance graph
Collaboration diagram for packer:
Collaboration graph

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.

Constructor & Destructor Documentation

◆ packer()

packer::packer ( bool  init_)

Class constructor.

References debug_, DUMMY_CONTENT_Bits, FRAME_OFFSET_Bits, getMyHdrBinLength(), hdr_length, M_BIT_Bits, n_bits, PKT_ID_Bits, printAllFields, and SRC_ID_Bits.

Here is the call graph for this function:

◆ ~packer()

packer::~packer ( )

Class destructor.

Member Function Documentation

◆ bindump() [1/2]

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

◆ bindump() [2/2]

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

References bindump().

Referenced by bindump(), and RxFrameSet::displaySet().

Here is the call graph for this function:

◆ 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.

References activePackers, debug_, getMyHdrBinLength(), getPayloadBinLength(), hdr_length, init(), payload_length, printAllFields, and printMap().

Here is the call graph for this function:

◆ 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.

Referenced by packerUWCBR::unpackMyHdr(), packerUwCsmaCa::unpackMyHdr(), PackerUwFlooding::unpackMyHdr(), packerUWIP::unpackMyHdr(), packerUwpolling::unpackMyHdr(), packerUWUDP::unpackMyHdr(), packer_uwUFetch::unpackMyHdr(), unpackMyHdr(), packerCOMMON::unpackMyHdr(), packerMAC::unpackMyHdr(), packer_uwApplication::unpackMyHdr(), and packer_uwRangingTDOA::unpackMyHdr().

◆ getHdrBinLength()

size_t packer::getHdrBinLength ( )

References getMyHdrBinLength().

Here is the call graph for this function:

◆ getHdrBytesLength()

size_t packer::getHdrBytesLength ( )
inline

References hdr_length.

Referenced by Uwal::fragmentPkt().

◆ getMyHdrBinLength()

size_t packer::getMyHdrBinLength ( )
protected

References n_bits.

Referenced by command(), getHdrBinLength(), and packer().

◆ getPayloadBinLength()

size_t packer::getPayloadBinLength ( )

References activePackers.

Referenced by command().

◆ getPayloadBytesLength()

size_t packer::getPayloadBytesLength ( )
inline

References payload_length.

◆ hex_bytes() [1/11]

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

◆ hex_bytes() [2/11]

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

◆ hex_bytes() [3/11]

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

◆ hex_bytes() [4/11]

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

◆ hex_bytes() [5/11]

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

◆ hex_bytes() [6/11]

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

◆ hex_bytes() [7/11]

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

◆ hex_bytes() [8/11]

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

◆ hex_bytes() [9/11]

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

◆ hex_bytes() [10/11]

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

◆ hex_bytes() [11/11]

◆ hexdump() [1/2]

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

◆ hexdump() [2/2]

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

References hexdump().

Referenced by Uwal::fragmentPkt(), hexdump(), packHdr(), packPayload(), printMyHdrField(), unpackHdr(), and unpackPayload().

Here is the call graph for this function:

◆ hexdump_nice() [1/2]

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

◆ 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)

References hexdump_nice().

Referenced by RxFrameSet::displaySet(), and hexdump_nice().

Here is the call graph for this function:

◆ init()

◆ packHdr()

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

◆ 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.

References activePackers, hdr_uwal::binPkt(), hdr_uwal::binPktLength(), debug_, hdr_length, hexdump(), and payload_length.

Referenced by Uwal::recv(), and Uwal::recvSyncClMsg().

Here is the call graph for this function:

◆ printMap()

void packer::printMap ( )

References activePackers, hdr_length, payload_length, and printMyHdrMap().

Referenced by command().

Here is the call graph for this function:

◆ printMyHdrField()

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

◆ printMyHdrFields()

void packer::printMyHdrFields ( Packet *  p)
protectedvirtual

◆ printMyHdrMap()

◆ 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.

Referenced by packerUWCBR::packMyHdr(), packerUwCsmaCa::packMyHdr(), PackerUwFlooding::packMyHdr(), packerUWIP::packMyHdr(), packerUwpolling::packMyHdr(), packerUWUDP::packMyHdr(), packer_uwUFetch::packMyHdr(), packMyHdr(), packerCOMMON::packMyHdr(), packerMAC::packMyHdr(), packer_uwApplication::packMyHdr(), and packer_uwRangingTDOA::packMyHdr().

◆ restoreSignedValue()

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

◆ unpackHdr()

Packet * packer::unpackHdr ( Packet *  p)

References hdr_uwal::binHdrLength(), hdr_uwal::binPkt(), debug_, hdr_length, hexdump(), and unpackMyHdr().

Referenced by Uwal::recv().

Here is the call graph for this function:

◆ 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.

References activePackers, hdr_uwal::binHdrLength(), hdr_uwal::binPkt(), hdr_uwal::binPktLength(), debug_, hexdump(), and payload_length.

Referenced by Uwal::checkRxFrameSet().

Here is the call graph for this function:

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).

Referenced by command(), getPayloadBinLength(), packPayload(), printMap(), and unpackPayload().

◆ debug_

◆ 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.

Referenced by init(), packer(), and printMyHdrMap().

◆ 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.

Referenced by init(), packer(), and printMyHdrMap().

◆ 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

Referenced by command(), getHdrBytesLength(), packer(), packHdr(), packPayload(), printMap(), and unpackHdr().

◆ 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.

Referenced by init(), packer(), and printMyHdrMap().

◆ 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.

Referenced by getMyHdrBinLength(), packer_uwApplication::init(), packerUWCBR::init(), packerUwCsmaCa::init(), PackerUwFlooding::init(), packerUWIP::init(), packerUwpolling::init(), packerUWUDP::init(), packer_uwUFetch::init(), init(), packerCOMMON::init(), packerMAC::init(), packer_uwRangingTDOA::init(), packer(), packerCOMMON::packerCOMMON(), packerMAC::packerMAC(), packerUWCBR::packerUWCBR(), PackerUwFlooding::PackerUwFlooding(), packerUWIP::packerUWIP(), packerUWUDP::packerUWUDP(), packerUWCBR::packMyHdr(), PackerUwFlooding::packMyHdr(), packerUWIP::packMyHdr(), packerUwpolling::packMyHdr(), packerUWUDP::packMyHdr(), packer_uwUFetch::packMyHdr(), packMyHdr(), packerCOMMON::packMyHdr(), packerMAC::packMyHdr(), packer_uwApplication::packMyHdr(), packer_uwRangingTDOA::packMyHdr(), printMyHdrField(), packerUWCBR::printMyHdrFields(), PackerUwFlooding::printMyHdrFields(), packerUWIP::printMyHdrFields(), packerUWUDP::printMyHdrFields(), printMyHdrFields(), packerCOMMON::printMyHdrFields(), packerMAC::printMyHdrFields(), packer_uwApplication::printMyHdrMap(), packer_uwUFetch::printMyHdrMap(), packer_uwRangingTDOA::printMyHdrMap(), packerUWCBR::unpackMyHdr(), PackerUwFlooding::unpackMyHdr(), packerUWIP::unpackMyHdr(), packerUwpolling::unpackMyHdr(), packerUWUDP::unpackMyHdr(), packer_uwUFetch::unpackMyHdr(), unpackMyHdr(), packerCOMMON::unpackMyHdr(), packerMAC::unpackMyHdr(), packer_uwApplication::unpackMyHdr(), and packer_uwRangingTDOA::unpackMyHdr().

◆ 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.

Referenced by command(), getPayloadBytesLength(), packHdr(), packPayload(), printMap(), and unpackPayload().

◆ 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.

Referenced by init(), packer(), and printMyHdrMap().

◆ printAllFields

bool packer::printAllFields
private

Referenced by command(), packer(), and printMyHdrFields().

◆ SRC_ID_Bits

size_t packer::SRC_ID_Bits
private

Referenced by init(), packer(), and printMyHdrMap().


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