Add nomfreq, freqofs, dlt to PDU metadata

Add Nominal Frequency, Carrier Frequency Offset and Data Link Type (DLT)
tags to PDU.

Signed-off-by: Jonathan Brucker jonathan.brucke@gmail.com
This commit is contained in:
Jonathan Brucker
2016-08-30 16:15:54 +00:00
parent da1b0eb713
commit bef6e3d962
3 changed files with 22 additions and 5 deletions
+12 -1
View File
@@ -24,6 +24,8 @@
using namespace gr::ieee802_11; using namespace gr::ieee802_11;
#define LINKTYPE_IEEE802_11 105 /* http://www.tcpdump.org/linktypes.html */
class decode_mac_impl : public decode_mac { class decode_mac_impl : public decode_mac {
public: public:
@@ -34,6 +36,8 @@ decode_mac_impl(bool log, bool debug) :
d_log(log), d_log(log),
d_debug(debug), d_debug(debug),
d_snr(0), d_snr(0),
d_nom_freq(0.0),
d_freq_offset(0.0),
d_ofdm(BPSK_1_2), d_ofdm(BPSK_1_2),
d_frame(d_ofdm, 0), d_frame(d_ofdm, 0),
d_frame_complete(true) { d_frame_complete(true) {
@@ -70,6 +74,8 @@ int general_work (int noutput_items, gr_vector_int& ninput_items,
int len_data = pmt::to_uint64(pmt::tuple_ref(tuple, 0)); int len_data = pmt::to_uint64(pmt::tuple_ref(tuple, 0));
int encoding = pmt::to_uint64(pmt::tuple_ref(tuple, 1)); int encoding = pmt::to_uint64(pmt::tuple_ref(tuple, 1));
d_snr = pmt::to_double(pmt::tuple_ref(tuple, 2)); d_snr = pmt::to_double(pmt::tuple_ref(tuple, 2));
d_nom_freq = pmt::to_double(pmt::tuple_ref(tuple, 3));
d_freq_offset = pmt::to_double(pmt::tuple_ref(tuple, 4));
ofdm_param ofdm = ofdm_param((Encoding)encoding); ofdm_param ofdm = ofdm_param((Encoding)encoding);
frame_param frame = frame_param(ofdm, len_data); frame_param frame = frame_param(ofdm, len_data);
@@ -141,6 +147,9 @@ void decode() {
pmt::pmt_t dict = pmt::make_dict(); pmt::pmt_t dict = pmt::make_dict();
dict = pmt::dict_add(dict, pmt::mp("encoding"), enc); dict = pmt::dict_add(dict, pmt::mp("encoding"), enc);
dict = pmt::dict_add(dict, pmt::mp("snr"), pmt::from_double(d_snr)); dict = pmt::dict_add(dict, pmt::mp("snr"), pmt::from_double(d_snr));
dict = pmt::dict_add(dict, pmt::mp("nomfreq"), pmt::from_double(d_nom_freq));
dict = pmt::dict_add(dict, pmt::mp("freqofs"), pmt::from_double(d_freq_offset));
dict = pmt::dict_add(dict, pmt::mp("dlt"), pmt::from_long(LINKTYPE_IEEE802_11));
message_port_pub(pmt::mp("out"), pmt::cons(dict, blob)); message_port_pub(pmt::mp("out"), pmt::cons(dict, blob));
} }
@@ -218,7 +227,9 @@ private:
frame_param d_frame; frame_param d_frame;
ofdm_param d_ofdm; ofdm_param d_ofdm;
double d_snr; double d_snr; // dB
double d_nom_freq; // nominal frequency, Hz
double d_freq_offset; // frequency offset, Hz
viterbi_decoder d_decoder; viterbi_decoder d_decoder;
uint8_t d_rx_symbols[48 * MAX_SYM]; uint8_t d_rx_symbols[48 * MAX_SYM];
+7 -2
View File
@@ -39,7 +39,8 @@ frame_equalizer_impl::frame_equalizer_impl(Equalizer algo, double freq, double b
gr::io_signature::make(1, 1, 64 * sizeof(gr_complex)), gr::io_signature::make(1, 1, 64 * sizeof(gr_complex)),
gr::io_signature::make(1, 1, 48)), gr::io_signature::make(1, 1, 48)),
d_current_symbol(0), d_log(log), d_debug(debug), d_equalizer(NULL), d_current_symbol(0), d_log(log), d_debug(debug), d_equalizer(NULL),
d_freq(freq), d_bw(bw), d_frame_bytes(0), d_frame_symbols(0) { d_freq(freq), d_bw(bw), d_frame_bytes(0), d_frame_symbols(0),
d_freq_offset_from_synclong(0.0) {
message_port_register_out(pmt::mp("symbols")); message_port_register_out(pmt::mp("symbols"));
@@ -131,6 +132,7 @@ frame_equalizer_impl::general_work (int noutput_items,
d_frame_symbols = 0; d_frame_symbols = 0;
d_frame_mod = d_bpsk; d_frame_mod = d_bpsk;
d_freq_offset_from_synclong = pmt::to_double(tags.front().value) * d_bw;
d_epsilon0 = pmt::to_double(tags.front().value) * d_bw / (2 * M_PI * d_freq); d_epsilon0 = pmt::to_double(tags.front().value) * d_bw / (2 * M_PI * d_freq);
d_er = 0; d_er = 0;
@@ -207,11 +209,14 @@ frame_equalizer_impl::general_work (int noutput_items,
if(decode_signal_field(out + o * 48)) { if(decode_signal_field(out + o * 48)) {
// TODO: it would better to use pmt::dict instead of raw list of numbers
add_item_tag(0, nitems_written(0) + o, add_item_tag(0, nitems_written(0) + o,
pmt::string_to_symbol("wifi_start"), pmt::string_to_symbol("wifi_start"),
pmt::make_tuple(pmt::from_uint64(d_frame_bytes), pmt::make_tuple(pmt::from_uint64(d_frame_bytes),
pmt::from_uint64(d_frame_encoding), pmt::from_uint64(d_frame_encoding),
pmt::from_double(d_equalizer->get_snr())), pmt::from_double(d_equalizer->get_snr()),
pmt::from_double(d_freq), // nominal frequency
pmt::from_double(d_freq_offset_from_synclong)),
pmt::string_to_symbol(name())); pmt::string_to_symbol(name()));
} }
} }
+3 -2
View File
@@ -59,8 +59,9 @@ private:
viterbi_decoder d_decoder; viterbi_decoder d_decoder;
// freq offset // freq offset
double d_freq; double d_freq; // Hz
double d_bw; double d_freq_offset_from_synclong; // Hz, estimation from "sync_long" block
double d_bw; // Hz
double d_er; double d_er;
double d_epsilon0; double d_epsilon0;
gr_complex d_prev_pilots[4]; gr_complex d_prev_pilots[4];