Added typical signalization channels (CCCH, BCCH, SDCCH) decoder and demapper for BCCH.

The implementation is quite dirty at this moment.
trx_hopping
piotr 2014-07-20 23:48:32 +02:00
parent 9d5d86362e
commit faacc72413
24 changed files with 1959 additions and 303 deletions

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='ASCII'?>
<flow_graph>
<timestamp>Sat Feb 8 13:47:51 2014</timestamp>
<timestamp>Fri Jul 18 10:24:08 2014</timestamp>
<block>
<key>options</key>
<param>
@ -51,6 +51,10 @@
<key>realtime_scheduling</key>
<value></value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>_coordinate</key>
<value>(10, 10)</value>
@ -74,6 +78,10 @@
<key>value</key>
<value>1625000/6*4</value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>_coordinate</key>
<value>(10, 170)</value>
@ -83,6 +91,80 @@
<value>0</value>
</param>
</block>
<block>
<key>blocks_message_debug</key>
<param>
<key>id</key>
<value>blocks_message_debug_0</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>_coordinate</key>
<value>(630, 183)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>gsm_receiver_hier</key>
<param>
<key>id</key>
<value>gsm_receiver_hier_0</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>input_rate</key>
<value>samp_rate</value>
</param>
<param>
<key>osr</key>
<value>4</value>
</param>
<param>
<key>arfcn</key>
<value>0</value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
</param>
<param>
<key>maxoutbuf</key>
<value>0</value>
</param>
<param>
<key>_coordinate</key>
<value>(352, 163)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>blocks_file_source</key>
<param>
@ -110,44 +192,9 @@
<value>1</value>
</param>
<param>
<key>affinity</key>
<key>alias</key>
<value></value>
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
</param>
<param>
<key>maxoutbuf</key>
<value>0</value>
</param>
<param>
<key>_coordinate</key>
<value>(267, 220)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>gsm_receiver_hier</key>
<param>
<key>id</key>
<value>gsm_receiver_hier_0</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>input_rate</key>
<value>samp_rate</value>
</param>
<param>
<key>osr</key>
<value>4</value>
</param>
<param>
<key>affinity</key>
<value></value>
@ -162,30 +209,7 @@
</param>
<param>
<key>_coordinate</key>
<value>(539, 220)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>blocks_message_debug</key>
<param>
<key>id</key>
<value>blocks_message_debug_0</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>_coordinate</key>
<value>(905, 249)</value>
<value>(118, 171)</value>
</param>
<param>
<key>_rotation</key>

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='ASCII'?>
<flow_graph>
<timestamp>Sat Feb 8 22:28:34 2014</timestamp>
<timestamp>Fri Jul 18 11:26:16 2014</timestamp>
<block>
<key>options</key>
<param>
@ -51,6 +51,10 @@
<key>realtime_scheduling</key>
<value></value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>_coordinate</key>
<value>(0, -1)</value>
@ -74,6 +78,10 @@
<key>value</key>
<value>100e6/80</value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>_coordinate</key>
<value>(-1, 160)</value>
@ -109,6 +117,10 @@
<key>short_id</key>
<value></value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>_coordinate</key>
<value>(486, 10)</value>
@ -164,6 +176,10 @@
<key>notebook</key>
<value></value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>_coordinate</key>
<value>(368, -1)</value>
@ -173,6 +189,80 @@
<value>0</value>
</param>
</block>
<block>
<key>gsm_receiver_hier</key>
<param>
<key>id</key>
<value>gsm_receiver_hier_0</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>input_rate</key>
<value>samp_rate</value>
</param>
<param>
<key>osr</key>
<value>4</value>
</param>
<param>
<key>arfcn</key>
<value>0</value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
</param>
<param>
<key>maxoutbuf</key>
<value>0</value>
</param>
<param>
<key>_coordinate</key>
<value>(348, 237)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>gsm_bursts_printer</key>
<param>
<key>id</key>
<value>gsm_bursts_printer_0</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>_coordinate</key>
<value>(587, 257)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>variable_slider</key>
<param>
@ -193,15 +283,15 @@
</param>
<param>
<key>min</key>
<value>800</value>
<value>900</value>
</param>
<param>
<key>max</key>
<value>1900</value>
<value>1000</value>
</param>
<param>
<key>num_steps</key>
<value>1000</value>
<value>500</value>
</param>
<param>
<key>style</key>
@ -219,6 +309,10 @@
<key>notebook</key>
<value></value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>_coordinate</key>
<value>(236, 0)</value>
@ -229,38 +323,98 @@
</param>
</block>
<block>
<key>gsm_receiver_hier</key>
<key>wxgui_fftsink2</key>
<param>
<key>id</key>
<value>gsm_receiver_hier_0</value>
<value>wxgui_fftsink2_0</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>input_rate</key>
<key>type</key>
<value>complex</value>
</param>
<param>
<key>title</key>
<value>FFT Plot</value>
</param>
<param>
<key>samp_rate</key>
<value>samp_rate</value>
</param>
<param>
<key>osr</key>
<value>4</value>
<key>baseband_freq</key>
<value>fc</value>
</param>
<param>
<key>y_per_div</key>
<value>10</value>
</param>
<param>
<key>y_divs</key>
<value>10</value>
</param>
<param>
<key>ref_level</key>
<value>0</value>
</param>
<param>
<key>ref_scale</key>
<value>2.0</value>
</param>
<param>
<key>fft_size</key>
<value>1024</value>
</param>
<param>
<key>fft_rate</key>
<value>15</value>
</param>
<param>
<key>peak_hold</key>
<value>False</value>
</param>
<param>
<key>average</key>
<value>False</value>
</param>
<param>
<key>avg_alpha</key>
<value>0</value>
</param>
<param>
<key>win</key>
<value>None</value>
</param>
<param>
<key>win_size</key>
<value></value>
</param>
<param>
<key>grid_pos</key>
<value></value>
</param>
<param>
<key>notebook</key>
<value></value>
</param>
<param>
<key>freqvar</key>
<value>None</value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
</param>
<param>
<key>maxoutbuf</key>
<value>0</value>
</param>
<param>
<key>_coordinate</key>
<value>(523, 275)</value>
<value>(654, 52)</value>
</param>
<param>
<key>_rotation</key>
@ -295,7 +449,11 @@
</param>
<param>
<key>dev_addr</key>
<value>addr=192.168.11.2</value>
<value></value>
</param>
<param>
<key>dev_args</key>
<value>""</value>
</param>
<param>
<key>sync</key>
@ -311,7 +469,7 @@
</param>
<param>
<key>clock_source0</key>
<value></value>
<value>internal</value>
</param>
<param>
<key>time_source0</key>
@ -925,6 +1083,10 @@
<key>bw31</key>
<value>0</value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
@ -939,36 +1101,19 @@
</param>
<param>
<key>_coordinate</key>
<value>(235, 251)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>gsm_bursts_printer</key>
<param>
<key>id</key>
<value>gsm_bursts_printer_0</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>_coordinate</key>
<value>(776, 287)</value>
<value>(101, 229)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<connection>
<source_block_id>uhd_usrp_source_0</source_block_id>
<sink_block_id>gsm_receiver_hier_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>gsm_receiver_hier_0</source_block_id>
<sink_block_id>gsm_bursts_printer_0</sink_block_id>
@ -977,7 +1122,7 @@
</connection>
<connection>
<source_block_id>uhd_usrp_source_0</source_block_id>
<sink_block_id>gsm_receiver_hier_0</sink_block_id>
<sink_block_id>wxgui_fftsink2_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>

