Project

General

Profile

RepeaterPage » History » Version 9

matt, 10/26/2017 02:52 AM

1 2 matt
h1. SUMMARY
2 1 zecke
3
 * Simultaneous multi-channel transmission/reception
4
 * Uses USRP and/or conventional receiver/transmitter hardware
5
 * Generic interface to Asterisk via app_rpt (full VOIP, radio control, and standard repeater functions)
6
 * Features: P25, analog NBFM with CTCSS
7
 * Expected to be fully "ROIP" [Radio Over IP] compatible
8
9 2 matt
h2. Multi-channel reception using the USRP
10 1 zecke
11
Assume we want to receive simultaneously the four signals shown below;
12
one conventional (analog) FM voice channel plus three P25
13
signals.  The two P25 voice channels are to be IMBE-decoded whereas the
14
P25 data channel is to be sent to Wireshark after decoding.  For all three voice
15
channels, we want to forward the received PTT and audio info to Asterisk app_rpt.
16
The received PTT [Push To Talk, or "keyed"] signal is a bit that ideally tracks
17
the state of the PTT key at transmitter, indicating the presence or absence of the
18
received signal.
19
20 8 matt
h2. Spectrum plot
21
22 7 matt
!spectrum.png!
23 1 zecke
24
Fig. 1 - Spectrum of repeater input band (sample; diagram not to scale)
25
26
For now, it's necessary to edit the source code file manually to specify
27
the list of channels/modes to be received (file usrp_rx.py):
28
29 3 matt
<pre>
30 1 zecke
channels = [
31
	{'freq':435.200e6, 'mode':'c4fm',  'port':32001},
32
	{'freq':435.350e6, 'mode':'fm',    'port':32002, 'ctcss':97.4},
33
	{'freq':435.600e6, 'mode':'cqpsk', 'port':23456, 'wireshark':1},
34
	{'freq':435.775e6, 'mode':'cqpsk', 'port':32003}
35
]
36 3 matt
</pre>
37 1 zecke
38
Individual channels are defined one per line; note that all definition lines
39
except the last must end with a comma.
40
41
We choose a frequency somewhere close to the center of this band.
42
which will set the USRP's nominal receive frequency; this must also
43
be manually set in the source file:
44
45 3 matt
<pre>
46 1 zecke
center_freq = 435.500e6
47 3 matt
</pre>
48 1 zecke
49
Before running the receiver app, we
50
 * measure the current calibration error value (I use kalibrate)
51
 * determine the optimum USRP receiver gain value
52
The values used in this example are +1234 and 35, respectively.
53
54
We're now ready to start the receiver:
55
56 3 matt
<pre>
57 1 zecke
usrp_rx.py -RA -c 1234 -H 127.0.0.1 -g 35 -d 25
58 3 matt
</pre>
59 1 zecke
60
The receiver continuously monitors all four channels.  For each of the three
61
voice channels, the audio and the PTT info ("key up" and "key down" events)
62
are forwarded to asterisk app_rpt over separate UDP channels.
63
64
 = P25 and/or analog NBFM Reception using a discriminator-tapped receiver =
65
66
One or more disc-tapped conventional receivers may be used at the same time, and can
67
coexist with one or more USRP's.
68
69
An audio cable is connected between the disc-tap point in the receiver and the PC soundcard.
70
71
Single-channel reception is possible using disctap_rx.py.
72
The app dynmically auto-detects the modulation type (P25 or analog NBFM).
73
74
Audio and PTT events are forwarded to asterisk app_rpt over two separate UDP
75
channels, depending on modulation type:
76
 * received P25 audio is sent to asterisk on UDP port 32004
77
 * when analog NBFM is received with the proper CTCSS tone (97.4 Hz), port 32005 is used
78
79 3 matt
<pre>
80 1 zecke
 disctap_rx.py -i -A 0.05 -c 97.4 -H 127.0.0.1 -p 32004 -g 35 -d 25
81 3 matt
</pre>
82 1 zecke
83
The -g (gain) parameter is used to set the proper audio gain level.  See
84
the hardware page for further guidance - this value is important for achieving
85
correct operation.
86
87 3 matt
h2. Asterisk and app_rpt
88 1 zecke
89
For all voice modes (IMBE and analog FM) the audio is transmitted
90
as frames over the UDP channel to and from Asterisk in the standard native audio format:
91
 * 50 frames per second
