Project

General

Profile

Osmocom Network In The Box » History » Version 40

neels, 11/09/2017 07:19 PM

1 23 neels
{{>toc}}
2
3 29 neels
h1. WIP
4
5 31 neels
*This wiki page is still new and in an alpha state. We're still checking whether it is consistent and contains all the important information.*
6 29 neels
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 32 neels
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" or CS) and data ("packet-switched" or PS) services.
22 2 neels
23 32 neels
Here is a table of the components you need:
24 1 neels
25 32 neels
|\4. *Required for*  |/3. *Program* |/3. *Description* |
26
|\2. *2G*  |\2. *3G* |
27
| *CS* | *PS* | *CS* | *PS* |
28
| ✔ | ✔ | ✔ | ✔ | [[OsmoHLR:]] | Home Location Register, stores subscriber IMSI, phone number and auth tokens. |
29
| ✔ | (1) | ✔ | (1) | [[OsmoMSC:]] | Mobile Switching Center, handles signalling, i.e. attach/detach of subscribers, call establishment, messaging (SMS and USSD). |
30
| ✔ |   | ✔ |   | [[OsmoMGW:]] | Media Gateway, is instructed by the MSC and/or the BSC to direct RTP streams for active voice calls. |
31
| ✔ | ✔ | ✔ | ✔ | [[OsmoSTP:]] | Signal Transfer Point, routes SCCP messages between MSC, BSC, HNBGW and for 3G also the SGSN. |
32
| ✔ | (1) |   |   | [[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". |
33
|   |   | ✔ | ✔ | [[OsmoHNBGW:]] | 3G HomeNodeB Gateway, receives the Iuh protocol from a 3G femto cell and forwards to MSC and SGSN by SCCP/M3UA via OsmoSTP. |
34
|   | ✔ (2) |   | ✔ (2) | [[OpenGGSN:|OsmoGGSN]] | Gateway GPRS Support Node, "opens" GTP tunnels received from SGSNs to internet uplink. |
35
|   | ✔ |   | ✔ | [[OsmoSGSN:]] | Serving GPRS Support Node, handles signalling, i.e. attach/detach of subscribers and PDP contexts. |
36
| ✔ | (1) |   |   | [[OsmoBTS:]] | for 2G networks, drives the TRX and ties to the BSC via Abis-interface. |
37
|   | ✔ |   |   | [[OsmoPCU:]] | for 2G networks, a component closely tied to the BTS, drives the TRX for PS timeslots and ties to the SGSN via Gb-interface. |
38 37 neels
|   |   | ✔ | ✔ | hNodeb | 3rd party 3G femto cell hardware to connect to OsmoHNBGW via Iuh |
39 5 neels
40 32 neels
1: PS is always an _addition_ to CS: even though these components do not handle PS requests, you need to have these to be able to setup and register with a network, which is a prerequisite for data services.
41 28 neels
42 32 neels
2: For the GGSN to successfully route packets to an internet uplink, the system needs to have
43 28 neels
* 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 33 neels
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
50 34 neels
# Replace 'eth0' with your ethernet device name, or use '*' for all.
51
</pre>
52 18 neels
53 5 neels
h1. Have to Know
54 10 neels
55
Each program features a detailed [[Osmocom Manuals|user manual]], your primary source of information to expand on the setup described here.
56 24 laforge
57 5 neels
Osmocom offers [[Binary_Packages|compiled packages for various distributions]]. If you're up to it, you may also [[Build from Source]].
58
59
Each Osmocom program typically has
60
61 1 neels
* a distinct configuration file;
62 25 neels
* a VTY telnet console for live interaction;
63 1 neels
* a CTRL interface for live interaction from 3rd party programs.
64 18 neels
65
See [[Port Numbers]] to find out which program runs VTY on which port.
66
67
h1. Configuration Examples
68 5 neels
69 6 neels
h2. OsmoHLR
70
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 26 neels
79 6 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 7 neels
81 6 neels
* There is a default point code, currently 0.23.1 (in 8.8.3 point code format).
82
* OsmoMSC will by default look for OsmoSTP on localhost's M3UA port, 2905.
83 7 neels
84 6 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
86 38 neels
You only need to set up your MCC, MNC.
87
88
<pre>
89
network
90
 network country code 1
91
 mobile network code 1
92
</pre>
93 9 neels
94 40 neels
h2. OsmoMGW for OsmoMSC
95 27 neels
96
*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.*
97 9 neels
98
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.
99
100
Its RTP IP address must be reachable by the BTS / the femto cell.
101
102 39 neels
* 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), which is the default, and your config file may remain entirely empty.
103
* With a separate BTS and/or RNC (e.g. 3G femto cell or nanoBTS), make sure to configure an IP address that is reachable by the hNodeB and BTS:
104 9 neels
105
*osmo-mgw.cfg*
106
<pre>
107
mgcp
108
  local ip 192.168.0.3
109
  bind ip 192.168.0.3
110
</pre>
111
112 40 neels
The default is to allow any MGW / BTS / femto cell IP address to connect.
113 1 neels
114 40 neels
h2. OsmoMGW for OsmoBSC
115 1 neels
116 40 neels
Since recently, OsmoBSC also requires an OsmoMGW instance to run alongside it. In a setup where OsmoBSC and OsmoMGW run on the same box, they may in fact share the same OsmoMGW instance. It is semantically more clear to run a separate OsmoMGW instance for the OsmoBSC, which then needs to operate on a different network interface to not interfere with OsmoMSC's MGW -- select a different address for @local ip@ and @bind ip@ above, for example:
117
118
*osmo-mgw-for-bsc.cfg*
119
<pre>
120
mgcp
121
  local ip 127.0.0.2
122
  bind ip 127.0.0.2
123
</pre>
124
125
Remember to set the mgw address in osmo-bsc.cfg accordingly (see below).
126 9 neels
127
h2. OsmoSTP
128
129
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.
130
131
The basic configuration that permits dynamic routing is:
132
133
*osmo-stp.cfg*
134
<pre>
135
cs7 instance 0
136
 xua rkm routing-key-allocation dynamic-permitted
137
 listen m3ua 2905
138
  accept-asp-connections dynamic-permitted
139 11 neels
</pre>
140
141
h2. OsmoBSC
142
143
OsmoBSC needs to register with OsmoSTP, and contact the MSC by its point code.
144
145
OsmoBSC also needs complete configuration of all connected BTS. This example shows configuration for a sysmoBTS.
146
147
Furthermore, some network properties need to be set.
148 15 neels
149
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:
150
151 11 neels
*osmo-bsc.cfg* for voice only
152
<pre>
153
network
154
 network country code 901
155
 mobile network code 70
156
 mm info 1
157
 short name Osmocom
158
 long name Osmocom
159
 auth policy closed
160
 encryption a5 0
161
 bts 0
162
  type sysmobts
163
  band GSM-1800
164
  cell_identity 0
165
  location_area_code 23
166
  ip.access unit_id 1800 0
167
  gprs mode none
168
  trx 0
169
   rf_locked 0
170
   arfcn 868
171
   nominal power 23
172
   timeslot 0
173
    phys_chan_config CCCH+SDCCH4
174
   timeslot 1
175
    phys_chan_config SDCCH8
176
   timeslot 2
177
    phys_chan_config TCH/H
178
   timeslot 3
179
    phys_chan_config TCH/H
180
   timeslot 4
181
    phys_chan_config TCH/H
182
   timeslot 5
183
    phys_chan_config TCH/H
184
   timeslot 6
185
    phys_chan_config TCH/H
186
   timeslot 7
187
    phys_chan_config TCH/H
188
cs7 instance 0
189
 ! osmo-bsc's own point code
190
 point-code 0.42.0
191
 ! address book entry named 'msc_remote', used below
192
 sccp-address msc_remote
193
  point-code 0.23.1
194
msc 0
195 1 neels
 msc-addr msc_remote
196 15 neels
</pre>
197
198
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:
199
200
201
*osmo-bsc.cfg* for voice and data service
202
<pre>
203
network
204
 network country code 901
205
 mobile network code 70
206
 mm info 1
207
 short name Osmocom
208
 long name Osmocom
209
 auth policy closed
210
 encryption a5 0
211
 bts 0
212
  type sysmobts
213
  band GSM-1800
214
  cell_identity 0
215
  location_area_code 23
216
  ip.access unit_id 1800 0
217
  gprs mode gprs
218
  trx 0
219
   rf_locked 0
220
   arfcn 868
221
   nominal power 23
222
   timeslot 0
223
    phys_chan_config CCCH+SDCCH4
224
   timeslot 1
225
    phys_chan_config SDCCH8
226
   timeslot 2
227
    phys_chan_config TCH/F_TCH/H_PDCH
228
   timeslot 3
229
    phys_chan_config TCH/F_TCH/H_PDCH
230
   timeslot 4
231
    phys_chan_config TCH/F_TCH/H_PDCH
232
   timeslot 5
233
    phys_chan_config TCH/F_TCH/H_PDCH
234
   timeslot 6
235
    phys_chan_config TCH/F_TCH/H_PDCH
236
   timeslot 7
237
    phys_chan_config PDCH
238
cs7 instance 0
239
 ! osmo-bsc's own point code
240
 point-code 0.42.0
241
 ! address book entry named 'msc_remote', used below
242
 sccp-address msc_remote
243
  point-code 0.23.1
244
msc 0
245
 msc-addr msc_remote
246
</pre>
247 12 neels
248 1 neels
h2. OsmoHNBGW
249 16 neels
250 1 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.)
251 16 neels
252
OsmoHNBGW needs to connect to OsmoSTP for routing, and needs to know the MSC and SGSN point codes.
253
254 12 neels
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.
255
256
*osmo-hnbgw.cfg*
257
<pre>
258
cs7 instance 0
259
 ! OsmoHNBGW's own local point code