View File

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='ASCII'?>
<flow_graph>
<timestamp>Sun Feb 9 11:14:11 2014</timestamp>
<timestamp>Fri Jul 18 10:24:38 2014</timestamp>
<block>
<key>options</key>
<param>
@ -51,6 +51,10 @@
<key>realtime_scheduling</key>
<value></value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>_coordinate</key>
<value>(0, -1)</value>
@ -60,29 +64,6 @@
<value>0</value>
</param>
</block>
<block>
<key>variable</key>
<param>
<key>id</key>
<value>samp_rate2</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>value</key>
<value>samp_rate/25</value>
</param>
<param>
<key>_coordinate</key>
<value>(-1, 160)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>variable</key>
<param>
@ -97,6 +78,10 @@
<key>value</key>
<value>100e6/10</value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>_coordinate</key>
<value>(2, 223)</value>
@ -106,6 +91,33 @@
<value>0</value>
</param>
</block>
<block>
<key>variable</key>
<param>
<key>id</key>
<value>samp_rate2</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>value</key>
<value>samp_rate/25</value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>_coordinate</key>
<value>(-1, 160)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>parameter</key>
<param>
@ -132,6 +144,10 @@
<key>short_id</key>
<value></value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>_coordinate</key>
<value>(486, 10)</value>
@ -187,6 +203,10 @@
<key>notebook</key>
<value></value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>_coordinate</key>
<value>(368, -1)</value>
@ -196,6 +216,198 @@
<value>0</value>
</param>
</block>
<block>
<key>gsm_bursts_printer</key>
<param>
<key>id</key>
<value>gsm_bursts_printer_0</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>_coordinate</key>
<value>(1019, 136)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>variable_slider</key>
<param>
<key>id</key>
<value>fc</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>label</key>
<value></value>
</param>
<param>
<key>value</key>
<value>957</value>
</param>
<param>
<key>min</key>
<value>800</value>
</param>
<param>
<key>max</key>
<value>1000</value>
</param>
<param>
<key>num_steps</key>
<value>1000</value>
</param>
<param>
<key>style</key>
<value>wx.SL_HORIZONTAL</value>
</param>
<param>
<key>converver</key>
<value>float_converter</value>
</param>
<param>
<key>grid_pos</key>
<value></value>
</param>
<param>
<key>notebook</key>
<value></value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>_coordinate</key>
<value>(236, 0)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>gsm_receiver_hier</key>
<param>
<key>id</key>
<value>gsm_receiver_hier_0_0</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>input_rate</key>
<value>samp_rate2</value>
</param>
<param>
<key>osr</key>
<value>4</value>
</param>
<param>
<key>arfcn</key>
<value>0</value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
</param>
<param>
<key>maxoutbuf</key>
<value>0</value>
</param>
<param>
<key>_coordinate</key>
<value>(755, 130)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>pfb_channelizer_ccf</key>
<param>
<key>id</key>
<value>pfb_channelizer_ccf_0</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>nchans</key>
<value>25</value>
</param>
<param>
<key>taps</key>
<value></value>
</param>
<param>
<key>osr</key>
<value>1</value>
</param>
<param>
<key>atten</key>
<value>100</value>
</param>
<param>
<key>ch_map</key>
<value>[]</value>
</param>
<param>
<key>bus_conns</key>
<value>[[0,],]</value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
</param>
<param>
<key>maxoutbuf</key>
<value>0</value>
</param>
<param>
<key>_coordinate</key>
<value>(384, 217)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>uhd_usrp_source</key>
<param>
@ -224,7 +436,11 @@
</param>
<param>
<key>dev_addr</key>
<value>addr=192.168.11.2</value>
<value></value>
</param>
<param>
<key>dev_args</key>
<value>""</value>
</param>
<param>
<key>sync</key>
@ -855,122 +1071,9 @@
<value>0</value>
</param>
<param>
<key>affinity</key>
<key>alias</key>
<value></value>
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
</param>
<param>
<key>maxoutbuf</key>
<value>0</value>
</param>
<param>
<key>_coordinate</key>
<value>(126, 251)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>gsm_bursts_printer</key>
<param>
<key>id</key>
<value>gsm_bursts_printer_0</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>_coordinate</key>
<value>(1019, 136)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>variable_slider</key>
<param>
<key>id</key>
<value>fc</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>label</key>
<value></value>
</param>
<param>
<key>value</key>
<value>957</value>
</param>
<param>
<key>min</key>
<value>800</value>
</param>
<param>
<key>max</key>
<value>1000</value>
</param>
<param>
<key>num_steps</key>
<value>1000</value>
</param>
<param>
<key>style</key>
<value>wx.SL_HORIZONTAL</value>
</param>
<param>
<key>converver</key>
<value>float_converter</value>
</param>
<param>
<key>grid_pos</key>
<value></value>
</param>
<param>
<key>notebook</key>
<value></value>
</param>
<param>
<key>_coordinate</key>
<value>(236, 0)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>gsm_receiver_hier</key>
<param>
<key>id</key>
<value>gsm_receiver_hier_0_0</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>input_rate</key>
<value>samp_rate2</value>
</param>
<param>
<key>osr</key>
<value>4</value>
</param>
<param>
<key>affinity</key>
<value></value>
@ -985,58 +1088,7 @@
</param>
<param>
<key>_coordinate</key>
<value>(755, 130)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>pfb_channelizer_ccf</key>
<param>
<key>id</key>
<value>pfb_channelizer_ccf_0</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>nchans</key>
<value>25</value>
</param>
<param>
<key>taps</key>
<value></value>
</param>
<param>
<key>osr</key>
<value>1</value>
</param>
<param>
<key>atten</key>
<value>100</value>
</param>
<param>
<key>ch_map</key>
<value>[]</value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
</param>
<param>
<key>maxoutbuf</key>
<value>0</value>
</param>
<param>
<key>_coordinate</key>
<value>(373, 282)</value>
<value>(126, 251)</value>
</param>
<param>
<key>_rotation</key>

