Project

General

Profile

Osmocom Network In The Box » History » Version 159

msuraev, 11/11/2022 02:52 PM

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