GNU Radio's CDMA Package
packet_header2.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_CDMA_PACKET_HEADER2_H
23#define INCLUDED_CDMA_PACKET_HEADER2_H
24
25#include <gnuradio/tags.h>
26#include <cdma/api.h>
27//#include <cdma/packet_header.h>
28#include <gnuradio/digital/packet_header_default.h>
29//#include <boost/enable_shared_from_this.hpp>
30//#include <boost/crc.hpp>
31
32namespace gr {
33 namespace cdma {
34
35 /*!
36 * \brief Default header formatter for digital packet transmission.
37 * \ingroup packet_operators_blk
38 *
39 * \details
40 * For bursty/packetized digital transmission, packets are usually prepended
41 * with a packet header, containing the number of bytes etc.
42 * This class is not a block, but a tool to create these packet header.
43 *
44 * This is a default packet header (see header_formatter()) for a description
45 * on the header format). To create other header, derive packet header creator
46 * classes from this function.
47 *
48 * gr::digital::packet_headergenerator_bb uses header generators derived from
49 * this class to create packet headers from data streams.
50 */
51 class CDMA_API packet_header2 : virtual public gr::digital::packet_header_default
52 {
53 public:
54 typedef boost::shared_ptr<packet_header2> sptr;
55
57 long header_len,
58 const std::string &len_tag_key="packet_len",
59 const std::string &num_tag_key="packet_num",
60 int bits_per_byte=1,
61 int tcm_type=1,
62 const std::string &tcm_type_key="tcm_type");
64
65 void set_tcm_type(int tcm_type){d_tcm_type = tcm_type; };
66 pmt::pmt_t num_tag_key() { return d_num_tag_key; };
67
68 //pmt::pmt_t len_tag_key() { return d_len_tag_key; };
69
70 /*!
71 * \brief Encodes the header information in the given tags into bits and places them into \p out
72 *
73 * Uses the following header format:
74 * Bits 0-11: The packet length (what was stored in the tag with key \p len_tag_key)
75 * Bits 12-15: The trellis coded modulation type
76 * Bits 16-27: The header number (counts up everytime this function is called)
77 * Bit 28-35: 8-Bit CRC
78 * All other bits: Are set to zero
79 *
80 * If the header length is smaller than 36, bits are simply left out. For this
81 * reason, they always start with the LSB.
82 *
83 * However, it is recommended to stay above 36 Bits, in order to have a working
84 * CRC.
85 */
87 long packet_len,
88 unsigned char *out,
89 const std::vector<tag_t> &tags=std::vector<tag_t>()
90 );
91
92 /*!
93 * \brief Inverse function to header_formatter().
94 *
95 * Reads the bit stream in \p header and writes a corresponding tag into \p tags.
96 */
97 bool header_parser(
98 const unsigned char *header,
99 std::vector<tag_t> &tags);
100
101 static sptr make(
102 long header_len,
103 const std::string &len_tag_key="packet_len",
104 const std::string &num_tag_key="packet_num",
105 int bits_per_byte=1,
106 int tcm_type=1,
107 const std::string &tcm_tag_key="tcm_type");
108
109 protected:
110 pmt::pmt_t d_tcm_tag_key;
112
113 };
114
115 } // namespace cdma
116} // namespace gr
117
118#endif /* INCLUDED_CDMA_PACKET_HEADER2_H */
119
#define CDMA_API
Definition: api.h:30
Default header formatter for digital packet transmission.
Definition: packet_header2.h:52
static sptr make(long header_len, const std::string &len_tag_key="packet_len", const std::string &num_tag_key="packet_num", int bits_per_byte=1, int tcm_type=1, const std::string &tcm_tag_key="tcm_type")
pmt::pmt_t num_tag_key()
Definition: packet_header2.h:66
pmt::pmt_t d_tcm_tag_key
Definition: packet_header2.h:110
packet_header2(long header_len, const std::string &len_tag_key="packet_len", const std::string &num_tag_key="packet_num", int bits_per_byte=1, int tcm_type=1, const std::string &tcm_type_key="tcm_type")
bool header_formatter(long packet_len, unsigned char *out, const std::vector< tag_t > &tags=std::vector< tag_t >())
Encodes the header information in the given tags into bits and places them into out.
boost::shared_ptr< packet_header2 > sptr
Definition: packet_header2.h:54
void set_tcm_type(int tcm_type)
Definition: packet_header2.h:65
int d_tcm_type
Definition: packet_header2.h:111
Definition: amp_var_est.h:30