Project

General

Profile

Osmocom Network In The Box » History » Version 55

neels, 11/11/2017 03:13 AM

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 55 neels
h2. Topology
54
55
{{graphviz_link()
56
digraph G {
57
  rankdir = LR;
58
59
  MS -> BTS -> BSC -> MSC -> HLR
60
}
61
}}
62
63 5 neels
h1. Have to Know
64 10 neels
65
Each program features a detailed [[Osmocom Manuals|user manual]], your primary source of information to expand on the setup described here.
66 24 laforge
67 5 neels
Osmocom offers [[Binary_Packages|compiled packages for various distributions]]. If you're up to it, you may also [[Build from Source]].
68
69
Each Osmocom program typically has
70
71 1 neels
* a distinct configuration file;
72 25 neels
* a VTY telnet console for live interaction;
73 1 neels
* a CTRL interface for live interaction from 3rd party programs.
74 18 neels
75
See [[Port Numbers]] to find out which program runs VTY on which port.
76
77
h1. Configuration Examples
78 5 neels
79 6 neels
h2. OsmoHLR
80
81 50 neels
osmo-hlr will automatically bootstrap an empty subscriber database. See the [[Osmocom Manuals|manual]] on how to add one or more subscribers -- if you don't know your IMSI, it can be useful to attempt a connection and watch the OsmoHLR log for a rejected IMSI.
82 6 neels
83 50 neels
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 with MSC and SGSN on the same machine as the HLR.
84 6 neels
85 48 neels
*osmo-hlr.cfg*
86
<pre>
87
# empty
88
</pre>
89
90 6 neels
h2. OsmoMSC
91
92
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.
93 26 neels
94 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.
95 7 neels
96 6 neels
* There is a default point code, currently 0.23.1 (in 8.8.3 point code format).
97
* OsmoMSC will by default look for OsmoSTP on localhost's M3UA port, 2905.
98 7 neels
99 51 neels
To direct RTP streams, OsmoMSC needs an OsmoMGW instance (see OsmoMGW below).
100 38 neels
101 51 neels
You only need to set up your MCC, MNC, and how to reach/use the MGW.
102 43 neels
103 49 neels
*osmo-msc.cfg*
104 38 neels
<pre>
105
network
106 53 neels
 network country code 901
107
 mobile network code 70
108 43 neels
msc
109 48 neels
 mgw remote-ip 192.168.0.5
110 45 neels
 mgw endpoint-range 1 32
111 38 neels
</pre>
112 9 neels
113 47 neels
h2. OsmoMGW
114 1 neels
115 52 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.
116
117 47 neels
You need an OsmoMGW to serve OsmoMSC's MGCP requests, and an OsmoMGW to serve OsmoBSC's MGCP requests. In fact, these two can be served by one single OsmoMGW instance. If you would like to keep two separate OsmoMGW instances, you need to take care that they don't attempt to bind to identical ports on the same IP address (for MGCP, but also for VTY and CTRL interfaces).
118
119
Consider that you have a 2G network with an external BTS (say a sysmoBTS), which means that you need your OsmoBSC's MGW instance to be reachable on a public interface. So far the MSC's MGW can be on a local loopback interface, it only needs to be reachable by the BSC's MGW and by the MSC.
120
121
If you also have a 3G femto cell, then the MSC's MGW instance also needs to be on a public interface. At this point you either need two public interface addresses, or you need to put one of the MGWs on a different MGCP port.
122
123
If you use one OsmoMGW for both BSC and MSC, there are no port conflicts, but you need to take care that MSC and BSC use differing endpoint identifiers, or they will interfere with each others' RTP stream configurations.
124
125
To increase the likelihood that your first setup will work out, below examples pick distinct endpoint ranges so that MSC and BSC could use the same MGW instance, while at the same time provide config files that allow running two MGWs on the same public IP address.
126
127
h3. OsmoMGW for OsmoMSC
128 1 neels
129 9 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. For osmo-bsc_mgcp, you can use the identical config as shown for the MSC's MGW here.*
130 47 neels
131 9 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 omit the 'bind ip'.
132
* 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:
133 1 neels
134 48 neels
*osmo-mgw-for-msc.cfg*
135 1 neels
<pre>
136 40 neels
mgcp
137 47 neels
 bind ip 192.168.0.5
138
 number endpoints 64