View File

@ -21,5 +21,7 @@ install(FILES
gsm_bursts_printer.xml
gsm_fcch_burst_tagger.xml
gsm_sch_detector.xml
gsm_fcch_detector.xml DESTINATION share/gnuradio/grc/blocks
gsm_fcch_detector.xml
gsm_get_bcch_or_ccch_bursts.xml
gsm_control_channels_decoder.xml DESTINATION share/gnuradio/grc/blocks
)

View File

@ -0,0 +1,16 @@
<?xml version="1.0"?>
<block>
<name>Control channels decoder</name>
<key>gsm_control_channels_decoder</key>
<category>GSM</category>
<import>import gsm</import>
<make>gsm.control_channels_decoder()</make>
<sink>
<name>bursts</name>
<type>message</type>
</sink>
<!-- <source>-->
<!-- <name>msgs_out</name>-->
<!-- <type>message</type>-->
<!-- </source>-->
</block>

View File

@ -0,0 +1,16 @@
<?xml version="1.0"?>
<block>
<name>Demapper for BCCH and CCCH</name>
<key>gsm_get_bcch_or_ccch_bursts</key>
<category>GSM</category>
<import>import gsm</import>
<make>gsm.get_bcch_or_ccch_bursts()</make>
<sink>
<name>bursts</name>
<type>message</type>
</sink>
<source>
<name>bursts</name>
<type>message</type>
</source>
</block>