260
 point-code 0.3.0
261
 ! Address book entries, used below
262
 sccp-address msc
263
  point-code 0.23.1
264
 sccp-address sgsn
265
  point-code 0.23.2
266
hnbgw
267
 iuh
268
  local-ip 192.168.0.3
269
 iucs
270
  remote-addr msc
271
 iups
272
  remote-addr sgsn
273 13 neels
</pre>
274
275
h2. OsmoGGSN
276 14 neels
277 13 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.
278
279
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.
280
281
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.
282
283 1 neels
OsmoGGSN furthermore indicates DNS servers, as well as an IPv4 address range to assign to subscribers' PDP contexts.
284 14 neels
285 13 neels
*osmo-ggsn.cfg*
286
<pre>
287
ggsn ggsn0
288
 gtp bind-ip 127.0.0.2
289
 apn internet
290
  tun-device tun4
291
  type-support v4
292
  ip dns 0 192.168.100.1
293
  ip dns 1 8.8.8.8
294 1 neels
  ip ifconfig 176.16.222.0/24
295 14 neels
  ip prefix dynamic 176.16.222.0/24
296
</pre>
297
298
h2. OsmoSGSN
299
300
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.
301
302
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).
303
304
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.
305
306
Finally, OsmoSGSN needs access to OsmoHLR to access subscriber data. Set 'auth-policy remote' to use the HLR for subscriber authorization. The default 
307
308
*osmo-sgsn.cfg*
309
<pre>
310
sgsn
311
 gtp local-ip 192.168.0.3
