Project

General

Profile

OpenBSC GPRS » History » Version 36

fixeria, 08/04/2018 02:45 AM

1 1 tnt
h1. [[OpenBSC:]] GPRS/EDGE Setup page
2 20 wirelesss
3 36 fixeria
{{>toc}}
4 1 tnt
5 12 tnt
h2. Pre-requisites
6
7 13 laforge
* BTS hardware: [[openbsc:sysmoBTS]], USRP, [[UmTRX:]], [[openbsc:nanoBTS]] with GPRS or EDGE support. [[openbsc:BS11]] are not supported.
8
* A compiled GGSN from [[OpenGGSN:]]
9
* A working and up-to-date [[OpenBSC:]] (see [[openbsc:Building_OpenBSC]])
10
*** You will need to (re-)build it after having installed [[OpenGGSN:]] so that the @libgtp@ is detected and the SGSN binary @osmo-sgsn@ built.
11 29 laforge
* A custom SIM for your network (recommended)
12
*** Depending on your authorization policy (see [[OsmoSGSN:]] user manual), it may refuse inbound roaming. It is easiest if you have a SIM that matches your custom MCC/MNC network
13 12 tnt
14
15
h2. Setup
16
17
18 1 tnt
First a little picture to illustrate the different elements and their interactions :
19
20 34 pespin
!gprs.3.png!
21 1 tnt
22 13 laforge
h3. Compiling [[OpenBSC:]] with [E]GPRS
23 12 tnt
24
25 11 tnt
The guide below was tested on Ubuntu 15.10 but should work on Debian as well.
26 1 tnt
27
First you need to download all dependencies:
28 9 tnt
29 12 tnt
<pre>
30 9 tnt
apt install libdbi0-dev libdbd-sqlite3 libtool autoconf git-core pkg-config make libortp-dev
31 12 tnt
</pre>
32 1 tnt
33 18 neels
Please follow instructions provided at [[Build from source]] in order to install these projects:
34 1 tnt
35 17 wirelesss
* openggsn
36
* libosmocore
37
* libosmo-abis
38
* libosmo-netif
39
* openbsc
40 11 tnt
* osmo-pcu
41 1 tnt
42 13 laforge
h3. [[OpenBSC:]] configuration
43 12 tnt
44
45 13 laforge
The first step is to configure [[OpenBSC:]] for gprs support. Add this to the @network/bts@ node in @openbsc.cfg@:
46 12 tnt
<pre>
47 3 tnt
gprs mode gprs
48
gprs routing area 0
49
gprs cell bvci 2
50
gprs nsei 101
51
gprs nsvc 0 nsvci 101
52 2 tnt
gprs nsvc 0 local udp port 23000
53 3 tnt
gprs nsvc 0 remote udp port 23000
54 1 tnt
gprs nsvc 0 remote ip 192.168.0.128
55 12 tnt
</pre>
56 4 tnt
57 33 pespin
The @gprs nsvc 0 remote@ entries @192.168.0.128:23000@ is the IP/port of the machine running the SGSN as seen from the BTS. It will be sent by [[OpenBSC:]] to the BTS in the configuration phase and the BTS will connect back to the SGSN using that address and port.
58 1 tnt
59 12 tnt
The second step is to allocate some timeslots to packet data. For this, just change the 1 or more @network/bts/trx/timeslot@ nodes using :
60
<pre>
61 1 tnt
phys_chan_config PDCH
62 12 tnt
</pre>
63 1 tnt
64
65
66 13 laforge
h3. [[OsmoSGSN:]] configuration
67 1 tnt
68 12 tnt
69
Here's a sample SGSN configuration file @osmo-sgsn.cfg@ with some explanations :
70
71
<pre>
72 1 tnt
!
73
! Osmocom SGSN configuration
74 2 tnt
!
75
!
76
line vty
77
 no login
78
!
79
sgsn
80
 gtp local-ip 192.168.1.128
81
 ggsn 0 remote-ip 192.168.1.129
82
 ggsn 0 gtp-version 1
83
!
84 1 tnt
ns
85
 timer tns-block 3
86
 timer tns-block-retries 3
87
 timer tns-reset 3
88
 timer tns-reset-retries 3
89
 timer tns-test 30
90 4 tnt
 timer tns-alive 3
91
 timer tns-alive-retries 10
92 1 tnt
 encapsulation udp local-ip 192.168.0.128
93 9 tnt
 encapsulation udp local-port 23000
94 1 tnt
 encapsulation framerelay-gre enabled 0