View File

@ -23,5 +23,8 @@
install(FILES
api.h
receiver.h
bursts_printer.h DESTINATION include/gsm
bursts_printer.h
get_bcch_or_ccch_bursts.h
control_channels_decoder.h
gsmtap.h DESTINATION include/gsm
)

View File

@ -0,0 +1,56 @@
/* -*- c++ -*- */
/*
* Copyright 2014 <+YOU OR YOUR COMPANY+>.
*
* This 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, or (at your option)
* any later version.
*
* This software 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 software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef INCLUDED_GSM_CONTROL_CHANNELS_DECODER_H
#define INCLUDED_GSM_CONTROL_CHANNELS_DECODER_H
#include <gsm/api.h>
#include <gnuradio/block.h>
namespace gr {
namespace gsm {
/*!
* \brief <+description of block+>
* \ingroup gsm
*
*/
class GSM_API control_channels_decoder : virtual public gr::block
{
public:
typedef boost::shared_ptr<control_channels_decoder> sptr;
/*!
* \brief Return a shared_ptr to a new instance of gsm::control_channels_decoder.
*
* To avoid accidental use of raw pointers, gsm::control_channels_decoder's
* constructor is in a private implementation
* class. gsm::control_channels_decoder::make is the public interface for
* creating new instances.
*/
static sptr make();
};
} // namespace gsm
} // namespace gr
#endif /* INCLUDED_GSM_CONTROL_CHANNELS_DECODER_H */

View File

@ -0,0 +1,56 @@
/* -*- c++ -*- */
/*
* Copyright 2014 <+YOU OR YOUR COMPANY+>.
*
* This 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, or (at your option)
* any later version.
*
* This software 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 software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef INCLUDED_GSM_GET_BCCH_OR_CCCH_BURSTS_H
#define INCLUDED_GSM_GET_BCCH_OR_CCCH_BURSTS_H
#include <gsm/api.h>
#include <gnuradio/block.h>
namespace gr {
namespace gsm {
/*!
* \brief <+description of block+>
* \ingroup gsm
*
*/
class GSM_API get_bcch_or_ccch_bursts : virtual public gr::block
{
public:
typedef boost::shared_ptr<get_bcch_or_ccch_bursts> sptr;
/*!
* \brief Return a shared_ptr to a new instance of gsm::get_bcch_or_ccch_bursts.
*
* To avoid accidental use of raw pointers, gsm::get_bcch_or_ccch_bursts's
* constructor is in a private implementation
* class. gsm::get_bcch_or_ccch_bursts::make is the public interface for
* creating new instances.
*/
static sptr make();
};
} // namespace gsm
} // namespace gr
#endif /* INCLUDED_GSM_GET_BCCH_OR_CCCH_BURSTS_H */

View File

