GNU Radio Manual and C++ API Reference  3.7.9.2
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
header_payload_demux.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /* Copyright 2012 Free Software Foundation, Inc.
3  *
4  * This file is part of GNU Radio
5  *
6  * GNU Radio is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3, or (at your option)
9  * any later version.
10  *
11  * GNU Radio is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with GNU Radio; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef INCLUDED_DIGITAL_HEADER_PAYLOAD_DEMUX_H
23 #define INCLUDED_DIGITAL_HEADER_PAYLOAD_DEMUX_H
24 
25 #include <gnuradio/digital/api.h>
26 #include <gnuradio/block.h>
27 
28 namespace gr {
29  namespace digital {
30 
31  /*!
32  * \brief Header/Payload demuxer.
33  * \ingroup packet_operators_blk
34  *
35  * \details
36  * This block is designed to demultiplex packets from a bursty transmission.
37  * The typical application for this block is the case when you are receiving
38  * packets with yet-to-determine length. This block will pass the header
39  * section to other blocks for demodulation. Using the information from the
40  * demodulated header, it will then output the payload. The beginning of the
41  * header needs to be identified by a trigger signal (see below).
42  *
43  * \section hpd_theory_of_ops Theory of Operation
44  *
45  * Input 0 takes a continuous transmission of samples (items).
46  * Input 1 is an optional input for the trigger signal (mark beginning of
47  * packets). In this case, a non-zero value on input 1 identifies the beginning of a packet.
48  * Otherwise, a tag with the key specified in \p trigger_tag_key is used as a
49  * trigger (its value is irrelevant).
50  *
51  * Until a trigger signal is detected, all samples are dropped onto the floor.
52  * Once a trigger is detected, a total of \p header_len items are copied to output 0.
53  * The block then stalls until it receives a message on the message port
54  * \p header_data. The message must be a PMT dictionary; all key/value pairs are
55  * copied as tags to the first item of the payload (which is assumed to be the
56  * first item after the header).
57  * The value corresponding to the key specified in \p length_tag_key is read
58  * and taken as the payload length. The payload, together with the header data
59  * as tags, is then copied to output 1.
60  *
61  * \section hpd_item_sizes Symbols, Items and Item Sizes
62  *
63  * To generically and transparently handle different kinds of modulations,
64  * including OFDM, this block distinguises between \b symbols and \b items.
65  *
66  * Items are what are consumed at the input. Anything that uses complex samples
67  * will therefore use an itemsize of `sizeof(gr_complex)`. Symbols are a way of
68  * grouping items. In OFDM, we usually don't care about individual samples, but
69  * we do care about full OFDM symbols, so we set \p items_per_symbol to the
70  * IFFT / FFT length of the OFDM modulator / demodulator.
71  * For most single-carrier modulations, this value can be set to 1 (the default
72  * value).
73  * If specified, \p guard_interval items are discarded before every symbol.
74  * This is useful for demuxing bursts of OFDM signals.
75  *
76  * On the output, we can deal with symbols directly by setting \p output_symbols
77  * to true. In that case, the output item size is the <em>symbol size</em>.
78  *
79  * \b Example: OFDM with 48 sub-carriers, using a length-64 IFFT on the modulator,
80  * and a cyclic-prefix length of 16 samples. In this case, the itemsize is
81  * `sizeof(gr_complex)`, because we're receiving complex samples. One OFDM symbol
82  * has 64 samples, hence \p items_per_symbol is set to 64, and \p guard_interval to
83  * 16. The header length is specified in number of OFDM symbols. Because we want to
84  * deal with full OFDM symbols, we set \p output_symbols to true.
85  *
86  * \section hpd_tag_handling Tag Handling
87  *
88  * Any tags on the input stream are copied to the corresponding output *if* they're
89  * on an item that is propagated. Note that a tag on the header items is copied to the
90  * header stream; that means the header-parsing block must handle these tags if they
91  * should go on the payload.
92  * A special case are tags on items that make up the guard interval. These are copied
93  * to the first item of the following symbol.
94  * If a tag is situated very close to the end of the payload, it might be unclear if
95  * it belongs to this packet or the following. In this case, it is possible that the
96  * tag might be propagated twice.
97  *
98  * Tags outside of packets are generally discarded. If this information is important,
99  * there are two additional mechanisms to preserve the tags:
100  * - Timing tags might be relevant to know \b when a packet was received. By
101  * specifying the name of a timestamp tag and the sample rate at this block, it
102  * keeps track of the time and will add the time to the first item of every packet.
103  * The name of the timestamp tag is usually 'rx_time' (see gr::uhd::usrp_source::make()).
104  * The time value must be specified in the UHD time format.
105  * - Other tags are simply stored and updated. As an example, the user might want to know the
106  * rx frequency, which UHD stores in the rx_freq tag. In this case, add the tag name 'rx_freq'
107  * to the list of \p special_tags. This block will then always save the most current value of
108  * 'rx_freq' and add it to the beginning of every packet.
109  *
110  */
111  class DIGITAL_API header_payload_demux : virtual public block
112  {
113  public:
114  typedef boost::shared_ptr<header_payload_demux> sptr;
115 
116  /*!
117  * \param header_len Number of symbols per header
118  * \param items_per_symbol Number of items per symbol
119  * \param guard_interval Number of items between two consecutive symbols
120  * \param length_tag_key Key of the frame length tag
121  * \param trigger_tag_key Key of the trigger tag
122  * \param output_symbols Output symbols (true) or items (false)?
123  * \param itemsize Item size (bytes per item)
124  * \param timing_tag_key The name of the tag with timing information, usually 'rx_time' or empty (this means timing info is discarded)
125  * \param samp_rate Sampling rate at the input. Necessary to calculate the rx time of packets.
126  * \param special_tags A vector of strings denoting tags which shall be preserved (see \ref hpd_tag_handling)
127  */
128  static sptr make(
129  int header_len,
130  int items_per_symbol=1,
131  int guard_interval=0,
132  const std::string &length_tag_key="frame_len",
133  const std::string &trigger_tag_key="",
134  bool output_symbols=false,
135  size_t itemsize=sizeof(gr_complex),
136  const std::string &timing_tag_key="",
137  const double samp_rate=1.0,
138  const std::vector<std::string> &special_tags=std::vector<std::string>()
139  );
140  };
141 
142  } // namespace digital
143 } // namespace gr
144 
145 #endif /* INCLUDED_DIGITAL_HEADER_PAYLOAD_DEMUX_H */
146 
#define DIGITAL_API
Definition: gr-digital/include/gnuradio/digital/api.h:30
std::complex< float > gr_complex
Definition: gr_complex.h:27
Include this header to use the message passing features.
Definition: logger.h:131
Header/Payload demuxer.
Definition: header_payload_demux.h:111
The abstract base class for all 'terminal' processing blocks.A signal processing flow is constructed ...
Definition: block.h:60
boost::shared_ptr< header_payload_demux > sptr
Definition: header_payload_demux.h:114
BLOCKS_API size_t itemsize(vector_type type)