Project

General

Profile

Osmocom Network In The Box » History » Version 29

neels, 10/30/2017 11:53 PM

1 23 neels
{{>toc}}
2
3 29 neels
h1. WIP
4
5
This wiki page is still new and in an alpha state. We're still checking whether it is consistent and lacks important bits.
6
7 1 neels
h1. Osmocom Network In The Box
8
9 22 neels
This is a brief guide to the most basic and minimal setup of an Osmocom 2G and/or 3G network for voice and data services. It is a good starting point for newcomers to familiarize with the software, and to expand upon by the [[Osmocom Manuals]] and other wiki pages.
10 21 neels
11 2 neels
h2. OsmoNITB R.I.P., long live the Network In The Box
12 1 neels
13 2 neels
Historically, Osmocom offered the [[OsmoNITB:]] "Network-In-The-Box" as an actual single program. It was a useful simplification at the time, but in 2017, Osmocom have decided to split OsmoNITB into programs more closely resembling traditional network architecture. It is recommended to use the new separate components instead of the OsmoNITB, since active development focus has moved there.
14 1 neels
15 4 neels
It is still very much possible to run a complete Osmocom core network in one "box". For example, a sysmoBTS can run the entire core network on the same hardware that drives the TRX, making it a complete network in actually one single box. At the same time, having separate components also allows scaling to large deployments, with properly distributed load and a central subscriber database.
16 1 neels
17 2 neels
To migrate from OsmoNITB to the new separate programs, see the [[OsmoNITB Migration Guide]].
18
19
h2. Part of this Complete Network
20
21
Assuming that you have your radio hardware ready (a BTS, a femto cell or an SDR driven by osmo-trx), the core network consists of separate programs providing voice/SMS/USSD ("circuit-switched") and data ("packet-switched") services.
22
23
h3. Circuit-Switched Components
24
25
To run a circuit-switched core network, you need:
26
27
* [[OsmoHLR:]] -- Home Location Register, stores subscriber IMSI, phone number and auth tokens.
28
* [[OsmoMSC:]] -- Mobile Switching Center, handles signalling, i.e. attach/detach of subscribers, call establishment, messaging (SMS and USSD).
29 1 neels
* [[OsmoMGW:]] -- Media Gateway, is instructed by the MSC and/or the BSC to direct RTP streams for active voice calls.
30 8 neels
* [[OsmoSTP:]] -- Signal Transfer Point, routes SCCP messages between MSC, BSC, HNBGW and for 3G also the SGSN.
31 2 neels
* [[OsmoBSC:]] -- 2G Base Station Controller, manages logical channels and other lower level aspects for one or more 2G BTS; it is technically part of the BSS and not the "core network".
32
* [[OsmoHNBGW:]] -- 3G HomeNodeB Gateway, receives the Iuh protocol from a 3G femto cell and forwards to MSC and SGSN by SCCP/M3UA via OsmoSTP.
33
34
h3. Packet-Switched Components
35
36 3 neels
* [[OpenGGSN:|OsmoGGSN]] -- Gateway GPRS Support Node, "opens" GTP tunnels received from SGSNs to internet uplink.
37 2 neels
* [[OsmoSGSN:]] -- Serving GPRS Support Node, handles signalling, i.e. attach/detach of subscribers and PDP contexts.
38
* [[OsmoHLR:]] -- same as for circuit switched, see above.
39
* [[OsmoHNBGW:]] -- for 3G packet switched networks, same as for 3G circuit switched, see above.
40
* ([[OsmoPCU:]] -- for 2G networks, a component closely tied to the BTS, drives the TRX and ties to the SGSN via Gb-interface.)
41 5 neels
42 28 neels
*NOTE:* For the GGSN to successfully route packets to an internet uplink, the system needs to have
43
* IP-forwarding enabled,
44
* IP-masquerading set up,
45
* a usable tunnel device set up.
46
47
<pre>
48
echo 1 > /proc/sys/net/ipv4/ip_forward
49
iptables -t nat -A POSTROUTING -o $dev -j MASQUERADE
50
</pre>
51
52
53 18 neels
h1. Have to Know
54 5 neels
55 10 neels
Each program features a detailed [[Osmocom Manuals|user manual]], your primary source of information to expand on the setup described here.
56
57 24 laforge
Osmocom offers [[Binary_Packages|compiled packages for various distributions]]. If you're up to it, you may also [[Build from Source]].
58 5 neels
59
Each Osmocom program typically has
60
61
* a distinct configuration file;
62 1 neels
* a VTY telnet console for live interaction;
63 25 neels
* a CTRL interface for live interaction from 3rd party programs.
64 1 neels
65 18 neels
See [[Port Numbers]] to find out which program runs VTY on which port.
66
67
h1. Configuration Examples
68
69 5 neels
h2. OsmoHLR
70 6 neels
71
See the [[Osmocom Manuals|manual]] on creating a subscriber database, and add one or more subscribers.
72
73
While you do need one, your configuration file may actually remain empty. This will serve GSUP on localhost (127.0.0.1), sufficient for a Network In The Box.
74
75
h2. OsmoMSC
76
77
The VLR component of OsmoMSC needs to connect to the OsmoHLR's GSUP server to know which subscribers are authorized. By default, it will connect to OsmoHLR on localhost, no explicit config needed.
78
79 26 neels
To be reachable by OsmoBSC and OsmoHNBGW, OsmoMSC needs an SCCP point code, and it needs to connect to OsmoSTP to make itself known to SCCP routing.
80 6 neels
81 7 neels
* There is a default point code, currently 0.23.1 (in 8.8.3 point code format).
82 6 neels
* OsmoMSC will by default look for OsmoSTP on localhost's M3UA port, 2905.
83
84 7 neels
To direct RTP streams, OsmoMSC needs an OsmoMGW instance. By default, it will look for an MGW on localhost and the default MGCP port, 4222.
85 6 neels
86
Again, your config file may remain empty.
87 9 neels
88
h2. OsmoMGW
89
90 27 neels
*NOTE: Currently, OsmoMSC still requires the legacy osmo-bsc_mgcp program, which will move to the new osmo-mgw soon. osmo-bsc_mgcp is still available from osmo-mgw.git.*
91
92 9 neels
The Media Gateway receives instructions in the form of MGCP messages from OsmoMSC. It forwards RTP streams directly between BTS, femto cells and remote endpoints, e.g. other MGW instances.
93
94
Its RTP IP address must be reachable by the BTS / the femto cell.
95
96
* In a setup that truly runs in one box (e.g. sysmoBTS or osmo-trx with co-located core network), this may be localhost (127.0.0.1).
97
* With a separate BTS or RNC (e.g. 3G femto cell or nanoBTS), make sure to configure an IP address that is reachable.
98
99
*osmo-mgw.cfg*
100
<pre>
101
mgcp
102
  local ip 192.168.0.3