312 1 neels
 ggsn 0 remote-ip 192.168.0.142
313 14 neels
 auth-policy remote
314 13 neels
 gsup remote-ip 127.0.0.1
315 17 neels
</pre>
316 18 neels
317 17 neels
h1. Running Examples
318
319
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.
320
321
When installed from debian or opkg feeds, you will find the systemd service files in /lib/systemd/system/.
322
323
Re/starting and stopping then works like this:
324
325
<pre>
326
systemctl restart osmo-hlr
327 1 neels
systemctl stop osmo-hlr
328
</pre>
329
330 36 neels
It can be useful to have an @osmo-all@ script to re/start or stop all components at once, edit to pick yours:
331
332
*osmo-all* script
333
<pre>
334
#!/bin/sh
335
cmd="${1:-start}"
336
set -ex
337
systemctl $cmd osmo-hlr osmo-msc osmo-mgw osmo-ggsn osmo-sgsn osmo-stp osmo-bsc osmo-hnbgw osmo-bts-sysmo osmo-pcu 
338
</pre>
339
340
which allows
341
342
<pre>
343
./osmo-all restart
344
./osmo-all status
345
./osmo-all stop
346
</pre>
347
348 1 neels
For illustration, the manual command invocations for the components would look like this:
349
350
<pre>
351
osmo-hlr -l hlr.db -c osmo-hlr.cfg
352
osmo-msc -c osmo-msc.cfg
353
osmo-mgw -c osmo-mgw.cfg
354 36 neels
osmo-ggsn -c osmo-ggsn.cfg
355
osmo-sgsn -c osmo-sgsn.cfg
356 1 neels
osmo-stp -c osmo-stp.cfg
357
osmo-bsc -c osmo-bsc.cfg
358
osmo-hnbgw -c osmo-hnbgw.cfg
359 36 neels
# on a 2G sysmoBTS:
360
osmo-bts-sysmo -c osmo-bts.cfg -s -M
361
osmo-pcu -c osmo-pcu.cfg
362 18 neels
</pre>
363
364
h1. Logging Examples
365
366
Osmocom programs have a common logging mechanism, configurable by the config files as well as the telnet VTY.
367
368
Depending on the system's logging configuration, logs may by default be visible in /var/log/daemon.log, or by using journalctl:
369
370
<pre>
371
journalctl -f -u osmo-hlr
372
</pre>
373
374 35 neels
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'; you may also need to 'systemctl unmask systemd-journald.service systemd-jounald.socket'. Logging will only start appearing for components that were restarted after these changes.
375 19 neels
376
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:
377
378
<pre>
379
$ telnet localhost 4254
380
OsmoMSC> logging enable 
381
OsmoMSC> logging level ?
382
  all      Global setting for all subsystems
383
  rll      A-bis Radio Link Layer (RLL)
384
  cc       Layer3 Call Control (CC)
385
  mm       Layer3 Mobility Management (MM)
386 35 neels
  [...]
387
OsmoMSC> logging level all ?
388 19 neels
everything debug      info       notice     error      fatal      
389 35 neels
OsmoMSC> logging level all debug 
390 19 neels
OsmoMSC> logging filter all 1
391 20 neels
</pre>
392
393 1 neels
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)