95
!
96
bssgp
97
!
98 12 tnt
</pre>
99 4 tnt
100 12 tnt
* The @gtp local-ip@ entry is the local IP the SGSN will bind to.
101
* The @ggsn 0 remote-ip@ entry if the remote IP of the GGSN. The SGSN will connect to it.
102
* Those two IPs *must* be different even if you're running both processes on the same machine. A solution for that is to put several IP aliases on the same network interface or use the loopback interface.
103 33 pespin
* The @encapsulation@ settings must be the same IP/port than you've setup in @openbsc.cfg@. The SGSN will listen to that address and port for connections coming from the BTS.
104 4 tnt
105 14 laforge
h3. [[OpenGGSN:]] configuration
106 12 tnt
107
108 2 tnt
The ggsn.conf file is pretty well documented. What is mostly of interest here is :
109 1 tnt
110 12 tnt
* The configuration of the GTP link. (Must match the @ggsn 0 remote-ip@ entry in @osmo-sgsn.cfg@)
111 2 tnt
112 12 tnt
<pre>
113 2 tnt
# TAG: listen
114 4 tnt
# Specifies the local IP address to listen to
115
listen 192.168.1.129
116 12 tnt
</pre>
117 1 tnt
118 12 tnt
* The configuration given to phones, IP pool & DNS.
119 1 tnt
120 12 tnt
<pre>
121 1 tnt
# TAG: dynip
122
# Dynamic IP address pool.
123
# Used for allocation of dynamic IP address when address is not given
124
# by HLR.
125 11 tnt
# If this option is not given then the net option is used as a substitute.
126 1 tnt
# dynip 192.168.254.0/24
127
128
# TAG: pcodns1/pcodns2
129
# Protocol configuration option domain name system server 1 & 2.
130
pcodns1 208.67.222.222
131 2 tnt
pcodns2 208.67.220.220
132
</pre>
133 1 tnt
134 15 laforge
h3. [[OsmoPCU:]] configuration
135 12 tnt
136
137
<pre>
138 11 tnt
pcu
139
 flow-control-interval 10
140
 cs 2
141
 alloc-algorithm dynamic
142
 alpha 0
143
 gamma 0
