diff --git a/CMakeLists.txt b/CMakeLists.txt index 6db9c4e..520d3b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,6 +97,13 @@ if(NOT ITPP_FOUND) message(FATAL_ERROR "ITPP required to compile ieee802-11") endif() +######################################################################## +# Setup logging options +######################################################################## + +include(GrMiscUtils) +GR_LOGGING() + ######################################################################## # On Apple only, set install name and use rpath correctly, if not already set ######################################################################## @@ -128,12 +135,14 @@ include_directories( ${CPPUNIT_INCLUDE_DIRS} ${ITPP_INCLUDE_DIR} ${GNURADIO_RUNTIME_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ) link_directories( ${Boost_LIBRARY_DIRS} ${CPPUNIT_LIBRARY_DIRS} ${GNURADIO_RUNTIME_LIBRARY_DIRS} + ${LOG4CPP_LIBRARY_DIRS} ) ######################################################################## diff --git a/MANIFEST.md b/MANIFEST.md new file mode 100644 index 0000000..8ffc210 --- /dev/null +++ b/MANIFEST.md @@ -0,0 +1,17 @@ +title: gr-ieee802-11 +author: + - Bastian Bloessl +copyright_owner: + - Bastian Bloessl +dependencies: + - gnuradio (>= 3.7.4) +repo: https://github.com/bastibl/gr-ieee802-11.git +tags: + - IEEE 802.11 + - WiFi + - OFDM +website: http://www.ccs-labs.org/projects/wime/ +brief: IEEE 802.11 a/g/p Transceiver +icon: http://www.ccs-labs.org/projects/wime/wime.png +--- +This an IEEE 802.11 a/g/p transceiver for GNU Radio v3.7. Over the air, I tested it with the Ettus USRP N210 with XCVR2450 and CBX daughterboards. For interoperability tests I use mainly an Atheros (ath5k) WiFi card. The code can also be used for packet error rate simulations. diff --git a/README.md b/README.md index cd0d6ca..d3daef4 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,10 @@ To actually install the blocks do sudo make install sudo ldconfig +### Adjust Maximum Shared Memory +Since the transmitter is using the Tagged Stream blocks it has to store a complete frame in the buffer before processing it. The default maximum shared memory might not be enough on most Linux systems. It can be increased with + + sudo sysctl -w kernel.shmmax=2147483648 ### OFDM PHY diff --git a/cmake/Modules/FindLog4cpp.cmake b/cmake/Modules/FindLog4cpp.cmake new file mode 100644 index 0000000..fc314c6 --- /dev/null +++ b/cmake/Modules/FindLog4cpp.cmake @@ -0,0 +1,53 @@ +# - Find Log4cpp +# Find the native LOG4CPP includes and library +# +# LOG4CPP_INCLUDE_DIR - where to find LOG4CPP.h, etc. +# LOG4CPP_LIBRARIES - List of libraries when using LOG4CPP. +# LOG4CPP_FOUND - True if LOG4CPP found. + + +if (LOG4CPP_INCLUDE_DIR) + # Already in cache, be silent + set(LOG4CPP_FIND_QUIETLY TRUE) +endif () + +find_path(LOG4CPP_INCLUDE_DIR log4cpp/Category.hh + /opt/local/include + /usr/local/include + /usr/include +) + +set(LOG4CPP_NAMES log4cpp) +find_library(LOG4CPP_LIBRARY + NAMES ${LOG4CPP_NAMES} + PATHS /usr/lib /usr/local/lib /opt/local/lib +) + + +if (LOG4CPP_INCLUDE_DIR AND LOG4CPP_LIBRARY) + set(LOG4CPP_FOUND TRUE) + set(LOG4CPP_LIBRARIES ${LOG4CPP_LIBRARY} CACHE INTERNAL "" FORCE) + set(LOG4CPP_INCLUDE_DIRS ${LOG4CPP_INCLUDE_DIR} CACHE INTERNAL "" FORCE) +else () + set(LOG4CPP_FOUND FALSE CACHE INTERNAL "" FORCE) + set(LOG4CPP_LIBRARY "" CACHE INTERNAL "" FORCE) + set(LOG4CPP_LIBRARIES "" CACHE INTERNAL "" FORCE) + set(LOG4CPP_INCLUDE_DIR "" CACHE INTERNAL "" FORCE) + set(LOG4CPP_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE) +endif () + +if (LOG4CPP_FOUND) + if (NOT LOG4CPP_FIND_QUIETLY) + message(STATUS "Found LOG4CPP: ${LOG4CPP_LIBRARIES}") + endif () +else () + if (LOG4CPP_FIND_REQUIRED) + message(STATUS "Looked for LOG4CPP libraries named ${LOG4CPPS_NAMES}.") + message(FATAL_ERROR "Could NOT find LOG4CPP library") + endif () +endif () + +mark_as_advanced( + LOG4CPP_LIBRARIES + LOG4CPP_INCLUDE_DIRS +) diff --git a/examples/wifi_loopback.grc b/examples/wifi_loopback.grc index c95b6f8..0359935 100644 --- a/examples/wifi_loopback.grc +++ b/examples/wifi_loopback.grc @@ -92,6 +92,633 @@ 0 + + variable + + id + out_buf_size + + + _enabled + True + + + value + 96000 + + + alias + + + + _coordinate + (272, 3) + + + _rotation + 0 + + + + ieee802_11_ofdm_mac + + id + ieee802_11_ofdm_mac_0 + + + _enabled + True + + + src_mac + [0x23, 0x23, 0x23, 0x23, 0x23, 0x23] + + + dst_mac + [0x42, 0x42, 0x42, 0x42, 0x42, 0x42] + + + bss_mac + [0xff, 0xff, 0xff, 0xff, 0xff, 0xff] + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (416, 139) + + + _rotation + 0 + + + + blocks_pdu_to_tagged_stream + + id + blocks_pdu_to_tagged_stream_0 + + + _enabled + True + + + type + float + + + tag + packet_len + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (136, 635) + + + _rotation + 0 + + + + ieee802_11_ofdm_parse_mac + + id + ieee802_11_ofdm_parse_mac_0 + + + _enabled + True + + + log + True + + + debug + True + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (104, 251) + + + _rotation + 180 + + + + blocks_message_strobe + + id + blocks_message_strobe_0 + + + _enabled + True + + + msg + pmt.intern("".join("x" for i in range(pdu_length))) + + + period + interval + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (48, 131) + + + _rotation + 0 + + + + variable_static_text + + id + snr_text + + + _enabled + True + + + label + SNR + + + value + str(snr) + + + converver + str_converter + + + formatter + None + + + grid_pos + + + + notebook + + + + alias + + + + _coordinate + (515, 8) + + + _rotation + 0 + + + + variable_slider + + id + snr + + + _enabled + True + + + label + + + + value + 10 + + + min + -15 + + + max + 30 + + + num_steps + 1000 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + alias + + + + _coordinate + (656, 11) + + + _rotation + 0 + + + + import + + id + import_0 + + + _enabled + True + + + import + import math + + + alias + + + + _coordinate + (376, 3) + + + _rotation + 0 + + + + blocks_multiply_const_vxx + + id + blocks_multiply_const_vxx_0 + + + _enabled + True + + + type + complex + + + const + (10**(snr/10.0))**.5 + + + vlen + 1 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (440, 427) + + + _rotation + 0 + + + + wxgui_numbersink2 + + id + wxgui_numbersink2_0 + + + _enabled + True + + + type + float + + + title + Frame Error Rate + + + units + % + + + samp_rate + 1 + + + min_value + 0 + + + max_value + 100 + + + factor + 1.0 + + + decimal_places + 2 + + + ref_level + 0 + + + number_rate + 15 + + + peak_hold + False + + + average + True + + + avg_alpha + 0.02 + + + show_gauge + True + + + win_size + + + + grid_pos + + + + notebook + + + + alias + + + + affinity + + + + _coordinate + (552, 555) + + + _rotation + 0 + + + + foo_wireshark_connector + + id + foo_wireshark_connector_0 + + + _enabled + False + + + tech + 127 + + + debug + False + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (688, 195) + + + _rotation + 0 + + + + blocks_file_sink + + id + blocks_file_sink_0 + + + _enabled + False + + + file + /tmp/ofdm.bin + + + type + byte + + + vlen + 1 + + + unbuffered + True + + + append + False + + + alias + + + + affinity + + + + _coordinate + (896, 187) + + + _rotation + 0 + + + + variable_slider + + id + interval + + + _enabled + True + + + label + PDU Interval (ms) + + + value + 100 + + + min + 0 + + + max + 1000 + + + num_steps + 1000 + + + style + wx.SL_HORIZONTAL + + + converver + int_converter + + + grid_pos + + + + notebook + + + + alias + + + + _coordinate + (1064, 11) + + + _rotation + 0 + + variable_chooser @@ -140,7 +767,7 @@ _coordinate - (1067, 10) + (888, 11) _rotation @@ -148,37 +775,10 @@ - import + variable_chooser id - import_0 - - - _enabled - True - - - import - import math - - - alias - - - - _coordinate - (422, 11) - - - _rotation - 0 - - - - variable_slider - - id - signal_power + chan_est _enabled @@ -190,27 +790,23 @@ value - 2.0 + 1 - min - 0 + choices + [0, 1] - max - 3 + labels + ["LMS", "Linear Comb"] - num_steps - 1000 + type + radio_buttons style - wx.SL_HORIZONTAL - - - converver - float_converter + wx.RA_HORIZONTAL grid_pos @@ -226,7 +822,149 @@ _coordinate - (693, 7) + (1056, 267) + + + _rotation + 0 + + + + wxgui_scopesink2 + + id + wxgui_scopesink2_0 + + + _enabled + True + + + type + complex + + + title + Scope Plot + + + samp_rate + pdu_length*8.0/24/interval + + + v_scale + 0 + + + v_offset + 0 + + + t_scale + 0 + + + ac_couple + False + + + xy_mode + True + + + num_inputs + 1 + + + win_size + + + + grid_pos + + + + notebook + + + + trig_mode + wxgui.TRIG_MODE_AUTO + + + y_axis_label + Counts + + + alias + + + + affinity + + + + _coordinate + (168, 499) + + + _rotation + 0 + + + + channels_channel_model + + id + channels_channel_model_0 + + + _enabled + True + + + noise_voltage + .5**.5 + + + freq_offset + freq_offset + + + epsilon + 1.0 + + + taps + 1.0 + + + seed + 0 + + + block_tags + False + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (632, 395) _rotation @@ -253,11 +991,11 @@ min - -10000 + -.1 max - 10000 + .1 num_steps @@ -285,7 +1023,7 @@ _coordinate - (947, 7) + (776, 11) _rotation @@ -293,347 +1031,58 @@ - blocks_add_xx + variable_slider id - blocks_add_xx_0 + pdu_length _enabled True - type - complex + label + - num_inputs - 2 + value + 500 - vlen - 1 + min + 0 + + + max + 1500 + + + num_steps + 1000 + + + style + wx.SL_HORIZONTAL + + + converver + int_converter + + + grid_pos + + + + notebook + alias - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - _coordinate - (592, 280) - - - _rotation - 180 - - - - wifi_phy_hier - - id - wifi_phy_hier_0 - - - _enabled - True - - - encoding - encoding - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (384, 264) - - - _rotation - 180 - - - - ieee802_11_ofdm_mac - - id - ieee802_11_ofdm_mac_0 - - - _enabled - True - - - src_mac - [0x23, 0x23, 0x23, 0x23, 0x23, 0x23] - - - dst_mac - [0x42, 0x42, 0x42, 0x42, 0x42, 0x42] - - - bss_mac - [0xff, 0xff, 0xff, 0xff, 0xff, 0xff] - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (376, 139) - - - _rotation - 0 - - - - blocks_message_strobe - - id - blocks_message_strobe_0 - - - _enabled - True - - - msg - pmt.intern("Hello World!") - - - period - 300 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (96, 131) - - - _rotation - 0 - - - - ieee802_11_ofdm_parse_mac - - id - ieee802_11_ofdm_parse_mac_0 - - - _enabled - True - - - log - True - - - debug - True - - - alias - - - - affinity - - - - _coordinate - (104, 251) - - - _rotation - 180 - - - - foo_wireshark_connector - - id - foo_wireshark_connector_0 - - - _enabled - False - - - tech - 127 - - - debug - False - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (632, 163) - - - _rotation - 0 - - - - blocks_file_sink - - id - blocks_file_sink_0 - - - _enabled - False - - - file - /tmp/ofdm.bin - - - type - byte - - - vlen - 1 - - - unbuffered - True - - - append - False - - - alias - - - - affinity - - - - _coordinate - (848, 155) - - - _rotation - 0 - - - - blocks_multiply_xx - - id - blocks_multiply_xx_0 - - - _enabled - True - - - type - complex - - - num_inputs - 2 - - - vlen - 1 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (544, 432) + (1088, 147) _rotation @@ -664,11 +1113,11 @@ pad_front - 10000 + 997 pad_tail - 10000 + 0 alias @@ -680,7 +1129,7 @@ minoutbuf - 48000 + out_buf_size maxoutbuf @@ -688,7 +1137,7 @@ _coordinate - (320, 395) + (272, 395) _rotation @@ -696,38 +1145,22 @@ - analog_sig_source_x + wifi_phy_hier id - analog_sig_source_x_0 + wifi_phy_hier_0 _enabled True - type - complex + encoding + encoding - samp_rate - samp_rate - - - waveform - analog.GR_COS_WAVE - - - freq - freq_offset - - - amp - 1 - - - offset - 0 + chan_est + chan_est alias @@ -747,271 +1180,13 @@ _coordinate - (328, 539) - - - _rotation - 0 - - - - variable_slider - - id - noise_power - - - _enabled - True - - - label - - - - value - 0.1 - - - min - 0.01 - - - max - 5 - - - num_steps - 1000 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - alias - - - - _coordinate - (814, 8) - - - _rotation - 0 - - - - variable_static_text - - id - snr - - - _enabled - True - - - label - SNR - - - value - str(10 * math.log10(signal_power/noise_power)) + "dB" - - - converver - str_converter - - - formatter - None - - - grid_pos - - - - notebook - - - - alias - - - - _coordinate - (515, 8) - - - _rotation - 0 - - - - analog_noise_source_x - - id - analog_noise_source_x_0 - - - _enabled - True - - - type - complex - - - noise_type - analog.GR_GAUSSIAN - - - amp - (noise_power/2.0)**0.5 - - - seed - 0 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (856, 259) + (384, 264) _rotation 180 - - blocks_multiply_const_vxx - - id - blocks_multiply_const_vxx_0 - - - _enabled - True - - - type - complex - - - const - signal_power**.5 - - - vlen - 1 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (696, 443) - - - _rotation - 0 - - - - foo_wireshark_connector_0 - blocks_file_sink_0 - 0 - 0 - - - analog_sig_source_x_0 - blocks_multiply_xx_0 - 0 - 1 - - - analog_noise_source_x_0 - blocks_add_xx_0 - 0 - 1 - - - blocks_multiply_xx_0 - blocks_multiply_const_vxx_0 - 0 - 0 - - - blocks_multiply_const_vxx_0 - blocks_add_xx_0 - 0 - 0 - - - ieee802_11_ofdm_mac_0 - foo_wireshark_connector_0 - phy out - in - - - ieee802_11_ofdm_mac_0 - wifi_phy_hier_0 - phy out - mac_in - - - blocks_add_xx_0 - wifi_phy_hier_0 - 0 - 0 - - - wifi_phy_hier_0 - ieee802_11_ofdm_mac_0 - mac_out - phy in - wifi_phy_hier_0 ieee802_11_ofdm_parse_mac_0 @@ -1024,16 +1199,64 @@ strobe app in - - foo_packet_pad2_0 - blocks_multiply_xx_0 - 0 - 0 - wifi_phy_hier_0 foo_packet_pad2_0 0 0 + + wifi_phy_hier_0 + ieee802_11_ofdm_mac_0 + mac_out + phy in + + + ieee802_11_ofdm_mac_0 + wifi_phy_hier_0 + phy out + mac_in + + + ieee802_11_ofdm_parse_mac_0 + blocks_pdu_to_tagged_stream_0 + fer + pdus + + + blocks_pdu_to_tagged_stream_0 + wxgui_numbersink2_0 + 0 + 0 + + + channels_channel_model_0 + wifi_phy_hier_0 + 0 + 0 + + + foo_packet_pad2_0 + blocks_multiply_const_vxx_0 + 0 + 0 + + + blocks_multiply_const_vxx_0 + channels_channel_model_0 + 0 + 0 + + + foo_wireshark_connector_0 + blocks_file_sink_0 + 0 + 0 + + + wifi_phy_hier_0 + wxgui_scopesink2_0 + 1 + 0 + diff --git a/examples/wifi_phy_hier.grc b/examples/wifi_phy_hier.grc index 6f00e91..0546b04 100644 --- a/examples/wifi_phy_hier.grc +++ b/examples/wifi_phy_hier.grc @@ -1,4 +1,5 @@ + Fri Jul 18 08:46:33 2014 @@ -84,7 +85,34 @@ _coordinate - (518, 18) + (488, 11) + + + _rotation + 0 + + + + variable + + id + window_size + + + _enabled + True + + + value + 48 + + + alias + + + + _coordinate + (296, 11) _rotation @@ -122,7 +150,7 @@ variable id - window_size + out_buf_size _enabled @@ -130,7 +158,7 @@ value - 48 + 96000 alias @@ -138,132 +166,7 @@ _coordinate - (323, 14) - - - _rotation - 0 - - - - parameter - - id - encoding - - - _enabled - True - - - label - - - - value - 0 - - - type - intx - - - short_id - - - - alias - - - - _coordinate - (429, 10) - - - _rotation - 0 - - - - blocks_divide_xx - - id - blocks_divide_xx_0 - - - _enabled - True - - - type - float - - - vlen - 1 - - - num_inputs - 2 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (1125, 703) - - - _rotation - 270 - - - - blocks_complex_to_mag_squared - - id - blocks_complex_to_mag_squared_0 - - - _enabled - True - - - vlen - 1 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (595, 553) + (648, 11) _rotation @@ -368,319 +271,6 @@ 180 - - blocks_conjugate_cc - - id - blocks_conjugate_cc_0 - - - _enabled - True - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (379, 642) - - - _rotation - 0 - - - - blocks_delay - - id - blocks_delay_0_0 - - - _enabled - True - - - type - complex - - - delay - 16 - - - num_ports - 1 - - - vlen - 1 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (233, 638) - - - _rotation - 0 - - - - ieee802_11_ofdm_sync_long - - id - sync_long - - - _enabled - True - - - log - False - - - debug - False - - - sync_length - sync_length - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (682, 808) - - - _rotation - 0 - - - - blocks_delay - - id - blocks_delay_0 - - - _enabled - True - - - type - complex - - - delay - sync_length - - - num_ports - 1 - - - vlen - 1 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (463, 841) - - - _rotation - 0 - - - - blocks_stream_to_vector - - id - blocks_stream_to_vector_0 - - - _enabled - True - - - type - complex - - - num_items - 64 - - - vlen - 1 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (1022, 824) - - - _rotation - 0 - - - - ieee802_11_ofdm_equalize_symbols - - id - ieee802_11_ofdm_equalize_symbols_0 - - - _enabled - True - - - debug - False - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (762, 940) - - - _rotation - 180 - - - - ieee802_11_ofdm_decode_signal - - id - ieee802_11_ofdm_decode_signal_0 - - - _enabled - True - - - log - False - - - debug - False - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (525, 932) - - - _rotation - 180 - - ieee802_11_ofdm_decode_mac @@ -693,7 +283,7 @@ log - True + False debug @@ -724,174 +314,6 @@ 180 - - pad_sink - - id - pad_sink_1 - - - _enabled - True - - - label - mac_out - - - type - message - - - vlen - 1 - - - num_streams - 1 - - - optional - False - - - _coordinate - (69, 940) - - - _rotation - 180 - - - - blocks_multiply_xx - - id - blocks_multiply_xx_0 - - - _enabled - True - - - type - complex - - - num_inputs - 2 - - - vlen - 1 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (609, 608) - - - _rotation - 0 - - - - ieee802_11_moving_average_xx - - id - ieee802_11_moving_average_xx_1 - - - _enabled - True - - - type - complex - - - length - window_size - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (764, 621) - - - _rotation - 0 - - - - blocks_complex_to_mag - - id - blocks_complex_to_mag_0 - - - _enabled - True - - - vlen - 1 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (973, 625) - - - _rotation - 0 - - ieee802_11_ofdm_mapper @@ -936,23 +358,152 @@ - digital_packet_headergenerator_bb + parameter id - digital_packet_headergenerator_bb_0 + encoding _enabled True - header_formatter - header_formatter.formatter() + label + - len_tag_key + value + ieee802_11.BPSK_1_2 + + + type + intx + + + short_id + + + + alias + + + + _coordinate + (400, 11) + + + _rotation + 0 + + + + parameter + + id + chan_est + + + _enabled + True + + + label + + + + value + 1 + + + type + + + + short_id + + + + alias + + + + _coordinate + (760, 11) + + + _rotation + 0 + + + + pad_sink + + id + pad_sink_2 + + + _enabled + True + + + label + mac_out + + + type + message + + + vlen + 1 + + + num_streams + 1 + + + optional + False + + + _coordinate + (69, 940) + + + _rotation + 180 + + + + blocks_tagged_stream_mux + + id + blocks_tagged_stream_mux_0 + + + _enabled + True + + + type + complex + + + ninputs + 2 + + + lengthtagname "packet_len" + + vlen + 1 + + + tag_preserve_head_pos + 1 + alias @@ -963,7 +514,7 @@ minoutbuf - 0 + out_buf_size maxoutbuf @@ -971,7 +522,42 @@ _coordinate - (222, 230) + (752, 248) + + + _rotation + 0 + + + + ieee802_11_chunks_to_symbols_xx + + id + ieee802_11_chunks_to_symbols_xx_0 + + + _enabled + True + + + alias + + + + affinity + + + + minoutbuf + out_buf_size + + + maxoutbuf + 0 + + + _coordinate + (504, 280) _rotation @@ -1026,7 +612,7 @@ _coordinate - (494, 230) + (504, 203) _rotation @@ -1034,70 +620,23 @@ - ieee802_11_chunks_to_symbols_xx + digital_packet_headergenerator_bb id - ieee802_11_chunks_to_symbols_xx_0 + digital_packet_headergenerator_bb_0 _enabled True - alias - + header_formatter + header_formatter.formatter() - affinity - - - - minoutbuf - 48000 - - - maxoutbuf - 0 - - - _coordinate - (499, 303) - - - _rotation - 0 - - - - blocks_tagged_stream_mux - - id - blocks_tagged_stream_mux_0 - - - _enabled - True - - - type - complex - - - ninputs - 2 - - - lengthtagname + len_tag_key "packet_len" - - vlen - 1 - - - tag_preserve_head_pos - 1 - alias @@ -1108,7 +647,7 @@ minoutbuf - 48000 + 0 maxoutbuf @@ -1116,91 +655,13 @@ _coordinate - (744, 269) + (232, 203) _rotation 0 - - pad_source - - id - pad_source_0 - - - _enabled - True - - - label - samp_in - - - type - complex - - - vlen - 1 - - - num_streams - 1 - - - optional - False - - - _coordinate - (57, 549) - - - _rotation - 0 - - - - pad_sink - - id - pad_sink_0 - - - _enabled - True - - - label - samp_out - - - type - complex - - - vlen - 1 - - - num_streams - 1 - - - optional - False - - - _coordinate - (470, 427) - - - _rotation - 180 - - digital_ofdm_carrier_allocator_cvc @@ -1245,7 +706,7 @@ minoutbuf - 10000 + out_buf_size maxoutbuf @@ -1253,7 +714,7 @@ _coordinate - (1005, 242) + (1008, 219) _rotation @@ -1296,7 +757,7 @@ minoutbuf - 100000 + out_buf_size maxoutbuf @@ -1304,7 +765,46 @@ _coordinate - (703, 411) + (704, 371) + + + _rotation + 180 + + + + pad_sink + + id + pad_sink_0 + + + _enabled + True + + + label + samp_out + + + type + complex + + + vlen + 1 + + + num_streams + 1 + + + optional + False + + + _coordinate + (472, 387) _rotation @@ -1353,6 +853,45 @@ affinity + + minoutbuf + out_buf_size + + + maxoutbuf + 0 + + + _coordinate + (1008, 355) + + + _rotation + 180 + + + + blocks_complex_to_mag_squared + + id + blocks_complex_to_mag_squared_0 + + + _enabled + True + + + vlen + 1 + + + alias + + + + affinity + + minoutbuf 0 @@ -1363,11 +902,222 @@ _coordinate - (1003, 395) + (600, 520) _rotation - 180 + 0 + + + + blocks_conjugate_cc + + id + blocks_conjugate_cc_0 + + + _enabled + True + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (384, 608) + + + _rotation + 0 + + + + blocks_delay + + id + blocks_delay_0_0 + + + _enabled + True + + + type + complex + + + delay + 16 + + + num_ports + 1 + + + vlen + 1 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (232, 603) + + + _rotation + 0 + + + + blocks_multiply_xx + + id + blocks_multiply_xx_0 + + + _enabled + True + + + type + complex + + + num_inputs + 2 + + + vlen + 1 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (608, 576) + + + _rotation + 0 + + + + blocks_complex_to_mag + + id + blocks_complex_to_mag_0 + + + _enabled + True + + + vlen + 1 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (976, 592) + + + _rotation + 0 + + + + pad_source + + id + pad_source_0 + + + _enabled + True + + + label + samp_in + + + type + complex + + + vlen + 1 + + + num_streams + 1 + + + optional + False + + + _coordinate + (56, 515) + + + _rotation + 0 @@ -1406,13 +1156,287 @@ _coordinate - (876, 549) + (880, 515) _rotation 0 + + blocks_delay + + id + blocks_delay_0 + + + _enabled + True + + + type + complex + + + delay + sync_length + + + num_ports + 1 + + + vlen + 1 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (440, 803) + + + _rotation + 0 + + + + blocks_stream_to_vector + + id + blocks_stream_to_vector_0 + + + _enabled + True + + + type + complex + + + num_items + 64 + + + vlen + 1 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (1000, 787) + + + _rotation + 0 + + + + pad_sink + + id + pad_sink_1 + + + _enabled + True + + + label + carriers + + + type + complex + + + vlen + 1 + + + num_streams + 1 + + + optional + True + + + _coordinate + (176, 867) + + + _rotation + 180 + + + + blocks_vector_to_stream + + id + blocks_vector_to_stream_0 + + + _enabled + True + + + type + complex + + + num_items + 48 + + + vlen + 1 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (312, 867) + + + _rotation + 180 + + + + ieee802_11_moving_average_xx + + id + ieee802_11_moving_average_xx_1 + + + _enabled + True + + + type + complex + + + length + window_size + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (768, 587) + + + _rotation + 0 + + + + blocks_divide_xx + + id + blocks_divide_xx_0 + + + _enabled + True + + + type + float + + + vlen + 1 + + + num_inputs + 2 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (1128, 672) + + + _rotation + 270 + + ieee802_11_ofdm_sync_short @@ -1433,11 +1457,7 @@ threshold - 0.7 * 0.75 - - - max_samples - 80 * 140 + 0.85 * 0.75 min_plateau @@ -1461,73 +1481,158 @@ _coordinate - (178, 775) + (152, 744) _rotation 0 + + ieee802_11_ofdm_sync_long + + id + sync_long + + + _enabled + True + + + log + False + + + debug + False + + + sync_length + sync_length + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (656, 771) + + + _rotation + 0 + + + + ieee802_11_ofdm_equalize_symbols + + id + ieee802_11_ofdm_equalize_symbols_0 + + + _enabled + True + + + algo + chan_est + + + debug + False + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (752, 931) + + + _rotation + 180 + + + + ieee802_11_ofdm_decode_signal + + id + ieee802_11_ofdm_decode_signal_0 + + + _enabled + True + + + log + True + + + debug + False + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (525, 932) + + + _rotation + 180 + + pad_source_1 ieee802_11_ofdm_mapper_0 0 in - - digital_chunks_to_symbols_xx_0 - blocks_tagged_stream_mux_0 - 0 - 0 - ieee802_11_ofdm_decode_mac_0 - pad_sink_1 + pad_sink_2 out 0 - - ieee802_11_moving_average_xx_0 - blocks_divide_xx_0 - 0 - 1 - - - ieee802_11_moving_average_xx_1 - blocks_complex_to_mag_0 - 0 - 0 - - - blocks_multiply_xx_0 - ieee802_11_moving_average_xx_1 - 0 - 0 - - - blocks_divide_xx_0 - sync_short - 0 - 1 - - - sync_short - sync_long - 0 - 0 - - - blocks_delay_0 - sync_long - 0 - 1 - - - sync_short - blocks_delay_0 - 0 - 0 - fft_vxx_0_1 ieee802_11_ofdm_equalize_symbols_0 @@ -1546,24 +1651,84 @@ 0 0 - - sync_long - blocks_stream_to_vector_0 - 0 - 0 - - - blocks_delay_0_0 - sync_short - 0 - 0 - blocks_stream_to_vector_0 fft_vxx_0_1 0 0 + + ieee802_11_ofdm_decode_signal_0 + blocks_vector_to_stream_0 + 0 + 0 + + + blocks_tagged_stream_mux_0 + digital_ofdm_carrier_allocator_cvc_0_0_0 + 0 + 0 + + + digital_packet_headergenerator_bb_0 + digital_chunks_to_symbols_xx_0 + 0 + 0 + + + ieee802_11_ofdm_mapper_0 + digital_packet_headergenerator_bb_0 + 0 + 0 + + + ieee802_11_ofdm_mapper_0 + ieee802_11_chunks_to_symbols_xx_0 + 0 + 0 + + + ieee802_11_chunks_to_symbols_xx_0 + blocks_tagged_stream_mux_0 + 0 + 1 + + + digital_chunks_to_symbols_xx_0 + blocks_tagged_stream_mux_0 + 0 + 0 + + + digital_ofdm_cyclic_prefixer_0_0 + pad_sink_0 + 0 + 0 + + + digital_ofdm_carrier_allocator_cvc_0_0_0 + fft_vxx_0_0 + 0 + 0 + + + fft_vxx_0_0 + digital_ofdm_cyclic_prefixer_0_0 + 0 + 0 + + + ieee802_11_moving_average_xx_1 + blocks_complex_to_mag_0 + 0 + 0 + + + blocks_multiply_xx_0 + ieee802_11_moving_average_xx_1 + 0 + 0 + pad_source_0 blocks_multiply_xx_0 @@ -1582,48 +1747,12 @@ 0 0 - - blocks_delay_0_0 - blocks_conjugate_cc_0 - 0 - 0 - blocks_conjugate_cc_0 blocks_multiply_xx_0 0 1 - - blocks_complex_to_mag_0 - blocks_divide_xx_0 - 0 - 0 - - - ieee802_11_chunks_to_symbols_xx_0 - blocks_tagged_stream_mux_0 - 0 - 1 - - - ieee802_11_ofdm_mapper_0 - ieee802_11_chunks_to_symbols_xx_0 - 0 - 0 - - - ieee802_11_ofdm_mapper_0 - digital_packet_headergenerator_bb_0 - 0 - 0 - - - digital_packet_headergenerator_bb_0 - digital_chunks_to_symbols_xx_0 - 0 - 0 - blocks_complex_to_mag_squared_0 ieee802_11_moving_average_xx_0 @@ -1631,27 +1760,69 @@ 0 - fft_vxx_0_0 - digital_ofdm_cyclic_prefixer_0_0 + blocks_complex_to_mag_0 + blocks_divide_xx_0 0 0 - blocks_tagged_stream_mux_0 - digital_ofdm_carrier_allocator_cvc_0_0_0 + blocks_delay_0_0 + blocks_conjugate_cc_0 0 0 - digital_ofdm_carrier_allocator_cvc_0_0_0 - fft_vxx_0_0 + ieee802_11_moving_average_xx_0 + blocks_divide_xx_0 + 0 + 1 + + + blocks_delay_0_0 + sync_short 0 0 - digital_ofdm_cyclic_prefixer_0_0 - pad_sink_0 + sync_short + sync_long 0 0 + + sync_short + blocks_delay_0 + 0 + 0 + + + sync_long + blocks_stream_to_vector_0 + 0 + 0 + + + blocks_delay_0 + sync_long + 0 + 1 + + + blocks_vector_to_stream_0 + pad_sink_1 + 0 + 0 + + + ieee802_11_moving_average_xx_1 + sync_short + 0 + 1 + + + blocks_divide_xx_0 + sync_short + 0 + 2 + diff --git a/examples/wifi_rx.grc b/examples/wifi_rx.grc index 50d7ca5..6992130 100644 --- a/examples/wifi_rx.grc +++ b/examples/wifi_rx.grc @@ -1,4 +1,5 @@ + Fri Jul 18 10:38:16 2014 @@ -57,7 +58,7 @@ _coordinate - (434, 15) + (8, 11) _rotation @@ -84,7 +85,7 @@ _coordinate - (601, 15) + (672, 75) _rotation @@ -111,657 +112,7 @@ _coordinate - (704, 18) - - - _rotation - 0 - - - - ieee802_11_ofdm_equalize_symbols - - id - ieee802_11_ofdm_equalize_symbols_0 - - - _enabled - True - - - debug - False - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (389, 720) - - - _rotation - 0 - - - - blocks_delay - - id - blocks_delay_0 - - - _enabled - True - - - type - complex - - - delay - sync_length - - - num_ports - 1 - - - vlen - 1 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (483, 567) - - - _rotation - 0 - - - - ieee802_11_ofdm_sync_long - - id - ieee802_11_ofdm_sync_long_0 - - - _enabled - True - - - log - False - - - debug - False - - - sync_length - sync_length - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (684, 534) - - - _rotation - 0 - - - - blocks_stream_to_vector - - id - blocks_stream_to_vector_0 - - - _enabled - True - - - type - complex - - - num_items - 64 - - - vlen - 1 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (913, 550) - - - _rotation - 0 - - - - ieee802_11_ofdm_decode_signal - - id - ieee802_11_ofdm_decode_signal_0 - - - _enabled - True - - - log - True - - - debug - False - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (656, 712) - - - _rotation - 0 - - - - blocks_conjugate_cc - - id - blocks_conjugate_cc_0 - - - _enabled - True - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (421, 348) - - - _rotation - 0 - - - - blocks_delay - - id - blocks_delay_0_0 - - - _enabled - True - - - type - complex - - - delay - 16 - - - num_ports - 1 - - - vlen - 1 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (259, 344) - - - _rotation - 0 - - - - blocks_multiply_xx - - id - blocks_multiply_xx_0 - - - _enabled - True - - - type - complex - - - num_inputs - 2 - - - vlen - 1 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (662, 314) - - - _rotation - 0 - - - - blocks_complex_to_mag - - id - blocks_complex_to_mag_0 - - - _enabled - True - - - vlen - 1 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (1038, 331) - - - _rotation - 0 - - - - ieee802_11_moving_average_xx - - id - ieee802_11_moving_average_xx_0 - - - _enabled - True - - - type - complex - - - length - window_size - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (819, 327) - - - _rotation - 0 - - - - variable_chooser - - id - samp_rate - - - _enabled - True - - - label - Sample Rate - - - value - 10e6 - - - choices - [10e6, 20e6] - - - labels - ["10 Mhz", "20 Mhz"] - - - type - radio_buttons - - - style - wx.RA_HORIZONTAL - - - grid_pos - - - - notebook - - - - alias - - - - _coordinate - (1107, 20) - - - _rotation - 0 - - - - blocks_complex_to_mag_squared - - id - blocks_complex_to_mag_squared_0 - - - _enabled - True - - - vlen - 1 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (461, 227) - - - _rotation - 0 - - - - variable_slider - - id - gain - - - _enabled - True - - - label - - - - value - 20 - - - min - 0 - - - max - 100 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - int_converter - - - grid_pos - - - - notebook - - - - alias - - - - _coordinate - (808, 19) - - - _rotation - 0 - - - - variable_chooser - - id - freq - - - _enabled - True - - - label - Channel - - - value - 5.89e9 - - - choices - [2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0] - - - labels - [' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'] - - - type - drop_down - - - style - wx.RA_HORIZONTAL - - - grid_pos - - - - notebook - - - - alias - - - - _coordinate - (929, 21) + (672, 11) _rotation @@ -815,554 +166,6 @@ 180 - - fft_vxx - - id - fft_vxx_0 - - - _enabled - True - - - type - complex - - - fft_size - 64 - - - forward - True - - - window - window.rectangular(64) - - - shift - True - - - nthreads - 1 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (138, 688) - - - _rotation - 0 - - - - variable_chooser - - id - lo_offset - - - _enabled - True - - - label - LO Offset - - - value - 0 - - - choices - [0, 6e9, 11e9] - - - labels - ['0 MHz', '6 MHz', '11 MHz'] - - - type - drop_down - - - style - wx.RA_HORIZONTAL - - - grid_pos - - - - notebook - - - - alias - - - - _coordinate - (254, 12) - - - _rotation - 0 - - - - ieee802_11_ofdm_parse_mac - - id - ieee802_11_ofdm_parse_mac_0 - - - _enabled - True - - - log - False - - - debug - True - - - alias - - - - affinity - - - - _coordinate - (969, 820) - - - _rotation - 180 - - - - ieee802_11_ofdm_decode_mac - - id - ieee802_11_ofdm_decode_mac_0 - - - _enabled - True - - - log - False - - - debug - False - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (930, 712) - - - _rotation - 0 - - - - ieee802_11_ether_encap - - id - ieee802_11_ether_encap_0 - - - _enabled - False - - - debug - False - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (904, 920) - - - _rotation - 180 - - - - foo_wireshark_connector - - id - foo_wireshark_connector_0 - - - _enabled - False - - - tech - 127 - - - debug - False - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (947, 1051) - - - _rotation - 180 - - - - blocks_tuntap_pdu - - id - blocks_tuntap_pdu_0 - - - _enabled - False - - - ifn - tap0 - - - mtu - 10000 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (663, 942) - - - _rotation - 180 - - - - blocks_file_sink - - id - blocks_file_sink_0 - - - _enabled - False - - - file - /tmp/ofdm.pcap - - - type - byte - - - vlen - 1 - - - unbuffered - True - - - append - True - - - alias - - - - affinity - - - - _coordinate - (721, 1043) - - - _rotation - 180 - - - - blocks_divide_xx - - id - blocks_divide_xx_0 - - - _enabled - True - - - type - float - - - vlen - 1 - - - num_inputs - 2 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (1193, 412) - - - _rotation - 270 - - - - ieee802_11_moving_average_xx - - id - ieee802_11_moving_average_xx_1 - - - _enabled - True - - - type - float - - - length - window_size + 16 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (782, 223) - - - _rotation - 0 - - - - ieee802_11_ofdm_sync_short - - id - ieee802_11_ofdm_sync_short_0 - - - _enabled - True - - - log - False - - - debug - False - - - threshold - 0.85 * 0.75 - - - max_samples - 80 * 160 - - - min_plateau - 2 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (212, 501) - - - _rotation - 0 - - - - notebook - - id - nb - - - _enabled - True - - - style - wx.NB_TOP - - - labels - ['constellation', 'autocorrelation'] - - - grid_pos - - - - notebook - - - - alias - - - - _coordinate - (641, 85) - - - _rotation - 0 - - wxgui_scopesink2 @@ -1446,6 +249,468 @@ 180 + + ieee802_11_ofdm_decode_signal + + id + ieee802_11_ofdm_decode_signal_0 + + + _enabled + True + + + log + True + + + debug + False + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (680, 707) + + + _rotation + 0 + + + + fft_vxx + + id + fft_vxx_0 + + + _enabled + True + + + type + complex + + + fft_size + 64 + + + forward + True + + + window + window.rectangular(64) + + + shift + True + + + nthreads + 1 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (152, 683) + + + _rotation + 0 + + + + blocks_delay + + id + blocks_delay_0 + + + _enabled + True + + + type + complex + + + delay + sync_length + + + num_ports + 1 + + + vlen + 1 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (480, 563) + + + _rotation + 0 + + + + blocks_stream_to_vector + + id + blocks_stream_to_vector_0 + + + _enabled + True + + + type + complex + + + num_items + 64 + + + vlen + 1 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (912, 547) + + + _rotation + 0 + + + + blocks_delay + + id + blocks_delay_0_0 + + + _enabled + True + + + type + complex + + + delay + 16 + + + num_ports + 1 + + + vlen + 1 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (256, 339) + + + _rotation + 0 + + + + blocks_conjugate_cc + + id + blocks_conjugate_cc_0 + + + _enabled + True + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (424, 344) + + + _rotation + 0 + + + + blocks_multiply_xx + + id + blocks_multiply_xx_0 + + + _enabled + True + + + type + complex + + + num_inputs + 2 + + + vlen + 1 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (664, 312) + + + _rotation + 0 + + + + ieee802_11_moving_average_xx + + id + ieee802_11_moving_average_xx_0 + + + _enabled + True + + + type + complex + + + length + window_size + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (816, 323) + + + _rotation + 0 + + + + blocks_complex_to_mag + + id + blocks_complex_to_mag_0 + + + _enabled + True + + + vlen + 1 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (1032, 328) + + + _rotation + 0 + + + + blocks_divide_xx + + id + blocks_divide_xx_0 + + + _enabled + True + + + type + float + + + vlen + 1 + + + num_inputs + 2 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (1192, 400) + + + _rotation + 270 + + wxgui_scopesink2 @@ -1522,13 +787,95 @@ _coordinate - (1174, 569) + (1171, 560) _rotation 270 + + ieee802_11_moving_average_xx + + id + ieee802_11_moving_average_xx_1 + + + _enabled + True + + + type + float + + + length + window_size + 16 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (808, 227) + + + _rotation + 0 + + + + blocks_complex_to_mag_squared + + id + blocks_complex_to_mag_squared_0 + + + _enabled + True + + + vlen + 1 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (464, 232) + + + _rotation + 0 + + uhd_usrp_source @@ -1681,12 +1028,16 @@ center_freq0 - uhd.tune_request(freq - lo_offset, lo_offset) + uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL) gain0 gain + + norm_gain0 + False + ant0 @@ -1703,6 +1054,10 @@ gain1 0 + + norm_gain1 + False + ant1 @@ -1719,6 +1074,10 @@ gain2 0 + + norm_gain2 + False + ant2 @@ -1735,6 +1094,10 @@ gain3 0 + + norm_gain3 + False + ant3 @@ -1751,6 +1114,10 @@ gain4 0 + + norm_gain4 + False + ant4 @@ -1767,6 +1134,10 @@ gain5 0 + + norm_gain5 + False + ant5 @@ -1783,6 +1154,10 @@ gain6 0 + + norm_gain6 + False + ant6 @@ -1799,6 +1174,10 @@ gain7 0 + + norm_gain7 + False + ant7 @@ -1815,6 +1194,10 @@ gain8 0 + + norm_gain8 + False + ant8 @@ -1831,6 +1214,10 @@ gain9 0 + + norm_gain9 + False + ant9 @@ -1847,6 +1234,10 @@ gain10 0 + + norm_gain10 + False + ant10 @@ -1863,6 +1254,10 @@ gain11 0 + + norm_gain11 + False + ant11 @@ -1879,6 +1274,10 @@ gain12 0 + + norm_gain12 + False + ant12 @@ -1895,6 +1294,10 @@ gain13 0 + + norm_gain13 + False + ant13 @@ -1911,6 +1314,10 @@ gain14 0 + + norm_gain14 + False + ant14 @@ -1927,6 +1334,10 @@ gain15 0 + + norm_gain15 + False + ant15 @@ -1943,6 +1354,10 @@ gain16 0 + + norm_gain16 + False + ant16 @@ -1959,6 +1374,10 @@ gain17 0 + + norm_gain17 + False + ant17 @@ -1975,6 +1394,10 @@ gain18 0 + + norm_gain18 + False + ant18 @@ -1991,6 +1414,10 @@ gain19 0 + + norm_gain19 + False + ant19 @@ -2007,6 +1434,10 @@ gain20 0 + + norm_gain20 + False + ant20 @@ -2023,6 +1454,10 @@ gain21 0 + + norm_gain21 + False + ant21 @@ -2039,6 +1474,10 @@ gain22 0 + + norm_gain22 + False + ant22 @@ -2055,6 +1494,10 @@ gain23 0 + + norm_gain23 + False + ant23 @@ -2071,6 +1514,10 @@ gain24 0 + + norm_gain24 + False + ant24 @@ -2087,6 +1534,10 @@ gain25 0 + + norm_gain25 + False + ant25 @@ -2103,6 +1554,10 @@ gain26 0 + + norm_gain26 + False + ant26 @@ -2119,6 +1574,10 @@ gain27 0 + + norm_gain27 + False + ant27 @@ -2135,6 +1594,10 @@ gain28 0 + + norm_gain28 + False + ant28 @@ -2151,6 +1614,10 @@ gain29 0 + + norm_gain29 + False + ant29 @@ -2167,6 +1634,10 @@ gain30 0 + + norm_gain30 + False + ant30 @@ -2183,6 +1654,10 @@ gain31 0 + + norm_gain31 + False + ant31 @@ -2209,13 +1684,786 @@ _coordinate - (4, 207) + (16, 211) _rotation 0 + + ieee802_11_ofdm_equalize_symbols + + id + ieee802_11_ofdm_equalize_symbols_0 + + + _enabled + True + + + algo + chan_est + + + debug + False + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (416, 707) + + + _rotation + 0 + + + + ieee802_11_ofdm_decode_mac + + id + ieee802_11_ofdm_decode_mac_0 + + + _enabled + True + + + log + True + + + debug + False + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (1000, 707) + + + _rotation + 0 + + + + variable_chooser + + id + lo_offset + + + _enabled + True + + + label + LO Offset + + + value + 0 + + + choices + [0, 6e6, 11e6] + + + labels + ['0 MHz', '6 MHz', '11 MHz'] + + + type + drop_down + + + style + wx.RA_HORIZONTAL + + + grid_pos + + + + notebook + + + + alias + + + + _coordinate + (176, 11) + + + _rotation + 0 + + + + variable_chooser + + id + chan_est + + + _enabled + True + + + label + + + + value + 1 + + + choices + [0, 1] + + + labels + ["LMS", "Linear Comb"] + + + type + radio_buttons + + + style + wx.RA_HORIZONTAL + + + grid_pos + + + + notebook + + + + alias + + + + _coordinate + (352, 11) + + + _rotation + 0 + + + + notebook + + id + nb + + + _enabled + True + + + style + wx.NB_TOP + + + labels + ['constellation', 'autocorrelation'] + + + grid_pos + + + + notebook + + + + alias + + + + _coordinate + (504, 11) + + + _rotation + 0 + + + + variable_slider + + id + gain + + + _enabled + True + + + label + + + + value + 20 + + + min + 0 + + + max + 100 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + int_converter + + + grid_pos + + + + notebook + + + + alias + + + + _coordinate + (776, 11) + + + _rotation + 0 + + + + variable_chooser + + id + freq + + + _enabled + True + + + label + Channel + + + value + 5.89e9 + + + choices + [2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0] + + + labels + [' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'] + + + type + drop_down + + + style + wx.RA_HORIZONTAL + + + grid_pos + + + + notebook + + + + alias + + + + _coordinate + (896, 11) + + + _rotation + 0 + + + + variable_chooser + + id + samp_rate + + + _enabled + True + + + label + Sample Rate + + + value + 10e6 + + + choices + [10e6, 20e6] + + + labels + ["10 Mhz", "20 Mhz"] + + + type + radio_buttons + + + style + wx.RA_HORIZONTAL + + + grid_pos + + + + notebook + + + + alias + + + + _coordinate + (1072, 11) + + + _rotation + 0 + + + + ieee802_11_ofdm_sync_short + + id + ieee802_11_ofdm_sync_short_0 + + + _enabled + True + + + log + False + + + debug + False + + + threshold + 0.85 * 0.75 + + + min_plateau + 2 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (216, 504) + + + _rotation + 0 + + + + ieee802_11_ofdm_sync_long + + id + ieee802_11_ofdm_sync_long_0 + + + _enabled + True + + + log + False + + + debug + False + + + sync_length + sync_length + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (672, 531) + + + _rotation + 0 + + + + ieee802_11_ofdm_parse_mac + + id + ieee802_11_ofdm_parse_mac_0 + + + _enabled + True + + + log + False + + + debug + True + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (960, 1099) + + + _rotation + 180 + + + + blocks_pdu_to_tagged_stream + + id + blocks_pdu_to_tagged_stream_0 + + + _enabled + True + + + type + float + + + tag + packet_len + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (720, 1107) + + + _rotation + 180 + + + + wxgui_numbersink2 + + id + wxgui_numbersink2_0 + + + _enabled + True + + + type + float + + + title + Frame Error Rate + + + units + % + + + samp_rate + 1 + + + min_value + 0 + + + max_value + 100 + + + factor + 1.0 + + + decimal_places + 2 + + + ref_level + 0 + + + number_rate + 15 + + + peak_hold + False + + + average + True + + + avg_alpha + 0.02 + + + show_gauge + True + + + win_size + + + + grid_pos + + + + notebook + + + + alias + + + + affinity + + + + _coordinate + (512, 1027) + + + _rotation + 180 + + + + foo_wireshark_connector + + id + foo_wireshark_connector_0 + + + _enabled + False + + + tech + 127 + + + debug + False + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (952, 947) + + + _rotation + 180 + + + + blocks_file_sink + + id + blocks_file_sink_0 + + + _enabled + False + + + file + /tmp/ofdm.pcap + + + type + byte + + + vlen + 1 + + + unbuffered + True + + + append + True + + + alias + + + + affinity + + + + _coordinate + (720, 939) + + + _rotation + 180 + + blocks_stream_to_vector_0 fft_vxx_0 @@ -2252,12 +2500,6 @@ 0 0 - - blocks_divide_xx_0 - ieee802_11_ofdm_sync_short_0 - 0 - 1 - ieee802_11_ofdm_equalize_symbols_0 ieee802_11_ofdm_decode_signal_0 @@ -2318,12 +2560,6 @@ 0 0 - - blocks_delay_0_0 - ieee802_11_ofdm_sync_short_0 - 0 - 0 - uhd_usrp_source_0 blocks_multiply_xx_0 @@ -2355,10 +2591,28 @@ in - ieee802_11_ofdm_decode_mac_0 - ieee802_11_ether_encap_0 - out - from wifi + blocks_divide_xx_0 + wxgui_scopesink2_0 + 0 + 0 + + + blocks_delay_0_0 + ieee802_11_ofdm_sync_short_0 + 0 + 0 + + + blocks_divide_xx_0 + ieee802_11_ofdm_sync_short_0 + 0 + 2 + + + ieee802_11_moving_average_xx_0 + ieee802_11_ofdm_sync_short_0 + 0 + 1 ieee802_11_ofdm_decode_mac_0 @@ -2367,9 +2621,15 @@ in - ieee802_11_ether_encap_0 - blocks_tuntap_pdu_0 - to tap + blocks_pdu_to_tagged_stream_0 + wxgui_numbersink2_0 + 0 + 0 + + + ieee802_11_ofdm_parse_mac_0 + blocks_pdu_to_tagged_stream_0 + fer pdus @@ -2378,10 +2638,4 @@ 0 0 - - blocks_divide_xx_0 - wxgui_scopesink2_0 - 0 - 0 - diff --git a/examples/wifi_transceiver.grc b/examples/wifi_transceiver.grc index ef552fb..f3efb9a 100644 --- a/examples/wifi_transceiver.grc +++ b/examples/wifi_transceiver.grc @@ -1,4 +1,5 @@ + Fri Jul 18 10:38:08 2014 @@ -119,61 +120,6 @@ 0 - - variable_chooser - - id - lo_offset - - - _enabled - True - - - label - LO Offset - - - value - 0 - - - choices - [0, 6e9, 11e9] - - - labels - ['0 MHz', '6 MHz', '11 MHz'] - - - type - drop_down - - - style - wx.RA_HORIZONTAL - - - grid_pos - - - - notebook - - - - alias - - - - _coordinate - (584, 7) - - - _rotation - 0 - - variable_slider @@ -406,45 +352,6 @@ 0 - - wifi_phy_hier - - id - wifi_phy_hier_0 - - - _enabled - True - - - encoding - 0 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (334, 360) - - - _rotation - 180 - - blocks_multiply_const_vxx @@ -637,53 +544,6 @@ 0 - - ieee802_11_ofdm_mac - - id - ieee802_11_ofdm_mac_0 - - - _enabled - True - - - src_mac - [0x23, 0x23, 0x23, 0x23, 0x23, 0x23] - - - dst_mac - [0x42, 0x42, 0x42, 0x42, 0x42, 0x42] - - - bss_mac - [0xff, 0xff, 0xff, 0xff, 0xff, 0xff] - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (303, 258) - - - _rotation - 0 - - ieee802_11_ofdm_parse_mac @@ -710,6 +570,14 @@ affinity + + minoutbuf + 0 + + + maxoutbuf + 0 + _coordinate (22, 290) @@ -720,823 +588,54 @@ - ieee802_11_ether_encap + variable_chooser id - ieee802_11_ether_encap_0 + lo_offset _enabled True - debug - False + label + LO Offset - alias - - - - affinity - - - - minoutbuf + value 0 - maxoutbuf - 0 + choices + [0, 6e6, 11e6] - _coordinate - (314, 157) - - - _rotation - 0 - - - - blocks_tuntap_pdu - - id - blocks_tuntap_pdu_0 - - - _enabled - True - - - ifn - tap0 - - - mtu - 440 - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (319, 80) - - - _rotation - 180 - - - - foo_packet_pad2 - - id - foo_packet_pad2_0 - - - _enabled - True - - - debug - False - - - delay - False - - - delay_sec - 0.001 - - - pad_front - 0 - - - pad_tail - 10000 - - - alias - - - - affinity - - - - minoutbuf - 100000 - - - maxoutbuf - 0 - - - _coordinate - (80, 511) - - - _rotation - 0 - - - - uhd_usrp_source - - id - uhd_usrp_source_0 - - - _enabled - True + labels + ['0 MHz', '6 MHz', '11 MHz'] type - fc32 + drop_down - otw + style + wx.RA_HORIZONTAL + + + grid_pos - stream_args + notebook - - stream_chans - [] - - - dev_addr - - - - dev_args - "" - - - sync - pc_clock - - - clock_rate - 0.0 - - - num_mboards - 1 - - - clock_source0 - - - - time_source0 - - - - sd_spec0 - - - - clock_source1 - - - - time_source1 - - - - sd_spec1 - - - - clock_source2 - - - - time_source2 - - - - sd_spec2 - - - - clock_source3 - - - - time_source3 - - - - sd_spec3 - - - - clock_source4 - - - - time_source4 - - - - sd_spec4 - - - - clock_source5 - - - - time_source5 - - - - sd_spec5 - - - - clock_source6 - - - - time_source6 - - - - sd_spec6 - - - - clock_source7 - - - - time_source7 - - - - sd_spec7 - - - - nchan - 1 - - - samp_rate - samp_rate - - - center_freq0 - uhd.tune_request(freq - lo_offset, lo_offset) - - - gain0 - rx_gain - - - ant0 - - - - bw0 - 0 - - - center_freq1 - 0 - - - gain1 - 0 - - - ant1 - - - - bw1 - 0 - - - center_freq2 - 0 - - - gain2 - 0 - - - ant2 - - - - bw2 - 0 - - - center_freq3 - 0 - - - gain3 - 0 - - - ant3 - - - - bw3 - 0 - - - center_freq4 - 0 - - - gain4 - 0 - - - ant4 - - - - bw4 - 0 - - - center_freq5 - 0 - - - gain5 - 0 - - - ant5 - - - - bw5 - 0 - - - center_freq6 - 0 - - - gain6 - 0 - - - ant6 - - - - bw6 - 0 - - - center_freq7 - 0 - - - gain7 - 0 - - - ant7 - - - - bw7 - 0 - - - center_freq8 - 0 - - - gain8 - 0 - - - ant8 - - - - bw8 - 0 - - - center_freq9 - 0 - - - gain9 - 0 - - - ant9 - - - - bw9 - 0 - - - center_freq10 - 0 - - - gain10 - 0 - - - ant10 - - - - bw10 - 0 - - - center_freq11 - 0 - - - gain11 - 0 - - - ant11 - - - - bw11 - 0 - - - center_freq12 - 0 - - - gain12 - 0 - - - ant12 - - - - bw12 - 0 - - - center_freq13 - 0 - - - gain13 - 0 - - - ant13 - - - - bw13 - 0 - - - center_freq14 - 0 - - - gain14 - 0 - - - ant14 - - - - bw14 - 0 - - - center_freq15 - 0 - - - gain15 - 0 - - - ant15 - - - - bw15 - 0 - - - center_freq16 - 0 - - - gain16 - 0 - - - ant16 - - - - bw16 - 0 - - - center_freq17 - 0 - - - gain17 - 0 - - - ant17 - - - - bw17 - 0 - - - center_freq18 - 0 - - - gain18 - 0 - - - ant18 - - - - bw18 - 0 - - - center_freq19 - 0 - - - gain19 - 0 - - - ant19 - - - - bw19 - 0 - - - center_freq20 - 0 - - - gain20 - 0 - - - ant20 - - - - bw20 - 0 - - - center_freq21 - 0 - - - gain21 - 0 - - - ant21 - - - - bw21 - 0 - - - center_freq22 - 0 - - - gain22 - 0 - - - ant22 - - - - bw22 - 0 - - - center_freq23 - 0 - - - gain23 - 0 - - - ant23 - - - - bw23 - 0 - - - center_freq24 - 0 - - - gain24 - 0 - - - ant24 - - - - bw24 - 0 - - - center_freq25 - 0 - - - gain25 - 0 - - - ant25 - - - - bw25 - 0 - - - center_freq26 - 0 - - - gain26 - 0 - - - ant26 - - - - bw26 - 0 - - - center_freq27 - 0 - - - gain27 - 0 - - - ant27 - - - - bw27 - 0 - - - center_freq28 - 0 - - - gain28 - 0 - - - ant28 - - - - bw28 - 0 - - - center_freq29 - 0 - - - gain29 - 0 - - - ant29 - - - - bw29 - 0 - - - center_freq30 - 0 - - - gain30 - 0 - - - ant30 - - - - bw30 - 0 - - - center_freq31 - 0 - - - gain31 - 0 - - - ant31 - - - - bw31 - 0 - alias - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - _coordinate - (447, 520) + (584, 7) _rotation @@ -1695,12 +794,16 @@ center_freq0 - uhd.tune_request(freq - lo_offset, lo_offset) + uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL) gain0 tx_gain + + norm_gain0 + False + ant0 @@ -1717,6 +820,10 @@ gain1 0 + + norm_gain1 + False + ant1 @@ -1733,6 +840,10 @@ gain2 0 + + norm_gain2 + False + ant2 @@ -1749,6 +860,10 @@ gain3 0 + + norm_gain3 + False + ant3 @@ -1765,6 +880,10 @@ gain4 0 + + norm_gain4 + False + ant4 @@ -1781,6 +900,10 @@ gain5 0 + + norm_gain5 + False + ant5 @@ -1797,6 +920,10 @@ gain6 0 + + norm_gain6 + False + ant6 @@ -1813,6 +940,10 @@ gain7 0 + + norm_gain7 + False + ant7 @@ -1829,6 +960,10 @@ gain8 0 + + norm_gain8 + False + ant8 @@ -1845,6 +980,10 @@ gain9 0 + + norm_gain9 + False + ant9 @@ -1861,6 +1000,10 @@ gain10 0 + + norm_gain10 + False + ant10 @@ -1877,6 +1020,10 @@ gain11 0 + + norm_gain11 + False + ant11 @@ -1893,6 +1040,10 @@ gain12 0 + + norm_gain12 + False + ant12 @@ -1909,6 +1060,10 @@ gain13 0 + + norm_gain13 + False + ant13 @@ -1925,6 +1080,10 @@ gain14 0 + + norm_gain14 + False + ant14 @@ -1941,6 +1100,10 @@ gain15 0 + + norm_gain15 + False + ant15 @@ -1957,6 +1120,10 @@ gain16 0 + + norm_gain16 + False + ant16 @@ -1973,6 +1140,10 @@ gain17 0 + + norm_gain17 + False + ant17 @@ -1989,6 +1160,10 @@ gain18 0 + + norm_gain18 + False + ant18 @@ -2005,6 +1180,10 @@ gain19 0 + + norm_gain19 + False + ant19 @@ -2021,6 +1200,10 @@ gain20 0 + + norm_gain20 + False + ant20 @@ -2037,6 +1220,10 @@ gain21 0 + + norm_gain21 + False + ant21 @@ -2053,6 +1240,10 @@ gain22 0 + + norm_gain22 + False + ant22 @@ -2069,6 +1260,10 @@ gain23 0 + + norm_gain23 + False + ant23 @@ -2085,6 +1280,10 @@ gain24 0 + + norm_gain24 + False + ant24 @@ -2101,6 +1300,10 @@ gain25 0 + + norm_gain25 + False + ant25 @@ -2117,6 +1320,10 @@ gain26 0 + + norm_gain26 + False + ant26 @@ -2133,6 +1340,10 @@ gain27 0 + + norm_gain27 + False + ant27 @@ -2149,6 +1360,10 @@ gain28 0 + + norm_gain28 + False + ant28 @@ -2165,6 +1380,10 @@ gain29 0 + + norm_gain29 + False + ant29 @@ -2181,6 +1400,10 @@ gain30 0 + + norm_gain30 + False + ant30 @@ -2197,6 +1420,10 @@ gain31 0 + + norm_gain31 + False + ant31 @@ -2226,6 +1453,1135 @@ 0 + + uhd_usrp_source + + id + uhd_usrp_source_0 + + + _enabled + True + + + type + fc32 + + + otw + + + + stream_args + + + + stream_chans + [] + + + dev_addr + + + + dev_args + "" + + + sync + pc_clock + + + clock_rate + 0.0 + + + num_mboards + 1 + + + clock_source0 + + + + time_source0 + + + + sd_spec0 + + + + clock_source1 + + + + time_source1 + + + + sd_spec1 + + + + clock_source2 + + + + time_source2 + + + + sd_spec2 + + + + clock_source3 + + + + time_source3 + + + + sd_spec3 + + + + clock_source4 + + + + time_source4 + + + + sd_spec4 + + + + clock_source5 + + + + time_source5 + + + + sd_spec5 + + + + clock_source6 + + + + time_source6 + + + + sd_spec6 + + + + clock_source7 + + + + time_source7 + + + + sd_spec7 + + + + nchan + 1 + + + samp_rate + samp_rate + + + center_freq0 + uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL) + + + gain0 + rx_gain + + + norm_gain0 + False + + + ant0 + + + + bw0 + 0 + + + center_freq1 + 0 + + + gain1 + 0 + + + norm_gain1 + False + + + ant1 + + + + bw1 + 0 + + + center_freq2 + 0 + + + gain2 + 0 + + + norm_gain2 + False + + + ant2 + + + + bw2 + 0 + + + center_freq3 + 0 + + + gain3 + 0 + + + norm_gain3 + False + + + ant3 + + + + bw3 + 0 + + + center_freq4 + 0 + + + gain4 + 0 + + + norm_gain4 + False + + + ant4 + + + + bw4 + 0 + + + center_freq5 + 0 + + + gain5 + 0 + + + norm_gain5 + False + + + ant5 + + + + bw5 + 0 + + + center_freq6 + 0 + + + gain6 + 0 + + + norm_gain6 + False + + + ant6 + + + + bw6 + 0 + + + center_freq7 + 0 + + + gain7 + 0 + + + norm_gain7 + False + + + ant7 + + + + bw7 + 0 + + + center_freq8 + 0 + + + gain8 + 0 + + + norm_gain8 + False + + + ant8 + + + + bw8 + 0 + + + center_freq9 + 0 + + + gain9 + 0 + + + norm_gain9 + False + + + ant9 + + + + bw9 + 0 + + + center_freq10 + 0 + + + gain10 + 0 + + + norm_gain10 + False + + + ant10 + + + + bw10 + 0 + + + center_freq11 + 0 + + + gain11 + 0 + + + norm_gain11 + False + + + ant11 + + + + bw11 + 0 + + + center_freq12 + 0 + + + gain12 + 0 + + + norm_gain12 + False + + + ant12 + + + + bw12 + 0 + + + center_freq13 + 0 + + + gain13 + 0 + + + norm_gain13 + False + + + ant13 + + + + bw13 + 0 + + + center_freq14 + 0 + + + gain14 + 0 + + + norm_gain14 + False + + + ant14 + + + + bw14 + 0 + + + center_freq15 + 0 + + + gain15 + 0 + + + norm_gain15 + False + + + ant15 + + + + bw15 + 0 + + + center_freq16 + 0 + + + gain16 + 0 + + + norm_gain16 + False + + + ant16 + + + + bw16 + 0 + + + center_freq17 + 0 + + + gain17 + 0 + + + norm_gain17 + False + + + ant17 + + + + bw17 + 0 + + + center_freq18 + 0 + + + gain18 + 0 + + + norm_gain18 + False + + + ant18 + + + + bw18 + 0 + + + center_freq19 + 0 + + + gain19 + 0 + + + norm_gain19 + False + + + ant19 + + + + bw19 + 0 + + + center_freq20 + 0 + + + gain20 + 0 + + + norm_gain20 + False + + + ant20 + + + + bw20 + 0 + + + center_freq21 + 0 + + + gain21 + 0 + + + norm_gain21 + False + + + ant21 + + + + bw21 + 0 + + + center_freq22 + 0 + + + gain22 + 0 + + + norm_gain22 + False + + + ant22 + + + + bw22 + 0 + + + center_freq23 + 0 + + + gain23 + 0 + + + norm_gain23 + False + + + ant23 + + + + bw23 + 0 + + + center_freq24 + 0 + + + gain24 + 0 + + + norm_gain24 + False + + + ant24 + + + + bw24 + 0 + + + center_freq25 + 0 + + + gain25 + 0 + + + norm_gain25 + False + + + ant25 + + + + bw25 + 0 + + + center_freq26 + 0 + + + gain26 + 0 + + + norm_gain26 + False + + + ant26 + + + + bw26 + 0 + + + center_freq27 + 0 + + + gain27 + 0 + + + norm_gain27 + False + + + ant27 + + + + bw27 + 0 + + + center_freq28 + 0 + + + gain28 + 0 + + + norm_gain28 + False + + + ant28 + + + + bw28 + 0 + + + center_freq29 + 0 + + + gain29 + 0 + + + norm_gain29 + False + + + ant29 + + + + bw29 + 0 + + + center_freq30 + 0 + + + gain30 + 0 + + + norm_gain30 + False + + + ant30 + + + + bw30 + 0 + + + center_freq31 + 0 + + + gain31 + 0 + + + norm_gain31 + False + + + ant31 + + + + bw31 + 0 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (447, 520) + + + _rotation + 0 + + + + wxgui_scopesink2 + + id + wxgui_scopesink2_0 + + + _enabled + True + + + type + complex + + + title + Scope Plot + + + samp_rate + 5000 + + + v_scale + 0 + + + v_offset + 0 + + + t_scale + 0 + + + ac_couple + False + + + xy_mode + True + + + num_inputs + 1 + + + win_size + + + + grid_pos + + + + notebook + + + + trig_mode + wxgui.TRIG_MODE_AUTO + + + y_axis_label + Counts + + + alias + + + + affinity + + + + _coordinate + (808, 411) + + + _rotation + 0 + + + + foo_packet_pad2 + + id + foo_packet_pad2_0 + + + _enabled + True + + + debug + False + + + delay + False + + + delay_sec + 0.001 + + + pad_front + 10000 + + + pad_tail + 10000 + + + alias + + + + affinity + + + + minoutbuf + 100000 + + + maxoutbuf + 0 + + + _coordinate + (80, 523) + + + _rotation + 0 + + + + blocks_tuntap_pdu + + id + blocks_tuntap_pdu_0 + + + _enabled + True + + + ifn + tap0 + + + mtu + 440 + + + istunflag + False + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (319, 80) + + + _rotation + 180 + + + + wifi_phy_hier + + id + wifi_phy_hier_0 + + + _enabled + True + + + encoding + 0 + + + chan_est + 0 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (334, 360) + + + _rotation + 180 + + + + ieee802_11_ether_encap + + id + ieee802_11_ether_encap_0 + + + _enabled + True + + + debug + False + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (314, 157) + + + _rotation + 0 + + + + ieee802_11_ofdm_mac + + id + ieee802_11_ofdm_mac_0 + + + _enabled + True + + + src_mac + [0x12, 0x34, 0x56, 0x78, 0x90, 0xab] + + + dst_mac + [0x30, 0x14, 0x4a, 0xe6, 0x46, 0xe4] + + + bss_mac + [0x42, 0x42, 0x42, 0x42, 0x42, 0x42] + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (303, 258) + + + _rotation + 0 + + ieee802_11_ether_encap_0 blocks_tuntap_pdu_0 @@ -2238,18 +2594,6 @@ pdus from tap - - ieee802_11_ofdm_mac_0 - ieee802_11_ether_encap_0 - app out - from wifi - - - ieee802_11_ether_encap_0 - ieee802_11_ofdm_mac_0 - to wifi - app in - ieee802_11_ofdm_mac_0 foo_wireshark_connector_0 @@ -2310,4 +2654,22 @@ 0 0 + + wifi_phy_hier_0 + wxgui_scopesink2_0 + 1 + 0 + + + ieee802_11_ether_encap_0 + ieee802_11_ofdm_mac_0 + to wifi + app in + + + wifi_phy_hier_0 + ieee802_11_ether_encap_0 + mac_out + from wifi + diff --git a/examples/wifi_tx.grc b/examples/wifi_tx.grc index e3c405e..d554b58 100644 --- a/examples/wifi_tx.grc +++ b/examples/wifi_tx.grc @@ -1,6 +1,6 @@ - Fri Jul 18 10:38:21 2014 + Fri Apr 17 13:08:32 2015 options @@ -65,50 +65,18 @@ - variable_slider + variable id - gain + out_buf_size _enabled True - - label - - value - 25 - - - min - 0 - - - max - 100 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - + 96000 alias @@ -116,7 +84,34 @@ _coordinate - (291, 12) + (996, 388) + + + _rotation + 0 + + + + variable + + id + antenna + + + _enabled + True + + + value + 'J1' + + + alias + + + + _coordinate + (873, 157) _rotation @@ -179,22 +174,26 @@ - blocks_message_strobe + ieee802_11_ofdm_mac id - blocks_message_strobe_0 + ieee802_11_ofdm_mac_0 _enabled True - msg - pmt.intern(" Hello World") + src_mac + [0x23, 0x23, 0x23, 0x23, 0x23, 0x23] - period - 300 + dst_mac + [0x42, 0x42, 0x42, 0x42, 0x42, 0x42] + + + bss_mac + [0xff, 0xff, 0xff, 0xff, 0xff, 255] alias @@ -214,7 +213,7 @@ _coordinate - (113, 154) + (446, 187) _rotation @@ -222,168 +221,97 @@ - variable_chooser + blocks_message_strobe id - lo_offset + blocks_message_strobe_0_0 _enabled True - label - LO Offset + msg + pmt.intern("".join("x" for i in range(pdu_length))) - value - 6e9 + period + period - choices - [0, 6e9, 11e9] + alias + - labels - ['0 MHz', '6 MHz', '11 MHz'] + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (81, 135) + + + _rotation + 0 + + + + blocks_socket_pdu + + id + blocks_socket_pdu_0 + + + _enabled + True type - drop_down + "UDP_SERVER" - style - wx.RA_HORIZONTAL - - - grid_pos + host - notebook - + port + 52001 + + + mtu + 10000 + + + tcp_no_delay + False alias - _coordinate - (697, 165) - - - _rotation - 0 - - - - variable_chooser - - id - freq - - - _enabled - True - - - label - Channel - - - value - 5.89e9 - - - choices - [2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0] - - - labels - [' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'] - - - type - drop_down - - - style - wx.RA_HORIZONTAL - - - grid_pos + affinity - notebook - - - - alias - - - - _coordinate - (419, 11) - - - _rotation - 0 - - - - variable_slider - - id - mult - - - _enabled - True - - - label - - - - value - .38 - - - min + minoutbuf 0 - max - 2 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - alias - + maxoutbuf + 0 _coordinate - (979, 10) + (177, 222) _rotation @@ -446,18 +374,148 @@ - wifi_phy_hier + variable_chooser id - wifi_phy_hier_0 + freq _enabled True - encoding - encoding + label + Channel + + + value + 5.89e9 + + + choices + [2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0] + + + labels + [' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'] + + + type + drop_down + + + style + wx.RA_HORIZONTAL + + + grid_pos + + + + notebook + + + + alias + + + + _coordinate + (428, 10) + + + _rotation + 0 + + + + variable_slider + + id + pdu_length + + + _enabled + True + + + label + + + + value + 100 + + + min + 0 + + + max + 1500 + + + num_steps + 1000 + + + style + wx.SL_HORIZONTAL + + + converver + int_converter + + + grid_pos + + + + notebook + + + + alias + + + + _coordinate + (982, 130) + + + _rotation + 0 + + + + foo_packet_pad2 + + id + foo_packet_pad2_0 + + + _enabled + True + + + debug + False + + + delay + False + + + delay_sec + 0.01 + + + pad_front + 100 + + + pad_tail + 1000 alias @@ -469,7 +527,7 @@ minoutbuf - 0 + out_buf_size maxoutbuf @@ -477,11 +535,184 @@ _coordinate - (461, 299) + (84, 444) _rotation - 180 + 0 + + + + variable_chooser + + id + lo_offset + + + _enabled + True + + + label + LO Offset + + + value + 0e9 + + + choices + [0, 6e9, 11e9] + + + labels + ['0 MHz', '6 MHz', '11 MHz'] + + + type + drop_down + + + style + wx.RA_HORIZONTAL + + + grid_pos + + + + notebook + + + + alias + + + + _coordinate + (915, 461) + + + _rotation + 0 + + + + variable_slider + + id + mult + + + _enabled + True + + + label + + + + value + .4 + + + min + 0 + + + max + 2 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + alias + + + + _coordinate + (980, 10) + + + _rotation + 0 + + + + variable_slider + + id + period + + + _enabled + True + + + label + + + + value + 100 + + + min + 1 + + + max + 10000 + + + num_steps + 1000 + + + style + wx.SL_HORIZONTAL + + + converver + int_converter + + + grid_pos + + + + notebook + + + + alias + + + + _coordinate + (972, 264) + + + _rotation + 0 @@ -528,7 +759,7 @@ _coordinate - (668, 333) + (733, 333) _rotation @@ -536,203 +767,58 @@ - blocks_multiply_const_vxx + variable_slider id - blocks_multiply_const_vxx_0 + tx_gain _enabled True - type - complex + label + - const - mult + value + 10 - vlen - 1 + min + 0 + + + max + 100 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + alias - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - _coordinate - (231, 329) - - - _rotation - 180 - - - - foo_packet_pad2 - - id - foo_packet_pad2_0 - - - _enabled - True - - - debug - False - - - delay - False - - - delay_sec - 0.01 - - - pad_front - 0 - - - pad_tail - 10000 - - - alias - - - - affinity - - - - minoutbuf - 100000 - - - maxoutbuf - 0 - - - _coordinate - (86, 444) - - - _rotation - 0 - - - - ieee802_11_ofdm_mac - - id - ieee802_11_ofdm_mac_0 - - - _enabled - True - - - src_mac - [0x23, 0x23, 0x23, 0x23, 0x23, 0x23] - - - dst_mac - [0x42, 0x42, 0x42, 0x42, 0x42, 0x42] - - - bss_mac - [0xff, 0xff, 0xff, 0xff, 0xff, 255] - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (446, 187) - - - _rotation - 0 - - - - blocks_socket_pdu - - id - blocks_socket_pdu_0 - - - _enabled - True - - - type - "UDP_SERVER" - - - host - - - - port - 52001 - - - mtu - 10000 - - - tcp_no_delay - False - - - alias - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (177, 222) + (292, 12) _rotation @@ -895,11 +981,11 @@ gain0 - gain + tx_gain ant0 - + antenna bw0 @@ -1422,30 +1508,145 @@ 0 - - blocks_message_strobe_0 - ieee802_11_ofdm_mac_0 - strobe - app in - - - blocks_socket_pdu_0 - ieee802_11_ofdm_mac_0 - pdus - app in - + + wifi_phy_hier + + id + wifi_phy_hier_0 + + + _enabled + True + + + encoding + encoding + + + chan_est + 0 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (461, 299) + + + _rotation + 180 + + + + blocks_null_sink + + id + blocks_null_sink_0 + + + _enabled + True + + + type + complex + + + vlen + 1 + + + num_inputs + 1 + + + bus_conns + [[0,],] + + + alias + + + + affinity + + + + _coordinate + (285, 333) + + + _rotation + 180 + + + + blocks_multiply_const_vxx + + id + blocks_multiply_const_vxx_0 + + + _enabled + True + + + type + complex + + + const + mult + + + vlen + 1 + + + alias + + + + affinity + + + + minoutbuf + 100000 + + + maxoutbuf + 0 + + + _coordinate + (89, 363) + + + _rotation + 180 + + foo_packet_pad2_0 uhd_usrp_sink_0 0 0 - - wifi_phy_hier_0 - blocks_multiply_const_vxx_0 - 0 - 0 - blocks_multiply_const_vxx_0 foo_packet_pad2_0 @@ -1470,4 +1671,28 @@ 0 0 + + blocks_message_strobe_0_0 + ieee802_11_ofdm_mac_0 + strobe + app in + + + blocks_socket_pdu_0 + ieee802_11_ofdm_mac_0 + pdus + app in + + + wifi_phy_hier_0 + blocks_null_sink_0 + 1 + 0 + + + wifi_phy_hier_0 + blocks_multiply_const_vxx_0 + 0 + 0 + diff --git a/grc/ieee802_11_ofdm_equalize_symbols.xml b/grc/ieee802_11_ofdm_equalize_symbols.xml index 479f3a3..5056085 100644 --- a/grc/ieee802_11_ofdm_equalize_symbols.xml +++ b/grc/ieee802_11_ofdm_equalize_symbols.xml @@ -5,7 +5,24 @@ ieee802_11_ofdm_equalize_symbols IEEE802.11 import ieee802_11 - ieee802_11.ofdm_equalize_symbols($debug) + ieee802_11.ofdm_equalize_symbols($algo, $debug) + set_algorithm($algo) + + + Algorithm + algo + ieee802_11.LINEAR_COMB + int + + + + Debug diff --git a/grc/ieee802_11_ofdm_freq_est.xml b/grc/ieee802_11_ofdm_freq_est.xml deleted file mode 100644 index 3c202b1..0000000 --- a/grc/ieee802_11_ofdm_freq_est.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - OFDM Freq Est - ieee802_11_ofdm_freq_est - IEEE802.11 - import ieee802_11 - ieee802_11.ofdm_freq_est($log, $debug) - - - Log - log - False - bool - - - - - - - Debug - debug - False - bool - - - - - - - in - complex - 1 - - - - out - complex - 1 - - - diff --git a/grc/ieee802_11_ofdm_mapper.xml b/grc/ieee802_11_ofdm_mapper.xml index 73399eb..baa9915 100644 --- a/grc/ieee802_11_ofdm_mapper.xml +++ b/grc/ieee802_11_ofdm_mapper.xml @@ -11,8 +11,41 @@ Encoding encoding - 0 + ieee802_11.BPSK_1_2 int + + + + + + + + + diff --git a/grc/ieee802_11_ofdm_parse_mac.xml b/grc/ieee802_11_ofdm_parse_mac.xml index cb6d9c9..2ebc9a2 100644 --- a/grc/ieee802_11_ofdm_parse_mac.xml +++ b/grc/ieee802_11_ofdm_parse_mac.xml @@ -44,5 +44,11 @@ message + + fer + message + 1 + + diff --git a/grc/ieee802_11_ofdm_sync_short.xml b/grc/ieee802_11_ofdm_sync_short.xml index 5ee8da9..0913174 100644 --- a/grc/ieee802_11_ofdm_sync_short.xml +++ b/grc/ieee802_11_ofdm_sync_short.xml @@ -5,7 +5,7 @@ ieee802_11_ofdm_sync_short IEEE802.11 import ieee802_11 - ieee802_11.ofdm_sync_short($threshold, $max_samples, $min_plateau, $log, $debug) + ieee802_11.ofdm_sync_short($threshold, $min_plateau, $log, $debug) Log @@ -46,13 +46,6 @@ real - - Max Samples - max_samples - 5200 - int - - Min Plateau min_plateau @@ -61,7 +54,6 @@ $threshold > 0 - $max_samples > 400 $min_plateau > 0 @@ -70,6 +62,12 @@ 1 + + abs + complex + 1 + + cor float diff --git a/include/ieee802-11/CMakeLists.txt b/include/ieee802-11/CMakeLists.txt index 02a70c7..8f1e454 100644 --- a/include/ieee802-11/CMakeLists.txt +++ b/include/ieee802-11/CMakeLists.txt @@ -74,7 +74,6 @@ list(APPEND include_sources ofdm_decode_mac.h ofdm_decode_signal.h ofdm_equalize_symbols.h - ofdm_freq_est.h ofdm_mac.h ofdm_mapper.h ofdm_parse_mac.h diff --git a/include/ieee802-11/ofdm_equalize_symbols.h b/include/ieee802-11/ofdm_equalize_symbols.h index 143b265..d9a1cc4 100644 --- a/include/ieee802-11/ofdm_equalize_symbols.h +++ b/include/ieee802-11/ofdm_equalize_symbols.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Bastian Bloessl + * Copyright (C) 2013, 2015 Bastian Bloessl * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +20,11 @@ #include #include +enum Equalizer { + LMS = 0, + LINEAR_COMB = 1, +}; + namespace gr { namespace ieee802_11 { @@ -28,7 +33,8 @@ class IEEE802_11_API ofdm_equalize_symbols : virtual public block public: typedef boost::shared_ptr sptr; - static sptr make(bool debug = false); + static sptr make(Equalizer algo, bool debug = false); + virtual void set_algorithm(Equalizer algo) = 0; }; diff --git a/include/ieee802-11/ofdm_sync_short.h b/include/ieee802-11/ofdm_sync_short.h index 2bfbca2..94d56e8 100644 --- a/include/ieee802-11/ofdm_sync_short.h +++ b/include/ieee802-11/ofdm_sync_short.h @@ -28,8 +28,7 @@ class IEEE802_11_API ofdm_sync_short : virtual public block public: typedef boost::shared_ptr sptr; - static sptr make(double threshold, unsigned int max_samples, - unsigned int min_plateau, bool log = false, bool debug = false); + static sptr make(double threshold, unsigned int min_plateau, bool log = false, bool debug = false); }; diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index f093028..9aeec13 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -94,12 +94,13 @@ add_dependencies(ieee802_11_generated_sources ieee802_11_generated_includes) ######################################################################## list(APPEND gr_ieee802_11_sources ${generated_sources} + equalizer/linear_comb.cc + equalizer/lms.cc chunks_to_symbols_impl.cc ether_encap_impl.cc ofdm_decode_mac.cc ofdm_decode_signal.cc ofdm_equalize_symbols.cc - ofdm_freq_est.cc ofdm_mac.cc ofdm_mapper.cc ofdm_parse_mac.cc @@ -115,6 +116,7 @@ list(APPEND gr_ieee802_11_libs ${Boost_LIBRARIES} ${GNURADIO_ALL_LIBRARIES} ${ITPP_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-ieee802_11 SHARED ${gr_ieee802_11_sources}) diff --git a/include/ieee802-11/ofdm_freq_est.h b/lib/equalizer/base.h similarity index 60% rename from include/ieee802-11/ofdm_freq_est.h rename to lib/equalizer/base.h index b891a81..1e8ffb5 100644 --- a/include/ieee802-11/ofdm_freq_est.h +++ b/lib/equalizer/base.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Bastian Bloessl + * Copyright (C) 2015 Bastian Bloessl * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,25 +14,24 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef INCLUDED_IEEE802_11_OFDM_FREQ_EST_H -#define INCLUDED_IEEE802_11_OFDM_FREQ_EST_H -#include -#include +#ifndef INCLUDED_IEEE802_11_EQUALIZER_BASE_H +#define INCLUDED_IEEE802_11_EQUALIZER_BASE_H + +#include namespace gr { namespace ieee802_11 { +namespace equalizer { -class IEEE802_11_API ofdm_freq_est : virtual public block -{ +class base { public: - - typedef boost::shared_ptr sptr; - static sptr make(bool log = false, bool debug = false); - + virtual ~base() {}; + virtual void equalize(const gr_complex *in, gr_complex *out, int n) = 0; }; -} // namespace ieee802_11 -} // namespace gr +} /* namespace channel_estimation */ +} /* namespace ieee802_11 */ +} /* namespace gr */ -#endif /* INCLUDED_IEEE802_11_OFDM_FREQ_EST_H */ +#endif /* INCLUDED_IEEE802_11_EQUALIZER_BASE_H */ diff --git a/lib/equalizer/linear_comb.cc b/lib/equalizer/linear_comb.cc new file mode 100644 index 0000000..455deaa --- /dev/null +++ b/lib/equalizer/linear_comb.cc @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2015 Bastian Bloessl + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "linear_comb.h" + +using namespace gr::ieee802_11::equalizer; + +void linear_comb::equalize(const gr_complex *in, gr_complex *out, int n) { + if(n < 2) + return; + + double avg_mag = (abs(in[11]) + abs(in[25]) + abs(in[39]) + abs(in[53])) / 4; + + gr_complex p = POLARITY[(n - 2) % 127 ]; + + double p1 = arg( p * in[11]); + double p2 = arg( p * in[25] * conj(p * in[11])) + p1; + double p3 = arg( p * in[39] * conj(p * in[25])) + p2; + double p4 = arg(-p * in[53] * conj(p * in[39])) + p3; + + double my = (p1 + p2 + p3 + p4) / 4; + double mx = (11.0 + 25 + 39 + 53) / 4; + + double var = (((11.0 * 11.0) + (25.0 * 25.0) + (39.0 * 39.0) + (53.0 * 53.0)) / 4) - (mx * mx); + double cov = (( (p1 * 11) + (p2 * 25) + (p3 * 39) + (p4 * 53) ) / 4) - (mx * my); + double beta = cov / var; + double alpha = my - beta * mx; + + int c = 0; + for(int n = 0; n < 64; n++) { + if( (n == 11) || (n == 25) || (n == 32) || (n == 39) || (n == 53) || (n < 6) || ( n > 58)) { + continue; + } else { + out[c] = in[n] * exp(gr_complex(0, -n * beta - alpha)) * gr_complex(1 / avg_mag, 0); + c++; + } + } + +} + +const gr_complex linear_comb::POLARITY[127] = { + 1, 1, 1, 1,-1,-1,-1, 1,-1,-1,-1,-1, 1, 1,-1, 1, + -1,-1, 1, 1,-1, 1, 1,-1, 1, 1, 1, 1, 1, 1,-1, 1, + 1, 1,-1, 1, 1,-1,-1, 1, 1, 1,-1, 1,-1,-1,-1, 1, + -1, 1,-1,-1, 1,-1,-1, 1, 1, 1, 1, 1,-1,-1, 1, 1, + -1,-1, 1,-1, 1,-1, 1, 1,-1,-1,-1, 1, 1,-1,-1,-1, + -1, 1,-1,-1, 1,-1, 1, 1, 1, 1,-1, 1,-1, 1,-1, 1, + -1,-1,-1,-1,-1, 1,-1, 1, 1,-1, 1,-1, 1, 1, 1,-1, + -1, 1,-1,-1,-1, 1, 1, 1,-1,-1,-1,-1,-1,-1,-1 }; diff --git a/lib/equalizer/linear_comb.h b/lib/equalizer/linear_comb.h new file mode 100644 index 0000000..dc598cc --- /dev/null +++ b/lib/equalizer/linear_comb.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2015 Bastian Bloessl + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef INCLUDED_IEEE802_11_EQUALIZER_LINEAR_COMB_H +#define INCLUDED_IEEE802_11_EQUALIZER_LINEAR_COMB_H + +#include "base.h" + +namespace gr { +namespace ieee802_11 { +namespace equalizer { + +class linear_comb: public base { +public: + virtual void equalize(const gr_complex *in, gr_complex *out, int n); +private: + static const gr_complex POLARITY[127]; +}; + +} /* namespace channel_estimation */ +} /* namespace ieee802_11 */ +} /* namespace gr */ + +#endif /* INCLUDED_IEEE802_11_EQUALIZER_LINEAR_COMB_H */ + diff --git a/lib/equalizer/lms.cc b/lib/equalizer/lms.cc new file mode 100644 index 0000000..65dddf3 --- /dev/null +++ b/lib/equalizer/lms.cc @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2015 Bastian Bloessl + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "lms.h" +#include +#include + +using namespace gr::ieee802_11::equalizer; + +void lms::equalize(const gr_complex *in, gr_complex *out, int n) { + + static float freq_offset = 0; + static float freq_sum = 0; + static float alpha = 0.9; + + if(n == 0) { + std::memcpy(carrier, in, 64 * sizeof(gr_complex)); + } else if(n == 1) { + gr_complex sum = + (carrier[11] * conj(in[11])) + + (carrier[25] * conj(in[25])) + + (carrier[39] * conj(in[39])) + + (carrier[53] * conj(in[53])); + freq_offset = arg(sum); + freq_sum = 0; + for(int i = 0; i < 64; i++) { + carrier[i] += in[i]; + carrier[i] *= ref[i] * gr_complex(0.5, 0); + } + } else { + + gr_complex p = POLARITY[(n - 2) % 127]; + gr_complex sum = + (carrier[11] * conj(in[11]) * p) + + (carrier[25] * conj(in[25]) * p) + + (carrier[39] * conj(in[39]) * p) + + (carrier[53] * conj(in[53]) * -p); + + freq_offset = (1 - alpha) * freq_offset + alpha * arg(sum); + freq_sum += freq_offset; + + //std::cout << "lms: symbol " << n + // << " p1 " << abs(carrier[11] * conj(in[11]) * p) + // << " p2 " << abs(carrier[25] * conj(in[25]) * p) + // << " p3 " << abs(carrier[39] * conj(in[39]) * p) + // << " p4 " << abs(carrier[53] * conj(in[53]) * -p) + // << std::endl; + //std::cout << "lms: symbol " << n + // << " p1 " << arg(carrier[11] * conj(in[11]) * p) + // << " p2 " << arg(carrier[25] * conj(in[25]) * p) + // << " p3 " << arg(carrier[39] * conj(in[39]) * p) + // << " p4 " << arg(carrier[53] * conj(in[53]) * -p) + // << std::endl; + + carrier[11] = in[11] * p; + carrier[25] = in[25] * p; + carrier[39] = in[39] * p; + carrier[53] = in[53] * -p; + + int c = 0; + for(int i = 0; i < 64; i++) { + if( (i == 11) || (i == 25) || (i == 32) || (i == 39) || (i == 53) || (i < 6) || ( i > 58)) { + continue; + } else { + out[c] = in[i] / carrier[i] * exp(gr_complex(0, freq_sum)); + c++; + } + } + } +} + +const gr_complex lms::ref[] = { + 0, 0, 0, 0, 0, 0, 1, 1, -1, -1, + 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, + 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, + 1, 1, 0, 1, -1, -1, 1, 1, -1, 1, + -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, + -1, 1, -1, 1, -1, 1, 1, 1, 1, 0, + 0, 0, 0, 0 +}; + +const gr_complex lms::POLARITY[127] = { + 1, 1, 1, 1,-1,-1,-1, 1,-1,-1,-1,-1, 1, 1,-1, 1, + -1,-1, 1, 1,-1, 1, 1,-1, 1, 1, 1, 1, 1, 1,-1, 1, + 1, 1,-1, 1, 1,-1,-1, 1, 1, 1,-1, 1,-1,-1,-1, 1, + -1, 1,-1,-1, 1,-1,-1, 1, 1, 1, 1, 1,-1,-1, 1, 1, + -1,-1, 1,-1, 1,-1, 1, 1,-1,-1,-1, 1, 1,-1,-1,-1, + -1, 1,-1,-1, 1,-1, 1, 1, 1, 1,-1, 1,-1, 1,-1, 1, + -1,-1,-1,-1,-1, 1,-1, 1, 1,-1, 1,-1, 1, 1, 1,-1, + -1, 1,-1,-1,-1, 1, 1, 1,-1,-1,-1,-1,-1,-1,-1 }; diff --git a/lib/equalizer/lms.h b/lib/equalizer/lms.h new file mode 100644 index 0000000..c6d1d2f --- /dev/null +++ b/lib/equalizer/lms.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2015 Bastian Bloessl + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef INCLUDED_IEEE802_11_EQUALIZER_LMS_H +#define INCLUDED_IEEE802_11_EQUALIZER_LMS_H + +#include "base.h" +#include + +namespace gr { +namespace ieee802_11 { +namespace equalizer { + +class lms: public base { +public: + virtual void equalize(const gr_complex *in, gr_complex *out, int n); +private: + gr_complex carrier[64]; + static const gr_complex ref[64]; + static const gr_complex POLARITY[127]; +}; + +} /* namespace channel_estimation */ +} /* namespace ieee802_11 */ +} /* namespace gr */ + +#endif /* INCLUDED_IEEE802_11_EQUALIZER_LMS_H */ + diff --git a/lib/ether_encap_impl.cc b/lib/ether_encap_impl.cc index 86bebc0..aaea027 100644 --- a/lib/ether_encap_impl.cc +++ b/lib/ether_encap_impl.cc @@ -60,7 +60,7 @@ ether_encap_impl::from_wifi(pmt::pmt_t msg) { return; } - // this is more than neeed + // this is more than needed char *buf = static_cast(std::malloc(data_len + sizeof(ethernet_header))); ethernet_header *ehdr = reinterpret_cast(buf); diff --git a/lib/ofdm_decode_mac.cc b/lib/ofdm_decode_mac.cc index 8f2a21a..50e1324 100644 --- a/lib/ofdm_decode_mac.cc +++ b/lib/ofdm_decode_mac.cc @@ -34,8 +34,9 @@ ofdm_decode_mac_impl(bool log, bool debug) : block("ofdm_decode_mac", gr::io_signature::make(0, 0, 0)), d_log(log), d_debug(debug), - ofdm(BPSK_1_2), - tx(ofdm, 0) { + d_ofdm(BPSK_1_2), + d_tx(d_ofdm, 0), + d_frame_complete(true) { message_port_register_out(pmt::mp("out")); @@ -82,34 +83,43 @@ int general_work (int noutput_items, gr_vector_int& ninput_items, pmt::string_to_symbol("ofdm_start")); if(tags.size()) { + if (d_frame_complete == false) { + dout << "Warning: starting to receive new frame before old frame was complete" << std::endl; + dout << "Already copied " << copied << " out of " << d_tx.n_sym << " symbols of last frame" << std::endl; + } + d_frame_complete = false; + pmt::pmt_t tuple = tags[0].value; int len_data = pmt::to_uint64(pmt::car(tuple)); int encoding = pmt::to_uint64(pmt::cdr(tuple)); - ofdm = ofdm_param((Encoding)encoding); - tx = tx_param(ofdm, len_data); + ofdm_param ofdm = ofdm_param((Encoding)encoding); + tx_param tx = tx_param(ofdm, len_data); - copied = 0; - - // this frame is garbage - if(tx.n_sym > 100) { - // FIXME: make this nicer, this way garbage frames are skipped - copied = tx.n_sym + 1; + // sanity check, more than MAX_SYM may indicate garbage + if(tx.n_sym <= MAX_SYM && tx.n_encoded_bits <= MAX_BITS) { + d_ofdm = ofdm; + d_tx = tx; + copied = 0; + dout << "Decode MAC: frame start -- len " << len_data + << " symbols " << tx.n_sym << " encoding " + << encoding << std::endl; + } else { + dout << "Dropping frame which is too large (symbols or bits)" << std::endl; } - dout << "Decode MAC: frame start -- len " << len_data - << " symbols " << tx.n_sym << " encoding " - << encoding << std::endl; } - if(copied < tx.n_sym) { + if(copied < d_tx.n_sym) { + dout << "copy one symbol, copied " << copied << " out of " << d_tx.n_sym << std::endl; std::memcpy(sym + (copied * 48), in, 48 * sizeof(gr_complex)); copied++; - if(copied == tx.n_sym) { + if(copied == d_tx.n_sym) { dout << "received complete frame - decoding" << std::endl; decode(); in += 48; i++; + d_frame_complete = true; break; } } @@ -131,18 +141,18 @@ void decode() { // skip service field boost::crc_32_type result; - result.process_bytes(out_bytes + 2, tx.psdu_size); + result.process_bytes(out_bytes + 2, d_tx.psdu_size); if(result.checksum() != 558161692) { dout << "checksum wrong -- dropping" << std::endl; return; } mylog(boost::format("encoding: %1% - length: %2% - symbols: %3%") - % ofdm.encoding % tx.psdu_size % tx.n_sym); + % d_ofdm.encoding % d_tx.psdu_size % d_tx.n_sym); // create PDU - pmt::pmt_t blob = pmt::make_blob(out_bytes + 2, tx.psdu_size - 4); - pmt::pmt_t enc = pmt::from_uint64(ofdm.encoding); + pmt::pmt_t blob = pmt::make_blob(out_bytes + 2, d_tx.psdu_size - 4); + pmt::pmt_t enc = pmt::from_uint64(d_ofdm.encoding); pmt::pmt_t dict = pmt::make_dict(); dict = pmt::dict_add(dict, pmt::mp("encoding"), enc); message_port_pub(pmt::mp("out"), pmt::cons(dict, blob)); @@ -151,12 +161,12 @@ void decode() { void demodulate() { cvec symbols; - symbols.set_length(tx.n_sym * 48); - for(int i = 0; i < tx.n_sym * 48; i++) { + symbols.set_length(d_tx.n_sym * 48); + for(int i = 0; i < d_tx.n_sym * 48; i++) { symbols[i] = std::complex(sym[i]); } - switch(ofdm.encoding) { + switch(d_ofdm.encoding) { case BPSK_1_2: case BPSK_3_4: @@ -185,10 +195,10 @@ void demodulate() { void deinterleave() { - int n_cbps = ofdm.n_cbps; + int n_cbps = d_ofdm.n_cbps; int first[n_cbps]; int second[n_cbps]; - int s = std::max(ofdm.n_bpsc / 2, 1); + int s = std::max(d_ofdm.n_bpsc / 2, 1); for(int j = 0; j < n_cbps; j++) { first[j] = s * (j / s) + ((j + int(floor(16.0 * j / n_cbps))) % s); @@ -198,7 +208,7 @@ void deinterleave() { second[i] = 16 * i - (n_cbps - 1) * int(floor(16.0 * i / n_cbps)); } - for(int i = 0; i < tx.n_sym; i++) { + for(int i = 0; i < d_tx.n_sym; i++) { for(int k = 0; k < n_cbps; k++) { deinter[i * n_cbps + second[first[k]]] = bits[i * n_cbps + k]; } @@ -213,7 +223,7 @@ void decode_conv() { code.set_generator_polynomials(generator, 7); bmat puncture_matrix; - switch(ofdm.encoding) { + switch(d_ofdm.encoding) { case BPSK_1_2: case QPSK_1_2: case QAM16_1_2: @@ -233,12 +243,12 @@ void decode_conv() { code.set_truncation_length(30); dout << "coding rate " << code.get_rate() << std::endl; - dout << tx.n_encoded_bits << std::endl; + dout << d_tx.n_encoded_bits << std::endl; - vec rx_signal(deinter, tx.n_encoded_bits); + vec rx_signal(deinter, d_tx.n_encoded_bits); code.reset(); - decoded_bits.set_length(tx.n_encoded_bits); + decoded_bits.set_length(d_tx.n_encoded_bits); code.decode_tail(rx_signal, decoded_bits); //dout << "length decoded " << decoded_bits.size() << std::endl; @@ -300,12 +310,14 @@ private: double deinter[1000 * 48]; char out_bits[40000]; char out_bytes[40000]; - bvec decoded_bits; - bool d_debug; - bool d_log; - tx_param tx; - ofdm_param ofdm; + bvec decoded_bits; + + bool d_debug; + bool d_log; + tx_param d_tx; + ofdm_param d_ofdm; int copied; + bool d_frame_complete; Modulator > bpsk; Modulator > qpsk; diff --git a/lib/ofdm_equalize_symbols.cc b/lib/ofdm_equalize_symbols.cc index 335d3bc..22f77be 100644 --- a/lib/ofdm_equalize_symbols.cc +++ b/lib/ofdm_equalize_symbols.cc @@ -17,6 +17,9 @@ #include #include "utils.h" +#include "equalizer/base.h" +#include "equalizer/linear_comb.h" +#include "equalizer/lms.h" #include using namespace gr::ieee802_11; @@ -25,12 +28,14 @@ using namespace gr::ieee802_11; class ofdm_equalize_symbols_impl : public ofdm_equalize_symbols { public: -ofdm_equalize_symbols_impl(bool debug) : block("ofdm_equalize_symbols", +ofdm_equalize_symbols_impl(Equalizer algo, bool debug) : block("ofdm_equalize_symbols", gr::io_signature::make(1, 1, 64 * sizeof(gr_complex)), gr::io_signature::make(1, 1, 48 * sizeof(gr_complex))), - d_debug(debug) { + d_debug(debug), d_equalizer(NULL) { set_relative_rate(1); + set_tag_propagation_policy(block::TPP_DONT); + set_algorithm(algo); } ~ofdm_equalize_symbols_impl(){ @@ -40,86 +45,76 @@ int general_work (int noutput_items, gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, gr_vector_void_star& output_items) { + gr::thread::scoped_lock lock(d_mutex); + const gr_complex *in = (const gr_complex*)input_items[0]; gr_complex *out = (gr_complex*)output_items[0]; - int noutput = noutput_items; int i = 0; - - std::vector tags; - const uint64_t nread = nitems_read(0); + int o = 0; dout << "SYMBOLS: input " << ninput_items[0] << " output " << noutput_items << std::endl; - while((i < ninput_items[0]) && (i < noutput)) { + while((i < ninput_items[0]) && (o < noutput_items)) { - get_tags_in_range(tags, 0, nread + i, nread + i + 1, - pmt::string_to_symbol("ofdm_start")); + get_tags_in_window(tags, 0, i, i + 1, pmt::string_to_symbol("ofdm_start")); + // new WiFi frame if(tags.size()) { - index = 0; + d_nsym = 0; } - gr_complex p = POLARITY[index]; - index++; - - // FIXME: think about this... average over amplitude or power - double avg_mag = (abs(in[11]) + abs(in[25]) + abs(in[39]) + abs(in[53])) / 4; - - - double p1 = arg( p * in[11]); - double p2 = arg( p * in[25] * conj(p * in[11])) + p1; - double p3 = arg( p * in[39] * conj(p * in[25])) + p2; - double p4 = arg(-p * in[53] * conj(p * in[39])) + p3; - - double my = (p1 + p2 + p3 + p4) / 4; - double mx = (11.0 + 25 + 39 + 53) / 4; - - double var = (((11.0 * 11.0) + (25.0 * 25.0) + (39.0 * 39.0) + (53.0 * 53.0)) / 4) - (mx * mx); - double cov = (( (p1 * 11) + (p2 * 25) + (p3 * 39) + (p4 * 53) ) / 4) - (mx * my); - double beta = cov / var; - double alpha = my - beta * mx; - - int o = 0; - for(int n = 0; n < 64; n++) { - if( (n == 11) || (n == 25) || (n == 32) || (n == 39) || (n == 53) || (n < 6) || ( n > 58)) { - continue; - } else { - // FIXME: think about this... square or not - out[o] = in[n] * exp(gr_complex(0, -n * beta - alpha)) * gr_complex(1 / avg_mag, 0); - o++; - } + // first data symbol (= signal field) + if(d_nsym == 2) { + add_item_tag(0, nitems_written(0) + o, + pmt::string_to_symbol("ofdm_start"), + pmt::PMT_T, + pmt::string_to_symbol(name())); } + d_equalizer->equalize(in + (i * 64), out + (o * 48), d_nsym); + + if(d_nsym > 1) { + o++; + } i++; - in += 64; - out += 48; + d_nsym++; } - dout << "SYMBOLS: produced / consumed " << i << std::endl; + dout << "SYMBOLS: consumed " << i << " produced " << o << std::endl; consume(0, i); - return i; + return o; +} + +void set_algorithm(Equalizer algo) { + gr::thread::scoped_lock lock(d_mutex); + delete d_equalizer; + + switch(algo) { + case LMS: + dout << "LMS" << std::endl; + d_equalizer = new equalizer::lms(); + break; + + case LINEAR_COMB: + dout << "Linear Comb" << std::endl; + d_equalizer = new equalizer::linear_comb(); + break; + } } private: - int index; + int d_nsym; const bool d_debug; - static const gr_complex POLARITY[127]; + equalizer::base *d_equalizer; + std::vector tags; + gr::thread::mutex d_mutex; }; -const gr_complex ofdm_equalize_symbols_impl::POLARITY[127] = { - 1, 1, 1, 1,-1,-1,-1, 1,-1,-1,-1,-1, 1, 1,-1, 1, - -1,-1, 1, 1,-1, 1, 1,-1, 1, 1, 1, 1, 1, 1,-1, 1, - 1, 1,-1, 1, 1,-1,-1, 1, 1, 1,-1, 1,-1,-1,-1, 1, - -1, 1,-1,-1, 1,-1,-1, 1, 1, 1, 1, 1,-1,-1, 1, 1, - -1,-1, 1,-1, 1,-1, 1, 1,-1,-1,-1, 1, 1,-1,-1,-1, - -1, 1,-1,-1, 1,-1, 1, 1, 1, 1,-1, 1,-1, 1,-1, 1, - -1,-1,-1,-1,-1, 1,-1, 1, 1,-1, 1,-1, 1, 1, 1,-1, - -1, 1,-1,-1,-1, 1, 1, 1,-1,-1,-1,-1,-1,-1,-1 }; ofdm_equalize_symbols::sptr -ofdm_equalize_symbols::make(bool debug) { - return gnuradio::get_initial_sptr(new ofdm_equalize_symbols_impl(debug)); +ofdm_equalize_symbols::make(Equalizer algo, bool debug) { + return gnuradio::get_initial_sptr(new ofdm_equalize_symbols_impl(algo, debug)); } diff --git a/lib/ofdm_freq_est.cc b/lib/ofdm_freq_est.cc deleted file mode 100644 index b45f0f1..0000000 --- a/lib/ofdm_freq_est.cc +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2013 Bastian Bloessl - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#include -#include "utils.h" -#include - -using namespace gr::ieee802_11; - - -class ofdm_freq_est_impl : public ofdm_freq_est { - -public: -ofdm_freq_est_impl(bool log, bool debug) : block("ofdm_freq_est", - gr::io_signature::make2(2, 2, sizeof(gr_complex), sizeof(gr_complex)), - gr::io_signature::make(1, 1, sizeof(gr_complex))), - d_log(log), - d_debug(debug), - d_state(SYNC) { - - set_tag_propagation_policy(block::TPP_DONT); -} - -int general_work (int noutput, gr_vector_int& ninput_items, - gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items) { - - const gr_complex *in = (const gr_complex*)input_items[0]; - gr_complex *out = (gr_complex*)output_items[0]; - - - return 0; -} - -void forecast (int noutput_items, gr_vector_int &ninput_items_required) { - ninput_items_required[0] = noutput_items; -} - -private: - enum {SYNC, COPY, RESET} d_state; - std::vector d_tags; - - const bool d_log; - const bool d_debug; -}; - -ofdm_freq_est::sptr -ofdm_freq_est::make(bool log, bool debug) { - return gnuradio::get_initial_sptr(new ofdm_freq_est_impl(log, debug)); -} - diff --git a/lib/ofdm_mac.cc b/lib/ofdm_mac.cc index 8ca4cf4..62d057e 100644 --- a/lib/ofdm_mac.cc +++ b/lib/ofdm_mac.cc @@ -65,7 +65,18 @@ ofdm_mac_impl(std::vector src_mac, std::vector dst_mac, std::v } void phy_in (pmt::pmt_t msg) { - message_port_pub(pmt::mp("app out"), msg); + // this must be a pair + if (!pmt::is_blob(pmt::cdr(msg))) + throw std::runtime_error("PMT must be blob"); + + // strip MAC header + // TODO: check for frame type to determine header size + pmt::pmt_t blob(pmt::cdr(msg)); + const char *mpdu = reinterpret_cast(pmt::blob_data(blob)); + std::cout << "pdu len " << pmt::blob_length(blob) << std::endl; + pmt::pmt_t msdu = pmt::make_blob(mpdu + 24, pmt::blob_length(blob) - 24); + + message_port_pub(pmt::mp("app out"), pmt::cons(pmt::car(msg), msdu)); } void app_in (pmt::pmt_t msg) { @@ -99,10 +110,13 @@ void app_in (pmt::pmt_t msg) { return; } + if(msg_len > 1500) { + throw std::invalid_argument("Frame too large (> 1500)"); + } + // make MAC frame int psdu_length; - char *psdu; - generate_mac_data_frame(msdu, msg_len, &psdu, &psdu_length); + generate_mac_data_frame(msdu, msg_len, &psdu_length); dict = pmt::dict_add(dict, pmt::mp("crc_included"), pmt::PMT_T); @@ -120,20 +134,18 @@ void app_in (pmt::pmt_t msg) { // blob - pmt::pmt_t mac = pmt::make_blob(psdu, psdu_length); + pmt::pmt_t mac = pmt::make_blob(d_psdu, psdu_length); // pdu message_port_pub(pmt::mp("phy out"), pmt::cons(dict, mac)); - - free(psdu); } -void generate_mac_data_frame(const char *msdu, int msdu_size, char **psdu, int *psdu_size) { +void generate_mac_data_frame(const char *msdu, int msdu_size, int *psdu_size) { // mac header mac_header header; header.frame_control = 0x0008; - header.duration = 0x002e; + header.duration = 0x0000; for(int i = 0; i < 6; i++) { header.addr1[i] = d_dst_mac[i]; @@ -152,18 +164,17 @@ void generate_mac_data_frame(const char *msdu, int msdu_size, char **psdu, int * //header size is 24, plus 4 for FCS means 28 bytes *psdu_size = 28 + msdu_size; - *psdu = (char *) calloc(*psdu_size, sizeof(char)); //copy mac header into psdu - std::memcpy(*psdu, &header, 24); + std::memcpy(d_psdu, &header, 24); //copy msdu into psdu - memcpy(*psdu + 24, msdu, msdu_size); + memcpy(d_psdu + 24, msdu, msdu_size); //compute and store fcs boost::crc_32_type result; - result.process_bytes(*psdu, msdu_size + 24); + result.process_bytes(d_psdu, msdu_size + 24); - unsigned int fcs = result.checksum(); - memcpy(*psdu + msdu_size + 24, &fcs, sizeof(unsigned int)); + uint32_t fcs = result.checksum(); + memcpy(d_psdu + msdu_size + 24, &fcs, sizeof(uint32_t)); } bool check_mac(std::vector mac) { @@ -176,6 +187,7 @@ private: uint8_t d_src_mac[6]; uint8_t d_dst_mac[6]; uint8_t d_bss_mac[6]; + uint8_t d_psdu[1528]; }; ofdm_mac::sptr diff --git a/lib/ofdm_mapper.cc b/lib/ofdm_mapper.cc index 351cbfc..7b52b31 100644 --- a/lib/ofdm_mapper.cc +++ b/lib/ofdm_mapper.cc @@ -82,8 +82,8 @@ int general_work(int noutput, gr_vector_int& ninput_items, // ############ INSERT MAC STUFF tx_param tx(d_ofdm, psdu_length); - if(tx.n_sym > 120) { - std::cout << "packet too large" < MAX_SYM) { + std::cout << "packet too large, maximum number of symbols is " << MAX_SYM << std::endl; return 0; } diff --git a/lib/ofdm_parse_mac.cc b/lib/ofdm_parse_mac.cc index 98232ca..957faf1 100644 --- a/lib/ofdm_parse_mac.cc +++ b/lib/ofdm_parse_mac.cc @@ -31,11 +31,13 @@ ofdm_parse_mac_impl(bool log, bool debug) : block("ofdm_parse_mac", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), - d_log(log), + d_log(log), d_last_seq_no(-1), d_debug(debug) { - message_port_register_in(pmt::mp("in")); - set_msg_handler(pmt::mp("in"), boost::bind(&ofdm_parse_mac_impl::parse, this, _1)); + message_port_register_in(pmt::mp("in")); + set_msg_handler(pmt::mp("in"), boost::bind(&ofdm_parse_mac_impl::parse, this, _1)); + + message_port_register_out(pmt::mp("fer")); } ~ofdm_parse_mac_impl() { @@ -89,10 +91,6 @@ void parse(pmt::pmt_t msg) { break; } - if(data_len < 32) { - return; - } - char *frame = (char*)pmt::blob_data(msg); // DATA @@ -251,13 +249,29 @@ void parse_data(char *buf, int length) { } dout << std::endl; - dout << "seq nr: " << int(h->seq_nr >> 4) << std::endl; + int seq_no = int(h->seq_nr >> 4); + dout << "seq nr: " << seq_no << std::endl; dout << "mac 1: "; print_mac_address(h->addr1, true); dout << "mac 2: "; print_mac_address(h->addr2, true); dout << "mac 3: "; print_mac_address(h->addr3, true); + + float lost_frames = seq_no - d_last_seq_no - 1; + if(lost_frames < 0) + lost_frames += 1 << 12; + + // calculate frame error rate + float fer = lost_frames / (lost_frames + 1); + dout << "instantaneous fer: " << fer << std::endl; + + // keep track of values + d_last_seq_no = seq_no; + + // publish FER estimate + pmt::pmt_t pdu = pmt::make_f32vector(lost_frames + 1, fer * 100); + message_port_pub(pmt::mp("fer"), pmt::cons( pmt::PMT_NIL, pdu )); } void parse_control(char *buf, int length) { @@ -341,7 +355,7 @@ void print_ascii(char* buf, int length) { private: bool d_log; bool d_debug; - + int d_last_seq_no; }; ofdm_parse_mac::sptr diff --git a/lib/ofdm_sync_long.cc b/lib/ofdm_sync_long.cc index 21b6d79..947ff6d 100644 --- a/lib/ofdm_sync_long.cc +++ b/lib/ofdm_sync_long.cc @@ -27,29 +27,29 @@ using namespace gr::ieee802_11; using namespace std; +bool compare_abs(const std::pair& first, const std::pair& second) { + return abs(get<0>(first)) > abs(get<0>(second)); +} + class ofdm_sync_long_impl : public ofdm_sync_long { public: ofdm_sync_long_impl(unsigned int sync_length, bool log, bool debug) : block("ofdm_sync_long", gr::io_signature::make2(2, 2, sizeof(gr_complex), sizeof(gr_complex)), gr::io_signature::make(1, 1, sizeof(gr_complex))), + d_fir(gr::filter::kernel::fir_filter_ccc(1, LONG)), d_log(log), d_debug(debug), d_offset(0), - d_freq_est(0), d_state(SYNC), SYNC_LENGTH(sync_length) { set_tag_propagation_policy(block::TPP_DONT); - d_fir = new gr::filter::kernel::fir_filter_ccc(1, LONG); d_correlation = gr::fft::malloc_complex(8192); - d_freq_est_buf = static_cast(std::malloc(sync_length * sizeof(gr_complex))); } ~ofdm_sync_long_impl(){ - delete d_fir; gr::fft::free(d_correlation); - free(d_freq_est_buf); } int general_work (int noutput, gr_vector_int& ninput_items, @@ -64,19 +64,21 @@ int general_work (int noutput, gr_vector_int& ninput_items, ninput_items[1] << " noutput " << noutput << " state " << d_state << std::endl; - int ninput = std::min(ninput_items[0], ninput_items[1]); + int ninput = std::min(std::min(ninput_items[0], ninput_items[1]), 8192); const unsigned int nread = nitems_read(0); get_tags_in_range(d_tags, 0, nread, nread + ninput); if (d_tags.size()) { std::sort(d_tags.begin(), d_tags.end(), gr::tag_t::offset_compare); - const gr::tag_t &tag = d_tags.front(); - const uint64_t offset = tag.offset; + const uint64_t offset = d_tags.front().offset; if(offset > nread) { ninput = offset - nread; } else { + if(d_offset && (d_state == SYNC)) { + throw std::runtime_error("wtf"); + } if(d_state == COPY) { d_state = RESET; } @@ -90,26 +92,20 @@ int general_work (int noutput, gr_vector_int& ninput_items, switch(d_state) { case SYNC: - d_fir->filterN(d_correlation, in, std::min(SYNC_LENGTH, std::max(ninput - 63, 0))); + d_fir.filterN(d_correlation, in, std::min(SYNC_LENGTH, std::max(ninput - 63, 0))); while(i + 63 < ninput) { - d_freq_est += in[i] * conj(in[i + 16]); - d_freq_est_buf[d_offset] = d_freq_est; - - d_cor.push_back(pair(abs(d_correlation[i]), d_offset)); + d_cor.push_back(pair(d_correlation[i], d_offset)); i++; d_offset++; if(d_offset == SYNC_LENGTH) { search_frame_start(); - d_freq_est = d_freq_est_buf[std::max(0, d_frame_start - 160 - 17)]; d_offset = 0; d_state = COPY; - mylog(boost::format("frame at %1% - freq_est (20M): %2%") % d_frame_start - % ((arg(d_freq_est) / 16) * 20e6 / (2 * M_PI))); break; } } @@ -117,59 +113,53 @@ int general_work (int noutput, gr_vector_int& ninput_items, break; case COPY: - while(i < ninput) { + while(i < ninput && o < noutput) { int rel = d_offset - d_frame_start; - if( (rel >= 0) && (rel % 80 > 15)) { - if(o >= noutput) { - break; - } + if(!rel) { + add_item_tag(0, nitems_written(0), + pmt::string_to_symbol("ofdm_start"), + pmt::PMT_T, + pmt::string_to_symbol(name())); + } - if(rel == 16) { - assert(o == 0); - add_item_tag(0, nitems_written(0) + o, - pmt::string_to_symbol("ofdm_start"), - pmt::PMT_T, - pmt::string_to_symbol(name())); - } - - out[o] = in_delayed[i] * exp(gr_complex(0, d_offset * arg(d_freq_est) / 16)); + if(rel >= 0 && (rel < 128 || ((rel - 128) % 80) > 15)) { + out[o] = in_delayed[i] * exp(gr_complex(0, d_offset * d_freq_offset)); o++; - } i++; d_offset++; + if(d_offset == 1) { + dout << "produced " << d_count << " " << d_count / 64.0 << std::endl; + d_count = 0; + } } break; - case RESET: + case RESET: { + int h = 0; while(o < noutput) { - int rel = (d_offset - d_frame_start) % 80; - - if(!rel) { + if(((d_count + h) % 64) == 0) { d_offset = 0; - d_freq_est = gr_complex(0, 0); d_state = SYNC; break; - } else if(rel > 15) { + } else { out[o] = 0; o++; } - d_offset++; + h++; } break; - - default: - std::runtime_error("bad state"); - break; + } } dout << "produced : " << o << " consumed: " << i << std::endl; + d_count += o; consume(0, i); consume(1, i); return o; @@ -193,11 +183,10 @@ void search_frame_start() { // sort list (highest correlation first) assert(d_cor.size() == SYNC_LENGTH); - d_cor.sort(); - d_cor.reverse(); + d_cor.sort(compare_abs); // copy list in vector for nicer access - vector > vec(d_cor.begin(), d_cor.end()); + vector > vec(d_cor.begin(), d_cor.end()); d_cor.clear(); // in case we don't find anything use SYNC_LENGTH @@ -205,17 +194,30 @@ void search_frame_start() { for(int i = 0; i < 3; i++) { for(int k = i + 1; k < 4; k++) { - int diff = abs(get<1>(vec[i]) - get<1>(vec[k])); + gr_complex first; + gr_complex second; + if(get<1>(vec[i]) > get<1>(vec[k])) { + first = get<0>(vec[k]); + second = get<0>(vec[i]); + } else { + first = get<0>(vec[i]); + second = get<0>(vec[k]); + } + int diff = abs(get<1>(vec[i]) - get<1>(vec[k])); if(diff == 64) { - d_frame_start = max(get<1>(vec[i]), get<1>(vec[k])) + 64; + d_frame_start = max(get<1>(vec[i]), get<1>(vec[k])) + 64 - 128 - 1; + d_freq_offset = arg(first * conj(second)) / 64; + //std::cout << "frequency offset " << d_freq_offset << std::endl; // nice match found, return immediately return; // TODO: check if these offsets make sense } else if(diff == 63) { - d_frame_start = max(get<1>(vec[i]), get<1>(vec[k])) + 63; + d_frame_start = max(get<1>(vec[i]), get<1>(vec[k])) + 63 - 128 - 1; + d_freq_offset = arg(first * conj(second)) / 64; } else if(diff == 65) { - d_frame_start = max(get<1>(vec[i]), get<1>(vec[k])) + 64; + d_frame_start = max(get<1>(vec[i]), get<1>(vec[k])) + 64 - 128 - 1; + d_freq_offset = arg(first * conj(second)) / 64; } } } @@ -223,14 +225,15 @@ void search_frame_start() { private: enum {SYNC, COPY, RESET} d_state; + int d_count; int d_offset; int d_frame_start; - gr_complex d_freq_est; + float d_freq_offset; + gr_complex *d_correlation; - gr_complex *d_freq_est_buf; - list > d_cor; + list > d_cor; std::vector d_tags; - gr::filter::kernel::fir_filter_ccc *d_fir; + gr::filter::kernel::fir_filter_ccc d_fir; const bool d_log; const bool d_debug; diff --git a/lib/ofdm_sync_short.cc b/lib/ofdm_sync_short.cc index 9b3c147..5c715a3 100644 --- a/lib/ofdm_sync_short.cc +++ b/lib/ofdm_sync_short.cc @@ -22,37 +22,39 @@ using namespace gr::ieee802_11; +static const int MIN_GAP = 480; +static const int MAX_SAMPLES = 540 * 80; + class ofdm_sync_short_impl : public ofdm_sync_short { public: -ofdm_sync_short_impl(double threshold, unsigned int max_samples, - unsigned int min_plateau, bool log, bool debug) : block("ofdm_sync_short", - gr::io_signature::make2(2, 2, sizeof(gr_complex), sizeof(float)), +ofdm_sync_short_impl(double threshold, unsigned int min_plateau, bool log, bool debug) : + block("ofdm_sync_short", + gr::io_signature::make3(3, 3, sizeof(gr_complex), sizeof(gr_complex), sizeof(float)), gr::io_signature::make(1, 1, sizeof(gr_complex))), - d_log(log), - d_debug(debug), - d_state(SEARCH), - d_plateau(0), - MAX_SAMPLES(max_samples), - MIN_PLATEAU(min_plateau), - d_threshold(threshold) { + d_log(log), + d_debug(debug), + d_state(SEARCH), + d_plateau(0), + d_freq_offset(0), + d_copied(0), + MIN_PLATEAU(min_plateau), + d_threshold(threshold) { set_tag_propagation_policy(block::TPP_DONT); } -~ofdm_sync_short_impl(){ -} - int general_work (int noutput_items, gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, gr_vector_void_star& output_items) { const gr_complex *in = (const gr_complex*)input_items[0]; - const float *in2 = (const float*)input_items[1]; + const gr_complex *in_abs = (const gr_complex*)input_items[1]; + const float *in_cor = (const float*)input_items[2]; gr_complex *out = (gr_complex*)output_items[0]; int noutput = noutput_items; - int ninput = std::min(ninput_items[0], ninput_items[1]); + int ninput = std::min(std::min(ninput_items[0], ninput_items[1]), ninput_items[2]); // dout << "SHORT noutput : " << noutput << " ninput: " << ninput_items[0] << std::endl; @@ -62,13 +64,14 @@ int general_work (int noutput_items, gr_vector_int& ninput_items, int i; for(i = 0; i < ninput; i++) { - if(in2[i] > d_threshold) { + if(in_cor[i] > d_threshold) { if(d_plateau < MIN_PLATEAU) { d_plateau++; } else { d_state = COPY; - d_copy_left = MAX_SAMPLES; + d_copied = 0; + d_freq_offset = arg(in_abs[i]) / 16; d_plateau = 0; insert_tag(nitems_written(0)); dout << "SHORT Frame!" << std::endl; @@ -79,27 +82,45 @@ int general_work (int noutput_items, gr_vector_int& ninput_items, } } - consume(0, i); - consume(1, i); + consume_each(i); return 0; } case COPY: { - int to_copy = std::min(d_copy_left, std::min(noutput, ninput)); - std::memcpy(out, in, to_copy * sizeof(gr_complex)); + int o = 0; + while( o < ninput && o < noutput && d_copied < MAX_SAMPLES) { + if(in_cor[o] > d_threshold) { + if(d_plateau < MIN_PLATEAU) { + d_plateau++; - d_copy_left -= to_copy; + // there's another frame + } else if(d_copied > MIN_GAP) { + d_copied = 0; + d_plateau = 0; + d_freq_offset = arg(in_abs[o]) / 16; + insert_tag(nitems_written(0) + o); + dout << "SHORT Frame!" << std::endl; + break; + } - if(!d_copy_left) { + } else { + d_plateau = 0; + } + + out[o] = in[o] * exp(gr_complex(0, -d_freq_offset * d_copied)); + o++; + d_copied++; + } + + if(d_copied == MAX_SAMPLES) { d_state = SEARCH; } - dout << "SHORT copied " << to_copy << std::endl; + dout << "SHORT copied " << o << std::endl; - consume(0, to_copy); - consume(1, to_copy); - return to_copy; + consume_each(o); + return o; } } @@ -118,18 +139,16 @@ void insert_tag(uint64_t item) { private: enum {SEARCH, COPY} d_state; - int d_copy_left; + int d_copied; int d_plateau; + float d_freq_offset; const double d_threshold; const bool d_log; const bool d_debug; - const unsigned int MAX_SAMPLES; const unsigned int MIN_PLATEAU; }; ofdm_sync_short::sptr -ofdm_sync_short::make(double threshold, unsigned int max_samples, - unsigned int min_plateau, bool log, bool debug) { - return gnuradio::get_initial_sptr(new ofdm_sync_short_impl(threshold, - max_samples, min_plateau, log, debug)); +ofdm_sync_short::make(double threshold, unsigned int min_plateau, bool log, bool debug) { + return gnuradio::get_initial_sptr(new ofdm_sync_short_impl(threshold, min_plateau, log, debug)); } diff --git a/lib/utils.h b/lib/utils.h index 69269ae..1e42242 100644 --- a/lib/utils.h +++ b/lib/utils.h @@ -23,6 +23,9 @@ #include #include +const int MAX_SYM = 520; // enough for 1500 byte BPSK 1/2 +const int MAX_BITS = 1550 * 8 * 2; + #define dout d_debug && std::cout #if defined(HAVE_LOG4CPP) && defined(ENABLE_GR_LOG) diff --git a/swig/ieee802_11_swig.i b/swig/ieee802_11_swig.i index 90df87a..e462598 100644 --- a/swig/ieee802_11_swig.i +++ b/swig/ieee802_11_swig.i @@ -31,7 +31,6 @@ #include "ieee802-11/ofdm_decode_mac.h" #include "ieee802-11/ofdm_decode_signal.h" #include "ieee802-11/ofdm_equalize_symbols.h" -#include "ieee802-11/ofdm_freq_est.h" #include "ieee802-11/ofdm_mac.h" #include "ieee802-11/ofdm_mapper.h" #include "ieee802-11/ofdm_parse_mac.h" @@ -51,7 +50,6 @@ %include "ieee802-11/ofdm_decode_mac.h" %include "ieee802-11/ofdm_decode_signal.h" %include "ieee802-11/ofdm_equalize_symbols.h" -%include "ieee802-11/ofdm_freq_est.h" %include "ieee802-11/ofdm_mac.h" %include "ieee802-11/ofdm_mapper.h" %include "ieee802-11/ofdm_parse_mac.h" @@ -68,7 +66,6 @@ GR_SWIG_BLOCK_MAGIC2(ieee802_11, moving_average_ff); GR_SWIG_BLOCK_MAGIC2(ieee802_11, ofdm_decode_mac); GR_SWIG_BLOCK_MAGIC2(ieee802_11, ofdm_decode_signal); GR_SWIG_BLOCK_MAGIC2(ieee802_11, ofdm_equalize_symbols); -GR_SWIG_BLOCK_MAGIC2(ieee802_11, ofdm_freq_est); GR_SWIG_BLOCK_MAGIC2(ieee802_11, ofdm_mac); GR_SWIG_BLOCK_MAGIC2(ieee802_11, ofdm_mapper); GR_SWIG_BLOCK_MAGIC2(ieee802_11, ofdm_parse_mac);