gr::digital::header_format_base
std::enable_shared_from_this< gr::digital::header_format_base >
gr::digital::header_format_crc
gr::digital::header_format_default
gnuradio/digital/header_format_base.h
state_t
gr::digital::header_format_base::state_t
STATE_SYNC_SEARCH
STATE_HAVE_SYNC
std::shared_ptr< header_format_base > std::shared_ptr<header_format_base> gr::digital::header_format_base::sptr sptr gr::digital::header_format_base::sptr
state_t state_t gr::digital::header_format_base::d_state d_state gr::digital::header_format_base::d_state

state of the state machine

header_buffer header_buffer gr::digital::header_format_base::d_hdr_reg d_hdr_reg gr::digital::header_format_base::d_hdr_reg

header_buffer object to hold header bits

pmt::pmt_t pmt::pmt_t gr::digital::header_format_base::d_info d_info gr::digital::header_format_base::d_info

info captured from the header

gr::logger_ptr gr::logger_ptr gr::digital::header_format_base::d_logger d_logger gr::digital::header_format_base::d_logger

Used by blocks to access the logger system.

gr::logger_ptr gr::logger_ptr gr::digital::header_format_base::d_debug_logger d_debug_logger gr::digital::header_format_base::d_debug_logger
gr::digital::header_format_base::header_format_base
()
header_format_base
gr::digital::header_format_base::header_format_base
virtual gr::digital::header_format_base::~header_format_base
()
~header_format_base
gr::digital::header_format_base::~header_format_base
sptr sptr gr::digital::header_format_base::base () base gr::digital::header_format_base::base
sptr sptr gr::digital::header_format_base::formatter () formatter gr::digital::header_format_base::formatter
bool virtual bool gr::digital::header_format_base::format (int nbytes_in, const unsigned char *input, pmt::pmt_t &output, pmt::pmt_t &info)=0 format gr::digital::header_format_base::format format format format format int nbytes_in const unsigned char * input pmt::pmt_t & output pmt::pmt_t & info

Function to creates a header. The child classes overload this function to format the header in the protocol-specific way.

nbytes_in

The length (in bytes) of the `input` payload

input

An array of unsigned chars of the packet payload

output

A pmt::u8vector with the new header prepended onto the input data.

info

A pmt::dict containing meta data and info about the PDU (generally from the metadata portion of the input PDU). Data can be extracted from this for the header formatting or inserted.

MUST be overloaded.
bool virtual bool gr::digital::header_format_base::parse (int nbits_in, const unsigned char *input, std::vector< pmt::pmt_t > &info, int &nbits_processed)=0 parse gr::digital::header_format_base::parse parse parse parse int nbits_in const unsigned char * input std::vector< pmt::pmt_t > & info int & nbits_processed

Parses a header. This function is overloaded in the child class, which knows how to convert the incoming hard bits (0's and 1's) back into a packet header.

nbits_in

The number of bits in the input array.

input

The input as hard decision bits.

info

A vector of pmt::dicts to hold any meta data or info about the PDU. When parsing the header, the formatter can add info from the header into this dict. Each packet has a single PMT dictionary of info, so the vector length is the number of packets received extracted during one call to this parser function.

nbits_processed

Number of input bits actually processed; If all goes well, this is nbits_in. A premature return after a bad header could be less than this.

MUST be overloaded.
size_t virtual size_t gr::digital::header_format_base::header_nbits () const =0 header_nbits gr::digital::header_format_base::header_nbits header_nbits header_nbits header_nbits header_nbits

Returns the length of the formatted header in bits. MUST be overloaded.

size_t size_t gr::digital::header_format_base::header_nbytes () const header_nbytes gr::digital::header_format_base::header_nbytes

Returns the length of the formatted header in bytes. Auto-calculated from the overloaded header_nbits().

void virtual void gr::digital::header_format_base::enter_search () enter_search gr::digital::header_format_base::enter_search

Enter Search state of the state machine to find the access code.

void virtual void gr::digital::header_format_base::enter_have_sync () enter_have_sync gr::digital::header_format_base::enter_have_sync enter_have_sync

Access code found, start getting the header.

void virtual void gr::digital::header_format_base::enter_have_header (int payload_len) enter_have_header gr::digital::header_format_base::enter_have_header enter_have_header int payload_len

Header found, setup for pulling in the hard decision bits.

bool virtual bool gr::digital::header_format_base::header_ok ()=0 header_ok gr::digital::header_format_base::header_ok header_ok header_ok header_ok

