diff --git a/CMakeLists.txt b/CMakeLists.txt index 020ab7e..daa483f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,7 +80,7 @@ set(GRC_BLOCKS_DIR ${GR_PKG_DATA_DIR}/grc/blocks) ######################################################################## # Find gnuradio build dependencies ######################################################################## -set(GR_REQUIRED_COMPONENTS RUNTIME FILTER FFT PMT) +set(GR_REQUIRED_COMPONENTS RUNTIME FILTER FFT PMT DIGITAL) find_package(Gnuradio) find_package(CppUnit) diff --git a/apps/nic.sh b/apps/nic.sh index cc02948..ec6b614 100755 --- a/apps/nic.sh +++ b/apps/nic.sh @@ -1,7 +1,7 @@ #!/bin/bash FILE="/tmp/ofdm.pcap" -FLOWGRAPH="ofdm_transceiver.py" +FLOWGRAPH="wifi_transceiver.py" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" ### create fifo diff --git a/examples/rx_demo.grc b/examples/rx_demo.grc index 345f4e6..50aaaeb 100644 --- a/examples/rx_demo.grc +++ b/examples/rx_demo.grc @@ -1,6 +1,6 @@ - Thu Dec 5 14:05:11 2013 + Sat Feb 1 18:56:56 2014 options @@ -60,29 +60,6 @@ 0 - - variable - - id - sync_length - - - _enabled - True - - - value - 320 - - - _coordinate - (601, 15) - - - _rotation - 0 - - variable @@ -107,50 +84,22 @@ - ieee802_11_ofdm_sync_short + variable id - ieee802_11_ofdm_sync_short_0 + sync_length _enabled True - log - False - - - debug - False - - - threshold - 0.8 - - - max_samples - 80 * 160 - - - min_plateau - 2 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 + value + 320 _coordinate - (212, 501) + (601, 15) _rotation @@ -1966,6 +1915,57 @@ 0 + + ieee802_11_ofdm_sync_short + + id + ieee802_11_ofdm_sync_short_0 + + + _enabled + True + + + log + False + + + debug + False + + + threshold + 0.85 + + + max_samples + 80 * 160 + + + min_plateau + 2 + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (212, 501) + + + _rotation + 0 + + blocks_stream_to_vector_0 fft_vxx_0 diff --git a/examples/ofdm_loopback.grc b/examples/wifi_loopback.grc similarity index 90% rename from examples/ofdm_loopback.grc rename to examples/wifi_loopback.grc index 81257dd..a994e13 100644 --- a/examples/ofdm_loopback.grc +++ b/examples/wifi_loopback.grc @@ -1,11 +1,11 @@ - Thu Dec 5 14:23:25 2013 + Sat Feb 1 18:28:19 2014 options id - ofdm_loopback + wifi_loopback _enabled @@ -134,580 +134,6 @@ 0 - - blocks_ctrlport_monitor_performance - - id - blocks_ctrlport_monitor_performance_0 - - - _enabled - False - - - en - True - - - _coordinate - (1055, 164) - - - _rotation - 0 - - - - blocks_ctrlport_monitor - - id - blocks_ctrlport_monitor_0 - - - _enabled - False - - - en - True - - - _coordinate - (1089, 216) - - - _rotation - 0 - - - - variable_slider - - id - freq_offset - - - _enabled - True - - - label - - - - value - 500 - - - min - -10000 - - - max - 10000 - - - num_steps - 1000 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (947, 7) - - - _rotation - 0 - - - - blocks_add_xx - - id - blocks_add_xx_0 - - - _enabled - True - - - type - complex - - - num_inputs - 2 - - - vlen - 1 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (583, 278) - - - _rotation - 180 - - - - ieee802_11_ofdm_parse_mac - - id - ieee802_11_ofdm_parse_mac_0 - - - _enabled - True - - - log - False - - - debug - True - - - affinity - - - - _coordinate - (113, 249) - - - _rotation - 180 - - - - ofdm_phy_hier - - id - ofdm_phy_hier_1 - - - _enabled - True - - - encoding - encoding - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (359, 261) - - - _rotation - 180 - - - - ieee802_11_ofdm_mac - - id - ieee802_11_ofdm_mac_0 - - - _enabled - True - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (374, 147) - - - _rotation - 0 - - - - blocks_message_strobe - - id - blocks_message_strobe_0 - - - _enabled - True - - - msg - pmt.intern("Hello World") - - - period - 200 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (83, 135) - - - _rotation - 0 - - - - foo_packet_pad - - id - foo_packet_pad_0 - - - _enabled - True - - - debug - False - - - pad_front - 60000 - - - pad_tail - 20000 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (353, 408) - - - _rotation - 0 - - - - blocks_multiply_xx - - id - blocks_multiply_xx_0 - - - _enabled - True - - - type - complex - - - num_inputs - 2 - - - vlen - 1 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (544, 428) - - - _rotation - 0 - - - - analog_sig_source_x - - id - analog_sig_source_x_0 - - - _enabled - True - - - type - complex - - - samp_rate - samp_rate - - - waveform - analog.GR_COS_WAVE - - - freq - freq_offset - - - amp - 1 - - - offset - 0 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (339, 547) - - - _rotation - 0 - - - - variable_slider - - id - signal_power - - - _enabled - True - - - label - - - - value - 0.39 - - - min - 0 - - - max - 3 - - - num_steps - 1000 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (693, 7) - - - _rotation - 0 - - - - blocks_multiply_const_vxx - - id - blocks_multiply_const_vxx_0 - - - _enabled - True - - - type - complex - - - const - signal_power**.5 - - - vlen - 1 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (696, 441) - - - _rotation - 0 - - - - variable_slider - - id - noise_power - - - _enabled - True - - - label - - - - value - 0.01 - - - min - 0.01 - - - max - 5 - - - num_steps - 1000 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (829, 5) - - - _rotation - 0 - - import @@ -774,92 +200,6 @@ 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 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (872, 258) - - - _rotation - 180 - - - - foo_wireshark_connector - - id - foo_wireshark_connector_0 - - - _enabled - False - - - tech - 127 - - - debug - False - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (628, 169) - - - _rotation - 0 - - blocks_file_sink @@ -903,6 +243,628 @@ 0 + + ieee802_11_ofdm_mac + + id + ieee802_11_ofdm_mac_0 + + + _enabled + True + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (374, 147) + + + _rotation + 0 + + + + analog_sig_source_x + + id + analog_sig_source_x_0 + + + _enabled + True + + + type + complex + + + samp_rate + samp_rate + + + waveform + analog.GR_COS_WAVE + + + freq + freq_offset + + + amp + 1 + + + offset + 0 + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (338, 548) + + + _rotation + 0 + + + + foo_wireshark_connector + + id + foo_wireshark_connector_0 + + + _enabled + False + + + tech + 127 + + + debug + False + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (628, 169) + + + _rotation + 0 + + + + ieee802_11_ofdm_parse_mac + + id + ieee802_11_ofdm_parse_mac_0 + + + _enabled + True + + + log + False + + + debug + True + + + affinity + + + + _coordinate + (110, 251) + + + _rotation + 180 + + + + 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 + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (865, 260) + + + _rotation + 180 + + + + blocks_multiply_const_vxx + + id + blocks_multiply_const_vxx_0 + + + _enabled + True + + + type + complex + + + const + signal_power**.5 + + + vlen + 1 + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (696, 452) + + + _rotation + 0 + + + + variable_slider + + id + signal_power + + + _enabled + True + + + label + + + + value + 2.0 + + + min + 0 + + + max + 3 + + + num_steps + 1000 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (693, 7) + + + _rotation + 0 + + + + blocks_message_strobe + + id + blocks_message_strobe_0 + + + _enabled + True + + + msg + pmt.intern("Hello World!") + + + period + 300 + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (92, 135) + + + _rotation + 0 + + + + blocks_add_xx + + id + blocks_add_xx_0 + + + _enabled + True + + + type + complex + + + num_inputs + 2 + + + vlen + 1 + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (581, 279) + + + _rotation + 180 + + + + blocks_multiply_xx + + id + blocks_multiply_xx_0 + + + _enabled + True + + + type + complex + + + num_inputs + 2 + + + vlen + 1 + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (544, 440) + + + _rotation + 0 + + + + variable_slider + + id + freq_offset + + + _enabled + True + + + label + + + + value + 0 + + + min + -10000 + + + max + 10000 + + + num_steps + 1000 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (947, 7) + + + _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 + + + + _coordinate + (814, 8) + + + _rotation + 0 + + + + wifi_phy_hier + + id + wifi_phy_hier_0 + + + _enabled + True + + + encoding + encoding + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (360, 262) + + + _rotation + 180 + + + + foo_packet_pad2 + + id + foo_packet_pad2_0 + + + _enabled + True + + + debug + False + + + delay + False + + + delay_sec + 0.001 + + + pad_front + 10000 + + + pad_tail + 10000 + + + affinity + + + + minoutbuf + 48000 + + + maxoutbuf + 0 + + + _coordinate + (315, 404) + + + _rotation + 0 + + foo_wireshark_connector_0 blocks_file_sink_0 @@ -915,30 +877,12 @@ 0 1 - - foo_packet_pad_0 - blocks_multiply_xx_0 - 0 - 0 - - - ofdm_phy_hier_1 - foo_packet_pad_0 - 0 - 0 - analog_noise_source_x_0 blocks_add_xx_0 0 1 - - blocks_add_xx_0 - ofdm_phy_hier_1 - 0 - 0 - blocks_multiply_xx_0 blocks_multiply_const_vxx_0 @@ -952,7 +896,31 @@ 0 - ofdm_phy_hier_1 + 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 mac_out in @@ -964,21 +932,15 @@ app in - ofdm_phy_hier_1 - ieee802_11_ofdm_mac_0 - mac_out - phy in + foo_packet_pad2_0 + blocks_multiply_xx_0 + 0 + 0 - ieee802_11_ofdm_mac_0 - ofdm_phy_hier_1 - phy out - mac_in - - - ieee802_11_ofdm_mac_0 - foo_wireshark_connector_0 - phy out - in + wifi_phy_hier_0 + foo_packet_pad2_0 + 0 + 0 diff --git a/examples/ofdm_phy_hier.grc b/examples/wifi_phy_hier.grc similarity index 73% rename from examples/ofdm_phy_hier.grc rename to examples/wifi_phy_hier.grc index fe7dad5..637edd2 100644 --- a/examples/ofdm_phy_hier.grc +++ b/examples/wifi_phy_hier.grc @@ -1,11 +1,11 @@ - Wed Nov 27 17:35:35 2013 + Sat Feb 1 19:26:09 2014 options id - ofdm_phy_hier + wifi_phy_hier _enabled @@ -13,7 +13,7 @@ title - OFDM PHY Hier + WiFi PHY Hier author @@ -60,29 +60,6 @@ 0 - - variable - - id - sync_length - - - _enabled - True - - - value - 320 - - - _coordinate - (213, 13) - - - _rotation - 0 - - variable @@ -107,38 +84,22 @@ - pad_source + variable id - pad_source_0 + sync_length _enabled True - label - samp_in - - - type - complex - - - vlen - 1 - - - num_streams - 1 - - - optional - False + value + 320 _coordinate - (48, 386) + (196, 14) _rotation @@ -146,118 +107,28 @@ - blocks_conjugate_cc + variable id - blocks_conjugate_cc_0 + header_formatter _enabled True - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 + value + ieee802_11.wifi_signal_field() _coordinate - (370, 480) + (518, 18) _rotation 0 - - blocks_delay - - id - blocks_delay_0_0 - - - _enabled - True - - - type - complex - - - delay - 16 - - - num_ports - 1 - - - vlen - 1 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (224, 476) - - - _rotation - 0 - - - - ieee802_11_ofdm_equalize_symbols - - id - ieee802_11_ofdm_equalize_symbols_0 - - - _enabled - True - - - debug - False - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (754, 809) - - - _rotation - 180 - - parameter @@ -293,588 +164,6 @@ 0 - - blocks_stream_to_vector - - id - blocks_stream_to_vector_0 - - - _enabled - True - - - type - complex - - - num_items - 64 - - - vlen - 1 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (1013, 661) - - - _rotation - 0 - - - - blocks_delay - - id - blocks_delay_0 - - - _enabled - True - - - type - complex - - - delay - sync_length - - - num_ports - 1 - - - vlen - 1 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (449, 678) - - - _rotation - 0 - - - - blocks_multiply_xx - - id - blocks_multiply_xx_0 - - - _enabled - True - - - type - complex - - - num_inputs - 2 - - - vlen - 1 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (596, 446) - - - _rotation - 0 - - - - blocks_complex_to_mag - - id - blocks_complex_to_mag_0 - - - _enabled - True - - - vlen - 1 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (960, 463) - - - _rotation - 0 - - - - blocks_complex_to_mag_squared - - id - blocks_complex_to_mag_squared_0 - - - _enabled - True - - - vlen - 1 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (586, 390) - - - _rotation - 0 - - - - blocks_divide_xx - - id - blocks_divide_xx_0 - - - _enabled - True - - - type - float - - - vlen - 1 - - - num_inputs - 2 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (1116, 540) - - - _rotation - 270 - - - - digital_ofdm_cyclic_prefixer - - id - digital_ofdm_cyclic_prefixer_0 - - - _enabled - True - - - input_size - 64 - - - cp_len - 16 - - - rolloff - 2 - - - tagname - - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (956, 238) - - - _rotation - 180 - - - - ieee802_11_ofdm_preamble - - id - ieee802_11_ofdm_preamble_0 - - - _enabled - True - - - debug - False - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (491, 254) - - - _rotation - 180 - - - - ieee802_11_ofdm_pilot - - id - ieee802_11_ofdm_pilot_0 - - - _enabled - True - - - debug - False - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (630, 116) - - - _rotation - 0 - - - - fft_vxx - - id - fft_vxx_0 - - - _enabled - True - - - type - complex - - - fft_size - 64 - - - forward - False - - - window - window.rectangular(64) - - - shift - True - - - nthreads - 1 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (850, 84) - - - _rotation - 0 - - - - blocks_multiply_const_vxx - - id - blocks_multiply_const_vxx_0 - - - _enabled - True - - - type - complex - - - const - 1/52**0.5 - - - vlen - 1 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (741, 254) - - - _rotation - 180 - - - - ieee802_11_moving_average_xx - - id - ieee802_11_moving_average_xx_1 - - - _enabled - True - - - type - complex - - - length - window_size - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (759, 459) - - - _rotation - 0 - - - - ieee802_11_moving_average_xx - - id - ieee802_11_moving_average_xx_0 - - - _enabled - True - - - type - float - - - length - window_size - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (867, 386) - - - _rotation - 0 - - - - ieee802_11_ofdm_sync_long - - id - sync_long - - - _enabled - True - - - log - False - - - debug - False - - - sync_length - sync_length - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (669, 645) - - - _rotation - 0 - - ieee802_11_ofdm_sync_short @@ -919,7 +208,124 @@ _coordinate - (169, 612) + (178, 775) + + + _rotation + 0 + + + + ieee802_11_moving_average_xx + + id + ieee802_11_moving_average_xx_0 + + + _enabled + True + + + type + float + + + length + window_size + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (876, 549) + + + _rotation + 0 + + + + blocks_divide_xx + + id + blocks_divide_xx_0 + + + _enabled + True + + + type + float + + + vlen + 1 + + + num_inputs + 2 + + + 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 + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (595, 553) _rotation @@ -974,85 +380,7 @@ _coordinate - (1000, 777) - - - _rotation - 180 - - - - ieee802_11_ofdm_decode_signal - - id - ieee802_11_ofdm_decode_signal_0 - - - _enabled - True - - - log - False - - - debug - False - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (511, 801) - - - _rotation - 180 - - - - pad_sink - - id - pad_sink_0 - - - _enabled - True - - - label - samp_out - - - type - complex - - - vlen - 1 - - - num_streams - 1 - - - optional - False - - - _coordinate - (175, 254) + (1009, 908) _rotation @@ -1091,7 +419,38 @@ _coordinate - (131, 116) + (390, 130) + + + _rotation + 180 + + + + blocks_conjugate_cc + + id + blocks_conjugate_cc_0 + + + _enabled + True + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (379, 642) _rotation @@ -1099,18 +458,194 @@ - ieee802_11_ofdm_mapper + blocks_delay id - ieee802_11_ofdm_mapper_0 + blocks_delay_0_0 _enabled True - encoding - encoding + type + complex + + + delay + 16 + + + num_ports + 1 + + + vlen + 1 + + + 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 + + + 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 + + + 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 + + + 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 @@ -1130,12 +665,51 @@ _coordinate - (382, 108) + (762, 940) _rotation + 180 + + + + ieee802_11_ofdm_decode_signal + + id + ieee802_11_ofdm_decode_signal_0 + + + _enabled + True + + + log + False + + + debug + False + + + affinity + + + + minoutbuf 0 + + maxoutbuf + 0 + + + _coordinate + (525, 932) + + + _rotation + 180 + ieee802_11_ofdm_decode_mac @@ -1169,7 +743,7 @@ _coordinate - (260, 801) + (283, 932) _rotation @@ -1208,7 +782,570 @@ _coordinate - (65, 809) + (69, 940) + + + _rotation + 180 + + + + blocks_multiply_xx + + id + blocks_multiply_xx_0 + + + _enabled + True + + + type + complex + + + num_inputs + 2 + + + vlen + 1 + + + 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 + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (764, 621) + + + _rotation + 0 + + + + blocks_complex_to_mag + + id + blocks_complex_to_mag_0 + + + _enabled + True + + + vlen + 1 + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (973, 625) + + + _rotation + 0 + + + + ieee802_11_ofdm_mapper + + id + ieee802_11_ofdm_mapper_0 + + + _enabled + True + + + encoding + encoding + + + debug + False + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (135, 123) + + + _rotation + 180 + + + + digital_packet_headergenerator_bb + + id + digital_packet_headergenerator_bb_0 + + + _enabled + True + + + header_formatter + header_formatter.formatter() + + + len_tag_key + "packet_len" + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (222, 230) + + + _rotation + 0 + + + + digital_chunks_to_symbols_xx + + id + digital_chunks_to_symbols_xx_0 + + + _enabled + True + + + in_type + byte + + + out_type + complex + + + symbol_table + [-1, 1] + + + dimension + 1 + + + num_ports + 1 + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (494, 230) + + + _rotation + 0 + + + + ieee802_11_chunks_to_symbols_xx + + id + ieee802_11_chunks_to_symbols_xx_0 + + + _enabled + True + + + 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 + "packet_len" + + + vlen + 1 + + + tag_preserve_head_pos + 1 + + + affinity + + + + minoutbuf + 48000 + + + maxoutbuf + 0 + + + _coordinate + (744, 269) + + + _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 + + id + digital_ofdm_carrier_allocator_cvc_0_0_0 + + + _enabled + True + + + fft_len + 64 + + + occupied_carriers + (range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27),) + + + pilot_carriers + ((-21, -7, 7, 21), ) + + + pilot_symbols + ((1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1)) + + + sync_words + ((0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), (0, 0j, 0, 0j, 0, 0j, -1, 1j, -1, 1j, -1, 1j, -1, -1j, 1, 1j, 1, -1j, -1, 1j, 1, 1j, 1, 1j, 1, 1j, -1, (-0-1j), 1, -1j, -1, 1j, 0, -1j, 1, (-0-1j), 1, -1j, 1, 1j, -1, -1j, 1, (-0-1j), -1, 1j, 1, 1j, 1, 1j, 1, 1j, -1, -1j, 1, 1j, 1, -1j, -1, 0j, 0, 0j, 0, 0j), (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)) + + + len_tag_key + "packet_len" + + + affinity + + + + minoutbuf + 10000 + + + maxoutbuf + 0 + + + _coordinate + (1005, 242) + + + _rotation + 0 + + + + digital_ofdm_cyclic_prefixer + + id + digital_ofdm_cyclic_prefixer_0_0 + + + _enabled + True + + + input_size + 64 + + + cp_len + 16 + + + rolloff + 2 + + + tagname + "packet_len" + + + affinity + + + + minoutbuf + 100000 + + + maxoutbuf + 0 + + + _coordinate + (703, 411) + + + _rotation + 180 + + + + fft_vxx + + id + fft_vxx_0_0 + + + _enabled + True + + + type + complex + + + fft_size + 64 + + + forward + False + + + window + tuple([1/52**.5] * 64) + + + shift + True + + + nthreads + 1 + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (1003, 395) _rotation @@ -1216,116 +1353,50 @@ - fft_vxx_0 - digital_ofdm_cyclic_prefixer_0 + pad_source_1 + ieee802_11_ofdm_mapper_0 + 0 + in + + + digital_chunks_to_symbols_xx_0 + blocks_tagged_stream_mux_0 0 0 - blocks_complex_to_mag_0 + ieee802_11_ofdm_decode_mac_0 + pad_sink_1 + out + 0 + + + ieee802_11_moving_average_xx_0 blocks_divide_xx_0 0 - 0 - - - blocks_conjugate_cc_0 - blocks_multiply_xx_0 - 0 1 - blocks_delay_0_0 - blocks_conjugate_cc_0 + ieee802_11_moving_average_xx_1 + blocks_complex_to_mag_0 0 0 - pad_source_0 - blocks_delay_0_0 + blocks_multiply_xx_0 + ieee802_11_moving_average_xx_1 0 0 - pad_source_0 - blocks_complex_to_mag_squared_0 - 0 - 0 - - - pad_source_0 - blocks_multiply_xx_0 - 0 - 0 - - - blocks_stream_to_vector_0 - fft_vxx_0_1 - 0 - 0 - - - digital_ofdm_cyclic_prefixer_0 - blocks_multiply_const_vxx_0 - 0 - 0 - - - blocks_delay_0_0 + blocks_divide_xx_0 sync_short 0 - 0 - - - sync_long - blocks_stream_to_vector_0 - 0 - 0 - - - ieee802_11_ofdm_decode_signal_0 - ieee802_11_ofdm_decode_mac_0 - 0 - 0 - - - ieee802_11_ofdm_equalize_symbols_0 - ieee802_11_ofdm_decode_signal_0 - 0 - 0 - - - fft_vxx_0_1 - ieee802_11_ofdm_equalize_symbols_0 - 0 - 0 - - - blocks_multiply_const_vxx_0 - ieee802_11_ofdm_preamble_0 - 0 - 0 - - - ieee802_11_ofdm_mapper_0 - ieee802_11_ofdm_pilot_0 - 0 - 0 - - - ieee802_11_ofdm_pilot_0 - fft_vxx_0 - 0 - 0 - - - ieee802_11_ofdm_preamble_0 - pad_sink_0 - 0 - 0 + 1 sync_short - blocks_delay_0 + sync_long 0 0 @@ -1337,25 +1408,103 @@ sync_short - sync_long + blocks_delay_0 0 0 - blocks_divide_xx_0 + fft_vxx_0_1 + ieee802_11_ofdm_equalize_symbols_0 + 0 + 0 + + + ieee802_11_ofdm_equalize_symbols_0 + ieee802_11_ofdm_decode_signal_0 + 0 + 0 + + + ieee802_11_ofdm_decode_signal_0 + ieee802_11_ofdm_decode_mac_0 + 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 + + + pad_source_0 + blocks_multiply_xx_0 + 0 + 0 + + + pad_source_0 + blocks_complex_to_mag_squared_0 + 0 + 0 + + + pad_source_0 + blocks_delay_0_0 + 0 + 0 + + + blocks_delay_0_0 + blocks_conjugate_cc_0 + 0 + 0 + + + blocks_conjugate_cc_0 + blocks_multiply_xx_0 + 0 1 - blocks_multiply_xx_0 - ieee802_11_moving_average_xx_1 + blocks_complex_to_mag_0 + blocks_divide_xx_0 0 0 - ieee802_11_moving_average_xx_1 - blocks_complex_to_mag_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 @@ -1366,21 +1515,27 @@ 0 - ieee802_11_moving_average_xx_0 - blocks_divide_xx_0 + fft_vxx_0_0 + digital_ofdm_cyclic_prefixer_0_0 0 - 1 + 0 - pad_source_1 - ieee802_11_ofdm_mapper_0 + blocks_tagged_stream_mux_0 + digital_ofdm_carrier_allocator_cvc_0_0_0 0 - in + 0 - ieee802_11_ofdm_decode_mac_0 - pad_sink_1 - out + digital_ofdm_carrier_allocator_cvc_0_0_0 + fft_vxx_0_0 + 0 + 0 + + + digital_ofdm_cyclic_prefixer_0_0 + pad_sink_0 + 0 0 diff --git a/examples/ofdm_rx.grc b/examples/wifi_rx.grc similarity index 97% rename from examples/ofdm_rx.grc rename to examples/wifi_rx.grc index 9c94790..bfb105c 100644 --- a/examples/ofdm_rx.grc +++ b/examples/wifi_rx.grc @@ -1,11 +1,11 @@ - Thu Dec 5 14:06:08 2013 + Mon Dec 30 11:05:22 2013 options id - ofdm_rx + wifi_rx _enabled @@ -618,52 +618,6 @@ 0 - - blocks_ctrlport_monitor - - id - blocks_ctrlport_monitor_0 - - - _enabled - False - - - en - True - - - _coordinate - (828, 166) - - - _rotation - 0 - - - - blocks_ctrlport_monitor_performance - - id - blocks_ctrlport_monitor_performance_0 - - - _enabled - False - - - en - True - - - _coordinate - (972, 169) - - - _rotation - 0 - - blocks_delay diff --git a/examples/ofdm_transceiver.grc b/examples/wifi_transceiver.grc similarity index 95% rename from examples/ofdm_transceiver.grc rename to examples/wifi_transceiver.grc index bee6a69..e6ae492 100644 --- a/examples/ofdm_transceiver.grc +++ b/examples/wifi_transceiver.grc @@ -1,51 +1,59 @@ - Fri Dec 6 17:59:08 2013 + Sat Feb 1 19:26:54 2014 - variable_chooser + options id - encoding + wifi_transceiver _enabled True - label - Encoding - - - value - 0 - - - choices - [0,1,2,3,4,5,6,7] - - - labels - ["BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"] - - - type - radio_buttons - - - style - wx.RA_HORIZONTAL - - - grid_pos + title - notebook + author + + + + description + + + + window_size + 1280, 1024 + + + generate_options + wx_gui + + + category + Custom + + + run_options + prompt + + + run + True + + + max_nouts + 0 + + + realtime_scheduling _coordinate - (1111, 6) + (12, 33) _rotation @@ -103,162 +111,6 @@ 0 - - blocks_ctrlport_monitor_performance - - id - blocks_ctrlport_monitor_performance_0 - - - _enabled - False - - - en - True - - - _coordinate - (611, 163) - - - _rotation - 0 - - - - blocks_ctrlport_monitor - - id - blocks_ctrlport_monitor_0 - - - _enabled - False - - - en - True - - - _coordinate - (807, 164) - - - _rotation - 0 - - - - variable_slider - - id - tx_gain - - - _enabled - True - - - label - - - - value - 15 - - - min - 0 - - - max - 100 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (1050, 134) - - - _rotation - 0 - - - - variable_slider - - id - rx_gain - - - _enabled - True - - - label - - - - value - 5 - - - min - 0 - - - max - 100 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (1162, 133) - - - _rotation - 0 - - variable_chooser @@ -435,107 +287,6 @@ 0 - - ieee802_11_ofdm_parse_mac - - id - ieee802_11_ofdm_parse_mac_0 - - - _enabled - True - - - log - False - - - debug - True - - - affinity - - - - _coordinate - (94, 308) - - - _rotation - 180 - - - - ieee802_11_ofdm_mac - - id - ieee802_11_ofdm_mac_0 - - - _enabled - True - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (339, 257) - - - _rotation - 0 - - - - foo_wireshark_connector - - id - foo_wireshark_connector_0 - - - _enabled - True - - - tech - 127 - - - debug - False - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (580, 308) - - - _rotation - 0 - - blocks_file_sink @@ -580,19 +331,15 @@ - ofdm_phy_hier + ieee802_11_ofdm_mac id - ofdm_phy_hier_1 + ieee802_11_ofdm_mac_0 _enabled True - - encoding - encoding - affinity @@ -607,55 +354,12 @@ _coordinate - (324, 355) + (339, 257) _rotation - 180 - - - - blocks_multiply_const_vxx - - id - blocks_multiply_const_vxx_0 - - - _enabled - True - - - type - complex - - - const - mult - - - vlen - 1 - - - affinity - - - - minoutbuf 0 - - maxoutbuf - 0 - - - _coordinate - (104, 385) - - - _rotation - 180 - variable_slider @@ -705,7 +409,7 @@ _coordinate - (1140, 247) + (963, 247) _rotation @@ -713,670 +417,234 @@ - uhd_usrp_sink + variable_slider id - uhd_usrp_sink_0 + tx_gain _enabled True + + label + + + + value + 15 + + + min + 0 + + + max + 100 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (642, 132) + + + _rotation + 0 + + + + variable_slider + + id + rx_gain + + + _enabled + True + + + label + + + + value + 5 + + + min + 0 + + + max + 100 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (759, 132) + + + _rotation + 0 + + + + variable_chooser + + id + encoding + + + _enabled + True + + + label + Encoding + + + value + 0 + + + choices + [0,1,2,3,4,5,6,7] + + + labels + ["BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"] + type - fc32 + radio_buttons - otw + style + wx.RA_HORIZONTAL + + + grid_pos - stream_args + notebook - stream_chans - [] + _coordinate + (929, 123) - dev_addr - - - - 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 - tx_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 + _rotation 0 + + + wifi_phy_hier - 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 + id + wifi_phy_hier_0 - ant31 - + _enabled + True - bw31 + encoding 0 affinity + + minoutbuf + 0 + + + maxoutbuf + 0 + _coordinate - (256, 487) + (334, 360) + + + _rotation + 180 + + + + foo_wireshark_connector + + id + foo_wireshark_connector_0 + + + _enabled + True + + + tech + 127 + + + debug + False + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (580, 308) _rotation @@ -2063,10 +1331,712 @@ - foo_packet_pad + ieee802_11_ofdm_parse_mac id - foo_packet_pad_0 + ieee802_11_ofdm_parse_mac_0 + + + _enabled + True + + + log + False + + + debug + True + + + affinity + + + + _coordinate + (93, 296) + + + _rotation + 180 + + + + uhd_usrp_sink + + id + uhd_usrp_sink_0 + + + _enabled + True + + + type + fc32 + + + otw + + + + stream_args + + + + stream_chans + [] + + + dev_addr + + + + 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 + tx_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 + + + affinity + + + + _coordinate + (256, 487) + + + _rotation + 0 + + + + foo_packet_pad2 + + id + foo_packet_pad2_0 _enabled @@ -2078,7 +2048,7 @@ delay - True + False delay_sec @@ -2086,7 +2056,7 @@ pad_front - 0 + 10000 pad_tail @@ -2098,7 +2068,7 @@ minoutbuf - 0 + 100000 maxoutbuf @@ -2106,7 +2076,7 @@ _coordinate - (73, 479) + (78, 479) _rotation @@ -2114,62 +2084,46 @@ - options + blocks_multiply_const_vxx id - ofdm_transceiver + blocks_multiply_const_vxx_0 _enabled True - title + type + complex + + + const + mult + + + vlen + 1 + + + affinity - author - + minoutbuf + 100000 - description - - - - window_size - 1280, 1024 - - - generate_options - wx_gui - - - category - Custom - - - run_options - prompt - - - run - True - - - max_nouts + maxoutbuf 0 - - realtime_scheduling - - _coordinate - (12, 33) + (108, 389) _rotation - 0 + 180 @@ -2178,30 +2132,6 @@ 0 0 - - foo_packet_pad_0 - uhd_usrp_sink_0 - 0 - 0 - - - uhd_usrp_source_0 - ofdm_phy_hier_1 - 0 - 0 - - - ieee802_11_ofdm_mac_0 - ofdm_phy_hier_1 - phy out - mac_in - - - ofdm_phy_hier_1 - ieee802_11_ofdm_mac_0 - mac_out - phy in - ieee802_11_ether_encap_0 blocks_tuntap_pdu_0 @@ -2226,12 +2156,6 @@ to wifi app in - - ofdm_phy_hier_1 - ieee802_11_ofdm_parse_mac_0 - mac_out - in - ieee802_11_ofdm_mac_0 foo_wireshark_connector_0 @@ -2239,20 +2163,50 @@ in - ofdm_phy_hier_1 - foo_wireshark_connector_0 - mac_out - in - - - ofdm_phy_hier_1 + wifi_phy_hier_0 blocks_multiply_const_vxx_0 0 0 + + wifi_phy_hier_0 + ieee802_11_ofdm_parse_mac_0 + mac_out + in + + + 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 + + + uhd_usrp_source_0 + wifi_phy_hier_0 + 0 + 0 + + + wifi_phy_hier_0 + foo_wireshark_connector_0 + mac_out + in + + + foo_packet_pad2_0 + uhd_usrp_sink_0 + 0 + 0 + blocks_multiply_const_vxx_0 - foo_packet_pad_0 + foo_packet_pad2_0 0 0 diff --git a/examples/ofdm_tx.grc b/examples/wifi_tx.grc similarity index 93% rename from examples/ofdm_tx.grc rename to examples/wifi_tx.grc index 38251d4..9fef251 100644 --- a/examples/ofdm_tx.grc +++ b/examples/wifi_tx.grc @@ -1,11 +1,11 @@ - Fri Dec 6 18:16:38 2013 + Sat Feb 1 19:26:11 2014 options id - ofdm_tx + wifi_tx _enabled @@ -115,263 +115,6 @@ 0 - - blocks_ctrlport_monitor_performance - - id - blocks_ctrlport_monitor_performance_0 - - - _enabled - False - - - en - True - - - _coordinate - (982, 299) - - - _rotation - 0 - - - - blocks_null_source - - id - blocks_null_source_0 - - - _enabled - True - - - type - complex - - - vlen - 1 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (692, 334) - - - _rotation - 180 - - - - 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 - - - - _coordinate - (697, 165) - - - _rotation - 0 - - - - variable_slider - - id - mult - - - _enabled - True - - - label - - - - value - 0.35 - - - min - 0 - - - max - 2 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - - - - notebook - - - - _coordinate - (979, 10) - - - _rotation - 0 - - - - blocks_ctrlport_monitor - - id - blocks_ctrlport_monitor_0 - - - _enabled - False - - - en - True - - - _coordinate - (980, 366) - - - _rotation - 0 - - - - ofdm_phy_hier - - id - ofdm_phy_hier_0 - - - _enabled - True - - - encoding - encoding - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (449, 300) - - - _rotation - 180 - - - - ieee802_11_ofdm_mac - - id - ieee802_11_ofdm_mac_0 - - - _enabled - True - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (465, 191) - - - _rotation - 0 - - variable_chooser @@ -424,61 +167,10 @@ - variable_chooser + blocks_socket_pdu id - samp_rate - - - _enabled - True - - - label - Sample Rate - - - value - 20e6 - - - choices - [10e6, 20e6] - - - labels - ["10 Mhz", "20 Mhz"] - - - type - radio_buttons - - - style - wx.RA_HORIZONTAL - - - grid_pos - - - - notebook - - - - _coordinate - (629, 14) - - - _rotation - 0 - - - - blocks_multiply_const_vxx - - id - blocks_multiply_const_vxx_1 + blocks_socket_pdu_0 _enabled @@ -486,15 +178,19 @@ type - complex + "UDP_SERVER" - const - mult + host + - vlen - 1 + port + 52001 + + + mtu + 10000 affinity @@ -510,11 +206,50 @@ _coordinate - (162, 330) + (200, 210) _rotation - 180 + 0 + + + + blocks_message_strobe + + id + blocks_message_strobe_0 + + + _enabled + True + + + msg + pmt.intern(" Hello World") + + + period + 300 + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (113, 154) + + + _rotation + 0 @@ -533,7 +268,7 @@ otw - sc16 + stream_args @@ -1181,7 +916,7 @@ _coordinate - (307, 420) + (279, 428) _rotation @@ -1189,22 +924,22 @@ - blocks_message_strobe + blocks_null_source id - blocks_message_strobe_0 + blocks_null_source_0 _enabled True - msg - pmt.intern("Hello World") + type + complex - period - 100 + vlen + 1 affinity @@ -1220,42 +955,34 @@ _coordinate - (113, 179) + (678, 333) _rotation - 0 + 180 - foo_packet_pad + blocks_multiply_const_vxx id - foo_packet_pad_0 + blocks_multiply_const_vxx_0 _enabled True - debug - False + type + complex - delay - True + const + mult - delay_sec - 0.001 - - - pad_front - 0 - - - pad_tail - 0 + vlen + 1 affinity @@ -1271,7 +998,89 @@ _coordinate - (93, 420) + (232, 329) + + + _rotation + 180 + + + + ieee802_11_ofdm_mac + + id + ieee802_11_ofdm_mac_0 + + + _enabled + True + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (465, 191) + + + _rotation + 0 + + + + variable_chooser + + id + lo_offset + + + _enabled + True + + + label + LO Offset + + + value + 6e9 + + + choices + [0, 6e9, 11e9] + + + labels + ['0 MHz', '6 MHz', '11 MHz'] + + + type + drop_down + + + style + wx.RA_HORIZONTAL + + + grid_pos + + + + notebook + + + + _coordinate + (697, 165) _rotation @@ -1294,7 +1103,7 @@ value - 5.22e9 + 5.89e9 choices @@ -1329,30 +1138,198 @@ 0 - - blocks_multiply_const_vxx_1 - foo_packet_pad_0 - 0 - 0 - - - ofdm_phy_hier_0 - blocks_multiply_const_vxx_1 - 0 - 0 - - - foo_packet_pad_0 - uhd_usrp_sink_0 - 0 - 0 - - - blocks_null_source_0 - ofdm_phy_hier_0 - 0 - 0 - + + variable_slider + + id + mult + + + _enabled + True + + + label + + + + value + .38 + + + min + 0 + + + max + 2 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + _coordinate + (979, 10) + + + _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 + + + + _coordinate + (629, 14) + + + _rotation + 0 + + + + wifi_phy_hier + + id + wifi_phy_hier_0 + + + _enabled + True + + + encoding + encoding + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (461, 299) + + + _rotation + 180 + + + + foo_packet_pad2 + + id + foo_packet_pad2_0 + + + _enabled + True + + + debug + False + + + delay + True + + + delay_sec + 0.001 + + + pad_front + 10000 + + + pad_tail + 0 + + + affinity + + + + minoutbuf + 100000 + + + maxoutbuf + 0 + + + _coordinate + (86, 420) + + + _rotation + 0 + + blocks_message_strobe_0 ieee802_11_ofdm_mac_0 @@ -1360,15 +1337,45 @@ app in - ofdm_phy_hier_0 + blocks_socket_pdu_0 + ieee802_11_ofdm_mac_0 + pdus + app in + + + foo_packet_pad2_0 + uhd_usrp_sink_0 + 0 + 0 + + + wifi_phy_hier_0 + blocks_multiply_const_vxx_0 + 0 + 0 + + + blocks_null_source_0 + wifi_phy_hier_0 + 0 + 0 + + + blocks_multiply_const_vxx_0 + foo_packet_pad2_0 + 0 + 0 + + + ieee802_11_ofdm_mac_0 + wifi_phy_hier_0 + phy out + mac_in + + + wifi_phy_hier_0 ieee802_11_ofdm_mac_0 mac_out phy in - - ieee802_11_ofdm_mac_0 - ofdm_phy_hier_0 - phy out - mac_in - diff --git a/grc/ieee802_11_chunks_to_symbols.xml b/grc/ieee802_11_chunks_to_symbols.xml new file mode 100644 index 0000000..2cdd2c5 --- /dev/null +++ b/grc/ieee802_11_chunks_to_symbols.xml @@ -0,0 +1,18 @@ + + + Chunks to Symbols + ieee802_11_chunks_to_symbols_xx + IEEE802.11 + import ieee802_11 + ieee802_11.chunks_to_symbols() + + in + byte + 1 + + + out + complex + 1 + + diff --git a/grc/ieee802_11_ofdm_mapper.xml b/grc/ieee802_11_ofdm_mapper.xml index aaaf570..73399eb 100644 --- a/grc/ieee802_11_ofdm_mapper.xml +++ b/grc/ieee802_11_ofdm_mapper.xml @@ -40,8 +40,7 @@ out - complex - 48 + byte 1 diff --git a/grc/ieee802_11_ofdm_pilot.xml b/grc/ieee802_11_ofdm_pilot.xml deleted file mode 100644 index a87c250..0000000 --- a/grc/ieee802_11_ofdm_pilot.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - OFDM Pilot - ieee802_11_ofdm_pilot - IEEE802.11 - import ieee802_11 - ieee802_11.ofdm_pilot($debug) - - - Debug - debug - False - bool - - - - - - - in - complex - 48 - 1 - - - - out - complex - 64 - 1 - - - diff --git a/include/ieee802-11/CMakeLists.txt b/include/ieee802-11/CMakeLists.txt index 5b0e007..f4492dd 100644 --- a/include/ieee802-11/CMakeLists.txt +++ b/include/ieee802-11/CMakeLists.txt @@ -69,6 +69,7 @@ add_custom_target(ieee802_11_generated_includes DEPENDS list(APPEND include_sources ${generated_includes} api.h + chunks_to_symbols.h ether_encap.h ofdm_decode_mac.h ofdm_decode_signal.h @@ -77,10 +78,10 @@ list(APPEND include_sources ofdm_mac.h ofdm_mapper.h ofdm_parse_mac.h - ofdm_pilot.h ofdm_preamble.h ofdm_sync_long.h ofdm_sync_short.h + wifi_signal_field.h ) install( diff --git a/include/ieee802-11/ofdm_pilot.h b/include/ieee802-11/chunks_to_symbols.h similarity index 66% rename from include/ieee802-11/ofdm_pilot.h rename to include/ieee802-11/chunks_to_symbols.h index fb9f6c7..be6ec86 100644 --- a/include/ieee802-11/ofdm_pilot.h +++ b/include/ieee802-11/chunks_to_symbols.h @@ -14,25 +14,23 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef INCLUDED_IEEE802_11_PILOT_H -#define INCLUDED_IEEE802_11_PILOT_H +#ifndef INCLUDED_IEEE802_11_CHUNKS_TO_SYMBOLS_H +#define INCLUDED_IEEE802_11_CHUNKS_TO_SYMBOLS_H #include -#include +#include namespace gr { namespace ieee802_11 { - -class IEEE802_11_API ofdm_pilot : virtual public sync_block + +class IEEE802_11_API chunks_to_symbols : virtual public tagged_stream_block { public: - - typedef boost::shared_ptr sptr; - static sptr make(bool debug = false); - + typedef boost::shared_ptr sptr; + static sptr make(); }; -} // namespace ieee802_11 -} // namespace gr +} /* namespace ieee802_11 */ +} /* namespace gr */ -#endif /* INCLUDED_IEEE802_11_PILOT_H */ +#endif /* INCLUDED_IEEE802_11_CHUNKS_TO_SYMBOLS_H */ diff --git a/include/ieee802-11/ofdm_preamble.h b/include/ieee802-11/ofdm_preamble.h index e22fcdd..2f7e7d6 100644 --- a/include/ieee802-11/ofdm_preamble.h +++ b/include/ieee802-11/ofdm_preamble.h @@ -18,12 +18,12 @@ #define INCLUDED_IEEE802_11_OFDM_PREAMBLE_H #include -#include +#include namespace gr { namespace ieee802_11 { -class IEEE802_11_API ofdm_preamble : virtual public block +class IEEE802_11_API ofdm_preamble : virtual public tagged_stream_block { public: diff --git a/include/ieee802-11/wifi_signal_field.h b/include/ieee802-11/wifi_signal_field.h new file mode 100644 index 0000000..3ac3da4 --- /dev/null +++ b/include/ieee802-11/wifi_signal_field.h @@ -0,0 +1,41 @@ +/* + * 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 . + */ + +#ifndef INCLUDED_IEEE802_11_WIFI_SIGNAL_FIELD_H +#define INCLUDED_IEEE802_11_WIFI_SIGNAL_FIELD_H + +#include +#include + +namespace gr { +namespace ieee802_11 { + +class IEEE802_11_API wifi_signal_field : virtual public digital::packet_header_default +{ +public: + typedef boost::shared_ptr sptr; + static sptr make(); + +protected: + wifi_signal_field(); +}; + +} // namespace ieee802_11 +} // namespace gr + +#endif /* INCLUDED_IEEE802_11_WIFI_SIGNAL_FIELD_H */ + diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 32e1d56..3e7f61f 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -101,6 +101,7 @@ include_directories( ######################################################################## list(APPEND gr_ieee802_11_sources ${generated_sources} + chunks_to_symbols_impl.cc ether_encap_impl.cc ofdm_decode_mac.cc ofdm_decode_signal.cc @@ -109,11 +110,11 @@ list(APPEND gr_ieee802_11_sources ofdm_mac.cc ofdm_mapper.cc ofdm_parse_mac.cc - ofdm_pilot.cc ofdm_preamble.cc ofdm_sync_long.cc ofdm_sync_short.cc utils.cc + wifi_signal_field_impl.cc ) list(APPEND gr_ieee802_11_libs @@ -122,6 +123,7 @@ list(APPEND gr_ieee802_11_libs ${GNURADIO_FFT_LIBRARIES} ${GNURADIO_PMT_LIBRARIES} ${GNURADIO_FILTER_LIBRARIES} + ${GNURADIO_DIGITAL_LIBRARIES} ) add_library(gnuradio-ieee802_11 SHARED ${gr_ieee802_11_sources}) diff --git a/lib/chunks_to_symbols_impl.cc b/lib/chunks_to_symbols_impl.cc new file mode 100644 index 0000000..8c532e7 --- /dev/null +++ b/lib/chunks_to_symbols_impl.cc @@ -0,0 +1,144 @@ +/* + * 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 "chunks_to_symbols_impl.h" +#include "utils.h" +#include +#include +#include + +using namespace gr::ieee802_11; + +chunks_to_symbols::sptr +chunks_to_symbols::make() +{ + return gnuradio::get_initial_sptr(new chunks_to_symbols_impl()); +} + +chunks_to_symbols_impl::chunks_to_symbols_impl() + : tagged_stream_block("wifi_chunks_to_symbols", + io_signature::make(1, 1, sizeof(char)), + io_signature::make(1, 1, sizeof(gr_complex)), "packet_len") { +} + +chunks_to_symbols_impl::~chunks_to_symbols_impl() { } + + +int +chunks_to_symbols_impl::work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) { + + const unsigned char *in = (unsigned char*)input_items[0]; + gr_complex *out = (gr_complex*)output_items[0]; + + std::vector tags; + get_tags_in_range(tags, 0, nitems_read(0), + nitems_read(0) + ninput_items[0], + pmt::mp("encoding")); + if(tags.size() != 1) { + throw std::runtime_error("no encoding in input stream"); + } + + Encoding encoding = (Encoding)pmt::to_long(tags[0].value); + + const gr_complex *mapping; + + switch (encoding) { + case BPSK_1_2: + case BPSK_3_4: + mapping = BPSK; + break; + + case QPSK_1_2: + case QPSK_3_4: + mapping = QPSK; + break; + + case QAM16_1_2: + case QAM16_3_4: + mapping = QAM16; + break; + + case QAM64_2_3: + case QAM64_3_4: + mapping = QAM64; + break; + + default: + throw std::invalid_argument("wrong encoding"); + break; + } + + for(int i = 0; i < ninput_items[0]; i++) { + out[i] = mapping[in[i]]; + } + + return ninput_items[0]; +} + +const gr_complex chunks_to_symbols_impl::BPSK[2] = { + gr_complex(-1.0, 0.0), gr_complex(1.0, 0.0)}; + +const gr_complex chunks_to_symbols_impl::QPSK[4] = { + gr_complex(-0.7071, -0.7071), gr_complex(-0.7071, 0.7071), + gr_complex(+0.7071, -0.7071), gr_complex(+0.7071, 0.7071)}; + +const gr_complex chunks_to_symbols_impl::QAM16[16] = { + gr_complex(-0.9487, -0.9487), gr_complex(-0.9487, -0.3162), + gr_complex(-0.9487, 0.9487), gr_complex(-0.9487, 0.3162), + gr_complex(-0.3162, -0.9487), gr_complex(-0.3162, -0.3162), + gr_complex(-0.3162, 0.9487), gr_complex(-0.3162, 0.3162), + gr_complex(0.9487, -0.9487), gr_complex(0.9487, -0.3162), + gr_complex(0.9487, 0.9487), gr_complex(0.9487, 0.3162), + gr_complex(0.3162, -0.9487), gr_complex(0.3162, -0.3162), + gr_complex(0.3162, 0.9487), gr_complex(0.3162, 0.3162)}; + +const gr_complex chunks_to_symbols_impl::QAM64[64] = { + gr_complex(-1.0801, -1.0801), gr_complex(-1.0801, -0.7715), + gr_complex(-1.0801, -0.1543), gr_complex(-1.0801, -0.4629), + gr_complex(-1.0801, 1.0801), gr_complex(-1.0801, 0.7715), + gr_complex(-1.0801, 0.1543), gr_complex(-1.0801, 0.4629), + gr_complex(-0.7715, -1.0801), gr_complex(-0.7715, -0.7715), + gr_complex(-0.7715, -0.1543), gr_complex(-0.7715, -0.4629), + gr_complex(-0.7715, 1.0801), gr_complex(-0.7715, 0.7715), + gr_complex(-0.7715, 0.1543), gr_complex(-0.7715, 0.4629), + gr_complex(-0.1543, -1.0801), gr_complex(-0.1543, -0.7715), + gr_complex(-0.1543, -0.1543), gr_complex(-0.1543, -0.4629), + gr_complex(-0.1543, 1.0801), gr_complex(-0.1543, 0.7715), + gr_complex(-0.1543, 0.1543), gr_complex(-0.1543, 0.4629), + gr_complex(-0.4629, -1.0801), gr_complex(-0.4629, -0.7715), + gr_complex(-0.4629, -0.1543), gr_complex(-0.4629, -0.4629), + gr_complex(-0.4629, 1.0801), gr_complex(-0.4629, 0.7715), + gr_complex(-0.4629, 0.1543), gr_complex(-0.4629, 0.4629), + gr_complex(1.0801, -1.0801), gr_complex(1.0801, -0.7715), + gr_complex(1.0801, -0.1543), gr_complex(1.0801, -0.4629), + gr_complex(1.0801, 1.0801), gr_complex(1.0801, 0.7715), + gr_complex(1.0801, 0.1543), gr_complex(1.0801, 0.4629), + gr_complex(0.7715, -1.0801), gr_complex(0.7715, -0.7715), + gr_complex(0.7715, -0.1543), gr_complex(0.7715, -0.4629), + gr_complex(0.7715, 1.0801), gr_complex(0.7715, 0.7715), + gr_complex(0.7715, 0.1543), gr_complex(0.7715, 0.4629), + gr_complex(0.1543, -1.0801), gr_complex(0.1543, -0.7715), + gr_complex(0.1543, -0.1543), gr_complex(0.1543, -0.4629), + gr_complex(0.1543, 1.0801), gr_complex(0.1543, 0.7715), + gr_complex(0.1543, 0.1543), gr_complex(0.1543, 0.4629), + gr_complex(0.4629, -1.0801), gr_complex(0.4629, -0.7715), + gr_complex(0.4629, -0.1543), gr_complex(0.4629, -0.4629), + gr_complex(0.4629, 1.0801), gr_complex(0.4629, 0.7715), + gr_complex(0.4629, 0.1543), gr_complex(0.4629, 0.4629)}; + diff --git a/lib/chunks_to_symbols_impl.h b/lib/chunks_to_symbols_impl.h new file mode 100644 index 0000000..040df2f --- /dev/null +++ b/lib/chunks_to_symbols_impl.h @@ -0,0 +1,46 @@ +/* + * 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 . + */ +#ifndef INCLUDED_IEEE802_11_CHUNKS_TO_SYMBOLS_IMPL_H +#define INCLUDED_IEEE802_11_CHUNKS_TO_SYMBOLS_IMPL_H + +#include + +namespace gr { +namespace ieee802_11 { + +class chunks_to_symbols_impl : public chunks_to_symbols +{ +public: + chunks_to_symbols_impl(); + ~chunks_to_symbols_impl(); + + int work(int noutput_items, + gr_vector_int &ninput_itmes, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + +protected: + static const gr_complex BPSK[2]; + static const gr_complex QPSK[4]; + static const gr_complex QAM16[16]; + static const gr_complex QAM64[64]; +}; + +} /* namespace ieee802_11 */ +} /* namespace gr */ + +#endif /* INCLUDED_IEEE802_11_CHUNKS_TO_SYMBOLS_IMPL_H */ diff --git a/lib/ofdm_mapper.cc b/lib/ofdm_mapper.cc index b9aae2b..62dffe2 100644 --- a/lib/ofdm_mapper.cc +++ b/lib/ofdm_mapper.cc @@ -29,7 +29,7 @@ static const int DATA_CARRIERS = 48; ofdm_mapper_impl(Encoding e, bool debug) : block ("ofdm_mapper", gr::io_signature::make(0, 0, 0), - gr::io_signature::make(1, 1, DATA_CARRIERS * sizeof(gr_complex))), + gr::io_signature::make(1, 1, sizeof(char))), d_symbols_offset(0), d_symbols(NULL), d_debug(debug), @@ -45,6 +45,7 @@ ofdm_mapper_impl(Encoding e, bool debug) : void print_message(const char *msg, size_t len) { + dout << std::hex << "OFDM MAPPER input symbols" << std::endl << "===========================" << std::endl; @@ -55,25 +56,12 @@ void print_message(const char *msg, size_t len) { dout << std::dec << std::endl; } -void map_to_symbols(const char *bits, size_t len) { - - dout << "OFDM MAPPER complex symbols" << std::endl - << "===========================" << std::endl; - - for(int i = 0; i < len; i++) { - - // the signal field is bpsk encoded - d_symbols[i] = (i < 48) ? BPSK[bits[i]] : mapping[bits[i]]; - dout << d_symbols[i] << " "; - } - dout << std::endl; -} int general_work(int noutput, gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, gr_vector_void_star& output_items ) { - gr_complex *out = (gr_complex*)output_items[0]; + unsigned char *out = (unsigned char*)output_items[0]; dout << "OFDM MAPPER called offset: " << d_symbols_offset << " length: " << d_symbols_len << std::endl; @@ -92,11 +80,12 @@ int general_work(int noutput, gr_vector_int& ninput_items, int psdu_length = pmt::blob_length(pmt::cdr(msg)); const char *psdu = static_cast(pmt::blob_data(pmt::cdr(msg))); - // ############ INSERT MAC STUFF tx_param tx(d_ofdm, psdu_length); - //tx.print_out(); - //ofdm.print_out(); + if(tx.n_sym > 120) { + std::cout << "packet too large" <(std::malloc(d_symbols_len * sizeof(gr_complex))); + pmt::pmt_t psdu_bytes = pmt::from_long(psdu_length); + add_item_tag(0, nitems_written(0), pmt::mp("psdu_len"), + psdu_bytes, srcid); - - print_message(static_cast(symbols), d_symbols_len); - map_to_symbols(static_cast(symbols), d_symbols_len); - - - - // add tag to indicate start of odfm frame - const pmt::pmt_t key = pmt::string_to_symbol("ofdm_start"); - const pmt::pmt_t value = pmt::from_uint64((d_symbols_len / DATA_CARRIERS)); - const pmt::pmt_t srcid = pmt::string_to_symbol(this->name()); - add_item_tag(0, this->nitems_written(0), key, value, srcid); + pmt::pmt_t encoding = pmt::from_long(d_ofdm.encoding); + add_item_tag(0, nitems_written(0), pmt::mp("encoding"), + encoding, srcid); free(data_bits); @@ -163,24 +150,15 @@ int general_work(int noutput, gr_vector_int& ninput_items, } } - int i = 0; - while(i < noutput) { + int i = std::min(noutput, d_symbols_len - d_symbols_offset); + std::memcpy(out, d_symbols + d_symbols_offset, i); + d_symbols_offset += i; - memcpy(out, d_symbols + d_symbols_offset, DATA_CARRIERS * sizeof(gr_complex)); - - i++; - d_symbols_offset += DATA_CARRIERS; - out += DATA_CARRIERS; - - if(d_symbols_offset == d_symbols_len) { - d_symbols_offset = 0; - free(d_symbols); - break; - } + if(d_symbols_offset == d_symbols_len) { + d_symbols_offset = 0; + free(d_symbols); } - dout << "OFDM MAPPER: output size: " << noutput << - " produced items: " << i << std::endl; return i; } @@ -190,43 +168,15 @@ void set_encoding(Encoding encoding) { gr::thread::scoped_lock lock(d_mutex); d_ofdm = ofdm_param(encoding); - - switch (encoding) { - case BPSK_1_2: - case BPSK_3_4: - mapping = BPSK; - break; - - case QPSK_1_2: - case QPSK_3_4: - mapping = QPSK; - break; - - case QAM16_1_2: - case QAM16_3_4: - mapping = QAM16; - break; - - case QAM64_2_3: - case QAM64_3_4: - mapping = QAM64; - break; - - default: - throw std::invalid_argument("wrong encoding"); - break; - } } private: bool d_debug; - gr_complex* d_symbols; + char* d_symbols; int d_symbols_offset; int d_symbols_len; ofdm_param d_ofdm; gr::thread::mutex d_mutex; - - const gr_complex *mapping; }; ofdm_mapper::sptr diff --git a/lib/ofdm_pilot.cc b/lib/ofdm_pilot.cc deleted file mode 100644 index 99e47c0..0000000 --- a/lib/ofdm_pilot.cc +++ /dev/null @@ -1,136 +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_pilot_impl : public ofdm_pilot { - -static const int TONES = 48; -static const int FFT_SIZE = 64; - -public: - -ofdm_pilot_impl(bool debug) : - sync_block ("ofdm_pilot", - gr::io_signature::make(1, 1, TONES * sizeof(gr_complex)), - gr::io_signature::make(1, 1, FFT_SIZE * sizeof(gr_complex))), - d_offset(0), - d_debug(debug) { - -} - -~ofdm_pilot_impl() { - -} - -int work (int noutput_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]; - - int i = 0; - int count = 0; - const uint64_t nread = nitems_read(0); - std::vector tags; - - while (count < noutput_items) { - - get_tags_in_range(tags, 0, nread + count, nread + count + 1, pmt::string_to_symbol("ofdm_start")); - - if(tags.size()) { - d_offset = 0; - dout << "OFDM PILOT: start of OFDM frame" << std::endl; - } - - // guard band - memset(out, 0, 6 * sizeof(gr_complex)); - - // subcarriers -26 to -22 - memcpy(out + 6, in, 5 * sizeof(gr_complex)); - - // pilot 1 - out[11] = POLARITY[d_offset]; - - // subcarriers -20 to -8 - memcpy(out + 12, in + 5, 13 * sizeof(gr_complex)); - - // pilot 2 - out[25] = POLARITY[d_offset]; - - // subcarriers -6 to -1 - memcpy(out + 26, in + 18, 6 * sizeof(gr_complex)); - - // DC - out[32] = 0; - - // subcarriers 1 to 6 - memcpy(out + 33, in + 24, 6 * sizeof(gr_complex)); - - // pilot 3 - out[39] = POLARITY[d_offset]; - - // pubcarriers 8 to 20 - memcpy(out + 40, in + 30, 13 * sizeof(gr_complex)); - - // pilot 4 - out[53] = -POLARITY[d_offset]; - - // subcarriers 22 to 26 - memcpy(out + 54, in + 43, 5 * sizeof(gr_complex)); - - // guard band - memset(out + 59, 0, 5 * sizeof(gr_complex)); - - - count++; - out += FFT_SIZE; - in += TONES; - d_offset = (d_offset + 1) % 127; - } - - dout << "OFDM PILOT: produced items: " << noutput_items << std::endl; - - return noutput_items; -} - -private: - bool d_debug; - int d_offset; - static const gr_complex POLARITY[127]; -}; - -const gr_complex ofdm_pilot_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_pilot::sptr -ofdm_pilot::make(bool debug) { - return gnuradio::get_initial_sptr(new ofdm_pilot_impl(debug)); -} - diff --git a/lib/ofdm_preamble.cc b/lib/ofdm_preamble.cc index f9fd4bb..11bde5e 100644 --- a/lib/ofdm_preamble.cc +++ b/lib/ofdm_preamble.cc @@ -24,133 +24,41 @@ using namespace gr::ieee802_11; class ofdm_preamble_impl : public ofdm_preamble { -static const int SYMBOL_LENGTH = 80; - public: -ofdm_preamble_impl(bool debug) : block("ofdm_preamble", +ofdm_preamble_impl(bool debug) : tagged_stream_block("ofdm_preamble", gr::io_signature::make(1, 1, sizeof(gr_complex)), - gr::io_signature::make(1, 1, sizeof(gr_complex))), - d_debug(debug), - d_state(IDLE) { - - set_relative_rate(1); - set_output_multiple(SYMBOL_LENGTH); + gr::io_signature::make(1, 1, sizeof(gr_complex)), + "packet_len"), + d_debug(debug) { set_tag_propagation_policy(block::TPP_DONT); } ~ofdm_preamble_impl(){ } -int general_work (int noutput_items, gr_vector_int& ninput_items, +int calculate_output_stream_length(const gr_vector_int &ninput_items) { + return ninput_items[0] + 320; +} + +int work (int noutput_items, gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, gr_vector_void_star& output_items) { - int ninput = ninput_items[0] / SYMBOL_LENGTH; - //assert(ninput_items[0] % SYMBOL_LENGTH == 0); - int noutput = noutput_items / SYMBOL_LENGTH; - const gr_complex *in = (const gr_complex*)input_items[0]; gr_complex *out = (gr_complex*)output_items[0]; - int written = 0; - int consumed = 0; + std::memcpy(out, PREAMBLE, 320 * sizeof(gr_complex)); + std::memcpy(out + 320, in, ninput_items[0] * sizeof(gr_complex)); - const uint64_t nread = this->nitems_read(0); - std::vector tags; - pmt::pmt_t key = pmt::string_to_symbol("tx_sob"); - pmt::pmt_t srcid = pmt::string_to_symbol(this->name()); - dout << "OFDM PREAMBLE: input size: " << ninput_items[0] << " output size: " - << noutput_items << std::endl; + int produced = ninput_items[0] + 320; + const pmt::pmt_t value = pmt::PMT_T; + const pmt::pmt_t src = pmt::string_to_symbol(alias()); - while(written < noutput) { + add_item_tag(0, nitems_written(0), pmt::mp("tx_sob"), value, src); + add_item_tag(0, nitems_written(0) + produced - 1, pmt::mp("tx_eob"), value, src); - // debug - dout << "OFDM PREAMBLE: iteration - consumed: " << consumed << - " written:" << written << std::endl; - //assert((consumed + 1) * SYMBOL_LENGTH <= ninput_items[0]); - - switch(d_state) { - - case IDLE: - - if(consumed >= ninput) { - goto out; - } - - dout << "OFDM PREAMBLE: start of new frame" << std::endl; - - get_tags_in_range(tags, 0, nread + consumed * SYMBOL_LENGTH, - nread + (consumed + 1) * SYMBOL_LENGTH - 1, - pmt::string_to_symbol("ofdm_start")); - - // looks like we changed to modulation scheme during the frame - if(tags.size() != 1) { - std::cout << "PREAMBLE: frame is longer than expected" << std::endl; - throw std::runtime_error("PREAMBLE: frame is too long"); - break; - } - d_frame_left = pmt::to_uint64(tags[0].value); - d_preamble_left = 4; - d_state = PRE; - - // add tag to indicate start of odfm frame - add_item_tag(0, this->nitems_written(0) + written * SYMBOL_LENGTH, key, pmt::PMT_T, srcid); - - // FALL THROUGH !!!!! - - case PRE: - - dout << "OFDM PREAMBLE: copy preamble" << std::endl; - - memcpy(out, PREAMBLE + (4 - d_preamble_left) * SYMBOL_LENGTH, - SYMBOL_LENGTH * sizeof(gr_complex)); - - out += SYMBOL_LENGTH; - written++; - d_preamble_left--; - - if(!d_preamble_left) { - d_state = FRAME; - } - - break; - - case FRAME: - if(consumed >= ninput) { - goto out; - } - - dout << "OFDM PREAMBLE: copy frame" << std::endl; - - memcpy(out, in, SYMBOL_LENGTH * sizeof(gr_complex)); - - consumed++; - in += SYMBOL_LENGTH; - out += SYMBOL_LENGTH; - written++; - d_frame_left--; - - if(!d_frame_left) { - d_state = IDLE; - insert_eob(nitems_written(0) + written * SYMBOL_LENGTH -1); - goto out; - } - - break; - - default: - assert(false); - break; - } - } - -out: - - dout << "PREAMBLE: consumed " << consumed * SYMBOL_LENGTH; - dout << " written " << written * SYMBOL_LENGTH << std::endl; - consume(0, consumed * SYMBOL_LENGTH); - return written * SYMBOL_LENGTH; + return produced; } void insert_eob(uint64_t item) { @@ -159,27 +67,10 @@ void insert_eob(uint64_t item) { const pmt::pmt_t eob_key = pmt::string_to_symbol("tx_eob"); const pmt::pmt_t value = pmt::PMT_T; const pmt::pmt_t srcid = pmt::string_to_symbol(this->name()); - add_item_tag(0, item, eob_key, value, srcid); -} - -void -forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - if(d_state == PRE) { - ninput_items_required[0] = 0; - } else { - ninput_items_required[0] = noutput_items; - } - - dout << "forecast noutput_items: " << noutput_items << " required: " << ninput_items_required[0] << std::endl; } private: bool d_debug; - size_t d_preamble_left; - size_t d_frame_left; - enum {IDLE, PRE, FRAME} d_state; - static gr_complex PREAMBLE[320]; }; diff --git a/lib/ofdm_sync_long.cc b/lib/ofdm_sync_long.cc index 8dc5e59..21b6d79 100644 --- a/lib/ofdm_sync_long.cc +++ b/lib/ofdm_sync_long.cc @@ -245,25 +245,22 @@ ofdm_sync_long::make(unsigned int sync_length, bool log, bool debug) { } const std::vector ofdm_sync_long_impl::LONG = { -gr_complex( -0.04097-0.9626011), gr_complex( 0.3179976-0.8892635), gr_complex( 0.7746551+0.6623833), -gr_complex( 0.1688942+0.2230874), gr_complex( 0.4785908-0.7016541), gr_complex( -0.9210497-0.441444), -gr_complex( -0.3065277-0.8493673), gr_complex( 0.7803301-0.2071068), gr_complex( 0.4267019+0.0326106), -gr_complex( 0.0079118-0.9200371), gr_complex( -1.094439-0.379038), gr_complex( 0.1958068-0.4682544), -gr_complex( 0.4693501-0.119512), gr_complex( -0.179866+1.285259), gr_complex( 0.9539127-0.0327648), -gr_complex( 0.5-0.5), gr_complex( 0.2953435+0.7867532), gr_complex( -0.4576508+0.3143887), -gr_complex( -1.050101+0.521818), gr_complex( 0.6577466+0.7388524), gr_complex( 0.5564548+0.1129757), -gr_complex( -0.4824808+0.650289), gr_complex( -0.451641-0.1744314), gr_complex( -0.28033-1.207107), -gr_complex( -0.9750961-0.1325297), gr_complex( -1.018595-0.164011), gr_complex( 0.6005896-0.5923234), -gr_complex( -0.0224476+0.4301941), gr_complex( -0.7351004+0.9210297), gr_complex( 0.7337324+0.8469733), -gr_complex( 0.0982767+0.7807964), gr_complex( -1.25+0), gr_complex( 0.0982767-0.7807964), -gr_complex( 0.7337324-0.8469733), gr_complex( -0.7351004-0.9210297), gr_complex( -0.0224476-0.4301941), -gr_complex( 0.6005896+0.5923234), gr_complex( -1.018595+0.164011), gr_complex( -0.9750961+0.1325297), -gr_complex( -0.28033+1.207107), gr_complex( -0.451641+0.1744314), gr_complex( -0.4824808-0.650289), -gr_complex( 0.5564548-0.1129757), gr_complex( 0.6577466-0.7388524), gr_complex( -1.050101-0.521818), -gr_complex( -0.4576508-0.3143887), gr_complex( 0.2953435-0.7867532), gr_complex( 0.5+0.5), -gr_complex( 0.9539127+0.0327648), gr_complex( -0.179866-1.285259), gr_complex( 0.4693501+0.119512), -gr_complex( 0.1958068+0.4682544), gr_complex( -1.094439+0.379038), gr_complex( 0.0079118+0.9200371), -gr_complex( 0.4267019-0.0326106), gr_complex( 0.7803301+0.2071068), gr_complex( -0.3065277+0.8493673), -gr_complex( -0.9210497+0.441444), gr_complex( 0.4785908+0.7016541), gr_complex( 0.1688942-0.2230874), -gr_complex( 0.7746551-0.6623833), gr_complex( 0.3179976+0.8892635), gr_complex( -0.04097+0.9626011), -gr_complex( 1.25+0)}; + +gr_complex( 1.3868, 0.0000), gr_complex(-0.0455, -1.0679), gr_complex( 0.3528, -0.9865), gr_complex( 0.8594, 0.7348), +gr_complex( 0.1874, 0.2475), gr_complex( 0.5309, -0.7784), gr_complex(-1.0218, -0.4897), gr_complex(-0.3401, -0.9423), +gr_complex( 0.8657, -0.2298), gr_complex( 0.4734, 0.0362), gr_complex( 0.0088, -1.0207), gr_complex(-1.2142, -0.4205), +gr_complex( 0.2172, -0.5195), gr_complex( 0.5207, -0.1326), gr_complex(-0.1995, 1.4259), gr_complex( 1.0583, -0.0363), +gr_complex( 0.5547, -0.5547), gr_complex( 0.3277, 0.8728), gr_complex(-0.5077, 0.3488), gr_complex(-1.1650, 0.5789), +gr_complex( 0.7297, 0.8197), gr_complex( 0.6173, 0.1253), gr_complex(-0.5353, 0.7214), gr_complex(-0.5011, -0.1935), +gr_complex(-0.3110, -1.3392), gr_complex(-1.0818, -0.1470), gr_complex(-1.1300, -0.1820), gr_complex( 0.6663, -0.6571), +gr_complex(-0.0249, 0.4773), gr_complex(-0.8155, 1.0218), gr_complex( 0.8140, 0.9396), gr_complex( 0.1090, 0.8662), +gr_complex(-1.3868, 0.0000), gr_complex( 0.1090, -0.8662), gr_complex( 0.8140, -0.9396), gr_complex(-0.8155, -1.0218), +gr_complex(-0.0249, -0.4773), gr_complex( 0.6663, 0.6571), gr_complex(-1.1300, 0.1820), gr_complex(-1.0818, 0.1470), +gr_complex(-0.3110, 1.3392), gr_complex(-0.5011, 0.1935), gr_complex(-0.5353, -0.7214), gr_complex( 0.6173, -0.1253), +gr_complex( 0.7297, -0.8197), gr_complex(-1.1650, -0.5789), gr_complex(-0.5077, -0.3488), gr_complex( 0.3277, -0.8728), +gr_complex( 0.5547, 0.5547), gr_complex( 1.0583, 0.0363), gr_complex(-0.1995, -1.4259), gr_complex( 0.5207, 0.1326), +gr_complex( 0.2172, 0.5195), gr_complex(-1.2142, 0.4205), gr_complex( 0.0088, 1.0207), gr_complex( 0.4734, -0.0362), +gr_complex( 0.8657, 0.2298), gr_complex(-0.3401, 0.9423), gr_complex(-1.0218, 0.4897), gr_complex( 0.5309, 0.7784), +gr_complex( 0.1874, -0.2475), gr_complex( 0.8594, -0.7348), gr_complex( 0.3528, 0.9865), gr_complex(-0.0455, 1.0679) + +}; diff --git a/lib/utils.cc b/lib/utils.cc index 5ae7a87..f476af8 100644 --- a/lib/utils.cc +++ b/lib/utils.cc @@ -21,32 +21,15 @@ #include // constellations for different modulations (normalized to avg power 1) -const std::complex BPSK[2] = { - std::complex(-1.0, 0.0), std::complex(1.0, 0.0)}; - const std::complex BPSK_D[2] = { std::complex(-1.0, 0.0), std::complex(1.0, 0.0)}; -const std::complex QPSK[4] = { - std::complex(-0.7071, -0.7071), std::complex(-0.7071, 0.7071), - std::complex(+0.7071, -0.7071), std::complex(+0.7071, 0.7071)}; - const std::complex QPSK_D[4] = { std::complex(-0.7071, -0.7071), std::complex(-0.7071, 0.7071), std::complex(+0.7071, -0.7071), std::complex(+0.7071, 0.7071)}; -const std::complex QAM16[16] = { - std::complex(-0.9487, -0.9487), std::complex(-0.9487, -0.3162), - std::complex(-0.9487, 0.9487), std::complex(-0.9487, 0.3162), - std::complex(-0.3162, -0.9487), std::complex(-0.3162, -0.3162), - std::complex(-0.3162, 0.9487), std::complex(-0.3162, 0.3162), - std::complex(0.9487, -0.9487), std::complex(0.9487, -0.3162), - std::complex(0.9487, 0.9487), std::complex(0.9487, 0.3162), - std::complex(0.3162, -0.9487), std::complex(0.3162, -0.3162), - std::complex(0.3162, 0.9487), std::complex(0.3162, 0.3162)}; - const std::complex QAM16_D[16] = { std::complex(-0.9487, -0.9487), std::complex(-0.9487, -0.3162), std::complex(-0.9487, 0.9487), std::complex(-0.9487, 0.3162), @@ -58,40 +41,6 @@ const std::complex QAM16_D[16] = { std::complex(0.3162, 0.9487), std::complex(0.3162, 0.3162)}; -const std::complex QAM64[64] = { - std::complex(-1.0801, -1.0801), std::complex(-1.0801, -0.7715), - std::complex(-1.0801, -0.1543), std::complex(-1.0801, -0.4629), - std::complex(-1.0801, 1.0801), std::complex(-1.0801, 0.7715), - std::complex(-1.0801, 0.1543), std::complex(-1.0801, 0.4629), - std::complex(-0.7715, -1.0801), std::complex(-0.7715, -0.7715), - std::complex(-0.7715, -0.1543), std::complex(-0.7715, -0.4629), - std::complex(-0.7715, 1.0801), std::complex(-0.7715, 0.7715), - std::complex(-0.7715, 0.1543), std::complex(-0.7715, 0.4629), - std::complex(-0.1543, -1.0801), std::complex(-0.1543, -0.7715), - std::complex(-0.1543, -0.1543), std::complex(-0.1543, -0.4629), - std::complex(-0.1543, 1.0801), std::complex(-0.1543, 0.7715), - std::complex(-0.1543, 0.1543), std::complex(-0.1543, 0.4629), - std::complex(-0.4629, -1.0801), std::complex(-0.4629, -0.7715), - std::complex(-0.4629, -0.1543), std::complex(-0.4629, -0.4629), - std::complex(-0.4629, 1.0801), std::complex(-0.4629, 0.7715), - std::complex(-0.4629, 0.1543), std::complex(-0.4629, 0.4629), - std::complex(1.0801, -1.0801), std::complex(1.0801, -0.7715), - std::complex(1.0801, -0.1543), std::complex(1.0801, -0.4629), - std::complex(1.0801, 1.0801), std::complex(1.0801, 0.7715), - std::complex(1.0801, 0.1543), std::complex(1.0801, 0.4629), - std::complex(0.7715, -1.0801), std::complex(0.7715, -0.7715), - std::complex(0.7715, -0.1543), std::complex(0.7715, -0.4629), - std::complex(0.7715, 1.0801), std::complex(0.7715, 0.7715), - std::complex(0.7715, 0.1543), std::complex(0.7715, 0.4629), - std::complex(0.1543, -1.0801), std::complex(0.1543, -0.7715), - std::complex(0.1543, -0.1543), std::complex(0.1543, -0.4629), - std::complex(0.1543, 1.0801), std::complex(0.1543, 0.7715), - std::complex(0.1543, 0.1543), std::complex(0.1543, 0.4629), - std::complex(0.4629, -1.0801), std::complex(0.4629, -0.7715), - std::complex(0.4629, -0.1543), std::complex(0.4629, -0.4629), - std::complex(0.4629, 1.0801), std::complex(0.4629, 0.7715), - std::complex(0.4629, 0.1543), std::complex(0.4629, 0.4629)}; - const std::complex QAM64_D[64] = { std::complex(-1.0801, -1.0801), std::complex(-1.0801, -0.7715), std::complex(-1.0801, -0.1543), std::complex(-1.0801, -0.4629), @@ -192,6 +141,7 @@ ofdm_param::ofdm_param(Encoding e) { } } + void ofdm_param::print() { std::cout << "OFDM Parameters:" << std::endl; @@ -202,6 +152,7 @@ ofdm_param::print() { std::cout << "n_dbps :" << n_dbps << std::endl; } + tx_param::tx_param(ofdm_param &ofdm, int psdu_length) { psdu_size = psdu_length; @@ -226,9 +177,6 @@ tx_param::print() { std::cout << "n_pad: " << n_pad << std::endl; } -int get_bit(int b, int i) { - return (b & (1 << i) ? 1 : 0); -} void scramble(const char *in, char *out, tx_param &tx, char initial_state) { @@ -243,10 +191,12 @@ void scramble(const char *in, char *out, tx_param &tx, char initial_state) { } } + void reset_tail_bits(char *scrambled_data, tx_param &tx) { memset(scrambled_data + tx.n_data - tx.n_pad - 6, 0, 6 * sizeof(char)); } + int ones(int n) { int sum = 0; for(int i = 0; i < 8; i++) { @@ -257,6 +207,7 @@ int ones(int n) { return sum; } + void convolutional_encoding(const char *in, char *out, tx_param &tx) { int state = 0; @@ -269,6 +220,7 @@ void convolutional_encoding(const char *in, char *out, tx_param &tx) { } } + void puncturing(const char *in, char *out, tx_param &tx, ofdm_param &ofdm) { int mod; @@ -306,6 +258,7 @@ void puncturing(const char *in, char *out, tx_param &tx, ofdm_param &ofdm) { } } + void interleave(const char *in, char *out, tx_param &tx, ofdm_param &ofdm, bool reverse) { int n_cbps = ofdm.n_cbps; @@ -332,6 +285,7 @@ void interleave(const char *in, char *out, tx_param &tx, ofdm_param &ofdm, bool } } + void interleave(const double *in, double *out, tx_param &tx, ofdm_param &ofdm, bool reverse) { int n_cbps = ofdm.n_cbps; @@ -357,6 +311,8 @@ void interleave(const double *in, double *out, tx_param &tx, ofdm_param &ofdm, b } } } + + void split_symbols(const char *in, char *out, tx_param &tx, ofdm_param &ofdm) { int symbols = tx.n_sym * 48; @@ -372,69 +328,6 @@ void split_symbols(const char *in, char *out, tx_param &tx, ofdm_param &ofdm) { } -void generate_signal_field(char *out, tx_param &tx, ofdm_param &ofdm) { - - //data bits of the signal header - char *signal_header = (char *) malloc(sizeof(char) * 24); - - //signal header after... - //convolutional encoding - char *encoded_signal_header = (char *) malloc(sizeof(char) * 48); - //interleaving - char *interleaved_signal_header = (char *) malloc(sizeof(char) * 48); - - int length = tx.psdu_size; - - // first 4 bits represent the modulation and coding scheme - signal_header[ 0] = get_bit(ofdm.rate_field, 3); - signal_header[ 1] = get_bit(ofdm.rate_field, 2); - signal_header[ 2] = get_bit(ofdm.rate_field, 1); - signal_header[ 3] = get_bit(ofdm.rate_field, 0); - // 5th bit is reserved and must be set to 0 - signal_header[ 4] = 0; - // then 12 bits represent the length - signal_header[ 5] = get_bit(length, 0); - signal_header[ 6] = get_bit(length, 1); - signal_header[ 7] = get_bit(length, 2); - signal_header[ 8] = get_bit(length, 3); - signal_header[ 9] = get_bit(length, 4); - signal_header[10] = get_bit(length, 5); - signal_header[11] = get_bit(length, 6); - signal_header[12] = get_bit(length, 7); - signal_header[13] = get_bit(length, 8); - signal_header[14] = get_bit(length, 9); - signal_header[15] = get_bit(length, 10); - signal_header[16] = get_bit(length, 11); - //18-th bit is the parity bit for the first 17 bits - int sum = 0; - for(int i = 0; i < 17; i++) { - if(signal_header[i]) { - sum++; - } - } - signal_header[17] = sum % 2; - - // last 6 bits must be set to 0 - for (int i = 0; i < 6; i++) { - signal_header[18 + i] = 0; - } - - ofdm_param signal_ofdm(BPSK_1_2); - tx_param signal_tx(signal_ofdm, 3); - signal_tx.n_data = 24; - signal_tx.n_sym = 1; - - // convolutional encoding (scrambling is not needed) - convolutional_encoding(signal_header, encoded_signal_header, signal_tx); - // interleaving - //interleave(encoded_signal_header, interleaved_signal_header, signal_tx, signal_ofdm); - interleave(encoded_signal_header, out, signal_tx, signal_ofdm); - - free(signal_header); - free(encoded_signal_header); - free(interleaved_signal_header); -} - void generate_bits(const char *psdu, char *data_bits, tx_param &tx) { // first 16 bits are zero (SERVICE/DATA field) diff --git a/lib/utils.h b/lib/utils.h index 7f665ca..47ab7ec 100644 --- a/lib/utils.h +++ b/lib/utils.h @@ -31,11 +31,6 @@ #define mylog(msg) do { d_log && std::cout << msg << std::endl; } while(0); #endif -extern const std::complex BPSK[2]; -extern const std::complex QPSK[4]; -extern const std::complex QAM16[16]; -extern const std::complex QAM64[64]; - // same mappings in double (itpp sucks) extern const std::complex BPSK_D[2]; extern const std::complex QPSK_D[4]; @@ -120,8 +115,6 @@ void interleave(const double *input, double *out, tx_param &tx, ofdm_param &ofdm void split_symbols(const char *input, char *out, tx_param &tx, ofdm_param &ofdm); -void generate_signal_field(char *out, tx_param &tx, ofdm_param &ofdm); - void generate_bits(const char *psdu, char *data_bits, tx_param &tx); #endif /* INCLUDED_IEEE802_11_OFDM_UTILS_H */ diff --git a/lib/wifi_signal_field_impl.cc b/lib/wifi_signal_field_impl.cc new file mode 100644 index 0000000..69968f4 --- /dev/null +++ b/lib/wifi_signal_field_impl.cc @@ -0,0 +1,142 @@ +/* + * 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 "wifi_signal_field_impl.h" +#include "utils.h" +#include + +using namespace gr::ieee802_11; + +wifi_signal_field::sptr +wifi_signal_field::make() { + return wifi_signal_field::sptr(new wifi_signal_field_impl()); +} + +wifi_signal_field::wifi_signal_field() : packet_header_default(48, "packet_len") {}; + + +wifi_signal_field_impl::wifi_signal_field_impl() : packet_header_default(48, "packet_len") {} + + +wifi_signal_field_impl::~wifi_signal_field_impl() {} + + +int wifi_signal_field_impl::get_bit(int b, int i) { + return (b & (1 << i) ? 1 : 0); +} + + +void wifi_signal_field_impl::generate_signal_field(char *out, tx_param &tx, ofdm_param &ofdm) { + + //data bits of the signal header + char *signal_header = (char *) malloc(sizeof(char) * 24); + + //signal header after... + //convolutional encoding + char *encoded_signal_header = (char *) malloc(sizeof(char) * 48); + //interleaving + char *interleaved_signal_header = (char *) malloc(sizeof(char) * 48); + + int length = tx.psdu_size; + + // first 4 bits represent the modulation and coding scheme + signal_header[ 0] = get_bit(ofdm.rate_field, 3); + signal_header[ 1] = get_bit(ofdm.rate_field, 2); + signal_header[ 2] = get_bit(ofdm.rate_field, 1); + signal_header[ 3] = get_bit(ofdm.rate_field, 0); + // 5th bit is reserved and must be set to 0 + signal_header[ 4] = 0; + // then 12 bits represent the length + signal_header[ 5] = get_bit(length, 0); + signal_header[ 6] = get_bit(length, 1); + signal_header[ 7] = get_bit(length, 2); + signal_header[ 8] = get_bit(length, 3); + signal_header[ 9] = get_bit(length, 4); + signal_header[10] = get_bit(length, 5); + signal_header[11] = get_bit(length, 6); + signal_header[12] = get_bit(length, 7); + signal_header[13] = get_bit(length, 8); + signal_header[14] = get_bit(length, 9); + signal_header[15] = get_bit(length, 10); + signal_header[16] = get_bit(length, 11); + //18-th bit is the parity bit for the first 17 bits + int sum = 0; + for(int i = 0; i < 17; i++) { + if(signal_header[i]) { + sum++; + } + } + signal_header[17] = sum % 2; + + // last 6 bits must be set to 0 + for (int i = 0; i < 6; i++) { + signal_header[18 + i] = 0; + } + + ofdm_param signal_ofdm(BPSK_1_2); + tx_param signal_tx(signal_ofdm, 3); + signal_tx.n_data = 24; + signal_tx.n_sym = 1; + + // convolutional encoding (scrambling is not needed) + convolutional_encoding(signal_header, encoded_signal_header, signal_tx); + // interleaving + //interleave(encoded_signal_header, interleaved_signal_header, signal_tx, signal_ofdm); + interleave(encoded_signal_header, out, signal_tx, signal_ofdm); + + free(signal_header); + free(encoded_signal_header); + free(interleaved_signal_header); +} + +bool wifi_signal_field_impl::header_formatter(long packet_len, unsigned char *out, const std::vector &tags) +{ + + bool encoding_found = false; + bool len_found = false; + int encoding = 0; + int len = 0; + + // read tags + for(int i = 0; i < tags.size(); i++) { + if(pmt::eq(tags[i].key, pmt::mp("encoding"))) { + encoding_found = true; + encoding = pmt::to_long(tags[i].value); + } else if(pmt::eq(tags[i].key, pmt::mp("psdu_len"))) { + len_found = true; + len = pmt::to_long(tags[i].value); + } + } + + // check if all tags are present + if( (!encoding_found) || (!len_found)) { + return false; + } + + ofdm_param ofdm((Encoding)encoding); + tx_param tx(ofdm, len); + + generate_signal_field((char*)out, tx, ofdm); + return true; +} + +bool wifi_signal_field_impl::header_parser( + const unsigned char *in, std::vector &tags) { + + throw std::runtime_error("not implemented yet"); + return false; +} diff --git a/lib/wifi_signal_field_impl.h b/lib/wifi_signal_field_impl.h new file mode 100644 index 0000000..b89d093 --- /dev/null +++ b/lib/wifi_signal_field_impl.h @@ -0,0 +1,47 @@ +/* + * 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 . + */ + +#ifndef INCLUDED_IEEE802_11_WIFI_SIGNAL_FIELD_IMPL_H +#define INCLUDED_IEEE802_11_WIFI_SIGNAL_FIELD_IMPL_H + +#include +#include "utils.h" + +namespace gr { +namespace ieee802_11 { + +class wifi_signal_field_impl : public wifi_signal_field +{ +public: + wifi_signal_field_impl(); + ~wifi_signal_field_impl(); + + bool header_formatter(long packet_len, unsigned char *out, + const std::vector &tags); + + bool header_parser(const unsigned char *header, + std::vector &tags); +private: + int get_bit(int b, int i); + void generate_signal_field(char *out, tx_param &tx, ofdm_param &ofdm); +}; + +} // namespace ieee802_11 +} // namespace gr + +#endif /* INCLUDED_IEEE802_11_WIFI_SIGNAL_FIELD_IMPL_H */ + diff --git a/swig/ieee802_11_swig.i b/swig/ieee802_11_swig.i index c0c1b9b..4fb6f7e 100644 --- a/swig/ieee802_11_swig.i +++ b/swig/ieee802_11_swig.i @@ -15,12 +15,16 @@ * along with this program. If not, see . */ #define IEEE802_11_API +#define DIGITAL_API %include "gnuradio.i" %include "ieee802_11_swig_doc.i" %{ +#include "gnuradio/digital/packet_header_default.h" + +#include "ieee802-11/chunks_to_symbols.h" #include "ieee802-11/ether_encap.h" #include "ieee802-11/moving_average_cc.h" #include "ieee802-11/moving_average_ff.h" @@ -31,12 +35,15 @@ #include "ieee802-11/ofdm_mac.h" #include "ieee802-11/ofdm_mapper.h" #include "ieee802-11/ofdm_parse_mac.h" -#include "ieee802-11/ofdm_pilot.h" #include "ieee802-11/ofdm_preamble.h" #include "ieee802-11/ofdm_sync_long.h" #include "ieee802-11/ofdm_sync_short.h" +#include "ieee802-11/wifi_signal_field.h" %} +%include "gnuradio/digital/packet_header_default.h" + +%include "ieee802-11/chunks_to_symbols.h" %include "ieee802-11/ether_encap.h" %include "ieee802-11/moving_average_cc.h" %include "ieee802-11/moving_average_ff.h" @@ -47,11 +54,12 @@ %include "ieee802-11/ofdm_mac.h" %include "ieee802-11/ofdm_mapper.h" %include "ieee802-11/ofdm_parse_mac.h" -%include "ieee802-11/ofdm_pilot.h" %include "ieee802-11/ofdm_preamble.h" %include "ieee802-11/ofdm_sync_long.h" %include "ieee802-11/ofdm_sync_short.h" +%include "ieee802-11/wifi_signal_field.h" +GR_SWIG_BLOCK_MAGIC2(ieee802_11, chunks_to_symbols); GR_SWIG_BLOCK_MAGIC2(ieee802_11, ether_encap); GR_SWIG_BLOCK_MAGIC2(ieee802_11, moving_average_cc); GR_SWIG_BLOCK_MAGIC2(ieee802_11, moving_average_ff); @@ -62,8 +70,12 @@ 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); -GR_SWIG_BLOCK_MAGIC2(ieee802_11, ofdm_pilot); GR_SWIG_BLOCK_MAGIC2(ieee802_11, ofdm_preamble); GR_SWIG_BLOCK_MAGIC2(ieee802_11, ofdm_sync_long); GR_SWIG_BLOCK_MAGIC2(ieee802_11, ofdm_sync_short); +%template(wifi_signal_field_sptr) boost::shared_ptr; +%pythoncode %{ +wifi_signal_field_sptr.__repr__ = lambda self: "" +wifi_signal_field = wifi_signal_field .make; +%} diff --git a/utils/create_long.R b/utils/create_long.R new file mode 100644 index 0000000..edaa1dd --- /dev/null +++ b/utils/create_long.R @@ -0,0 +1,26 @@ + +fft.shift <- function(sym) { + + sym <- matrix(sym, ncol=64) + + # the explicit dimensions are required + # if sym contains only one row + m1 <- matrix(sym[,33:64], ncol=32) + m2 <- matrix(sym[, 1:32], ncol=32) + + return(cbind(m1, m2)) +} + +### symbols as defined in the standard +sym <- c(1, 1, -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) +freq <- c(rep(0, 6), sym, rep(0, 5)) + +pre <- fft(fft.shift(freq), inverse=T) / sqrt(52) + + +for(i in seq(1, 64, 4)) { + cat("\t\tgr_complex(", sprintf("% .4f", Re(pre[ i])), ", ", sprintf("% .4f", Im(pre[ i])), "), ", sep="") + cat( "gr_complex(", sprintf("% .4f", Re(pre[i+1])), ", ", sprintf("% .4f", Im(pre[i+1])), "), ", sep="") + cat( "gr_complex(", sprintf("% .4f", Re(pre[i+2])), ", ", sprintf("% .4f", Im(pre[i+2])), "), ", sep="") + cat( "gr_complex(", sprintf("% .4f", Re(pre[i+3])), ", ", sprintf("% .4f", Im(pre[i+3])), "),\n", sep="") +} diff --git a/utils/pilots.py b/utils/pilots.py new file mode 100644 index 0000000..49b19e9 --- /dev/null +++ b/utils/pilots.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python + + +polarity = [ + 1, 1, 1, 1,-1,-1,-1, 1,-1,-1,-1,-1, 1, 1,-1, 1, + -1,-1, 1, 1,-1, 1, 1,-1, 1, 1, 1, 1, 1, 1,-1, 1, + 1, 1,-1, 1, 1,-1,-1, 1, 1, 1,-1, 1,-1,-1,-1, 1, + -1, 1,-1,-1, 1,-1,-1, 1, 1, 1, 1, 1,-1,-1, 1, 1, + -1,-1, 1,-1, 1,-1, 1, 1,-1,-1,-1, 1, 1,-1,-1,-1, + -1, 1,-1,-1, 1,-1, 1, 1, 1, 1,-1, 1,-1, 1,-1, 1, + -1,-1,-1,-1,-1, 1,-1, 1, 1,-1, 1,-1, 1, 1, 1,-1, + -1, 1,-1,-1,-1, 1, 1, 1,-1,-1,-1,-1,-1,-1,-1] + + +print "polarity" +print tuple((x, x, x, -x) for x in polarity) + + +print "pattern" +print tuple((-21, -7, 7, 21) for x in range(127)) diff --git a/utils/power.R b/utils/power.R new file mode 100644 index 0000000..e1682da --- /dev/null +++ b/utils/power.R @@ -0,0 +1,13 @@ +library(TTR) +library(ggplot2) + +### test file +in.file <- file('/tmp/ofdm.bin', 'rb') + +sig <- readBin(in.file, double(), n=10000, size=4, endian='little') + +sig <- sig[seq(1, length(sig), 2)] + 1i * sig[seq(2, length(sig), 2)] + +pow <- abs(sig)^2 + +plot(SMA(pow, 1600), type='l') diff --git a/utils/sync_words.py b/utils/sync_words.py new file mode 100644 index 0000000..7a9412f --- /dev/null +++ b/utils/sync_words.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python + + +short = tuple([(52**.5/24**.5) * x for x in [0, 0, 0, 0, 0, 0, 0, 0, 1+1j, 0, 0, 0, -1-1j, 0, 0, 0, 1+1j, 0, 0, 0, -1-1j, 0, 0, 0, -1-1j, 0, 0, 0, 1+1j, 0, 0, 0, 0, 0, 0, 0, -1-1j, 0, 0, 0, -1-1j, 0, 0, 0, 1+1j, 0, 0, 0, 1+1j, 0, 0, 0, 1+1j, 0, 0, 0, 1+1j, 0, 0, 0, 0, 0, 0, 0]]) + +long_norm = tuple([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]) + + +mul = tuple([1, -1j, -1, 1j] * 16) +long_rot = tuple([x * y for x, y in zip(long_norm, mul)]) + + +sync = tuple([short, short, long_rot, long_norm]) + + +assert(len(short) == 64) +assert(len(long_norm) == 64) +assert(len(long_rot) == 64) +assert(len(sync) == 4) + +print "power short: " + str(sum([abs(x)**2 for x in short])) +print "power long: " + str(sum([abs(x)**2 for x in long_norm])) + +print "sync sequence" +print sync +print "len sync: " + str(len(sync)) + + + + + + +