Project

General

Profile

Osmocom Network In The Box » History » Version 163

neels, 12/08/2023 01:26 AM

1 1 neels
h1. Osmocom Network In The Box
2 126 fixeria
3
{{>toc}}
4 1 neels
5 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.
6 21 neels
7 146 neels
*If this documentation is inaccurate or has you stumped, let's improve it!*
8
Contact us:
9
10 153 laforge
* #osmocom on libera.chat IRC
11 161 laforge
* the openbsc@lists.osmocom.org [[Mailing Lists|mailing list]]
12
* our new "Discourse forum":https://discourse.osmocom.org/c/cni
13 146 neels
14 68 neels
h1. OsmoNITB R.I.P., long live the Network In The Box
15 1 neels
16 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.
17 1 neels
18 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.
19 1 neels
20 2 neels
To migrate from OsmoNITB to the new separate programs, see the [[OsmoNITB Migration Guide]].
21
22 68 neels
h1. Part of this Complete Network
23 2 neels
24 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.
25 2 neels
26 32 neels
Here is a table of the components you need:
27 1 neels
28 32 neels
|\4. *Required for*  |/3. *Program* |/3. *Description* |
29
|\2. *2G*  |\2. *3G* |
30
| *CS* | *PS* | *CS* | *PS* |
31 92 neels
| ✔ | ✔ | ✔ | ✔ | [[Osmocom Network In The Box#OsmoHLR|OsmoHLR]] | Home Location Register, stores subscriber IMSI, phone number and auth tokens. |
32 99 neels
| ✔ | (1) | ✔ (3) | (1) | [[Osmocom Network In The Box#OsmoMSC|OsmoMSC]] | Mobile Switching Center, handles signalling, i.e. attach/detach of subscribers, call establishment, messaging (SMS and USSD). |
33 92 neels
| ✔ |   | ✔ |   | [[Osmocom Network In The Box#OsmoMGW|OsmoMGW]] | Media Gateway, is instructed by the MSC and/or the BSC to direct RTP streams for active voice calls. |
34
| ✔ | ✔ | ✔ | ✔ | [[Osmocom Network In The Box#OsmoSTP|OsmoSTP]] | Signal Transfer Point, routes SCCP messages between MSC, BSC, HNBGW and for 3G also the SGSN. |
35
| ✔ | (1) |   |   | [[Osmocom Network In The Box#OsmoBSC|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". |
36
|   |   | ✔ | ✔ | [[Osmocom Network In The Box#OsmoHNBGW|OsmoHNBGW]] | 3G HomeNodeB Gateway, receives the Iuh protocol from a 3G femto cell and forwards to MSC and SGSN by SCCP/M3UA via OsmoSTP. |
37
|   | ✔ (2) |   | ✔ (2) | [[Osmocom Network In The Box#OsmoGGSN|OsmoGGSN]] | Gateway GPRS Support Node, "opens" GTP tunnels received from SGSNs to internet uplink. |
38 99 neels
|   | ✔ |   | ✔ (3) | [[Osmocom Network In The Box#OsmoSGSN|OsmoSGSN]] | Serving GPRS Support Node, handles signalling, i.e. attach/detach of subscribers and PDP contexts. |
39 92 neels
| ✔ | (1) |   |   | [[Osmocom Network In The Box#OsmoBTS|OsmoBTS]] | for 2G networks, drives the TRX and ties to the BSC via Abis-interface. |
40
|   | ✔ |   |   | [[Osmocom Network In The Box#OsmoPCU|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. |
41 37 neels
|   |   | ✔ | ✔ | hNodeb | 3rd party 3G femto cell hardware to connect to OsmoHNBGW via Iuh |
42 145 neels
|   |   |   |   | [[osmo-sip-connector|OsmoSIPConnector]] | Optional: switch OsmoMSC to external MNCC and forward Call Control and RTP to a PBX of your choice. |
43 5 neels
44 99 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. That is mostly due to policy by the mobile phones, theoretically they could accept a network without voice service.
45 1 neels
46 32 neels
2: For the GGSN to successfully route packets to an internet uplink, it needs a tun device set up and usually IP masquerading/forwarding enabled. Please refer to the OsmoGGSN manual for more details.
47 99 neels
48
3: If building from source, remember to build with --enable-iu. (Our binary packages are built with --enable-iu.)
49 18 neels
50 68 neels
h2. Topology
51 55 neels
52
{{graphviz_link()
53 154 neels
54
55 55 neels
digraph G {
56
  rankdir = LR;
57 56 neels
  
58
  MS [label="MS\n(2G phone)"]
59
  UE [label="UE\n(3G phone)"]
60 143 neels
  PBX [label="PBX\nAsterisk, FreeSwitch,\nKamailio, Yate, ..."]
61 1 neels
62 56 neels
  subgraph cluster_bts {
63
    BTS [rank="min"]
64
    PCU [rank="min"]
65
  }
66
67 1 neels
  subgraph cluster_msc_mgw {
68 154 neels
    style=dotted
69 56 neels
    MSC
70 1 neels
    MGW1 [label="MGW"]
71 154 neels
    MSC -> MGW1 [label="MGCP",constraint=false]
72 56 neels
  }
73 1 neels
74 56 neels
  subgraph cluster_bsc_mgw {
75 154 neels
    style=dotted
76 1 neels
    BSC
77
    MGW2 [label="MGW"]
78 154 neels
    BSC -> MGW2 [label="MGCP",constraint=false]
79 1 neels
  }
80
81 154 neels
  subgraph cluster_hnbgw_mgw_upf {
82
    style=dotted
83
    MGW3 [label="MGW"]
84
    UPF
85
    HNBGW
86
    HNBGW -> MGW3 [label="MGCP",constraint=false]
87
    HNBGW -> UPF [label="PFCP",constraint=false]
88
  }
89
90 1 neels
  hNodeB [shape="box",label="hNodeB\n(3G femto cell)"]
91
92 154 neels
  MS -> BTS [label="Um",style="bold"]
93
  MS -> PCU [style="dashed,bold"]
94 61 neels
95 154 neels
  BTS -> BSC [label="Abis/IP",style=bold]
96 58 neels
  STP [label="STP\n(SCCP/M3UA)"]
97 154 neels
  BSC -> STP -> MSC [label="A",style=bold]
98
  MSC -> HLR [label="\nGSUP",style=bold]
99
  SGSN -> HLR [label="GSUP",style="dashed,bold"]
100
  UE -> hNodeB [label="Uu",style=bold]
101
  UE -> hNodeB [style="dashed,bold"]
102
  hNodeB -> HNBGW [label="Iuh",style="bold"]
103
  STP2 [label="STP\n(SCCP/M3UA)"]
104
  HNBGW -> STP2 -> SGSN [label="IuPS",style="dashed,bold"]
105
  HNBGW -> STP2 -> MSC [label="IuCS",style="bold"]
106
  PCU -> SGSN [label="Gb",style="dashed,bold"]
107
  SGSN -> GGSN [label="GTP-C",style="dashed,bold"]
108 1 neels
  SGSN -> GGSN [label="GTP-U(2G)",style="dashed"]
109 154 neels
  hNodeB -> UPF -> GGSN [label="GTP-U(3G)",style="dashed"]
110 143 neels
  GGSN -> internet [label="tun",style="dashed"]
111
112
  BTS -> MGW2 -> MGW1 [label="RTP"]
113
  MGW1 -> MGW1 [label="RTP"]
114
  MGW2 -> MGW2 [label="RTP (LCLS)"]
115 154 neels
  hNodeB -> MGW3 [label="IuUP/RTP",constraint=false]
116
  MGW3 -> MGW1 [label="IuUP/RTP"]
117 103 neels
118 154 neels
  MSC -> SIPConnector [label="MNCC socket",style=bold]
119 56 neels
120 154 neels
  SIPConnector -> PBX [label="SIP",style=bold]
121 55 neels
  MGW1 -> PBX [label="RTP"]
122
123 5 neels
  A, B, C, D [style="invisible"]
124 10 neels
  A -> B [label="data (PS)",style="dashed"]
125
  C -> D [label="voice/SMS/USSD (CS)"]
126 24 laforge
127 5 neels
}
128 154 neels
129 5 neels
130
}}
131 1 neels
132 25 neels
h1. Have to Know
133 1 neels
134 18 neels
Each program features a detailed [[Osmocom Manuals|user manual]], your primary source of information to expand on the setup described here.
135 102 neels
136 18 neels
Osmocom offers [[Binary_Packages|compiled packages for various distributions]]. If you're up to it, you may also [[Build from Source]].
137 147 neels
138
Each Osmocom program typically has
139
140
* a distinct configuration file;
141
* a VTY telnet console for live interaction;
142
* a CTRL interface for live interaction from 3rd party programs.
143 148 neels
144 147 neels
See [[Port Numbers]] to find out which program runs what services on which port.
145 18 neels
146 158 msuraev
h2. Realtime scheduling hierarchy
147
148
The time-critical components use realtime scheduling policy (round-robin by default) - see https://man7.org/linux/man-pages/man7/sched.7.html
149
150 159 msuraev
Note: this does not imply we require realtime kernel - the scheduler will set it's priorities regardless of it. The realtime version of the GNU/Linux kernel will provide additional guarantees on the absense of jitter and meeting the process execution deadlines which are nice but not strictly required in our case.
151
152 158 msuraev
The priority hierarchy of those components looks as follows (higher priority on top):
153
{{graphviz_link()
154
155
digraph G {
156
  
157
rankdir = LR;
158
 subgraph cluster_legend {
159
    style=dotted
160
161
  A, B, C, D [style="invisible"]
162
 A -> B [label="normal",style="dashed,bold"]
163
 C -> D [label="realtime",style=bold]
164
  }
165
166
167
}
168
169
}}
170
171
{{graphviz_link()
172
173
digraph G {
174
  
175
  TRX [label="OsmoTRX"]
176
  BTS [label="OsmoBTS"]
177
  MGW [label="OsmoMGW"]
178
  PCU [label="OsmoPCU"]
179
  XXX [label="The rest of the system"]
180
 
181
  TRX -> BTS [style=bold]
182 159 msuraev
  TRX -> PCU [style=bold]
183 1 neels
  BTS -> MGW [style=bold]
184 159 msuraev
  PCU -> MGW [style=bold]
185 158 msuraev
  MGW -> XXX [style="dashed,bold"]
186
}
187
188
}}
189
190 5 neels
h1. The State of 3G Voice
191 83 neels
192 163 neels
IuCS doesn't talk plain RTP, it talks IuUP inside the RTP payload (!). That is another header, and the AMR bits inside that are mangled and shifted around, even though the underlying codec is still AMR.
193 1 neels
194 163 neels
We fully support IuUP in OsmoMGW, OsmoHNBGW and OsmoMSC.
195
OsmoMGW is typically instructed by OsmoMSC to transcode IuUP to plain AMR.
196 1 neels
197 163 neels
TFO voice call interop between 2G and 3G is possible:
198
199
* So far all hNodeB we have tested are capable of 12k2 AMR, so that it is interoperable with AMR-FR 12k2 on a 2G TCH/F timeslot.
200
* Some hNodeB can be instructed via standard RANAP/Iu messaging to use AMR-HR compatible AMR rates, so that TCH/H is possible depending on the hNodeB.
201
202
At the time of writing, codec negotiation in OsmoMSC is still being polished to properly manage codecs choices between two call legs.
203 72 neels
204 6 neels
h1. Configuration Examples
205 50 neels
206 1 neels
Here is a tarball of the config files discussed below: attachment:nitb.tar
207 127 neels
208
h2. OsmoHLR
209 1 neels
210
[[OsmoHLR:]] is the Home Location Register: it stores subscriber IMSI, phone number and auth tokens. This is where you configure who is allowed on your network and who has which phone number. It also handles USSD services (like "*100#").
211 127 neels
212
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. To migrate subscribers from an older OsmoNITB database, see the [[OsmoNITB migration guide]].
213
214
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.
215
216
This example optionally configures two USSD services and logging.
217
218
*osmo-hlr.cfg* (download: attachment:nitb.tar)
219
<pre>
220
hlr
221
 ussd route prefix *#100# internal own-msisdn
222 128 neels
 ussd route prefix *#101# internal own-imsi
223 48 neels
224
log stderr
225 97 neels
 logging filter all 1
226
 logging print extended-timestamp 1
227 6 neels
 logging print category 1
228 1 neels
 logging print category-hex 0
229 93 neels
 logging print level 1
230 66 neels
 logging print file basename last
231 6 neels
 logging level set-all debug
232 26 neels
</pre>
233 6 neels
234 7 neels
Once your HLR is running, you will want to add subscribers with authentication keys to the HLR database. Please refer to the OsmoHLR [[Osmocom Manuals]], section "Managing Subscribers".
235 86 neels
236 6 neels
h2. OsmoMSC
237 7 neels
238 51 neels
[[OsmoMSC:]] is the Mobile Switching Center: it handles signalling, i.e. attach/detach of subscribers, call establishment, messaging (SMS and USSD). The OsmoMSC is your central "manager" of the network.
239 38 neels
240 51 neels
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.
241 43 neels
242 108 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.
243 1 neels
244 38 neels
* There is a default point code, currently 0.23.1 (in 8.8.3 point code format, see [[Point Codes]]).
245
* OsmoMSC will by default look for OsmoSTP on localhost's M3UA port, 2905.
246 53 neels
247
To direct RTP streams, OsmoMSC needs an OsmoMGW instance (see OsmoMGW below).
248 1 neels
249 134 neels
You only need to set up your MCC, MNC, and how to reach/use the MGW.
250
251 128 neels
*osmo-msc.cfg* (download: attachment:nitb.tar)
252
<pre>
253
network
254
 network country code 901
255
 mobile network code 70
256 1 neels
msc
257 134 neels
 mgw remote-ip 192.168.0.9
258 128 neels
 # For nano3G:
259
 iu rab-assign-addr-enc x213
260 38 neels
 
261 47 neels
log stderr
262 1 neels
 logging filter all 1
263
 logging print extended-timestamp 1
264 93 neels
 logging print category 1
265 52 neels
 logging print category-hex 0
266 47 neels
 logging print level 1
267
 logging print file basename last
268
 logging level set-all info
269
</pre>
270
271
h2. OsmoMGW
272 105 neels
273
[[OsmoMGW:]] is the Media Gateway: it is instructed by the MSC and/or the BSC to direct RTP streams for active voice calls. The Media Gateway receives instructions in the form of MGCP messages from OsmoMSC/OsmoBSC. It forwards RTP streams directly between BTS, femto cells and remote endpoints, e.g. other MGW instances, and its job is to transcode between codecs (future).
274 47 neels
275 105 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).
276 47 neels
277
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.
278 1 neels
279 101 neels
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.
280
281 1 neels
You may decide to use one OsmoMGW for both BSC and MSC, if your network topology allows.
282 9 neels
(There used to be the need to separate the endpoint config for BSC and MSC, but now the MGW takes care of that automatically.)
283 1 neels
284 108 neels
To increase the likelihood that your first setup will work out, below examples pick distinct MGCP ports and VTY interfaces, which allows running two MGWs on the same public IP address.
285 48 neels
286 82 neels
h3. OsmoMGW for OsmoMSC
287 40 neels
288 82 neels
OsmoMGW listens for MGCP connections, by default on port 2427.
289 1 neels
290 129 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'.
291
* 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:
292
293
*osmo-mgw-for-msc.cfg* (download: attachment:nitb.tar)
294
<pre>
295
mgcp
296
 bind ip 192.168.0.9
297
line vty
298
 bind 127.0.0.1
299 1 neels
 
300
log stderr
301 47 neels
 logging filter all 1
302 1 neels
 logging print extended-timestamp 1
303 130 neels
 logging print category 1
304 1 neels
 logging print category-hex 0
305 124 neels
 logging print level 1
306 1 neels
 logging print file basename last
307 108 neels
 logging level set-all info
308 1 neels
</pre>
309 40 neels
310 82 neels
h3. OsmoMGW for OsmoBSC
311 47 neels
312
OsmoBSC also requires an OsmoMGW instance to run alongside it. In a setup where OsmoBSC and OsmoMSC can both reach it directly, they may in fact share the same OsmoMGW instance (endpoints are allocated dynamically).
313 41 neels
314 1 neels
It is semantically more clear to run a separate OsmoMGW instance for the OsmoBSC. When running on the same machine, though, then each MGW obviously needs to use different UDP ports, for example:
315
316 130 neels
*osmo-mgw-for-bsc.cfg* (download: attachment:nitb.tar)
317
<pre>
318
mgcp
319
 bind ip 192.168.0.9
320
 # default port is 2427 (is used for MSC's MGW)
321
 bind port 12427
322
line vty
323
 # default VTY interface is on 127.0.0.1 (used for MSC's MGW)
324
 bind 127.0.0.2
325
326 1 neels
log stderr
327 40 neels
 logging filter all 1
328 130 neels
 logging print extended-timestamp 1
329 1 neels
 logging print category 1
330 9 neels
 logging print category-hex 0
331
 logging print level 1
332 131 neels
 logging print file basename last
333 1 neels
 logging level set-all info
334 131 neels
335
</pre>
336 9 neels
337
Note that osmo-bsc.cfg below sets the 'mgw remote-port' to the 'bind port' configured here; if the MGWs run on distinct interfaces, the default ports will do in both cases.
338 108 neels
339 155 neels
h3. OsmoMGW for OsmoHNBGW
340
341
Since 2022, OsmoHNBGW also supports an MGW instance as a local hop for 3G related IuUP/RTP.
342
343
*osmo-mgw-for-hnbgw.cfg* (download: attachment:nitb.tar)
344
<pre>
345
mgcp
346
 bind ip 192.168.0.9
347
 bind port 22427
348
line vty
349
 bind 127.0.0.3
350
351
log stderr
352
 logging filter all 1
353
 logging print extended-timestamp 1
354
 logging print category 1
355
 logging print category-hex 0
356
 logging print level 1
357
 logging print file basename last
358
 logging level set-all info
359
360
</pre>
361
362
Note that osmo-hnbgw.cfg below sets the 'mgw remote-port' to the 'bind port' configured here; if the MGWs run on distinct interfaces, the default ports will do in both cases.
363
364 9 neels
h2. OsmoSTP
365
366
[[OsmoSTP:]] is the Signal Transfer Point; think of it like a network switch that quietly routes messages between components, for the SS7 system. You almost never need to look at its logging or configuration.
367
368 1 neels
OsmoSTP acts as a server for routing SCCP 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.
369 131 neels
370
The basic configuration that permits dynamic routing is:
371
372
*osmo-stp.cfg* (download: attachment:nitb.tar)
373
<pre>
374
cs7 instance 0
375
 xua rkm routing-key-allocation dynamic-permitted
376
 listen m3ua 2905
377
  accept-asp-connections dynamic-permitted
378 11 neels
379 1 neels
log stderr
380
 logging filter all 1
381 11 neels
 logging print extended-timestamp 1
382 93 neels
 logging print category 1
383 67 neels
 logging print category-hex 0
384 87 neels
 logging print level 1
385 11 neels
 logging print file basename last
386 132 neels
 logging level set-all info
387 42 neels
</pre>
388 132 neels
389 15 neels
h2. OsmoBSC
390
391 1 neels
[[OsmoBSC:]] is the 2G Base Station Controller: it manages logical channels and other lower level aspects for one or more 2G BTS. The BSC tells the MSC what the phones would like to do, and in turn the MSC tells the BSC to establish channels, page phones, and take care of the lower level BTS maintenance.
392 132 neels
393 15 neels
OsmoBSC needs to register with OsmoSTP, and contact the MSC by its point code. If not configured otherwise, it will use OsmoMSC's default point code to contact it, see [[Point Codes]].
394 83 neels
395 15 neels
OsmoBSC needs to contact an OsmoMGW on its MGCP port, to manage RTP streams between BTS and the MSC's MGW, as discussed above under "OsmoMGW".
396 108 neels
397 48 neels
OsmoBSC also needs complete configuration of all connected BTS -- usually the BTS side configures the phy, unit id and the BSC's remote address, and the BSC configures everything else over OML. This example shows configuration for a sysmoBTS.
398 75 neels
399
Furthermore, some network properties need to be set.
400 1 neels
401 75 neels
The 'gprs mode' determines whether packet switched access will be enabled. 'gprs mode none' switches off data services, it tells osmo-bts not to contact osmo-pcu to establish data service. Note that if you set 'gprs mode gprs' but fail to provide a working PCU, a phone may oscillate between BTS cells to try to establish GPRS service.
402 1 neels
403 75 neels
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 voice-and-data service based on Osmocom style dynamic timeslots:
404 1 neels
405 132 neels
*osmo-bsc.cfg* for voice and data service (download: attachment:nitb.tar)
406 75 neels
<pre>
407 132 neels
network
408 75 neels
 network country code 901
409 82 neels
 mobile network code 70
410 75 neels
 bts 0
411
  type sysmobts
412
  band GSM-1800
413
  location_area_code 23
414
  # This is the unit id that has to match the BTS configuration
415
  ip.access unit_id 1800 0
416
  codec-support fr hr amr
417
  gprs mode gprs
418
  gprs nsvc 0 remote ip 192.168.0.9
419
  gprs nsvc 0 remote udp port 23000
420
  gprs nsvc 0 local udp port 23000
421
  gprs nsvc 0 nsvci 1800
422
  gprs nsei 1800
423
  gprs cell bvci 1800
424
  trx 0
425
   rf_locked 0
426 1 neels
   arfcn 868
427 75 neels
   nominal power 23
428
   timeslot 0
429
    phys_chan_config CCCH+SDCCH4
430
   timeslot 1
431
    phys_chan_config SDCCH8
432
   timeslot 2
433
    phys_chan_config TCH/F_TCH/H_PDCH
434
   timeslot 3
435
    phys_chan_config TCH/F_TCH/H_PDCH
436 1 neels
   timeslot 4
437 75 neels
    phys_chan_config TCH/F_TCH/H_PDCH
438 82 neels
   timeslot 5
439 1 neels
    phys_chan_config TCH/F_TCH/H_PDCH
440
   timeslot 6
441
    phys_chan_config TCH/F_TCH/H_PDCH
442 132 neels
   timeslot 7
443
    phys_chan_config PDCH
444
e1_input
445
 e1_line 0 driver ipa
446
msc 0
447
 mgw remote-ip 192.168.0.9
448
 mgw remote-port 12427
449
 allow-emergency deny
450
 codec-list hr3
451 1 neels
452
log stderr
453
 logging filter all 1
454
 logging print extended-timestamp 1
455 93 neels
 logging print category 1
456 1 neels
 logging print category-hex 0
457 89 neels
 logging print level 1
458 1 neels
 logging print file basename last
459
 logging level set-all info
460
</pre>
461 108 neels
462 1 neels
h2. OsmoHNBGW
463 82 neels
464
[[OsmoHNBGW:]] is the 3G HomeNodeB Gateway, found in the osmo-iuh.git repository: it receives the Iuh protocol from a 3G femto cell, separates it into IuCS and IuPS and forwards to the MSC and SGSN.
465
466 133 neels
OsmoHNBGW needs to connect to OsmoSTP for routing, and needs to know the MSC and SGSN point codes. If omitted, it assumes OsmoSTP on 127.0.0.1 and uses the point codes that are default in OsmoMSC and OsmoSGSN, see [[Point Codes]].
467
468
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.
469
470
*osmo-hnbgw.cfg* (download: attachment:nitb.tar)
471
<pre>
472
hnbgw
473
 iuh
474
  local-ip 192.168.0.9
475 156 neels
 mgcp
476
  mgw remote-ip 192.168.0.9
477 157 neels
  mgw remote-port 22427
478 156 neels
 pfcp
479
  remote-addr 192.168.0.9
480 1 neels
 
481
log stderr
482 133 neels
 logging filter all 1
483 96 neels
 logging print extended-timestamp 1
484 133 neels
 logging print category 1
485 1 neels
 logging print category-hex 0
486 98 neels
 logging print level 1
487 95 neels
 logging print file basename last
488 1 neels
 logging level set-all info
489
</pre>
490 93 neels
491 1 neels
*NOTE:* For the nano3G, the MSC must encode X.213 style addresses in the RAB assignment, see osmo-msc.cfg, 'iu rab-assign-addr-enc x213'.
492 135 neels
493 1 neels
*NOTE:* To connect your femto cell to the HNBGW, see for example [[Configuring_the_ipaccess_nano3G]]
494 135 neels
495
*NOTE:* The 'hnbap-allow-tmsi' option is just a workaround for the nano3G passing a TMSI as UE-Register identity, which would normally have to be an IMSI.
496 156 neels
497
*NOTE:* Using a UPF as a GTP hop is optional
498
499
h2. OsmoUPF
500
501
[[OsmoUPF:]] provides a local hop for the GTP user plane of 3G PS: it receives PFCP instructions from OsmoHNBGW, and maps GTP tunnels from the hNodeB (Access) side to the GGSN (Core) side.
502
503
OsmoUPF requires to be run on Linux. OsmoUPF uses Linux kernel features to handle the GTP user plane in kernel space: the GTP module for encapsulation/decapsulation from/to "the internet", and netfilter (nftables) to forward GTP tunnels between two interfaces. The netfilter features in use require at least a Linux 5.17 kernel.
504
505
To be able to use the kernel featrues, the osmo-upf program needs to have cap_net_admin permissions, as given by the following command -- when installed from packages, this should already be taken care of:
506
507
<pre>
508
sudo setcap cap_net_admin+pe /usr/bin/osmo-upf
509
</pre>
510
511
The UPF paired with OsmoHNBGW will always do tunnel mapping, and never does encapsulation/decapsulation, which means that it does not require a GTP device.
512
513
*osmo-upf.cfg* (download: attachment:nitb.tar)
514
<pre>
515
pfcp
516
 local-addr 192.168.0.9
517
nft
518
 # netfilter requires no specifc configuration
519
gtp
520
 # if encaps/decaps of GTP to "the internet" is required, uncomment the following line:
521
 #dev create apn0
522
log stderr
523
 logging filter all 1
524
 logging print extended-timestamp 1
525
 logging print category 1
526
 logging print category-hex 0
527
 logging print level 1
528
 logging print file basename last
529
 logging level set-all info
530
</pre>
531 135 neels
532
h2. OsmoGGSN
533 1 neels
534 135 neels
[[OpenGGSN:|OsmoGGSN]] is the Gateway GPRS Support Node: it "opens" GTP tunnels received from SGSNs to internet uplink. To provide packet switched service, OsmoGGSN must offer GTP service to the OsmoSGSN.
535
536
Notably, both OsmoGGSN and OsmoSGSN must use identical GTP port numbers, which is an intrinsic requirement of the GTP protocol. Hence they must not run on the same IP address. Furthermore, for 2G networks, the SGSN must be reachable by the PCU and thus needs to be on a public interface if the BTS is a separate box; for 3G networks, the GGSN must be reachable by the hNodeB and thus needs to be on a public interface. So, to cover both, you need to have *two* public interfaces; this example uses 192.168.0.42, assumed to be an IP address available on the local ethernet interface.
537
538
Refer to your distribution on how to configure a second IP address.
539
540
(In an aside, this script would obtain a second address from your DHCP server:
541
542
<pre>
543
#!/bin/sh
544 82 neels
# usage: ./second_dhclient.sh eth0
545
dev="${1:-eth0}"
546 135 neels
nr="$(ip a | grep "^[0-9]*: $dev" | wc -l)"
547 82 neels
name="$(echo "$dev" | sed 's/[^0-9a-fA-F]//g' | head -c 1)"
548 1 neels
mac="ac:ac:1a:b0:a0:$name$nr"
549 13 neels
set -e -x
550 82 neels
sudo ip link add link $dev address $mac $dev.$nr type macvlan
551 13 neels
sudo dhclient $dev.$nr
552 82 neels
ip addr show dev $dev.$nr
553
</pre>
554
555
For this example to work, the DCHP server would need to assign to you the address 192.168.0.42.)
556
557
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.
558
559
It also needs access to a tun device with an address range available to subscribers' PDP contexts. 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 'apn0' device has been created ahead of time, with:
560 76 neels
561 13 neels
<pre>
562 85 neels
sudo ip tuntap add dev apn0 mode tun user $USER group $USER
563 13 neels
sudo ip addr add 192.168.42.0/24 dev apn0
564 85 neels
sudo ip link set apn0 up
565 84 neels
</pre>
566 108 neels
567 125 neels
IPv4 operation is enabled by default, but for future compatibility, it is good to indicate that explicitly.
568 13 neels
569 137 neels
OsmoGGSN furthermore indicates DNS servers, as well as an IPv4 address range to assign to subscribers' PDP contexts.
570
571
Note that the APN named in this config file (here "internet") needs to be configured on your phone, see [[Osmocom Network In The Box#APN-for-Data-Service|APN for Data Service]] below. With the @default-apn@ command, any unknown APN name will use that default APN instead, but still you usually have to define _some_ APN on your phone so that it even tries to connect to the data service.
572
573 13 neels
A profound part of GGSN configuration is the network setup of your system: you need to allow the packets to be routed between the subscribers and your internet uplink. See the [[Osmocom Manuals|OsmoGGSN User Manual]], section _Running OsmoGGSN_ / _Routing_.
574 82 neels
575 1 neels
*osmo-ggsn.cfg* (download: attachment:nitb.tar)
576
NOTE: this configuration requires the _apn0_ tun device to be configured and up, as well as IP-forwarding and masquerading to be enabled -- please see the manual as indicated above.
577
<pre>
578
log stderr
579 137 neels
 logging level all debug
580 1 neels
 logging filter all 1
581
 logging print category 1
582
ggsn ggsn0
583
 gtp bind-ip 192.168.0.42
584 137 neels
 apn internet
585 135 neels
  tun-device apn0
586
  type-support v4
587
  ip dns 0 192.168.0.1
588
  ip dns 1 9.9.9.9
589
  ip prefix dynamic 192.168.42.0/24
590
  no shutdown
591
 default-apn internet
592
 no shutdown ggsn
593 14 neels
 
594 67 neels
log stderr
595
 logging filter all 1
596 14 neels
 logging print extended-timestamp 1
597 93 neels
 logging print category 1
598 14 neels
 logging print category-hex 0
599
 logging print level 1
600
 logging print file basename last
601
 logging level set-all info
602
</pre>
603 136 neels
604 88 neels
h2. OsmoSGSN
605
606 14 neels
[[OsmoSGSN:]] is the Serving GPRS Support Node: it handles signalling, i.e. attach/detach of subscribers and PDP contexts for data services.
607 136 neels
608 1 neels
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.
609 108 neels
610 14 neels
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).
611 77 neels
612 82 neels
For 3G, OsmoSGSN needs to be reachable by the HNBGW for IuPS. If you're running _only_ 3G, the SGSN does not need to listen on a public IP address.
613
614 79 neels
For 3G IuPS, the SGSN must sign up at OsmoSTP with a point code that the HNBGW knows. If not configured explicitly, the respective defaults are used, see [[Point Codes]].
615 14 neels
616 1 neels
Finally, OsmoSGSN needs access to OsmoHLR to access subscriber data. Set 'auth-policy remote' to use the HLR for subscriber authorization.
617
618
*osmo-sgsn.cfg* (download: attachment:nitb.tar)
619
<pre>
620
sgsn
621 136 neels
 gtp local-ip 192.168.0.9
622
 ggsn 0 remote-ip 192.168.0.42
623
 ggsn 0 gtp-version 1
624
 auth-policy remote
625
 gsup remote-ip 127.0.0.1
626
ns
627
 encapsulation udp local-ip 192.168.0.9
628
 encapsulation udp local-port 23000
629
 encapsulation framerelay-gre enabled 0
630 1 neels
  
631
log stderr
632
 logging filter all 1
633 93 neels
 logging print extended-timestamp 1
634
 logging print category 1
635
 logging print category-hex 0
636
 logging print level 1
637
 logging print file basename last
638 151 neels
 logging level set-all info
639
</pre>
640 152 neels
641
The @auth-policy remote@ requires that you have the SIM cards' authentication tokens in your OsmoHLR database. Instead, you can use @auth-policy accept-all@, but be aware that this will only work for 2G. 3G networks _require_ successful authentication, and @auth-policy remote@ is your _only_ option for a 3G SGSN.
642 151 neels
643
h1. OsmoBTS
644
645
[[OsmoBTS:]] operates 2G radio hardware. OsmoBTS supports various hardware platforms including sysmoBTS and USRP. Instead, you may choose BTS vendors like ip.access or Siemens, which can also directly operate with OsmoBSC without OsmoBTS being involved.
646 93 neels
647
Depending on the used hardware, you may need to launch matching BTS implementations, for example:
648
649
| SDR based BTS like USRP, B210, umTRX (see [[OsmoTRX:OsmoTRX#RF-Hardware-support|OsmoTRX hardware]]) | run osmo-trx and osmo-bts-trx on the machine hosting the SDR device |
650 162 laforge
| sysmoBTS device (https://sysmocom.de/products/bts/) | run osmo-bts-sysmo and osmo-pcu on the sysmoBTS box itself |
651 93 neels
| other Osmocom based BTS, see [[OsmoBTS:Wiki#Backends-Hardware-support|OsmoBTS]] | run the matching osmo-bts-* variant |
652
| third party BTS, like ip.access nanoBTS | typically run in their own box, and you do not launch Osmocom software on them, but configure them to connect to your BSC |
653
| 3G femto cell, like ip.access nano3G | this is not even a BTS but an hNodeB ("BTS" is a 2G term) -- you configure a 3G femto cell to connect to OsmoHNBGW |
654
655
The BTS needs to know where to reach OsmoBSC's Abis interface, and its unit id needs to match one of the BTS unit ids configured at OsmoBSC.
656
657
An example configuration for a sysmoBTS is:
658
659
<pre>
660
phy 0
661
 instance 0
662
bts 0
663
 band 1800
664
 ipa unit-id 1800 0
665
 oml remote-ip 192.168.0.9
666
 trx 0
667
  phy 0 instance 0
668
</pre>
669
670
h1. OsmoPCU
671
672
[[OsmoPCU:]] operates the packet-switched part of 2G radio hardware. Timeslots used for data transmission are controlled by the PCU instead of the BTS. OsmoPCU is typically configured from the @gprs@ config items in OsmoBSC, which is communicated to the PCU via OML and OsmoBTS (via the PCU socket). An example configuration for OsmoPCU would be:
673
674 17 neels
<pre>
675
pcu
676
 flow-control-interval 10
677 122 laforge
 cs 2
678 17 neels
 alloc-algorithm dynamic
679 122 laforge
 alpha 0
680 17 neels
 gamma 0
681
</pre>
682
683 1 neels
h1. Running Examples
684
685
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@.
686 36 neels
687 150 neels
When installed from debian or opkg feeds, you will find the systemd service files in @/lib/systemd/system/@.
688
689
Re/starting and stopping then works like this:
690
691
<pre>
692
systemctl restart osmo-hlr
693
systemctl stop osmo-hlr
694
</pre>
695
696
For illustration, the manual command invocations for the components would look like this on a typical CNI standalone host:
697
<pre>
698
osmo-hlr -l hlr.db -c osmo-hlr.cfg
699
osmo-msc -c osmo-msc.cfg
700
osmo-mgw -c osmo-mgw-for-msc.cfg
701
osmo-mgw -c osmo-mgw-for-bsc.cfg
702
osmo-ggsn -c osmo-ggsn.cfg
703 1 neels
osmo-sgsn -c osmo-sgsn.cfg
704
osmo-stp -c osmo-stp.cfg
705
osmo-bsc -c osmo-bsc.cfg
706
osmo-hnbgw -c osmo-hnbgw.cfg
707
osmo-sip-connector -c osmo-sip-connector.cfg
708 150 neels
</pre>
709 1 neels
710 150 neels
h2. Convenience Launcher
711 48 neels
712
It can be useful to have an @osmo-all@ script to re/start or stop all components at once, edit to pick yours:
713 36 neels
714 1 neels
*osmo-all* script
715
<pre>
716
#!/bin/sh
717 36 neels
cmd="${1:-status}"
718
set -ex
719
systemctl $cmd osmo-hlr osmo-msc osmo-mgw osmo-ggsn osmo-sgsn osmo-stp osmo-bsc osmo-hnbgw osmo-sip-connector
720 18 neels
</pre>
721
722
which allows
723
724
<pre>
725 82 neels
./osmo-all restart
726
./osmo-all status
727 18 neels
./osmo-all stop
728
</pre>
729 1 neels
730
h1. Logging Examples
731
732
Osmocom programs have a common logging mechanism, configurable by the config files as well as the telnet VTY.
733
734
h2. System Logging
735 82 neels
736
Depending on the system's logging configuration, logs may by default be visible in /var/log/daemon.log, or by using journalctl:
737 1 neels
738
<pre>
739
journalctl -f -u osmo-hlr
740
</pre>
741
742
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.
743
744
h2. telnet VTY logging
745 18 neels
746
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:
747
748 35 neels
<pre>
749 19 neels
$ telnet localhost 4254
750
OsmoMSC> logging enable 
751
OsmoMSC> logging level ?
752 1 neels
  all      Global setting for all subsystems
753
  rll      A-bis Radio Link Layer (RLL)
754
  cc       Layer3 Call Control (CC)
755
  mm       Layer3 Mobility Management (MM)
756 138 neels
  [...]
757
OsmoMSC> logging level all ?
758 139 neels
everything debug      info       notice     error      fatal      
759 138 neels
OsmoMSC> logging level all debug 
760
OsmoMSC> logging filter all 1
761
</pre>
762
763
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.
764
765
Here is a useful 'expect' script to attach to osmo-* components by name and start logging while still having a vty prompt:
766
767
*vty* script (download: attachment:nitb.tar)
768
<pre>
769
#!/usr/bin/expect -f
770
set vty [lindex $argv 0]
771
set host localhost
772
switch $vty {
773
 hlr { set port 4258 }
774
 bsc { set port 4242 }
775
 mgw { set port 4243 }
776
 mgw2 {
777
        set host 127.0.0.2
778
        set port 4243
779
      }
780
 sg { set port 4245 }
781
 msc { set port 4254 }
782
 sip { set port 4256 }
783
 gg { set port 4260 }
784
 osmo-hlr { set port 4258 }
785
 osmo-bsc { set port 4242 }
786
 osmo-mgw { set port 4243 }
787
 osmo-mgw-for-bsc { set port 4243 }
788
 osmo-mgw-for-msc {
789
        set host 127.0.0.2
790
        set port 4243
791
      }
792
 osmo-sgsn { set port 4245 }
793
 osmo-msc { set port 4254 }
794
 osmo-sip-connector { set port 4256 }
795
 osmo-ggsn { set port 4260 }
796
 default { set port 4242 }
797
}
798
spawn telnet localhost $port
799
expect ">"
800
send "enable\r"
801
expect "#"
802
send "logging enable\r"
803
expect "#"
804
send "logging print category 1\r"
805
expect "#"
806
send "logging print category-hex 0\r"
807
expect "#"
808
send "logging print level 1\r"
809
expect "#"
810
send "logging print file basename last\r"
811
expect "#"
812
send "logging print extended-timestamp 1\r"
813
expect "#"
814
send "logging level set-all notice\r"
815
expect "#"
816
switch $vty {
817
 msc {
818
  send "logging level mm info\r"
819
  expect "#"
820 1 neels
  send "logging level cc info\r"
821
  expect "#"
822
 }
823
}
824
send "logging filter all 1\r"
825
expect "#"
826
interact
827
</pre>
828
829
h2. stderr logging
830
831
A common configuration you can add to any of the above configuration files to show *all* logging on stderr is:
832
833
<pre>
834
log stderr
835 90 neels
 logging filter all 1
836
 logging color 1
837
 logging print category 1
838
 logging timestamp 1
839
 logging print extended-timestamp 1
840
 logging level all debug
841
</pre>
842
843
The @filter all 1@ switches on logging, read "do not discard all logging". The amount of logging seen is determined by @logging level ...@ commands, here all categories are set to level @debug@, to show absolutely all logging. You will probably want to refine that.
844
845
h1. Point Codes
846
847
If you'd like to configure non-default point-codes, see this example for OsmoHNBGW on the general approach:
848
849
<pre>
850
cs7 instance 0
851
 # HNBGW's local point code
852
 point-code 0.23.5
853
 # Address book entries, used below
854
 sccp-address my_msc
855 76 neels
  point-code 0.23.1
856
 sccp-address my_sgsn
857
  point-code 0.23.4
858
hnbgw
859
 iucs
860
  remote-addr my_msc
861
 iups
862
  remote-addr my_sgsn
863
</pre>
864
865
h1. Troubleshooting
866
867
h2. APN for Data Service
868
869
For the data service to work, phones generally need an APN added to their
870
configuration, or they will not even attempt to establish a data connection.
871
The APN should match the name configured in osmo-ggsn.conf.
872
873
The APN configuration steps are usually similar to:
874
875
* Navigate to APN settings:
876
** 'Settings'
877
** 'Wireless & Networks'
878 1 neels
** 'Mobile networks'
879 117 duo_kali
** 'Access Point Names'
880 110 duo_kali
* You should see the list of APNs (possibly empty)
881 1 neels
* Press the Menu button
882 140 neels
* Choose 'New APN'
883
* Enter values for 'Name' as well as 'APN'
884
* Again press the Menu button
885
* Choose 'Save'
886
* The APN should now appear in the list of APNs.
887
* Possibly tap the bullet icon to select the APN as default.
888
889
</pre>
890
891
892 1 neels
h1. Tips and Facts
893
894
h2. Analyzing 3G RTP streams in wireshark
895
896
IuCS actually uses UP over RTP. See 3GPP TS 25.414, and 25.415 6.6.2.
897
(an interesting insight is https://www.ietf.org/mail-archive/web/avt/current/msg05907.html )
898
899
In the wireshark preferences, go to protocol IuUP, enable it and enter the dynamic protocol
900
number that you see in the RTP frames (e.g. 96).
Add picture from clipboard (Maximum size: 48.8 MB)