GNU Radio 3.7.3 C++ API
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  * 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_PACKET_HEADER_OFDM_H
23 #define INCLUDED_DIGITAL_PACKET_HEADER_OFDM_H
24 
25 #include <vector>
26 #include <gnuradio/digital/api.h>
28 
29 namespace gr {
30  namespace digital {
31 
32  /*!
33  * \brief Header utility for OFDM signals.
34  * \ingroup ofdm_blk
35  */
37  {
38  public:
40 
42  const std::vector<std::vector<int> > &occupied_carriers,
43  int n_syms,
44  const std::string &len_tag_key,
45  const std::string &frame_len_tag_key,
46  const std::string &num_tag_key,
47  int bits_per_header_sym,
48  int bits_per_payload_sym,
49  bool scramble_header);
51 
52  /*!
53  * \brief Header formatter.
54  *
55  * Does the same as packet_header_default::header_formatter(), but
56  * optionally scrambles the bits (this is more important for OFDM to avoid
57  * PAPR spikes).
58  */
59  bool header_formatter(
60  long packet_len,
61  unsigned char *out,
62  const std::vector<tag_t> &tags
63  );
64 
65  /*!
66  * \brief Inverse function to header_formatter().
67  *
68  * Does the same as packet_header_default::header_parser(), but
69  * adds another tag that stores the number of OFDM symbols in the
70  * packet.
71  * Note that there is usually no linear connection between the number
72  * of OFDM symbols and the packet length because a packet might
73  * finish mid-OFDM-symbol.
74  */
75  bool header_parser(
76  const unsigned char *header,
77  std::vector<tag_t> &tags);
78 
79  /*!
80  * \param occupied_carriers See carrier allocator
81  * \param n_syms The number of OFDM symbols the header should be (usually 1)
82  * \param len_tag_key The tag key used for the packet length (number of bytes)
83  * \param frame_len_tag_key The tag key used for the frame length (number of
84  * OFDM symbols, this is the tag key required for the
85  * frame equalizer etc.)
86  * \param num_tag_key The tag key used for packet numbering.
87  * \param bits_per_header_sym Bits per complex symbol in the header, e.g. 1 if
88  * the header is BPSK modulated, 2 if it's QPSK
89  * modulated etc.
90  * \param bits_per_payload_sym Bits per complex symbol in the payload. This is
91  * required to figure out how many OFDM symbols
92  * are necessary to encode the given number of
93  * bytes.
94  * \param scramble_header Set this to true to scramble the bits. This is highly
95  * recommended, as it reduces PAPR spikes.
96  */
97  static sptr make(
98  const std::vector<std::vector<int> > &occupied_carriers,
99  int n_syms,
100  const std::string &len_tag_key="packet_len",
101  const std::string &frame_len_tag_key="frame_len",
102  const std::string &num_tag_key="packet_num",
103  int bits_per_header_sym=1,
104  int bits_per_payload_sym=1,
105  bool scramble_header=false
106  );
107 
108 
109  protected:
110  pmt::pmt_t d_frame_len_tag_key; //!< Tag key of the additional frame length tag
111  const std::vector<std::vector<int> > d_occupied_carriers; //!< Which carriers/symbols carry data
112  int d_syms_per_set; //!< Helper variable: Total number of elements in d_occupied_carriers
114  std::vector<unsigned char> d_scramble_mask; //!< Bits are xor'd with this before tx'ing
115  };
116 
117  } // namespace digital
118 } // namespace gr
119 
120 #endif /* INCLUDED_DIGITAL_PACKET_HEADER_OFDM_H */
121 
int d_bits_per_payload_sym
Definition: packet_header_ofdm.h:113
Header utility for OFDM signals.
Definition: packet_header_ofdm.h:36
#define DIGITAL_API
Definition: gr-digital/include/gnuradio/digital/api.h:30
shared_ptr documentation stub
Definition: shared_ptr_docstub.h:15
int d_syms_per_set
Helper variable: Total number of elements in d_occupied_carriers.
Definition: packet_header_ofdm.h:112
std::vector< unsigned char > d_scramble_mask
Bits are xor'd with this before tx'ing.
Definition: packet_header_ofdm.h:114
pmt::pmt_t d_frame_len_tag_key
Tag key of the additional frame length tag.
Definition: packet_header_ofdm.h:110
boost::shared_ptr< packet_header_ofdm > sptr
Definition: packet_header_ofdm.h:39
boost::intrusive_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting). See http://www.boost.org/libs/smart_ptr/smart_ptr.htm
Definition: pmt.h:56
const std::vector< std::vector< int > > d_occupied_carriers
Which carriers/symbols carry data.
Definition: packet_header_ofdm.h:111
Default header formatter for digital packet transmission.
Definition: packet_header_default.h:49