Commit Graph

26 Commits

Author SHA1 Message Date
Vadim Yanitskiy 3f4c6a8fbe coding: fix wrong n_bits_total reported for PDTCH CS2 and CS3
In gsm0503_pdtch_decode(), we decode CS2 and CS3 as if no puncturing
was employed, reordering the coded bits and setting punctured ones
to 0 manually.  Because of that, osmo_conv_decode_ber_punctured()
reports n_bits_total higher than we actually receive over the air.

Change-Id: I6b20cc450f25c48175a61da02644d66c08e22ece
Related: OS#6342, OS#6200
2024-01-31 23:10:40 +07:00
Vadim Yanitskiy 6c4be02962 coding: fix artificial bit errors for PDTCH CS2 and CS3
GPRS coding schemes CS2 and CS3 (defined in 3GPP TS 45.003 sections
5.1.2 and 5.1.3, respectively) employ so-called puncturing, which
can be described as intentional removal of coded bits.  The goal
of puncturing is to reduce the number of coded bits, so that they
fit into 4 bursts.  The receiving side recovers punctured bits,
as if they were received corrupted.

The puncturing is also used for other channel types like TCH/F9.6,
TCH/F14.4, TCH/AFS and TCH/AHS, but only for CS2 and CS3 we're
doing puncturing/depuncturing *manually*.  This explains why
we're seeing artificial bit errors only for CS2 and CS3.

gsm0503_pdtch_decode() should not be reporting punctured bits as
bit errors, fix this by using osmo_conv_decode_ber_punctured().

Change-Id: I024276d167e769396187998d881f8e7626461249
Related: OS#6342, OS#6200
2024-01-31 23:10:40 +07:00
Vadim Yanitskiy 74b31acb5d tests/coding: fix -Wmaybe-uninitialized in test_pdtch()
I am seeing this when building with gcc v13.2.1:

tests/coding/coding_test.c: In function ‘test_pdtch’:
tests/coding/coding_test.c:444:23: warning: ‘*result[<unknown>]’
                                   may be used uninitialized
  444 |                 result[len - 1] &= 0x7f;
      |                 ~~~~~~^~~~~~~~~
tests/coding/coding_test.c:448:23: warning: ‘*result[39]’
                                   may be used uninitialized
  448 |                 result[len - 1] &= 0x07;
      |                 ~~~~~~^~~~~~~~~

The idea here is to pre-clear some bits in the resulting buffer,
because they're not going to be set during decoding of the burst
bits.  The problem is that result[] holds uninitialized data, so
we're basically taking a 'garbage' octet and clear some of its
bits.  The remaining 'garbage' bits of that octet are overwritten
by the decoder, so in the end we still get deterministic results.

Let's make GCC happy by clearing all bits in the last octet.

Change-Id: I24d79de8b3a5f4184b71414504657e5857498e0e
2023-12-08 03:58:37 +07:00
Vadim Yanitskiy fadda01f44 coding: implement encoding/decoding API for TCH/F2.4
See 3GPP TS 45.003 section 3.6.  This channel mode is a bit special,
because unlike the other CSD specific channel modes it's interleaved
over 8 (not 22!) consecutive bursts, just like TCH/FS.

Change-Id: I4685376c8deb04db670684c9ebf685ad6fc989fa
Related: OS#1572
2023-07-08 06:42:09 +07:00
Vadim Yanitskiy b04d59e997 coding: fix _tch_csd_burst_map(): do not overwrite FACCH
As was demonstrated in the unit test [1], FACCH bitstealing does not
work as expected in conjunction CSD specific encoding functions.

The problem is in _tch_csd_burst_map(): we don't check the stealing
flags hu(B) and hl(B) and overwrite both odd and even numbered bits
unconditionally.  Even worse, we reset these stealing flags to 0.

* Do not overwrite the hu(B) and hl(B) flags.
* Copy *even* numbered bits only if hu(B) is not set.
* Copy *odd* numbered bits only if hl(B) is not set.

Change-Id: Ib5395c70e3e725469c18ff7d4c47c62ddfdbd55d
Related: [1] Idc6decec3b84981d2aab4e27caab9ad65180f945
Related: OS#1572
2023-05-26 02:48:21 +07:00
Vadim Yanitskiy 31f761f7c1 coding: test FACCH/[FH] bitstealing in test_csd()
In test_csd() we encode three data frames filled-in with three specific
patterns and then try decoding them.  Additionally execute the same set
of tests, but with FACCH/[FH] bitstealing (pattern 0x2b).

As can be seen from the test output, we have problems decoding FACCH:

* FACCH/F: decoding fails (n_errors=0 / n_bits_total=0),
* FACCH/H: decoding with errors (n_errors=2 / n_bits_total=456).

A patch fixing the problem follows.

Change-Id: Idc6decec3b84981d2aab4e27caab9ad65180f945
Related: OS#1572
2023-05-26 02:48:18 +07:00
Vadim Yanitskiy b334022aba coding: implement dedicated codec API for FACCH/[FH]
Currently FACCH/[FH] encoding and decoding is implemented as part of
the gsm0503_tch_[fh]r_{en,de}code and gsm0503_tch_a[fh]s_{en,de}code
API.  This works fine for speech because one FACCH frame completely
replaces one or two speech frames, but this is not the case for CSD.