103
  bind ip 192.168.0.3
104
</pre>
105
106
The default is to allow any BTS / femto cell IP address to connect.
107
108
(Near future: a second OsmoMGW may be needed to run alongside each OsmoBSC instance.)
109
110
h2. OsmoSTP
111
112
OsmoSTP acts as a server for routing messages. OsmoMSC, OsmoBSC, OsmoHNBGW and OsmoSGSN contact OsmoSTP and announce their own point code, after which they may instruct OsmoSTP to route SCCP messages to each other by these point codes.
113
114
The basic configuration that permits dynamic routing is:
115
116
*osmo-stp.cfg*
117
<pre>
118
cs7 instance 0
119
 xua rkm routing-key-allocation dynamic-permitted
120
 listen m3ua 2905
121
  accept-asp-connections dynamic-permitted
122
</pre>
123 11 neels
124
h2. OsmoBSC
125
126
OsmoBSC needs to register with OsmoSTP, and contact the MSC by its point code.
127
128
OsmoBSC also needs complete configuration of all connected BTS. This example shows configuration for a sysmoBTS.
129
130
Furthermore, some network properties need to be set.
131
132 15 neels
The 'gprs mode' determines whether packet switched access will be enabled. 'gprs mode none' switches off data services, as osmo-bts will not contact osmo-pcu to establish data service. This is a configuration without packet switched service:
133
134
*osmo-bsc.cfg* for voice only
135 11 neels
<pre>
136
network
137
 network country code 901
