Project

General

Profile

OpenBSC GPRS » History » Version 25

wirelesss, 12/21/2016 02:27 PM

1 12 tnt
{{>toc}}
2 1 tnt
3
4 20 wirelesss
h1. [[OpenBSC:]] GPRS/EDGE Setup page
5 1 tnt
6
7
8 12 tnt
h2. Pre-requisites
9
10
11 13 laforge
* BTS hardware: [[openbsc:sysmoBTS]], USRP, [[UmTRX:]], [[openbsc:nanoBTS]] with GPRS or EDGE support. [[openbsc:BS11]] are not supported.
12
* A compiled GGSN from [[OpenGGSN:]]
13
* A working and up-to-date [[OpenBSC:]] (see [[openbsc:Building_OpenBSC]])
14
*** You will need to (re-)build it after having installed [[OpenGGSN:]] so that the @libgtp@ is detected and the SGSN binary @osmo-sgsn@ built.
15 12 tnt
* A custom SIM for your network
16 13 laforge
*** Currently [[OsmoSGSN:]] refuses all roaming, so you need a SIM that matches your custom MCC/MNC network
17 12 tnt
18
19
h2. Setup
20
21
22 1 tnt
First a little picture to illustrate the different elements and their interactions :
23
24 13 laforge
!gprs.2.png!
25 1 tnt
26 13 laforge
h3. Compiling [[OpenBSC:]] with [E]GPRS
27 12 tnt
28
29 11 tnt
The guide below was tested on Ubuntu 15.10 but should work on Debian as well.
30 1 tnt
31
First you need to download all dependencies:
32 9 tnt
33 12 tnt
<pre>
34 9 tnt
apt install libdbi0-dev libdbd-sqlite3 libtool autoconf git-core pkg-config make libortp-dev
35 12 tnt
</pre>
36 1 tnt
37 18 neels
Please follow instructions provided at [[Build from source]] in order to install these projects:
38 1 tnt
39 17 wirelesss
* openggsn
40
* libosmocore
41
* libosmo-abis
42
* libosmo-netif
43
* openbsc
44 11 tnt
* osmo-pcu
45 1 tnt
46 13 laforge
h3. [[OpenBSC:]] configuration
47 12 tnt
48
49 13 laforge
The first step is to configure [[OpenBSC:]] for gprs support. Add this to the @network/bts@ node in @openbsc.cfg@:
50 12 tnt
<pre>
51 3 tnt
gprs mode gprs
52
gprs routing area 0
53
gprs cell bvci 2
54
gprs nsei 101
55
gprs nsvc 0 nsvci 101
56 2 tnt
gprs nsvc 0 local udp port 23000
57 3 tnt
gprs nsvc 0 remote udp port 23000
58 1 tnt
gprs nsvc 0 remote ip 192.168.0.128
59 12 tnt
</pre>
60 4 tnt
61 23 wirelesss
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.
62 1 tnt
63 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 :
64
<pre>
65 1 tnt
phys_chan_config PDCH
66 12 tnt
</pre>
67 1 tnt
68
69
70 13 laforge
h3. [[OsmoSGSN:]] configuration
71 1 tnt
72 12 tnt
73
Here's a sample SGSN configuration file @osmo-sgsn.cfg@ with some explanations :
74
75
<pre>
76 1 tnt
!
77
! Osmocom SGSN configuration
78 2 tnt
!
79
!
80
line vty
81
 no login
82
!
83
sgsn
84
 gtp local-ip 192.168.1.128
85
 ggsn 0 remote-ip 192.168.1.129
86
 ggsn 0 gtp-version 1
87
!
88 1 tnt
ns
89
 timer tns-block 3
90
 timer tns-block-retries 3
91
 timer tns-reset 3
92
 timer tns-reset-retries 3
93
 timer tns-test 30
94 4 tnt
 timer tns-alive 3
95
 timer tns-alive-retries 10
96 1 tnt
 encapsulation udp local-ip 192.168.0.128
97 9 tnt
 encapsulation udp local-port 23000
98 1 tnt
 encapsulation framerelay-gre enabled 0
99
!
100
bssgp
101
!
102 12 tnt
</pre>
103 4 tnt
104 12 tnt
* The @gtp local-ip@ entry is the local IP the SGSN will bind to.
105
* The @ggsn 0 remote-ip@ entry if the remote IP of the GGSN. The SGSN will connect to it.
106
* 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.
107
* The @encapsulation@ settings must be the same IP/port than you've setup in @openbsc.cfg@
108 4 tnt
109 14 laforge
h3. [[OpenGGSN:]] configuration
110 12 tnt
111
112 2 tnt
The ggsn.conf file is pretty well documented. What is mostly of interest here is :
113 1 tnt
114 12 tnt
* The configuration of the GTP link. (Must match the @ggsn 0 remote-ip@ entry in @osmo-sgsn.cfg@)
115 2 tnt
116 12 tnt
<pre>
117 2 tnt
# TAG: listen
118 4 tnt
# Specifies the local IP address to listen to
119
listen 192.168.1.129
120 12 tnt
</pre>
121 1 tnt
122 12 tnt
* The configuration given to phones, IP pool & DNS.
123 1 tnt
124 12 tnt
<pre>
125 1 tnt
# TAG: dynip
126
# Dynamic IP address pool.
127
# Used for allocation of dynamic IP address when address is not given
128
# by HLR.
129 11 tnt
# If this option is not given then the net option is used as a substitute.
130 1 tnt
# dynip 192.168.254.0/24
131
132
# TAG: pcodns1/pcodns2
133
# Protocol configuration option domain name system server 1 & 2.
134
pcodns1 208.67.222.222
135 2 tnt
pcodns2 208.67.220.220
136
</pre>
137 1 tnt
138 15 laforge
h3. [[OsmoPCU:]] configuration
139 12 tnt
140
141
<pre>
142 11 tnt
pcu
143
 flow-control-interval 10