According to 3GPP TS 45.002, sections 4.2.5 and 4.3.5, for TCH data
channels FACCH does not replace data frames but disturbs some amount
of bits from them.  Therefore we need to be able to perform FACCH
encoding and decoding independently from CSD specific coding API.

Change-Id: I0c7a9c180dcafe64e6aebe53518d3d11e1f29886
Related: OS#1572
2023-05-26 02:35:11 +07:00
Vadim Yanitskiy 9a22827cf6 coding: implement TCH/F9.6, TCH/[FH]4.8, TCH/H2.4, TCH/F14.4
Implement all CSD specific channel modes, except TCH/F2.4.  All of
these modes are more or less similar to each other.  The TCH/F2.4
is more similar to TCH/FS and slightly more complicated.

FACCH/F and FACCH/H will be implemented in a follow-up change.

Change-Id: Ib482817b5f6a4e3c7299f6e0b3841143b60fc93d
Related: OS#1572
2023-05-25 19:08:53 +07:00
Vadim Yanitskiy e677fccf44 coding: use gsm0503_tch_hr_decode2() in coding_test
Let's make sure the new API is covered by unit tests.
This patch also fixes a deprecation warning.

Change-Id: I4dea43f68941b5986ecc51b2e41c80741a711002
Related: 57a3b3a51f
2023-05-25 14:58:21 +07:00
Oliver Smith 04bfb7165b treewide: remove FSF address
Remove the paragraph about writing to the Free Software Foundation's
mailing address. The FSF has changed addresses in the past, and may do
so again. In 2021 this is not useful, let's rather have a bit less
boilerplate at the start of source files.

Change-Id: I5050285e75cf120407a1d883e99b3c4bcae8ffd7
2021-12-14 12:44:03 +01:00
Pau Espin e7d0d70ce7 tests/coding_test: Fix test_pdtch() results
When switching the l2 structures passes to test_pdtch() to be constant,
it was noted that output of the test changes. This happens because same
array is tested several times with different length, incrementing each
time. Since the test was modifying the input array directly, it means
each new run of test_pdtch() the array was further modified.
Upon constifying the structures, we copy the array and hence only modify
the required bits each time.

Change-Id: Iffd0ca3669eb8d0d2e80d754fc8acbf72f1bebe8
2020-04-17 10:15:05 +00:00
Pau Espin ce28d2ebba tests/coding: Test decoding of DL EGPRS data packet
Change-Id: Ide23a484b980995f24092d1cfbf062aed58fdf61
2020-04-17 10:15:05 +00:00
Vadim Yanitskiy 9e713f3828 coding: fix bit ordering in 11-bit RACH coding functions
According to 3GPP TS 44.004, figure 7.4a.b, the format of 11-bit
RACH uplink / Uplink access burst block is as defined follows:

  <---------------------------------------------------

      8     7     6     5     4     3     2     1
  +--------------------------------------------------+
  |  11 bit RACH uplink / Uplink access burst block  | OCT1
  +--------------------------------------------------+
                                 |                   | OCT2
                                 +-------------------+

As was (correctly) assumed in [1], the bit ordering in 11-bit RACH
coding functions is wrong. The problem is that neither of generic
functions from bit16gen.h can be used to load / store the RA11
value (regardless of the endianness), because they assume that
the payload is 16 bit long.

With this patch applied, RA11 values from [1] look correct:

  < EGPRS Packet channel request message content > ::=
    < Signalling : 110011  < RandomBits : 00111 > > |
    < Signalling : 110011  < RandomBits : 00110 > > |
    < Signalling : 110011  < RandomBits : 01111 > > |
    < Signalling : 110011  < RandomBits : 01100 > > |
    < Signalling : 110011  < RandomBits : 00111 > > |
    < Signalling : 110011  < RandomBits : 10110 > > ;

[1] Id80e471d252b9416217b56f4c8c0a8f5f1289fee

Change-Id: I43d30611dd69f77f2b3b46f4b56056a8891d3c24
Related: OS#1548
2020-04-01 01:09:31 +07:00
Vadim Yanitskiy 41ce6753bc tests/coding: add 11-bit Access Burst samples from a real phone
This change adds several soft-bit (-127 .. 127) sequences containing
EGPRS Packet Channel Request message (11-bit, payload only) sent by
an EGPRS capable phone, and captured on the BTS/PCU side using a
tool from the TRX Toolkit - trx_sniff.py.

As can be seen from the test output, none of decoded RA11 values
looks like a valid EGPRS Packet Channel Request message (see
table 11.2.5a.2 of 3GPP TS 44.060). All test sequences contain
the same message with several random bits:

  < EGPRS Packet channel request message content > ::=
      < Signalling : 110011  < RandomBits : bit (5) > >;

since the phone was trying to perform Attach Request. It seems
the bit order of decoded messages is somehow wrong.