138
 mobile network code 70
139
 mm info 1
140
 short name Osmocom
141
 long name Osmocom
142
 auth policy closed
143
 encryption a5 0
144
 bts 0
145
  type sysmobts
146
  band GSM-1800
147
  cell_identity 0
148
  location_area_code 23
149
  ip.access unit_id 1800 0
150
  gprs mode none
151
  trx 0
152
   rf_locked 0
153
   arfcn 868
154
   nominal power 23
155
   timeslot 0
156
    phys_chan_config CCCH+SDCCH4
157
   timeslot 1
158
    phys_chan_config SDCCH8
159
   timeslot 2
160
    phys_chan_config TCH/H
161
   timeslot 3
162
    phys_chan_config TCH/H
163
   timeslot 4
164
    phys_chan_config TCH/H
165
   timeslot 5
166
    phys_chan_config TCH/H
167
   timeslot 6
168
    phys_chan_config TCH/H
169
   timeslot 7
170
    phys_chan_config TCH/H
171
cs7 instance 0
172
 ! osmo-bsc's own point code
173
 point-code 0.42.0
174
 ! address book entry named 'msc_remote', used below
175
 sccp-address msc_remote
176
  point-code 0.23.1
177
msc 0
178
 msc-addr msc_remote
179 1 neels
</pre>
180 15 neels
181
To allow data service, set a 'gprs mode gprs' or 'gprs mode egprs', and configure PDCH timeslots. Traditionally, a fixed amount of TCH timeslots for voice and PDCH timeslots for data service are configured. OsmoBTS also supports two types of dynamic timeslots, as described in the "Abis manual":http://ftp.osmocom.org/docs/latest/osmobts-abis.pdf, chapter "Dynamic Channel Combinations". The following is a configuration with data service based on Osmocom style dynamic timeslots:
182
183
184
*osmo-bsc.cfg* for voice and data service
185
<pre>
186
network
187
 network country code 901
188
 mobile network code 70
189
 mm info 1
190
 short name Osmocom
191
 long name Osmocom
192
 auth policy closed
193
 encryption a5 0
194
 bts 0
195
  type sysmobts
196
  band GSM-1800
197
  cell_identity 0
198
  location_area_code 23
199
  ip.access unit_id 1800 0
200
  gprs mode gprs
201
  trx 0
202
   rf_locked 0
203
   arfcn 868
204
   nominal power 23
205
   timeslot 0
206
    phys_chan_config CCCH+SDCCH4
207
   timeslot 1
208
    phys_chan_config SDCCH8
209
   timeslot 2
210
    phys_chan_config TCH/F_TCH/H_PDCH
211
   timeslot 3
212
    phys_chan_config TCH/F_TCH/H_PDCH
213
   timeslot 4
214
    phys_chan_config TCH/F_TCH/H_PDCH
215
   timeslot 5
216
    phys_chan_config TCH/F_TCH/H_PDCH
217
   timeslot 6
218
    phys_chan_config TCH/F_TCH/H_PDCH
219
   timeslot 7
220
    phys_chan_config PDCH
221
cs7 instance 0
222
 ! osmo-bsc's own point code
223
 point-code 0.42.0
224
 ! address book entry named 'msc_remote', used below
225
 sccp-address msc_remote
226
  point-code 0.23.1
227
msc 0
228
 msc-addr msc_remote
229
</pre>
230
231 12 neels
h2. OsmoHNBGW
232 1 neels
233 16 neels
For connecting a 3G hNodeB (femto cell), OsmoHNBGW is needed to receive Iuh and forward IuCS and IuPS. (For a pure 2G setup, no HNBGW is needed.)
234 1 neels
235 16 neels
OsmoHNBGW needs to connect to OsmoSTP for routing, and needs to know the MSC and SGSN point codes.
236
237
It must also be reachable by the hNodeB, hence its Iuh must typically run on a public IP, not a loopback address like 127.0.0.1.
238 12 neels
239
*osmo-hnbgw.cfg*
240
<pre>
241
cs7 instance 0
242
 ! OsmoHNBGW's own local point code
243
 point-code 0.3.0