@ -30,7 +30,11 @@ list(APPEND gsm_sources
receiver/viterbi_detector.cc
receiver/sch.c
burst_printer/bursts_printer_impl.cc
)
demapping/get_bcch_or_ccch_bursts_impl.cc
decoding/control_channels_decoder_impl.cc
decoding/cch.c
decoding/fire_crc.c
)
add_library(gnuradio-gsm SHARED ${gsm_sources})
target_link_libraries(gnuradio-gsm ${Boost_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES}

View File

@ -23,10 +23,10 @@
#endif
#include <gnuradio/io_signature.h>
#include "bursts_printer_impl.h"
#include <gsmtap.h>
#include <gsm/gsmtap.h>
#include <iterator>
#include <algorithm>
#include "bursts_printer_impl.h"
namespace gr {
namespace gsm {

553
lib/decoding/cch.c Normal file
View File

@ -0,0 +1,553 @@
//#include "system.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
//#include <exception>
//#include <stdexcept>
#include <math.h>
//#include "burst_types.h"
#include "cch.h"
#include "fire_crc.h"
/*
* GSM SACCH -- Slow Associated Control Channel
*
* These messages are encoded exactly the same as on the BCCH.
* (Broadcast Control Channel.)
*
* Input: 184 bits
*
* 1. Add parity and flushing bits. (Output 184 + 40 + 4 = 228 bit)
* 2. Convolutional encode. (Output 228 * 2 = 456 bit)
* 3. Interleave. (Output 456 bit)
* 4. Map on bursts. (4 x 156 bit bursts with each 2x57 bit content data)
*/
/*
* Parity (FIRE) for the GSM SACCH channel.
*
* g(x) = (x^23 + 1)(x^17 + x^3 + 1)
* = x^40 + x^26 + x^23 + x^17 + x^3 + 1
*/
static const unsigned char parity_polynomial[PARITY_SIZE + 1] = {
1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0,
0, 1, 0, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0,
1
};
// remainder after dividing data polynomial by g(x)
static const unsigned char parity_remainder[PARITY_SIZE] = {
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1
};
/*
static void parity_encode(unsigned char *d, unsigned char *p) {
int i;
unsigned char buf[DATA_BLOCK_SIZE + PARITY_SIZE], *q;
memcpy(buf, d, DATA_BLOCK_SIZE);
memset(buf + DATA_BLOCK_SIZE, 0, PARITY_SIZE);
for(q = buf; q < buf + DATA_BLOCK_SIZE; q++)
if(*q)
for(i = 0; i < PARITY_SIZE + 1; i++)
q[i] ^= parity_polynomial[i];
for(i = 0; i < PARITY_SIZE; i++)
p[i] = !buf[DATA_BLOCK_SIZE + i];
}
*/
int parity_check(unsigned char *d) {
unsigned int i;
unsigned char buf[DATA_BLOCK_SIZE + PARITY_SIZE], *q;
memcpy(buf, d, DATA_BLOCK_SIZE + PARITY_SIZE);
for(q = buf; q < buf + DATA_BLOCK_SIZE; q++)
if(*q)
for(i = 0; i < PARITY_SIZE + 1; i++)
q[i] ^= parity_polynomial[i];
return memcmp(buf + DATA_BLOCK_SIZE, parity_remainder, PARITY_SIZE);
}
/*
* Convolutional encoding and Viterbi decoding for the GSM SACCH channel.
*/
/*
* Convolutional encoding:
*
* G_0 = 1 + x^3 + x^4
* G_1 = 1 + x + x^3 + x^4
*
* i.e.,
*
* c_{2k} = u_k + u_{k - 3} + u_{k - 4}
* c_{2k + 1} = u_k + u_{k - 1} + u_{k - 3} + u_{k - 4}
*/
#define K 5
#define MAX_ERROR (2 * CONV_INPUT_SIZE + 1)
/*
* Given the current state and input bit, what are the output bits?
*
* encode[current_state][input_bit]
*/
static const unsigned int encode[1 << (K - 1)][2] = {
{0, 3}, {3, 0}, {3, 0}, {0, 3},
{0, 3}, {3, 0}, {3, 0}, {0, 3},
{1, 2}, {2, 1}, {2, 1}, {1, 2},
{1, 2}, {2, 1}, {2, 1}, {1, 2}
};
/*
* Given the current state and input bit, what is the next state?
*
* next_state[current_state][input_bit]
*/
static const unsigned int next_state[1 << (K - 1)][2] = {
{0, 8}, {0, 8}, {1, 9}, {1, 9},
{2, 10}, {2, 10}, {3, 11}, {3, 11},
{4, 12}, {4, 12}, {5, 13}, {5, 13},
{6, 14}, {6, 14}, {7, 15}, {7, 15}
};
/*
* Given the previous state and the current state, what input bit caused
* the transition? If it is impossible to transition between the two
* states, the value is 2.
*
* prev_next_state[previous_state][current_state]
*/
static const unsigned int prev_next_state[1 << (K - 1)][1 << (K - 1)] = {
{ 0, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2},
{ 0, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2},
{ 2, 0, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2},
{ 2, 0, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2},
{ 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2},
{ 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2},
{ 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2},
{ 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2},
{ 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2},
{ 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2},
{ 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2},
{ 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2},
{ 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 1, 2},
{ 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 1, 2},
{ 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 1},
{ 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 1}
};
static inline unsigned int hamming_distance2(unsigned int w) {
return (w & 1) + !!(w & 2);
}
/*
static void conv_encode(unsigned char *data, unsigned char *output) {
unsigned int i, state = 0, o;
// encode data
for(i = 0; i < CONV_INPUT_SIZE; i++) {
o = encode[state][data[i]];
state = next_state[state][data[i]];
*output++ = !!(o & 2);
*output++ = o & 1;
}
}
*/
int conv_decode(unsigned char *output, unsigned char *data) {
int i, t;
unsigned int rdata, state, nstate, b, o, distance, accumulated_error,
min_state, min_error, cur_state;
unsigned int ae[1 << (K - 1)]; // accumulated error
unsigned int nae[1 << (K - 1)]; // next accumulated error
unsigned int state_history[1 << (K - 1)][CONV_INPUT_SIZE + 1];
// initialize accumulated error, assume starting state is 0
for(i = 0; i < (1 << (K - 1)); i++){
ae[i] = nae[i] = MAX_ERROR;
}
ae[0] = 0;
// build trellis
for(t = 0; t < CONV_INPUT_SIZE; t++) {
// get received data symbol
rdata = (data[2 * t] << 1) | data[2 * t + 1];
// for each state
for(state = 0; state < (1 << (K - 1)); state++) {
// make sure this state is possible
if(ae[state] >= MAX_ERROR)
continue;
// find all states we lead to
for(b = 0; b < 2; b++) {
// get next state given input bit b
nstate = next_state[state][b];
// find output for this transition
o = encode[state][b];
// calculate distance from received data
distance = hamming_distance2(rdata ^ o);
// choose surviving path
accumulated_error = ae[state] + distance;
if(accumulated_error < nae[nstate]) {
// save error for surviving state
nae[nstate] = accumulated_error;
// update state history
state_history[nstate][t + 1] = state;
}
}
}
// get accumulated error ready for next time slice
for(i = 0; i < (1 << (K - 1)); i++) {
ae[i] = nae[i];
nae[i] = MAX_ERROR;
}
}
// the final state is the state with the fewest errors
min_state = (unsigned int)-1;
min_error = MAX_ERROR;
for(i = 0; i < (1 << (K - 1)); i++) {
if(ae[i] < min_error) {
min_state = i;
min_error = ae[i];
}
}
// trace the path
cur_state = min_state;
for(t = CONV_INPUT_SIZE; t >= 1; t--) {
min_state = cur_state;
cur_state = state_history[cur_state][t]; // get previous
output[t - 1] = prev_next_state[cur_state][min_state];
}
// return the number of errors detected (hard-decision)
return min_error;
}
/*
* GSM SACCH interleaving and burst mapping
*
* Interleaving:
*
* Given 456 coded input bits, form 4 blocks of 114 bits:
*
* i(B, j) = c(n, k) k = 0, ..., 455
* n = 0, ..., N, N + 1, ...
* B = B_0 + 4n + (k mod 4)
* j = 2(49k mod 57) + ((k mod 8) div 4)
*
* Mapping on Burst:
*
* e(B, j) = i(B, j)
* e(B, 59 + j) = i(B, 57 + j) j = 0, ..., 56
* e(B, 57) = h_l(B)
* e(B, 58) = h_n(B)
*
* Where h_l(B) and h_n(B) are bits in burst B indicating flags.
*/
/*
static void interleave(unsigned char *data, unsigned char *iBLOCK) {
int j, k, B;
// for each bit in input data
for(k = 0; k < CONV_SIZE; k++) {
B = k % 4;
j = 2 * ((49 * k) % 57) + ((k % 8) / 4);
iBLOCK[B * iBLOCK_SIZE + j] = data[k];