139 1 neels
</pre>
140
141 47 neels
h3. OsmoMGW for OsmoBSC
142 1 neels
143 47 neels
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, as long as BSC and MSC use different endpoint identifiers.
144 1 neels
145 47 neels
It is semantically more clear to run a separate OsmoMGW instance for the OsmoBSC, which then needs to not interfere with the other MGW's ports, for example:
146 1 neels
147
*osmo-mgw-for-bsc.cfg*
148 41 neels
<pre>
149 40 neels
mgcp
150 47 neels
 bind ip 192.168.0.5
151
 # default port, used for MSC's MGW, is 2427
152
 bind port 12427
153
 number endpoints 64
154 41 neels
line vty
155 47 neels
 # default VTY interface, used for MSC's MGW, is 127.0.0.1
156 41 neels
 bind 127.0.0.2
157 40 neels
</pre>
158
159 54 neels
Note that osmo-bsc.cfg below sets the 'mgw remote-port' to the 'bind port' configured here (the method to run two MGW on the same public IP address), and picks a different 'mgw endpoint' range than the OsmoMSC (the method to use the same MGW for both BSC and MSC) -- these are two separate, redundant measures, and you usually would pick only one of them.
160 9 neels
161
h2. OsmoSTP
162
163
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.
164
165
The basic configuration that permits dynamic routing is:
166
167
*osmo-stp.cfg*
168
<pre>
169
cs7 instance 0
170
 xua rkm routing-key-allocation dynamic-permitted
171
 listen m3ua 2905
172 11 neels
  accept-asp-connections dynamic-permitted
173
</pre>
174
175
h2. OsmoBSC
176
177 1 neels
OsmoBSC needs to register with OsmoSTP, and contact the MSC by its point code.
178 11 neels
179 48 neels
OsmoBSC needs to contact an OsmoMGW to direct RTP streams between BTS and the MSC's MGW, as discussed above under "OsmoMGW".
180 42 neels
181 11 neels
OsmoBSC also needs complete configuration of all connected BTS. This example shows configuration for a sysmoBTS.
182 15 neels
183
Furthermore, some network properties need to be set.
184
185 11 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:
186 1 neels
187
*osmo-bsc.cfg* for voice only
188
<pre>
189
network
190 48 neels
 network country code 901
191
 mobile network code 70
192 43 neels
 mm info 1
193 11 neels
 short name OsmoBSC
194
 long name OsmoBSC
195
 bts 0
196
  type sysmobts
197
  band GSM-1800
198 1 neels
  location_area_code 23
199 11 neels
  ip.access unit_id 1800 0
200
  trx 0
201
   rf_locked 0
202
   arfcn 868
203
   nominal power 23
204 48 neels
   max_power_red 20
205 11 neels
   timeslot 0
206
    phys_chan_config CCCH+SDCCH4
207
   timeslot 1
208
    phys_chan_config SDCCH8
209
   timeslot 2
210
    phys_chan_config TCH/H
211
   timeslot 3
212
    phys_chan_config TCH/H
213
   timeslot 4
214
    phys_chan_config TCH/H
215 1 neels
   timeslot 5
216
    phys_chan_config TCH/H
217
   timeslot 6
218
    phys_chan_config TCH/H
219
   timeslot 7
220
    phys_chan_config TCH/H
221 48 neels
e1_input
222
 e1_line 0 driver ipa
223 15 neels
msc 0
224 48 neels
 mgw remote-ip 192.168.0.5
225
 mgw remote-port 12427
226
 mgw endpoint-range 33 64
227
 allow-emergency deny
228
 codec-list hr3
229 15 neels
</pre>
230
231
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:
232
233
234
*osmo-bsc.cfg* for voice and data service
235 43 neels
<pre>
236 48 neels
# todo
237 15 neels
</pre>
238 12 neels
239 1 neels
h2. OsmoHNBGW
240
241 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.)
242
243
OsmoHNBGW needs to connect to OsmoSTP for routing, and needs to know the MSC and SGSN point codes.
244 12 neels
245
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.
246
247
*osmo-hnbgw.cfg*
248
<pre>
249
cs7 instance 0
250
 ! OsmoHNBGW's own local point code
251
 point-code 0.3.0
252
 ! Address book entries, used below
253
 sccp-address msc
254
  point-code 0.23.1
255
 sccp-address sgsn
256
  point-code 0.23.2
257
hnbgw
258
 iuh
259 48 neels
  local-ip 192.168.0.5
260 12 neels
 iucs
261
  remote-addr msc