244
 ! Address book entries, used below
245
 sccp-address msc
246
  point-code 0.23.1
247
 sccp-address sgsn
248
  point-code 0.23.2
249
hnbgw
250
 iuh
251
  local-ip 192.168.0.3
252
 iucs
253
  remote-addr msc
254
 iups
255
  remote-addr sgsn
256
</pre>
257 13 neels
258
h2. OsmoGGSN
259
260 14 neels
To provide packet switched service, OsmoGGSN must offer GTP service to the OsmoSGSN. Notably, both OsmoGGSN and OsmoSGSN must use identical port numbers, which an intrinsic requirement of the GTP protocol. Hence they must not run on the same IP address. It is sufficient to, for example, run OsmoGGSN on 127.0.0.2, and OsmoSGSN's GTP on 127.0.0.1.
261 13 neels
262
OsmoGGSN maintains a gsn_restart counter, to be able to reliably communicate to the SGSN that it has restarted. This is kept in the 'state-dir', by default in /tmp.
263
264
It also needs access to a tun device. This may be configured ahead of time, so that OsmoGGSN does not need root privileges. If run with 'sudo', OsmoGGSN may also create its own tun device. In below example, the 'tun4' device has been created ahead of time. IPv4 operation is enabled by default, but for future compatibility, it is good to indicate that explicitly.
265
266
OsmoGGSN furthermore indicates DNS servers, as well as an IPv4 address range to assign to subscribers' PDP contexts.
267 1 neels
268 14 neels
*osmo-ggsn.cfg*
269 13 neels
<pre>
270
ggsn ggsn0
271
 gtp bind-ip 127.0.0.2
272
 apn internet
273
  tun-device tun4
274
  type-support v4
275
  ip dns 0 192.168.100.1
276
  ip dns 1 8.8.8.8
277
  ip ifconfig 176.16.222.0/24
278 1 neels
  ip prefix dynamic 176.16.222.0/24
279 14 neels
</pre>
280
281
h2. OsmoSGSN
282
283
OsmoSGSN needs to reach the GGSN to establish GTP tunnels for subscribers. It must have a separate GTP IP address from OsmoGGSN, as mentioned before.
284
285
For 2G, OsmoSGSN needs to be reachable by the PCU, and needs a public IP for the Gb interface if it is not running directly on the BTS hardware (e.g. on sysmoBTS or when using osmo-trx). For 2G operation, SGSN and GGSN may both use a local IP address for GTP, as long as they differ (e.g. 127.0.0.1 and 127.0.0.2).
286
287
For 3G, OsmoSGSN needs to be reachable by both the HNBGW for IuPS as well as by the hNodeB for GTP, i.e. it definitely needs to have a public IP address for the GTP port. IuPS may remain local if both HNBGW and SGSN are on the same box.
288
289
Finally, OsmoSGSN needs access to OsmoHLR to access subscriber data. Set 'auth-policy remote' to use the HLR for subscriber authorization. The default 
290
291
*osmo-sgsn.cfg*
292
<pre>
293
sgsn
294
 gtp local-ip 192.168.0.3
295
 ggsn 0 remote-ip 192.168.0.142
296 1 neels
 auth-policy remote
297 14 neels
 gsup remote-ip 127.0.0.1
