summaryrefslogtreecommitdiff
path: root/2019/osmodevcon2019-iu_3g_testing/osmodevcon2019-iu_3g_testing.adoc
blob: 9a2bde67bde18b503d33d9ab1a6c0d9940faf028 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
Iu / 3G testing of Osmo{MSC,SGSN,HNBGW} using TTCN-3
====================================================
:author:	Harald Welte <laforge@gnumonks.org>
:copyright:	2019 by Harald Welte (License: CC-BY-SA)
:backend:	slidy
:max-width:	45em


== Osmocom TTCN-3 Test Suites

* developed in 2017+2018
* compiled using Eclipse TITAN
** uses just a command-line compiler + Makefiles
** no IDE needed at all, don't let _Eclipse_ fool you
* containerized in Docker
* executed by Jenkins CI

== Test Suite Philosophy

* test one network element (our IUT)
* test external behavior (3GPP and non-3GPP)
* emulate entire environment from TTCN-3
* don't reuse Osmocom C-code protocol implementations in the tests
* test against independent TTCN-3 implementations!

== What to test?

* successful cases
* erroneous cases (no answer, NACK, ...)
** many difficult to reproduce with real phones/devices
* load / resource exhaustion
* spec compliance
* focus on functionality actually relevant to IUT

== Why TTCN-3 + TITAN

* TTCN-3 specifically designed for telecom protocol testing
* TITAN team released many telecom protocols in TTCN-3, such as
** BSSAP, L3 (RR/MM/CC), SMS (CP/RP/TP), SS, M3UA, SCCP, GTP, NS, BSSGP, ...
** shortens our test development cycle
** permits us to test against known working industry implementations

== SGSN_Tests.ttcn so far

* external interfaces
** Gb (emulates PCU side NS/BSSGP + MS)
** Gp (emulates GGSN)
** GSUP (emulates HLR)
** VTY

no 3G (IuCS) testing at all

[graphviz]
----
digraph G {
  rankdir=LR;
  SGSN [label="SGSN\nosmo-sgsn",shape="box"];
  ATS [label="ATS\nSGSN_Tests.ttcn"];

  ATS -> SGSN [label="Gb"];
  SGSN-> ATS [label="Gp (GTP)"];
  ATS -> SGSN [label="VTY"];
}
----

== A vs. Iu

* In theory, almost identical
** both use one SCCP connection per subscriber / radio channel
** both encapsulate the same Layer3 (DTAP) towards MS/UE
** more or less a 1:1: mapping between BSSMAP and RANAP
*** e.g. COMPLETE LAYER3 INFO -> InitialUeMessage
*** e.g. ASSIGNMENT -> RabAssignment
*** e.g. CLEAR -> IuRelease procedure
* In practise, _things are complicated..._

== A interface

image::gsm_control_stack_2g_cs.svg[width="100%"]

== Iu-CS interface

image::gsm_control_stack_3g_cs.svg[width="100%"]

== What's so special about Iu?

* not specified in human-readable text/tables, but ASN.1
* uses rather advanced features of ASN.1 syntax (information object classes)
* uses rather exotic ancoding APER (Aligned Packed Encoding Rules)
* Ericsson didn't release any titan.ProtocolModule.* for Iu

== TTCN-3 and ASN.1

* both TTCN-3 and ASN.1 originate at ITU
** TTCN-3 spec covers "native" use of ASN.1 within TTCN-3
*** no code generation (e.g. .asn1 -> .ttcn)
*** asn syntax can be directly used from TTCN-3 sources
**** all types are imported into the TTCN3 namespace

== Name mangling of ASN.1 types in TTCN-3

* replace all hyphen with underscore
** e.g. RANAP-PDU -> RANAP_PDU


== Eclipse TITAN and ASN.1

* Eclipse TITAN can parse the RANAP ASN.1 
** you simply add the *.asn files next to your *.ttcn files when compiling
* ASN.1 compiled directly to C++, no intermediate .ttcn code generated
** makes life a bit hard initially, while you still learn about the mapping of names/types/etc.
* TITAN only supports BER, no other encoding rules like APER