262
 iups
263 13 neels
  remote-addr sgsn
264
</pre>
265
266 14 neels
h2. OsmoGGSN
267 13 neels
268
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.
269
270
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.
271
272
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.
273 1 neels
274 14 neels
OsmoGGSN furthermore indicates DNS servers, as well as an IPv4 address range to assign to subscribers' PDP contexts.
275 13 neels
276
*osmo-ggsn.cfg*
277
<pre>
278
ggsn ggsn0
279
 gtp bind-ip 127.0.0.2
280
 apn internet
281
  tun-device tun4
282
  type-support v4
283
  ip dns 0 192.168.100.1
284 1 neels
  ip dns 1 8.8.8.8
285 14 neels
  ip ifconfig 176.16.222.0/24
286
  ip prefix dynamic 176.16.222.0/24
287
</pre>
288
289
h2. OsmoSGSN
290
291
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.
292
293
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).
294
295
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.
296
297
Finally, OsmoSGSN needs access to OsmoHLR to access subscriber data. Set 'auth-policy remote' to use the HLR for subscriber authorization. The default 
298
299 1 neels
*osmo-sgsn.cfg*
300
<pre>
301 14 neels
sgsn
302
 gtp local-ip 192.168.0.3
303
 ggsn 0 remote-ip 192.168.0.142
304 1 neels
 auth-policy remote
305 14 neels
 gsup remote-ip 127.0.0.1
306 13 neels
</pre>
307 17 neels
308 18 neels
h1. Running Examples
309 17 neels
310
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.
311
312
When installed from debian or opkg feeds, you will find the systemd service files in /lib/systemd/system/.
313
314
Re/starting and stopping then works like this:
315
316
<pre>
317
systemctl restart osmo-hlr
318
systemctl stop osmo-hlr
319 1 neels
</pre>
320
321
It can be useful to have an @osmo-all@ script to re/start or stop all components at once, edit to pick yours:
322 36 neels
323
*osmo-all* script
324
<pre>
325
#!/bin/sh
326
cmd="${1:-start}"
327
set -ex
328
systemctl $cmd osmo-hlr osmo-msc osmo-mgw osmo-ggsn osmo-sgsn osmo-stp osmo-bsc osmo-hnbgw osmo-bts-sysmo osmo-pcu 
329
</pre>
330
331
which allows
332
333
<pre>
334
./osmo-all restart
335
./osmo-all status
336
./osmo-all stop
337
</pre>
338
339 1 neels
For illustration, the manual command invocations for the components would look like this:
340
341
<pre>
342
osmo-hlr -l hlr.db -c osmo-hlr.cfg
343
osmo-msc -c osmo-msc.cfg
344 48 neels
osmo-mgw -c osmo-mgw-for-msc.cfg
345
osmo-mgw -c osmo-mgw-for-bsc.cfg
346 36 neels
osmo-ggsn -c osmo-ggsn.cfg
347 1 neels
osmo-sgsn -c osmo-sgsn.cfg
348
osmo-stp -c osmo-stp.cfg
349
osmo-bsc -c osmo-bsc.cfg
350 36 neels
osmo-hnbgw -c osmo-hnbgw.cfg
351
# on a 2G sysmoBTS:
352
osmo-bts-sysmo -c osmo-bts.cfg -s -M
353 18 neels
osmo-pcu -c osmo-pcu.cfg
354
</pre>
355
356
h1. Logging Examples
357
358
Osmocom programs have a common logging mechanism, configurable by the config files as well as the telnet VTY.
359
360
Depending on the system's logging configuration, logs may by default be visible in /var/log/daemon.log, or by using journalctl:
361
362
<pre>
363
journalctl -f -u osmo-hlr
364
</pre>
365 35 neels
366 19 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.
367
368
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:
369
370
<pre>
371
$ telnet localhost 4254
372
OsmoMSC> logging enable 
373
OsmoMSC> logging level ?
374
  all      Global setting for all subsystems
375
  rll      A-bis Radio Link Layer (RLL)
376
  cc       Layer3 Call Control (CC)
377 35 neels
  mm       Layer3 Mobility Management (MM)
378
  [...]
379 19 neels
OsmoMSC> logging level all ?
380 35 neels
everything debug      info       notice     error      fatal      
381 19 neels
OsmoMSC> logging level all debug 
382 20 neels
OsmoMSC> logging filter all 1
383
</pre>
384 1 neels
385
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)