92
 * 160 audio samples per frame
93
 * 8000 samples per second
94
 * signed
95
 * 16-bit
96
 * linear
97
98 3 matt
h3. Build asterisk with app_rpt
99 1 zecke
100
As a prereq make sure the Linux kernel headers are installed, as zaptel installs kernel modules.
101
102
First obtain and unpack the sources
103
104 3 matt
 - http://ohnosec.org/drupal/node/6   [use @svn checkout@ to grab the "Asterisk Sources"]
105 1 zecke
106 3 matt
Locate the toplevel directory - this should have several subdirectories including @zaptel@ and @asterisk@ .
107 1 zecke
108 3 matt
Then locate the subdirectory named @asterisk/channels@ ,
109
and copy the files @chan_usrp.c@ and @chan_usrp.h@ (from @repeater/src/lib@ in the op25 sources) to this subdirectory.
110 1 zecke
111
Now, build and install asterisk and app_rpt
112
113 3 matt
@cd@ to the toplevel directory
114
115
@cd zaptel && ./configure && make && sudo make install@
116
117 1 zecke
and then (again from the toplevel directory)
118
119 3 matt
@cd asterisk && ./configure && make && sudo make install@
120
121
122 1 zecke
For a first time installation of asterisk there are also other steps such as config file installation.
123 3 matt
Before setting up @rpt.conf@ you must first set up asterisk itself - see for example
124 1 zecke
125
http://www.voip-info.org/wiki/view/Asterisk+quickstart
126
127 3 matt
h2. Configuration
128 1 zecke
129 3 matt
We define five repeater nodes in @/etc/asterisk/rpt.conf@
130 1 zecke
131 3 matt
<pre>
132 1 zecke
[000]
133
rxchannel = usrp/127.0.0.1:34001:32001
134
duplex = 2
135
scheduler=scheduler
136
functions = functions-repeater
137
hangtime=0
138
authlevel = 0
139
140
[001]
141
rxchannel = usrp/127.0.0.1:34002:32002
142
duplex = 2
143
scheduler=scheduler
144
functions = functions-repeater
145
hangtime=0
146
authlevel = 0
147
148
[002]
149
rxchannel = usrp/127.0.0.1:34003:32003
150
duplex = 2
151
scheduler=scheduler
152
functions = functions-repeater
153
hangtime=0
154
authlevel = 0
155
156
[003]
157
rxchannel = usrp/127.0.0.1:34004:32004
158
duplex = 2
159
scheduler=scheduler
160
functions = functions-repeater
161
hangtime=0
162
authlevel = 0
163
164
[004]
165
rxchannel = usrp/127.0.0.1:34005:32005
166
duplex = 2
167
scheduler=scheduler
168
functions = functions-repeater
169
hangtime=0
170
authlevel = 0
171 3 matt
</pre>
172 1 zecke
173
Continuing the example of five voice channels from above, we define five repeater nodes (channels).  Voice and PTT traffic that 
174
is output by asterisk/app_rpt for RF transmission is forwarded to usrp_tx.py (see below) using UDP ports in the 3400x range.
175
Voice data received in usrp_rx.py and/or disctap_rx.py is forwarded to asterisk/app_rpt (chan_usrp.c) via ports in the 3200x range.
176
177 3 matt
The driver invocation in @rpt.conf@ is
178
<pre>
179 1 zecke
    usrp/HISIP:HISPORT[:MYPORT]       
180
    HISIP is the IP address (or FQDN) of the GR app
181
    HISPORT is the UDP socket of the GR app
182
    MYPORT (optional) is the UDP socket that Asterisk listens on
183
             for this channel   
