GNU Radio's GSM Package: gsm_constants.h Source File

GNU Radio's GSM Package

gsm_constants.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3 * @file
4 * @author (C) 2014 by Piotr Krysik <ptrkrysik@gmail.com>
5 * @section LICENSE
6 *
7 * Gr-gsm is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
10 * any later version.
11 *
12 * Gr-gsm is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with gr-gsm; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
21 */
22
23 #ifndef INCLUDED_GSM_CONSTANTS_H
24 #define INCLUDED_GSM_CONSTANTS_H
25
26 #define GSM_SYMBOL_RATE (1625000.0/6.0) //symbols per second
27 #define GSM_SYMBOL_PERIOD (1.0/GSM_SYMBOL_RATE) //seconds per symbol
28
29 //Burst timing
30 #define TAIL_BITS 3
31 #define GUARD_BITS 8
32 #define GUARD_FRACTIONAL 0.25 //fractional part of guard period
33 #define GUARD_PERIOD GUARD_BITS + GUARD_FRACTIONAL
34 #define DATA_BITS 57 //size of 1 data block in normal burst
35 #define STEALING_BIT 1
36 #define N_TRAIN_BITS 26
37 #define N_SYNC_BITS 64
38 #define USEFUL_BITS 142 //(2*(DATA_BITS+STEALING_BIT) + N_TRAIN_BITS )
39 #define FCCH_BITS USEFUL_BITS
40 #define BURST_SIZE (USEFUL_BITS+2*TAIL_BITS)
41 #define PROCESSED_CHUNK BURST_SIZE+2*GUARD_PERIOD
42
43 #define SCH_DATA_LEN 39
44 #define TS_BITS (TAIL_BITS+USEFUL_BITS+TAIL_BITS+GUARD_BITS) //a full TS (156 bits)
45 #define TS_PER_FRAME 8
46 #define FRAME_BITS (TS_PER_FRAME * TS_BITS + 2) // 156.25 * 8
47 #define FCCH_POS TAIL_BITS
48 #define SYNC_POS 39
49 #define TRAIN_POS ( TAIL_BITS + (DATA_BITS+STEALING_BIT) + 5) //first 5 bits of a training sequence
50 //aren't used for channel impulse response estimation
51 #define TRAIN_BEGINNING 5
52 #define SAFETY_MARGIN 6 //
53
54 #define FCCH_HITS_NEEDED (USEFUL_BITS - 4)
55 #define FCCH_MAX_MISSES 1
56 #define FCCH_MAX_FREQ_OFFSET 100
57
58 #define CHAN_IMP_RESP_LENGTH 5
59
60 #define MAX_SCH_ERRORS 10 //maximum number of subsequent sch errors after which gsm receiver goes to find_next_fcch state
61
62 typedef enum {empty, fcch_burst, sch_burst, normal_burst, rach_burst, dummy, dummy_or_normal, normal_or_noise} burst_type;
63 typedef enum {unknown, multiframe_26, multiframe_51} multiframe_type;
64
65 static const unsigned char SYNC_BITS[] = {
66 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0,
67 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
68 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1,
69 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1
70 };
71
72 const unsigned FCCH_FRAMES[] = {0, 10, 20, 30, 40};
73 const unsigned SCH_FRAMES[] = {1, 11, 21, 31, 41};
74
75 const unsigned BCCH_FRAMES[] = {2, 3, 4, 5}; //!!the receiver shouldn't care about logical
76 //!!channels so this will be removed from this header
77 const unsigned TEST_CCH_FRAMES[] = {2, 3, 4, 5, 6, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18, 19, 22, 23, 24, 25, 26, 27, 28, 29, 32, 33, 34, 35, 36, 37, 38, 39, 42, 43, 44, 45, 46, 47, 48, 49};
78 const unsigned TRAFFIC_CHANNEL_F[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
79 const unsigned TEST51[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50};
80
81
82 #define TSC0 0
83 #define TSC1 1
84 #define TSC2 2
85 #define TSC3 3
86 #define TSC4 4
87 #define TSC5 5
88 #define TSC6 6
89 #define TSC7 7
90 #define TS_DUMMY 8
91
92 #define TRAIN_SEQ_NUM 9
93
94 #define TIMESLOT0 0
95 #define TIMESLOT1 1
96 #define TIMESLOT2 2
97 #define TIMESLOT3 3
98 #define TIMESLOT4 4
99 #define TIMESLOT5 5
100 #define TIMESLOT6 6
101 #define TIMESLOT7 7
102
103
104 static const unsigned char train_seq[TRAIN_SEQ_NUM][N_TRAIN_BITS] = {
105 {0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1},
106 {0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1},
107 {0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0},
108 {0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0},
109 {0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1},
110 {0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0},
111 {1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1},
112 {1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0},
113 {0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1} // DUMMY
114 };
115
116
117 //Dummy burst 0xFB 76 0A 4E 09 10 1F 1C 5C 5C 57 4A 33 39 E9 F1 2F A8
118 static const unsigned char dummy_burst[] = {
119 0, 0, 0,
120 1, 1, 1, 1, 1, 0, 1, 1, 0, 1,
121 1, 1, 0, 1, 1, 0, 0, 0, 0, 0,
122 1, 0, 1, 0, 0, 1, 0, 0, 1, 1,
123 1, 0, 0, 0, 0, 0, 1, 0, 0, 1,
124 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
125 0, 1, 1, 1, 1, 1, 0, 0,
126
127 0, 1, 1, 1, 0, 0, 0, 1, 0, 1,
128 1, 1, 0, 0, 0, 1, 0, 1, 1, 1,
129 0, 0, 0, 1, 0, 1,
130
131 0, 1, 1, 1, 0, 1, 0, 0, 1, 0,
132 1, 0, 0, 0, 1, 1, 0, 0, 1, 1,
133 0, 0, 1, 1, 1, 0, 0, 1, 1, 1,
134 1, 0, 1, 0, 0, 1, 1, 1, 1, 1,
135 0, 0, 0, 1, 0, 0, 1, 0, 1, 1,
136 1, 1, 1, 0, 1, 0, 1, 0,
137 0, 0, 0
138 };
139
140
141 /*
142 * The frequency correction burst is used for frequency synchronization
143 * of the mobile. This is broadcast in TS0 together with the SCH and
144 * BCCH.
145 *
146 * Modulating the bits below causes a spike at 62.5kHz above (below for
147 * COMPACT) the center frequency. One can use this spike with a narrow
148 * band filter to accurately determine the center of the channel.
149 */
150 static const unsigned char fc_fb[] = {
151 0, 0, 0, //I don't use this tables,
152 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //I copied this here from burst_types.h because
153 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //the description is very informative - p.krysik
154 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
155 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
156 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
157 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
158 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
159 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
160 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
161 0, 0, 0
162 };
163
164 static const unsigned char fc_compact_fb[] = {
165 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
166 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
167 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
168 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
169 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
170 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
171 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
172 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
173 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0
174 };
175
176
177 #endif /* INCLUDED_GSM_CONSTANTS_H */
multiframe_51
Definition: gsm_constants.h:63
BCCH_FRAMES
const unsigned BCCH_FRAMES[]
Definition: gsm_constants.h:75
normal_or_noise
Definition: gsm_constants.h:62
dummy_burst
static const unsigned char dummy_burst[]
Definition: gsm_constants.h:118
multiframe_26
Definition: gsm_constants.h:63
normal_burst
Definition: gsm_constants.h:62
FCCH_FRAMES
const unsigned FCCH_FRAMES[]
Definition: gsm_constants.h:72
N_TRAIN_BITS
#define N_TRAIN_BITS
Definition: gsm_constants.h:36
TRAIN_SEQ_NUM
#define TRAIN_SEQ_NUM
Definition: gsm_constants.h:92
burst_type
burst_type
Definition: gsm_constants.h:62
TEST51
const unsigned TEST51[]
Definition: gsm_constants.h:79
SYNC_BITS
static const unsigned char SYNC_BITS[]
Definition: gsm_constants.h:65
SCH_FRAMES
const unsigned SCH_FRAMES[]
Definition: gsm_constants.h:73
sch_burst
Definition: gsm_constants.h:62
empty
Definition: gsm_constants.h:62
dummy_or_normal
Definition: gsm_constants.h:62
fc_fb
static const unsigned char fc_fb[]
Definition: gsm_constants.h:150
multiframe_type
multiframe_type
Definition: gsm_constants.h:63
rach_burst
Definition: gsm_constants.h:62
fcch_burst
Definition: gsm_constants.h:62
fc_compact_fb
static const unsigned char fc_compact_fb[]
Definition: gsm_constants.h:164
unknown
Definition: gsm_constants.h:63
train_seq
static const unsigned char train_seq[TRAIN_SEQ_NUM][N_TRAIN_BITS]
Definition: gsm_constants.h:104
dummy
Definition: gsm_constants.h:62
TEST_CCH_FRAMES
const unsigned TEST_CCH_FRAMES[]
!the receiver shouldn&#39;t care about logical !channels so this will be removed from this header ...
Definition: gsm_constants.h:77
TRAFFIC_CHANNEL_F
const unsigned TRAFFIC_CHANNEL_F[]
Definition: gsm_constants.h:78