144 12 tnt
</pre>
145 11 tnt
146
147 12 tnt
h3. Network configuration
148
149 1 tnt
You will also need to configure some networking rules to allow connectivity from @tun0@. Look up linux networking/nat howtos on google.
150 21 msuraev
151
h4. Modern systems
152
153
Add following setting to /etc/systemd/network:
154
155
wired.network:
156
<pre>
157
[Match]
158
Name=enp2s0
159
160
[Network]
161
DHCP=ipv4
162
IPMasquerade=yes
163
</pre>
164
165
tun.network:
166
<pre>
167
[Match]
168
Name=tun0
169
170
[Network]
171
Address=192.168.0.1
172
IPMasquerade=yes
173
</pre>
174
175
The setup above assume that you're using interface *enp2s0* to access the internet from the machine which runs openggsn. Notice the *IPMasquerade* option on both interfaces. This also assume the default 192.168.0.1/24 ip address range used by openggsn. If your situation differs - adjust accordingly using https://www.freedesktop.org/software/systemd/man/systemd.network.html as a reference.
176
177
h4. Legacy systems
178
179 1 tnt
The basic setup for testing only in a safe environment would be :
180
181
<pre>
182 21 msuraev
sh# echo 1 > /proc/sys/net/ipv4/ip_forward
183 34 pespin
sh# iptables -A POSTROUTING -s 192.168.254.0/24 -t nat -o enp2s0 -j MASQUERADE
184 1 tnt
</pre>
185
186 34 pespin
(replace @enp2s0@ by the interface connected to the gateway which provides your machine connectivity)
187 12 tnt
188 21 msuraev
h4. DNS issues
189
190 16 dexter
In some cases the DNS server might be hardcoded in the phones APN settings. To work around this problem one might choose to enforce the usage of a specific DNS server by redirecting all DNS traffic via iptables:
191 11 tnt
192 1 tnt
<pre>
193 21 msuraev
sh# iptables -t nat -I PREROUTING -i tun0 -p udp --dport 53 -j DNAT --to-dest 1.2.3.4
194 1 tnt
</pre>
195
196
(replace @1.2.3.4@ with the ip-address of your DNS-Server)
197
198 21 msuraev
You can put this into .sh file and reference it from openggsn config using
199
<pre>
200
ipup /full/path/to/your.sh
201
</pre>
202
203 11 tnt
h2. Running
204
205
206
Sample startup sequence (adjust logging and configuration files location as you see fit):
207
<pre>
208 13 laforge
osmo-nitb -s -c ~/.config/osmocom/open-bsc.cfg -l ~/.config/osmocom/hlr.sqlite3 -P -m -C -T --debug=DSQL:DLSMS:DRLL:DCC:DMM:DRR:DMSC:DHO:DGPRS:DNS:DLLC:DCTRL 2>&1 | tee /tmp/openbsc.log
209 11 tnt
sudo ggsn -c ~/.config/osmocom/ggsn.conf -f -d
210 13 laforge
osmo-sgsn -c ~/.config/osmocom/osmo-sgsn.cfg -d DRLL:DCC:DMM:DRR:DNM:DMSC:DHO:DGPRS:DNS:DLLC:DCTRL
211 11 tnt
212 13 laforge
cd osmo-trx/Transceiver52M
213 12 tnt
sudo chrt 20 ./osmo-trx
214
cd osmo-bts/src/osmo-bts-trx
215
sudo chrt 15 ./osmobts-trx -c ~/.config/osmocom/osmo-bts.cfg -i 224.0.0.1 -d DRLL:DCC:DMM:DRR:DNM:DMSC:DHO:DGPRS:DNS:DLLC:DCTRL
216 11 tnt
217 1 tnt
osmo-pcu/src
218
sudo ./osmo-pcu -c ~/.config/osmocom/osmo-pcu.cfg
219 12 tnt
</pre>
220 11 tnt
221
Note: [[OsmoTRX:]] is only necessary with USRP/UmTRX transceivers (At the time of writing 201509-fairwaves-rebase branch of [[OsmoBTS:]] is necessary as well for compatibility). 
222
223
Once you're done with experimenting and ready for production setup it might be convenient to create systemd units so all the parts are started automatically.
224
225 22 wirelesss
h2. Authorization Policy
226
227 28 wirelesss
Authorization determines whether a particular subscriber can access
228
your network or not.
229 22 wirelesss
230 1 tnt
The following 4 authorization policy options are available:
231
232 28 wirelesss
** @accept-all@: All IMSIs will be accepted.
233 1 tnt
234 28 wirelesss
** @acl-only@: Accept only IMSIs, which are explicitly white-listed by the Access Control List (ACL), and the rest will be rejected.
235 22 wirelesss
236 28 wirelesss
** @closed@: Accept only home network subscribers. The combination of MCC and MNC fully identifies subscriber's Home network. The ACL is also heeded.
237 22 wirelesss
238 28 wirelesss
** @remote@: GSUP protocol is uesed to remotely access a HLR. Only remote subscription data will be used.
239 22 wirelesss
240 28 wirelesss
Example: Assign or change authorization policy:
241 22 wirelesss
242
<pre>
243
OsmoSGSN> enable
244
OsmoSGSN# configure terminal
245
OsmoSGSN(config)# sgsn
246
OsmoSGSN(config-sgsn)# auth-policy acl-only 
247
OsmoSGSN(config-sgsn)# write
248 1 tnt
Configuration saved to sgsn.cfg
249 22 wirelesss
OsmoSGSN(config-sgsn)# exit
250
OsmoSGSN(config)# exit
251
OsmoSGSN# disable
252
OsmoSGSN>
253
</pre> 
254
255 28 wirelesss
In the example acl-only is selected as authorization policy.
256 27 wirelesss
After this we are saving current changes to configuration file using command @write@ to make this policy persistent.
257
258 4 tnt
h2. Troubleshooting
259 6 tnt
260 12 tnt
261 1 tnt
* double-check that your phones have APN set to something. "Internet" will do for example. The value of APN is not checked but if it's unset the phones' baseband might not even try to initiate GPRS connection.
262
263
You can access vty from 
264 13 laforge
* [[OsmoNITB:]] on port 4242 See [[osmonitb:osmo-nitb_VTY]]
265 1 tnt
* [[OsmoSGSN:]] on port 4245. See [[osmosgsn:osmo-sgsn_VTY]]
266 30 neels
267 32 neels
h2. enable wireshark dissector for GPRS / GMM messages
268 30 neels
269
In wireshark's default configuration, GMM messages show merely as UDP packets without being decoded.
270 35 laforge
(port 23000 going between the SGSN and PCU, see [[cellular-infrastructure:Port Numbers]])
271 31 neels
272
Persistently:
273
* _Preferences_
274
* _Protocols_
275
* _GPRS-NS_
276
* Add _,23000_ to _GPRS NS UDP ports_
277
278
Quick way but is apparently not saved:
279
* Right-click on a UDP port 23000 packet to open the context menu
280 30 neels
* _Decode as..._
281
* _GPRS-NS_
Add picture from clipboard (Maximum size: 48.8 MB)