184 3 matt
</pre>
185 1 zecke
186 4 matt
TIP: You can use the @usrp show@ command to display status information from within the Asterisk CLI.
187 1 zecke
188 3 matt
TIP: Another handy command is @rpt playback@ to start transmission on a channel.
189 1 zecke
190 3 matt
h2. Channel Bank Configuration
191 1 zecke
192
Typically the audio links are terminated on channel banks which provide a standard interface to user
193
equipment.  Commonly, this equipment places an "offhook" indication on the signalling circuit when it
194
wishes to initiate a radio transmission, and signals the end of the transmission by placing the circuit
195
in the "onhook" state.  Standard audio transmission levels are defined at the channel bank interface.
196
197 3 matt
A standard FXS port on the channel bank is defined in @/etc/asterisk/zapata.conf@ with
198
<pre>
199 1 zecke
signalling=fxo_ls
200
immediate=yes
201
context = chan1
202
channel => 1
203 3 matt
</pre>
204 1 zecke
205
An offhook (PTT) signal from user equipment on the FXS channel bank port 
206 3 matt
(due to the @immmediate=yes@) starts processing in @/etc/asterisk/extensions.conf@:
207 1 zecke
208 3 matt
<pre>
209 1 zecke
[chan1]
210
exten => s,1,Dial(local/1@radio/n)
211 3 matt
</pre>
212
This jumps to extension "1" in context @radio@ (also in @/etc/asterisk/extensions.conf@)
213
<pre>
214 1 zecke
[radio]
215
exten => 1,1,rpt(000|D)
216
exten => 2,1,rpt(001|D)
217
exten => 3,1,rpt(002|D)
218
exten => 4,1,rpt(003|D)
219
exten => 5,1,rpt(004|D)
220 3 matt
</pre>
221 1 zecke
222
So the call resulting from the offhook (PTT) signal is routed to 
223 3 matt
extension "1" in context @[radio]@ where it's connected to the desired
224 1 zecke
repeater node (channel).  If the GR app is running it will initiate
225
radio transmission.  An onhook signal on the FXS channel bank port
226
causes the end of the transmission by ending the asterisk call in
227 3 matt
progress*. The @hangtime=0@ setting in @rpt.conf@ was used to reduce the
228 1 zecke
tail delay in this setup.
229
230
*The end of the transmission may be modified however, for example when
231
app_rpt appends an "ID" or if a "timeout" occurs.
232
233
Note: "Dumb" mode is used in these examples (theory: if it can't be made to work in its dumb mode, there's no prayer of getting smart mode to work)
234
235 3 matt
h2. USRP Transmission
236 1 zecke
237
The multi-channel USRP transmitter app currently has some limitations:
238
 * Transmit channel spacing is at arbitrary 25 KHz intervals
239
 * Analog NBFM mode is not yet supported
240
Before running the app you must first determine (example values shown in square brackets - YMMV)
241
 * the USRP TX daughterboard ID (A or B) [A]
242
 * carrier frequency of the first ("center") TX channel [435.125 MHz]
243
 * number of channels to be transmitted [five]
244
 * the first UDP port number over which usrp_tx.py receives data from chan_usrp.c [port 34001]
245
Example:
246 3 matt
247
@usrp_tx.py -TA -e -f 435.125e6 -n 5 -p 34001@
248
249 1 zecke
Here we also request a FFT display. With port 34001 as the starting UDP port number and
250 3 matt
five channels, @usrp_tx.py@ listens on ports 34001-34005 for TX traffic coming from chan_usrp.c, as
251
configured in @/etc/asterisk/rpt.conf@ (see above).
252 1 zecke
253 3 matt
h2. Soundcard Transmission
254 1 zecke
255
The soundcard TX program outputs an analog waveform that is suitable for application to the
256
modulator stage of an FM transmitter.  It listens on the UDP port for audio frames sent to it
257
by asterisk/chan_usrp.  The analog audio thus received is encoded by the soundcard TX app to
258
IMBE voice code words, which are in turn assembled into P25 voice frames (LDU1/LDU2's).  The
259
resulting 4800 baud symbol stream is then RRC filtered and shaped according to the P25 spec.
260
This signal is output to the sound card (and optionally to an on-screen oscilloscope using
261 3 matt
the @-e@ option).
262 1 zecke
263
This app may be run on the same server as asterisk or on a different machine.
264
265
Currently only a single channel is supported (per invocation of soundcard_tx).  If more than
266
one TX channel is to be used simultaneously, run a another copy of the app (either on a different
267
host or using a different UDP port).
268
269
Syntax:
270
271 5 matt
@soundcard_tx.py -g 0.3 -p 32001@
272 3 matt
273
274
The gain value (@0.3@) would cause the output envelope (ranging from -3 to +3) to be scaled to
275 1 zecke
fit within the standard band from -1 to +1.  Values larger than 0.3 may cause clipping and distortion.
276
277
The final output amplitude to the radio can also be adjusted in discrete steps using the audio mixer
278 3 matt
application (e.g., @alsamixer@)
279 9 matt
280
281
!spectrum.png!
Add picture from clipboard (Maximum size: 48.8 MB)