144
 cs 2
145
 alloc-algorithm dynamic
146
 alpha 0
147
 gamma 0
148 12 tnt
</pre>
149 11 tnt
150
151 12 tnt
h3. Network configuration
152
153 1 tnt
You will also need to configure some networking rules to allow connectivity from @tun0@. Look up linux networking/nat howtos on google.
154 21 msuraev
155
h4. Modern systems
156
157
Add following setting to /etc/systemd/network:
158
159
wired.network:
160
<pre>
161
[Match]
162
Name=enp2s0
163
164
[Network]
165
DHCP=ipv4
166
IPMasquerade=yes
167
</pre>
168
169
tun.network:
170
<pre>
171
[Match]
172
Name=tun0
173
174
[Network]
175
Address=192.168.0.1
176
IPMasquerade=yes
177
</pre>
178
179
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.
180
181
h4. Legacy systems
182
183 1 tnt
The basic setup for testing only in a safe environment would be :
184
185
<pre>
186 21 msuraev
sh# echo 1 > /proc/sys/net/ipv4/ip_forward
187
sh# iptables -A POSTROUTING -s 192.168.254.0/24 -t nat -o eth0 -j MASQUERADE
188 1 tnt
</pre>
189
190
(replace @eth0@ by the interface providing your machine connectivity)
191 12 tnt
192 21 msuraev
h4. DNS issues
193
194 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:
195 11 tnt
196 1 tnt
<pre>
197 21 msuraev
sh# iptables -t nat -I PREROUTING -i tun0 -p udp --dport 53 -j DNAT --to-dest 1.2.3.4
198 1 tnt
</pre>
199
200
(replace @1.2.3.4@ with the ip-address of your DNS-Server)
201
202 21 msuraev
You can put this into .sh file and reference it from openggsn config using
203
<pre>
204
ipup /full/path/to/your.sh
205
</pre>
206
207 11 tnt
h2. Running
208
209
210
Sample startup sequence (adjust logging and configuration files location as you see fit):
211
<pre>
212 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
213 11 tnt
sudo ggsn -c ~/.config/osmocom/ggsn.conf -f -d
214 13 laforge
osmo-sgsn -c ~/.config/osmocom/osmo-sgsn.cfg -d DRLL:DCC:DMM:DRR:DNM:DMSC:DHO:DGPRS:DNS:DLLC:DCTRL
215 11 tnt
216 13 laforge
cd osmo-trx/Transceiver52M
217 12 tnt
sudo chrt 20 ./osmo-trx
218
cd osmo-bts/src/osmo-bts-trx
219
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
220 11 tnt
221 1 tnt
osmo-pcu/src
222
sudo ./osmo-pcu -c ~/.config/osmocom/osmo-pcu.cfg
223 12 tnt
</pre>
224 11 tnt
225
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). 
226
227
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.
228
229 22 wirelesss
h2. Authorization Policy
230
231
Authorization determines whether particular subscriber can access your network or not.
232
233 24 wirelesss
The following 4 authorization policy options are available:
234 1 tnt
235 23 wirelesss
** @accept-all@: When this option is selected then all IMSIs will be accepted. Using this pcan be dangerous one.
236 1 tnt
237 25 wirelesss
** @acl-only@: In this case you will allow SGSN to accept only IMSIs, which are explicitly white-listed by the Access Control List (ACL) and the rest will be rejected. 
238 22 wirelesss
239 23 wirelesss
** @closed@: This option allows you to accept only home network subscribers either the ones, which are in the ACL or MCC/MNC match. (i.e. MCC 901, MNC 700, IMSI 901700000003080).  
240 22 wirelesss
241 23 wirelesss
** @remote@: When this authorization option is selected then the GSUP protocol to remotely access a HLR will be used. Remote subscription data only will be used.
242 22 wirelesss
243
Example: How to assign or change current authorization policy follows below:
244
245
<pre>
246
OsmoSGSN> enable
247
OsmoSGSN# configure terminal
248
OsmoSGSN(config)# sgsn
249
OsmoSGSN(config-sgsn)# auth-policy acl-only 
250
OsmoSGSN(config-sgsn)# write
251
Configuration saved to sgsn.cfg
252
OsmoSGSN(config-sgsn)# exit
253
OsmoSGSN(config)# exit
254
OsmoSGSN# disable
255
OsmoSGSN>
256
</pre> 
257
258
In the example acl-olny is selected as authorization policy.
259
After this we are saving current changes to configuration file using command @write@ to make this policy persistent.
260 4 tnt
  
261
h2. Troubleshooting
262 6 tnt
263 12 tnt
264 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.
265
266
You can access vty from 
267 13 laforge
* [[OsmoNITB:]] on port 4242 See [[osmonitb:osmo-nitb_VTY]]
268
* [[OsmoSGSN:]] on port 4245. See [[osmosgsn:osmo-sgsn_VTY]]
Add picture from clipboard (Maximum size: 48.8 MB)