298 13 neels
</pre>
299 17 neels
300 18 neels
h1. Running Examples
301 17 neels
302
Each Osmocom program comes with a systemd service file. It is recommended to place config files in /etc/osmocom/ and launch the individual components using systemd.
303
304
When installed from debian or opkg feeds, you will find the systemd service files in /lib/systemd/system/.
305
306
Re/starting and stopping then works like this:
307
308
<pre>
309
systemctl restart osmo-hlr
310
systemctl stop osmo-hlr
311 1 neels
</pre>
312
313
For illustration, the manual command invocations for the components would look like this:
314
315
<pre>
316
osmo-hlr -l hlr.db -c osmo-hlr.cfg
317
osmo-msc -c osmo-msc.cfg
318
osmo-mgw -c osmo-mgw.cfg
319
osmo-stp -c osmo-stp.cfg
320
osmo-bsc -c osmo-bsc.cfg
321
osmo-hnbgw -c osmo-hnbgw.cfg
322
osmo-ggsn -c osmo-ggsn.cfg
323
osmo-sgsn -c osmo-sgsn.cfg
324
</pre>
325 18 neels
326
h1. Logging Examples
327
328
Osmocom programs have a common logging mechanism, configurable by the config files as well as the telnet VTY.
329
330
Depending on the system's logging configuration, logs may by default be visible in /var/log/daemon.log, or by using journalctl:
331
332
<pre>
333
journalctl -f -u osmo-hlr
334
</pre>
335
336
When journalctl is used, it may be necessary to enable it first, e.g. by setting "Storage=volatile" in /etc/systemd/journald.conf followed by a 'systemctl restart systemd-journald'.
337
338 19 neels
A sure way to see the logs is to connect to the program's telnet VTY and enable logging on the VTY session -- this way you do not modify the application's default logging, but create a separate logging target for your telnet VTY session:
339
340
<pre>
341
$ telnet localhost 4254
342
OsmoMSC> logging enable 
343
OsmoMSC> logging level ?
344
  all      Global setting for all subsystems
345
  rll      A-bis Radio Link Layer (RLL)
346
  cc       Layer3 Call Control (CC)
347
  mm       Layer3 Mobility Management (MM)
348
  rr       Layer3 Radio Resource (RR)
349
  rsl      A-bis Radio Siganlling Link (RSL)
350
  nm       A-bis Network Management / O&M (NM/OML)
351
  mncc     MNCC API for Call Control application
352
  pag      Paging Subsystem
353
  meas     Radio Measurement Processing
354
  sccp     SCCP Protocol
355
  msc      Mobile Switching Center
356
  mgcp     Media Gateway Control Protocol
357
  ho       Hand-Over
358
  db       Database Layer
359
  ref      Reference Counting
360
  gprs     GPRS Packet Service
361
  ns       GPRS Network Service (NS)
362
  bssgp    GPRS BSS Gateway Protocol (BSSGP)
363
  llc      GPRS Logical Link Control Protocol (LLC)
364
  sndcp    GPRS Sub-Network Dependent Control Protocol (SNDCP)
365
  nat      GSM 08.08 NAT/Multiplexer
366
  ctrl     Control interface
367
  smpp     SMPP interface for external SMS apps
368
  filter   BSC/NAT IMSI based filtering
369
  ranap    Radio Access Network Application Part Protocol
370
  sua      SCCP User Adaptation Protocol
371
  pcu      PCU Interface
372
  vlr      Visitor Location Register
373
  iucs     Iu-CS Protocol
374
  sigtran  SIGTRAN Signalling Transport
375
  lglobal  Library-internal global log family
376
  llapd    LAPD in libosmogsm
377
  linp     A-bis Intput Subsystem
378
  lmux     A-bis B-Subchannel TRAU Frame Multiplex
379
  lmi      A-bis Input Driver for Signalling
380
  lmib     A-bis Input Driver for B-Channels (voice)
381
  lsms     Layer3 Short Message Service (SMS)
382
  lctrl    Control Interface
383
  lgtp     GPRS GTP library
384
  lstats   Statistics messages and logging
385
  lgsup    Generic Subscriber Update Protocol
386
  loap     Osmocom Authentication Protocol
387
  lss7     libosmo-sigtran Signalling System 7
388
  lsccp    libosmo-sigtran SCCP Implementation
389
  lsua     libosmo-sigtran SCCP User Adaptation
390
  lm3ua    libosmo-sigtran MTP3 User Adaptation
391
  lmgcp    libosmo-mgcp Media Gateway Control Protocol
392
OsmoMSC> logging level mm ?
393
everything debug      info       notice     error      fatal      
394
OsmoMSC> logging level mm debug 
395
OsmoMSC> logging level rr debug
396
OsmoMSC> logging filter all 1
397
</pre>
398 20 neels
399
You will see logging output on your telnet console immediately. Note that the VTY prompt is still listening, so you may at any time issue 'logging filter all 0' to switch off logging, and be able to type commands without being cluttered by ongoing log output.
Add picture from clipboard (Maximum size: 48.8 MB)