Project

General

Profile

Osmocom Network In The Box » History » Version 146

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