GNU Radio Manual and C++ API Reference  3.10.9.1
The Free & Open Software Radio Ecosystem
packet_header_ofdm.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  * SPDX-License-Identifier: GPL-3.0-or-later
7  *
8  */
9 
10 #ifndef INCLUDED_DIGITAL_PACKET_HEADER_OFDM_H
11 #define INCLUDED_DIGITAL_PACKET_HEADER_OFDM_H
12 
13 #include <gnuradio/digital/api.h>
15 #include <vector>
16 
17 namespace gr {
18 namespace digital {
19 
20 /*!
21  * \brief Header utility for OFDM signals.
22  * \ingroup ofdm_blk
23  */
25 {
26 public:
27  typedef std::shared_ptr<packet_header_ofdm> sptr;
28 
29  packet_header_ofdm(const std::vector<std::vector<int>>& occupied_carriers,
30  int n_syms,
31  const std::string& len_tag_key,
32  const std::string& frame_len_tag_key,
33  const std::string& num_tag_key,
34  int bits_per_header_sym,
35  int bits_per_payload_sym,
36  bool scramble_header);
37  ~packet_header_ofdm() override;
38 
39  /*!
40  * \brief Header formatter.
41  *
42  * Does the same as packet_header_default::header_formatter(), but
43  * optionally scrambles the bits (this is more important for OFDM to avoid
44  * PAPR spikes).
45  */
46  bool header_formatter(long packet_len,
47  unsigned char* out,
48  const std::vector<tag_t>& tags) override;
49 
50  /*!
51  * \brief Inverse function to header_formatter().
52  *
53  * Does the same as packet_header_default::header_parser(), but
54  * adds another tag that stores the number of OFDM symbols in the
55  * packet.
56  * Note that there is usually no linear connection between the number
57  * of OFDM symbols and the packet length because a packet might
58  * finish mid-OFDM-symbol.
59  */
60  bool header_parser(const unsigned char* header, std::vector<tag_t>& tags) override;
61 
62  /*!
63  * \param occupied_carriers See carrier allocator
64  * \param n_syms The number of OFDM symbols the header should be (usually 1)
65  * \param len_tag_key The tag key used for the packet length (number of bytes)
66  * \param frame_len_tag_key The tag key used for the frame length (number of
67  * OFDM symbols, this is the tag key required for the
68  * frame equalizer etc.)
69  * \param num_tag_key The tag key used for packet numbering.
70  * \param bits_per_header_sym Bits per complex symbol in the header, e.g. 1 if
71  * the header is BPSK modulated, 2 if it's QPSK
72  * modulated etc.
73  * \param bits_per_payload_sym Bits per complex symbol in the payload. This is
74  * required to figure out how many OFDM symbols
75  * are necessary to encode the given number of
76  * bytes.
77  * \param scramble_header Set this to true to scramble the bits. This is highly
78  * recommended, as it reduces PAPR spikes.
79  */
80  static sptr make(const std::vector<std::vector<int>>& occupied_carriers,
81  int n_syms,
82  const std::string& len_tag_key = "packet_len",
83  const std::string& frame_len_tag_key = "frame_len",
84  const std::string& num_tag_key = "packet_num",
85  int bits_per_header_sym = 1,
86  int bits_per_payload_sym = 1,
87  bool scramble_header = false);
88 
89 
90 protected:
91  pmt::pmt_t d_frame_len_tag_key; //!< Tag key of the additional frame length tag
92  const std::vector<std::vector<int>>
93  d_occupied_carriers; //!< Which carriers/symbols carry data
95  std::vector<unsigned char>
96  d_scramble_mask; //!< Bits are xor'd with this before tx'ing
97 };
98 
99 } // namespace digital
100 } // namespace gr
101 
102 #endif /* INCLUDED_DIGITAL_PACKET_HEADER_OFDM_H */
Default header formatter for digital packet transmission.
Definition: packet_header_default.h:38
std::shared_ptr< packet_header_default > sptr
Definition: packet_header_default.h:40
Header utility for OFDM signals.
Definition: packet_header_ofdm.h:25
int d_bits_per_payload_sym
Definition: packet_header_ofdm.h:94
const std::vector< std::vector< int > > d_occupied_carriers
Which carriers/symbols carry data.
Definition: packet_header_ofdm.h:93
pmt::pmt_t d_frame_len_tag_key
Tag key of the additional frame length tag.
Definition: packet_header_ofdm.h:91
std::vector< unsigned char > d_scramble_mask
Bits are xor'd with this before tx'ing.
Definition: packet_header_ofdm.h:96
bool header_parser(const unsigned char *header, std::vector< tag_t > &tags) override
Inverse function to header_formatter().
static sptr make(const std::vector< std::vector< int >> &occupied_carriers, int n_syms, const std::string &len_tag_key="packet_len", const std::string &frame_len_tag_key="frame_len", const std::string &num_tag_key="packet_num", int bits_per_header_sym=1, int bits_per_payload_sym=1, bool scramble_header=false)
std::shared_ptr< packet_header_ofdm > sptr
Definition: packet_header_ofdm.h:27
bool header_formatter(long packet_len, unsigned char *out, const std::vector< tag_t > &tags) override
Header formatter.
packet_header_ofdm(const std::vector< std::vector< int >> &occupied_carriers, int n_syms, const std::string &len_tag_key, const std::string &frame_len_tag_key, const std::string &num_tag_key, int bits_per_header_sym, int bits_per_payload_sym, bool scramble_header)
#define DIGITAL_API
Definition: gr-digital/include/gnuradio/digital/api.h:18
GNU Radio logging wrapper.
Definition: basic_block.h:29
std::shared_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting).
Definition: pmt.h:83