== BER - APER transcoding

* we need a transcoder that
** parses RANAP in APER and converts it to BER (Rx)
** parses RANAP in BER and converts it to APER (Tx)
* use which tool to do the job?
** asn1c (APER still not upstream; we don't want to run asn1c on ATS + IUT)
** erlang (we don't want to run an Erlang VM next to every TTCN-3 test)
** ffasn1c (proprietary, but sysmocom has a license and can share generated binary code)

== libfftranscode

* binary-only shared library generated by sysmocom, available from http://ftp.osmocom.org/binaries/libfftranscode/
** contact me if you have a valid use case for running tests on non-x86_64 / non-debian systems
* contains libffasn1c runtime code and ffasn1c-generated code for RANAP, RUA, HNBAP
* can be extended for other APER based protcols like S1AP (LTE) as needed
** contact me if you want to write TTCN3 tests for other protocols

== Writing RANAP templates

How to write RANAP templates without a ttcn source file?

Theory:

* use binary RANAP packets from pcap files
* feed them into the TITAN decoder
* look at the log output
* copy + paste + customize

== Problems

Problems:

 RANAP_Selftests.ttcn:49: Dynamic test case error: While BER-decoding type '@RANAPMIN.RANAP-PDU': While decoding '@RANAPMIN.RANAP-PDU' type: Alternative 'initiatingMessage': While decoding '@RANAPMIN.InitiatingMessage' type: Component 'value_': While checking tags (expecting [2]): Tag mismatch: Received: [UNIVERSAL 16].

* somehow TITAN cannot parse the BER generate by ffasn1c :(
** this is where I gave up for ~6 months after the first attempt
** I re-visited this in early April 2018
** one direction (BER encode) could be fixed by hacking runtime library source
** other direction required fix in compiler
** new version of ffasn1c has been released -> works

== Integrating with existing test suites

* existing tests are written without planning for 3G
* a lot of what they test is in L3/DTAP and should work over A + IuCS
* how to reuse them with 3G?

== BSSAP_Emulation -> RAN_Emulation

image::bssap_ranap_rename.png[width="100%"]


== BSSAP_Emulation -> RAN_Emulation

* copy + paste + edit `BSSAP_CodecPort` -> `RANAP_CodecPort`
* modularize protocol support (build without MGCP/BSSAP)
* rename `f_bssap_*` to `f_ran_adapter_*`
* add config option `cfg.transport == RANAP_TRANSPORT_IuCS`
* connect lower end of `RAN_Emulation` to `RANAP_CodecPort`, not `BSSAP_CodecPort`

== How does this look to the test case

* whenever L3 PDUs (DTA) are sent/received: no change
* whenever BSSMAP is transceived: distinguish BSSMAP vs RANAP
* good abstraction using functions can help

image::bssap_ranap_conditional_altsteps.png[width="100%"]

== Abstracting the send side

image::cl3_or_initialue.png[width="100%"]

image::cl3_or_initialue2.png[width="100%"]

== Extending a 2G test case to 3G

image::msc_iu_testcase.png[width="100%"]

== OsmoSGSN test suite

* MSC was easy: IuCS is very much like A.
* as opposed to the A interface (MSC) Gb doesn't use SCCP transport
* no similarity between 2G (Gb) and 3G (IuPS) protocol stack

== Gb interface

image::gsm_control_stack_2g_ps.svg[width="100%"]

== Iu-PS interface

image::gsm_control_stack_3g_ps.svg[width="100%"]

== OsmoSGSN test suite

* no concept of "subscriber connection" in 2G / Gb
* 3G IuPS very much like IuCS: SCCP connection per subscriber
* less common infrastructure that can be shared between 2G and 3G tests

== Further Reading

* http://git.osmocom.org/osmo-ttcn3-hacks/
* http://git.osmocom.org/docker-playground/
* http://osmocom.org/projects/cellular-infrastructure/wiki/Titan_TTCN3_Notes

== EOF

End of File
personal git repositories of Harald Welte. Your mileage may vary