Verify that the header is valid.

int virtual int gr::digital::header_format_base::header_payload ()=0 header_payload gr::digital::header_format_base::header_payload header_payload header_payload header_payload header_payload

Get info from the header; return payload length and package rest of data in d_info dictionary.

Base header formatter class.

Creates a base class that other packet formatters will inherit from. The child classes create and parse protocol-specific headers. To add a new protocol processing class, create a class that inherits from this and overload the necessary functions. The main functions to overload are:

- header_format_base::format: takes in a payload and creates a header from it.

- header_format_base::parse: receive bits and extract the header info. These are expected to be hard bits (0 or 1) that have either been sliced or gone through an FEC decoder.

- header_format_base::header_nbits: the number of bits in the full header (including an access code).

- header_format_base::header_ok: checks to see if the received header is ok. Since the header often specifies the length of the frame to decode next, it is important that this information be correct.

- header_format_base::header_payload: unpacks the header register (from the class header_buffer) as a set of bits into its component parts of the header. For example, this may find and extract the frame length field as a 16-bit value and/or flags related to the type of modulation and FEC codes used in the frame's payload.

Protected functions of this class that the child class should overload include:

- enter_search

- enter_have_sync

- enter_have_header

These three function represent the different states of the parsing state machine. Expected behavior is that the protocol has some known word that we are first looking for the identify the start of the frame. The parsing FSM starts in a state to search for the beginning of the header, normally by looking for a known word (i.e., the access code). Then it changes state to read in the full header. We expect that the protocol provides the length of the header for processing, so the parsing looks pulls in the full length of the header. Then it changes state to the "have header" state for checking and processing. The base class provides the basic functionality for this state machine. However, most likely, each child class must manage these states for themselves.

This class is specifically designed to work with packets/frames in the asynchronous PDU architecture of GNU Radio. See the packet_format_async block for formatting the headers onto payloads and packet_parse_b block for parsing headers in a receiver.

The Packet Format block takes in a PDU and uses a formatter class derived from this class to add a header onto the packet. The Packet Format blocks takes in the PDU, unpacks the message, and passes it to a formatter class' format function, which builds a header based on the payload. The header is passed back and emitted from formatter block as a separate output. The async format block, packet_format_async, has two message output ports. The 'header' port passes the header out as a PDU and the 'payload' passes the payload out as a PDU. The flowgraph can then separately modulate and combine these two pieces in the follow-on processing.

The packet_sync_b block uses the formatter class by calling the 'parse' function to parse the received packet headers. This parser block is a sink for the data stream and emits a message from an 'info' port that contains an PMT dictionary of the information in the header. The formatter class determines the dictionary keys.

This is the base class for dealing with formatting headers for different protocols and purposes. For other header formatting behaviors, create a child class from here and overload the format, parse, and parsing state machine functions as necessary.

header_format_default

header_format_counter

gr::digital::header_format_base
gr::digital::header_format_counter
gr::digital::header_format_crc
gr::digital::header_format_default
gr::digital::header_format_ofdm
std::enable_shared_from_this< gr::digital::header_format_base >
gr::digital::header_buffer
gr::digital::header_format_base
d_hdr_reg
d_info
d_debug_logger
d_logger
std::enable_shared_from_this< gr::digital::header_format_base >
std::shared_ptr< logger >
std::shared_ptr< pmt_base >
- gr::digital::header_format_base
  base
- gr::digital::header_format_base
  d_debug_logger
- gr::digital::header_format_base
  d_hdr_reg
- gr::digital::header_format_base
  d_info
- gr::digital::header_format_base
  d_logger
- gr::digital::header_format_base
  d_state
- gr::digital::header_format_base
  enter_have_header
- gr::digital::header_format_base
  enter_have_sync
- gr::digital::header_format_base
  enter_search
- gr::digital::header_format_base
  format
- gr::digital::header_format_base
  formatter
- gr::digital::header_format_base
  header_format_base
- gr::digital::header_format_base
  header_nbits
- gr::digital::header_format_base
  header_nbytes
- gr::digital::header_format_base
  header_ok
- gr::digital::header_format_base
  header_payload
- gr::digital::header_format_base
  parse
- gr::digital::header_format_base
  sptr
- gr::digital::header_format_base
  STATE_HAVE_SYNC
- gr::digital::header_format_base
  STATE_SYNC_SEARCH
- gr::digital::header_format_base
  state_t
- gr::digital::header_format_base
  ~header_format_base