Change-Id: Id80e471d252b9416217b56f4c8c0a8f5f1289fee
Related: OS#1548
2020-03-31 19:26:44 +07:00
Vadim Yanitskiy 88c61c3822 tests/coding: cosmetic: use ARRAY_SIZE() macro from utils.h
Change-Id: Ie6278d84d405f073669e607f978ca5b187bcf78e
2020-03-31 15:37:27 +07:00
Vadim Yanitskiy 0f4919e915 tests/coding: reduce verbosity of 8-bit / 11-bit RACH coding tests
We don't really need additional 1.4M of debug output, given that
we test every possible 8-bit and 11-bit RA value. It's enough
to print error message if the resulting value does not match.

Otherwise it's hard to read the expected output without commenting
the related log statements out. Note that it's still possible to
re-enable verbose debug output by defining DEBUG.

Change-Id: I0d5ed90cb0a2b3007d665520a73b0fa0b86a4099
2020-03-31 15:37:23 +07:00
Vadim Yanitskiy ca466cf5f6 tests/coding: check return value of encoding / decoding functions
Change-Id: I78850a4ab2fb7cd63bb4a3789f934634b6fb2cb7
2020-03-31 15:34:07 +07:00
Max a478590250 coding: check gsm0503_rach_*() results
Check return value of RACH encode/decode functions and fail test on
unexpected results.

Change-Id: I41bfa808e3c064a11152e7ce8ee77a01d38a0744
Related: OS#1854
2019-03-05 11:30:39 +01:00
Harald Welte 6950b191e8 coding: Add BER-reporting RACH decode functions
For all other decode operations we report the BER, but not for the
RACH.  This results in osmo-bts-trx not being able to report BER
to the higher layers, which is possible on other BTS backends.

Let's close this gap by introducing gsm0503_rach_ext_decode_ber()
and gsm0503_rach_decode_ber() with the usual n_errors / n_bits_total
arguments.

Change-Id: I2b1926a37bde860dcfeb0d613eb55a71271928c5
2018-02-26 12:26:38 +01:00
Pau Espin 41911d0380 tests: coding_test: Fix compilation with -O0
inline keyword is a hint for the compiler to inline the function, but
it's not mandatory. If no static or extern is specified, the definition
is only visible in the current unit but the identifier still has
external linkage.
When running with -O0 it seems the compiler (gcc 7.2.1) decides to use
the external linkage but at the same time it seems it's not generating
the function symbol. Fix it by explicitly stating that we want to use
static linking for this function.

coding/coding_test.o: In function `test_xcch':
libosmocore/tests/coding/coding_test.c:86: undefined reference to `dump_ubits'
libosmocore/tests/coding/coding_test.c:87: undefined reference to `dump_sbits'

Change-Id: I18018adec05ce1c2ddbca38653311d74c7454ce8
2018-02-08 09:41:35 +00:00
Max 32e5641dbb Add functions for extended RACH coding
Add support for extended RACH (11 bit) according 3GPP TS 45.003 §5.3.2:

* convolutional code with puncturing
* encoding/decoding routines
* corresponding tests

Change-Id: I85a34a82d5cd39a594ee89d91a2338226066ab5d
Related: OS#1548
2017-12-11 10:36:47 +00:00
Max 33dbecbbeb coding test: use OSMO_ASSERT
Change-Id: I896d6aaae3c36b87243b7dc270267090dcb44afe
2017-11-30 13:16:58 +01:00
Max 458a6f59e3 coding test: move bit dump into functions
Change-Id: I65c75e56831420d3daf386ea280c13ae9cb64d1b
2017-11-28 18:08:52 +01:00
Max 0176b4a978 coding test: enable debug output
Change-Id: I1ec23ca3cf0d973c77b8c4e7e23e0e75a4f0a7a3
2017-11-28 18:08:31 +01:00
Max 29d489f081 coding test: cosmetic cleanup
* remove duplicate code: use function from libosmocore
* use utility function to dump ubits
* reformat for easier reading
* link against libosmocore

Change-Id: I8c31b0954176a2c53305936a025c92a793b6d9b6
2017-11-28 18:02:03 +01:00
Vadim Yanitskiy 3262f820b5 libosmocoding: migrate transcoding routines from OsmoBTS
There are some projects, such as GR-GSM and OsmocomBB, which would
benefit from using one shared implementation of GSM 05.03 code. So,
this commit introduces a new sub-library called libosmocoding, which
(for now) provides GSM, GPRS and EDGE transcoding routines, migrated
from OsmoBTS.

The original GSM 05.03 code from OsmoBTS was relicensed under
GPLv2-or-later with permission of copyright holders (Andreas Eversberg,
Alexander Chemeris and Tom Tsou).

The following data types are currently supported:

 - xCCH
 - PDTCH (CS 1-4 and MCS 1-9)
 - TCH/FR
 - TCH/HR
 - TCH/AFS
 - RCH/AHS
 - RACH
 - SCH

Change-Id: I0c3256b87686d878e4e716d12393cad5924fdfa1
2017-03-07 01:06:38 +07:00