Commit Graph

2848 Commits

Author SHA1 Message Date
Vadim Yanitskiy 2060b5b7cc trxcon/scheduler: refactor Downlink measurement processing
So far we used to store the sums of ToA and RSSI measurements in the
logical channel state, and after decoding of a block, we did calculate
the average. This approach works fine for xCCH and PDTCH, but when it
comes to block-diagonal interleaving (which is used on TCH/F and TCH/H
channels), the results are incorrect. The problem is that a burst on
TCH may carry 57 bits of one encoded frame and 57 bits of another.

Instead of calculating the sum of measurements on the fly, let's push
them into a circular buffer (the measurement history), and keep them
there even after decoding of a block. This would allow us to calculate
the average of N last measurements depending on the interleaving type.

A single circular buffer can hold up to 8 unique measurements, so the
recent measurements would basically override the oldest ones.

Change-Id: I211ee3314f0a284112a4deddc0e93028f4a27cef
2020-03-08 22:50:54 +00:00
Vadim Yanitskiy d534d43fc1 trxcon/scheduler: TCH/H & FACCH/H: fix notes on interleaving
Change-Id: I16cdd2261b3d0d99286c30584847f93d72d02ac0
2020-03-08 22:50:54 +00:00
Vadim Yanitskiy 03f220ecae trxcon/scheduler: make TDMA_FN_INC(fn) behave like ++fn
Change-Id: I9c2fa26df54b5de836a18f09363a9221c24ae707
2020-03-08 22:50:54 +00:00
Harald Welte a1be0a6b62 cbch_sniff: Use CCCH_MODE_COMBINED_CBCH, not CCCH_MODE_COMBINED
In Change-Id Ia94ebf22a2ec439dfe1f31d703b832ae57b48ef2 we
introduced a new member to the ccch_mode enum: CCCH_MODE_COMBINED_CBCH,
which is to be used to tell the PHY if a CBCH is present on the combined
CCCH+SDCCH/4+CBCH or not (CCCH+SDCCH4).

This was implemented in trxcon + calypso firmware, but cbch_sniff has
not been updated accordingly.

Related: OS#4439
Change-Id: I429d45cfb181da4a2e767e92f1213ccd08c6d440
2020-03-07 16:25:46 +01:00
Harald Welte 90616c1eba virtphy: Don't pass CBCH to L1CTL if not requested by application
Doing so can create a number of warning messages in e.g. 'mobile'
like
<0015> lapd_core.c:1239 Unnumbered frame not allowed. (dl=0x55c632f9f220)
<0015> lapd_core.c:392 sending MDL-ERROR-IND cause 12 from state LAPD_STATE_IDLE (dl=0x55c632f9f220)
<0015> lapdm.c:481 sending MDL-ERROR-IND 12
<0001> gsm48_rr.c:4977 MDL-Error (cause 12) ignoring

Change-Id: I2cf65be5b2f879fe940e08c9f369bc1cada7b0dd
Closes: OS#4439
2020-03-07 16:25:46 +01:00
Harald Welte d32797677d virt_l1_sched_execute: talloc_free() TDMA item after unlinking it
We so far relied on it being free'd once the TDMA item is free'd,
but let's make it more explicit.  After we've unlinked it from the
list, nobody is going to reference it ever again.

Change-Id: I57a596428be10ce720e0b528ecfc44a70e3e3078
2020-03-07 10:31:48 +01:00
Harald Welte ee26ba6e60 cosmetic: Use INIT_LLIST_HEAD() and llist_add_tail()
... instead of manually re-inventing them.

Change-Id: I7e0810aa7fd1daa8f9f3e46a207589a4c6da836b
2020-03-07 10:18:18 +01:00
Neels Hofmeyr 0c77a7f4cf mobile: fix gsm_recv_voice: pull l1ctl header from TCH payload
That function encapsulates the RTP payload in an MNCC header, but the l1ctl dl
header has to be removed first to get only the RTP payload in the MNCC
structure.

Change-Id: Id6ddc9b1da43e88c5b9468d4397a39953bdf533a
2020-03-05 13:32:58 +01:00
Neels Hofmeyr bf4a026db9 remove unused func decl
Change-Id: I94c8fff1557c0ce50cc3072573ef7cda8622fb84
2020-03-05 13:32:56 +01:00
Vadim Yanitskiy 60ce345755 mobile/gsm322: fix use-after-free of cs->si reported by ASan
This pointer cs->si stores an address to the System Information of
a currently selected cell. When we release System Information,
ensure that it does not point to free()d memory.

Change-Id: Ife2ddf7274a48447a9ded9035f9dd01befaf2e6c
2020-03-01 02:22:13 +07:00
Vadim Yanitskiy c083e2ce90 layer23/l1ctl: fix NULL-pointer dereference reported by ASan
Some applications (e.g. ccch_scan) may not initialize ms->cellsel.si,
some (e.g. mobile) may need some time to initialize it. Let's assume
that 'bs_ag_blks_res' is 1 if System Information is not available.

Change-Id: Ie695d9700c01ee1e6778950a2f3c8610b69d2143
2020-03-01 02:22:13 +07:00
Vadim Yanitskiy 3f25909e10 trxcon/scheduler: print completeness of the Rx burst buffers
Change-Id: Ife9f5eabc23aa2eea08b190361e10a98e890d608
Related: OS#3554
2020-03-01 01:46:51 +07:00
Vadim Yanitskiy 2d355c2453 virt_phy/build: add configure option to build with ASan/USBan
Change-Id: I23fc4e38632c02269b3895115ba4e3171cc212d1
2020-02-27 23:46:40 +07:00
Harald Welte 938faa16e4 layer23: Terminate process if L2 socket fails/dissappears
We don't recover from this situation at all, so it's best to
terminate the process.

Change-Id: I487d18e4afe2cae9f777a30864e680b5dc821fc1
2020-02-26 00:13:04 +01:00
Pau Espin 5738e579b2 layer23: Fix build against gpsd >= 3.20
During 3.19->3.20 dev cycle, some fields were transformed from
timestamp_t or double to timespec_t. See for instance gpsd.git
f7c230fceb6d64483757f8c32afb98e6a2cb9413.

Change-Id: Ie8ba19d030b6f46f2d8afc270a732ce8c26c438f
2020-01-13 17:28:25 +01:00
Pau Espin 6970755342 layer23: Avoid sending downlink AGCH/PCH fill frames over GSMTAP
Some bits are taken from osmo-bts l1sap.c.

Change-Id: Id21e9334b620b8ab3ad404708bfd5358e3555ab6
2019-12-31 17:05:50 +00:00
Pau Espin ae431deae4 layer23: Identify AGCH from PCH on tx of GSMTAP downlink messages
Some bits are taken from osmo-bts l1sap.c

Change-Id: I0adab003a4060c9cef730e0432859659c51bd087
2019-12-31 17:05:50 +00:00
Pau Espin 750faef5ba mobile: Send correct ARFCN in UL gsmtap
Change-Id: I9f677866095413a0efeb8a336ce15a2dbca2228c
2019-12-31 17:05:50 +00:00
Vadim Yanitskiy 7a49fc31c1 trx_toolkit/data_dump.py: rewrite unit tests to use unittest framework
Change-Id: I8b934c15ba96d856aa79d10bf296d1446f043dd1
2019-12-31 17:03:12 +00:00
Vadim Yanitskiy 5cee398277 trx_toolkit/data_msg.py: rewrite unit tests to use unittest framework
Change-Id: Ia0cc7447b193a705e994078d16f3902339219916
2019-12-31 17:03:12 +00:00
Vadim Yanitskiy f445db03c7 contrib/jenkins.sh: also run unit tests for TRX Toolkit
Python's unittest module will automatically discover all unit tests
in a given directory (files starting with 'test*.py'). The existing
tests will be rewritten in subsequent changes.

Change-Id: Ia3990dc8e1ff98b83d3ee25fafa5b029f46646cd
2019-12-31 17:03:12 +00:00
Vadim Yanitskiy 5198385533 contrib/jenkins.sh: also verify building the firmware
Change-Id: I4c224ef7855a2ac35476cbdd96c29565151a2830
2019-12-31 17:03:12 +00:00
Pau Espin 4ddb2e61c7 layer23: Fix trailing whitespace
Change-Id: I295f285e5fc3cdc372723f6b4de2415a94d4979a
2019-12-20 16:47:21 +01:00
Pau Espin 5b7fc0a8cc trxcon: Use current MS Power on dummy meas reports
backpointers are added in order to access the TRX, as advised in the
existing comment.

Change-Id: I975cfc5f5d63eb32a7f8932a7f6a544c9a12233c
2019-12-04 14:41:56 +01:00
Vadim Yanitskiy 7069dfc051 trxcon/sched_trx.c: fix potential NULL-pointer dereference
Change-Id: If1ecd9f5a70fa448327c62d38d76c8443b939248
2019-12-01 13:11:42 +00:00
Harald Welte 0356e56572 Check for osmo_fsm_register() error return value
Change-Id: I3e849b7ec8a7ed610f779dac57cc0c1d1aeb1aa5
2019-12-01 13:46:06 +01:00
Vadim Yanitskiy a15fbcbdf3 trx_toolkit/clck_gen.py: drop unneeded debug print()
Change-Id: I372af77d5b0b24fa38e304b782ca5b3d0888211b
2019-11-24 02:24:42 +07:00
Vadim Yanitskiy 6b0946ee69 trx_toolkit/clck_gen.py: turn CLCKGen's thread into a daemon
If the main thread crashes, the CLCKGen's thread would never stop.
It would also happen if the main thread terminates without calling
CLCKGen.stop().  Let's prevent this by creating a daemon thread.

Change-Id: I9d41c5baa25fa0a263758414a164c1bded25e04e
2019-11-24 02:24:42 +07:00
Vadim Yanitskiy baf07c4be2 trx_toolkit/clck_gen.py: refactor CLCKGen to use a single thread
The previous approach was based on threading.Timer, so on each clock
iteration one thread spawned another new thread.  So far it worked
well, but such frequent spawning involves an additional overhead.

After this change, CLCKGen.start() allocates and starts a new thread,
that periodically sends clock indications and sleep()s during the
indication intervals.  The CLCKGen.stop() in its turn terminates
that thread and frees the memory.

Change-Id: Ibe477eb0a1ee2193c1ff16452a407be7e858b2ef
2019-11-24 02:24:34 +07:00
Vadim Yanitskiy ae8e5ad648 trx_toolkit/fake_trx.py: send NOPE.ind in case of path loss simulation
Since TRXD header version 1, we should send NOPE indications to the
L1 side in absence of TRX2L1 bursts, and IDLE indications during
IDLE TDMA frames (basically noise measurements).

This change is the first step towards the goal: if a given burst
is to be dropped due to the path loss simulation (see FAKE_DROP),
mark the carrier TRX2L1 message as NOPE.ind and send anyway.

Change-Id: Iabd0af665e3108d23a908638f943a5b689986e2c
Related: OS#3428, OS#2975
2019-11-20 15:05:57 +00:00
Vadim Yanitskiy 7108c28c38 trx_toolkit/data_msg.py: fix: NOPE.ind also contains C/I filed
Change-Id: I281fb7387a83fec7e097ebf8650c95713d3f70e9
2019-11-20 15:05:57 +00:00
Vadim Yanitskiy b1ae186c55 trx_toolkit/fake_trx.py: refactor L12TRX -> TRX2L1 burst transformation
The burst transformation in BurstForwarder.forward_msg() used to be
done only once, so then the resulting message was distributed over
the list of connected (and active) transceivers.

This approach limits the path loss simulation capabilities, because
a reference to the same message is passed to FakeTRX.send_data_msg().
If one transceiver changes (or removes) the burst bits, the other
transceivers would not receive the original message.

Let's do the transformation individually for each transceiver,
so the original message will always remain unchanged.

Change-Id: Ia016a3a9bb6e9f17182a7168aa5a501ae9b9978b
2019-11-20 15:05:57 +00:00
Vadim Yanitskiy 65dbd471fc mobile/gsm48_mm.h: use fixed-size integer types in packed structures
Change-Id: I54ed93c03ebe776bdc7eb761a8194da3ab0b67fb
2019-11-17 19:09:59 +07:00
Vadim Yanitskiy 62164b9eab mobile/gsm48_mm.h: mark some structures as 'packed'
In several code paths we put / push structures from 'gsm48_mm.h' into
the message buffers, so then they're unpacked by the message receivers.

The AddressSanitizer complains about unaligned pointer access and
potentially unexpected behaviour. Let's fix this by explicitly
marking those structures as 'packed'.

Change-Id: I6af7475c609b3293af708540d569fe1616fab43f
2019-11-17 18:49:11 +07:00
Vadim Yanitskiy afd5b8247f mobile/gsm48_rr.c: fix NULL-pointer dereference in gsm48_rr_check_mode()
In some cases (e.g. at start up) ms->rrlayer may not be initialized.
Let's access ms->settings directly since we already have a pointer
to struct osmocom_ms.

Change-Id: Ia9720132fcda960dcecefab9ae48398946503dc4
2019-11-17 17:46:48 +07:00
Vadim Yanitskiy 2605d96720 trx_toolkit: fix: do not use 'is' / 'is not' with string and numerical literals
Since version 3.8, Python warnins us that using the "is" and "is not"
operators with string and numerical literals is a bad idea. Let's
avoid this and use the classical '==' and '!=' operators instead.

Change-Id: Iaed86d630ac1e0b9b4f72bbf3c788e325783456d
Bug description: https://bugs.python.org/issue34850
2019-11-17 17:46:48 +07:00
Pau Espin eb0560e19e trxcon: Fix missing header for GSM_MACBLOCK_LEN
Due to recent include dependency tree change in libosmocore, trxcon
fails now to build since it uncovered it's missing a header inclusion
for a symbol it is using:

osmocom-bb/src/host/trxcon/sched_trx.h:204:20: error: ‘GSM_MACBLOCK_LEN’ undeclared here (not in a function)
  204 |   uint8_t mr_cache[GSM_MACBLOCK_LEN];
      |                    ^~~~~~~~~~~~~~~~

Change-Id: Ide22e525c106342b00171a8c08bb7265d19a651b
2019-11-05 12:52:22 +01:00
Martin Hauke a4046877c6 Fix typo: miliseconds -> milliseconds
Change-Id: I472c12fd1dfbff4ca1ead972535d735857f1c3e7
2019-10-22 14:07:31 +00:00
Martin Hauke 1f7a2ab5d3 Fix common misspellings and typos
Change-Id: I962b42871693f33b1054d43d195817e9cd84bb64
2019-10-17 08:07:39 +00:00
Vadim Yanitskiy 9731f0d322 host/trxcon: add optional GSMTAP frame logging support
This feature may be useful for our TTCN-3 testing infrastructure.
By default it's disabled, and can be enabled using command line
arguments of the main binary:

  ./trxcon -g 127.0.0.1 ...

Change-Id: Iab4128fee5f18d816830fdca6c5ebebaf7451902
2019-10-05 17:50:20 +07:00
Vadim Yanitskiy 5516b42336 trxcon/scheduler: fix handling of PTCCH logical channel
According to 3GPP TS 45.010, section 5.6.2, for packet-switched
channels the BTS shall monitor the delay of the Access Bursts
sent by the MS on PTCCH and respond with timing advance values
for all MS performing the procedure on that PDCH.

According to 3GPP TS 45.002, section 3.3.4.2, PTCCH (Packet Timing
advance control channel) is a packet dedicated channel, that is
used for continuous Timing Advance control (mentioned above).

There are two sub-types of that logical channel:

  - PTCCH/U (Uplink): used to transmit random Access Bursts
    to allow estimation of the Timing Advance for one MS in
    packet transfer mode.

  - PTCCH/D (Downlink): used by the network to transmit
    Timing Advance updates for several MS.

As per 3GPP TS 45.003, section 5.2, the coding scheme used for
PTCCH/U is the same as for PRACH as specified in subclause 5.3,
while the coding scheme used for PTCCH/D is the same as for
CS-1 as specified in subclause 5.1.1.

The way we used to handle both PTCCH/U and PTCCH/D is absolutely
wrong - it has nothing to do with xCCH coding. Instead, we need
to use rx_pdtch_fn() for Downlink and tx_rach_fn() for Uplink.

Also, since we only have a shared RSL channel number for PDCH
(Osmocom-specific RSL_CHAN_OSMO_PDCH), there should be a way
to distinguish both PDTCH and PTCCH logical channels. Let's
introduce TRX_CH_LID_PTCCH for that.

Change-Id: I2d1e9b8a66f027047f8d7bdc3f82ff9d8ebcc25e
2019-09-30 20:50:28 +07:00
Vadim Yanitskiy a2ac6d6724 trxcon/scheduler: fix comment in description of PDTCH
Change-Id: Ifd4197b64e89ae6da93ef32189f437a6e297b03f
2019-09-30 20:50:14 +07:00
Vadim Yanitskiy 5afc0e4cb0 trx_toolkit/data_msg.py: enrich some ValueError messages
Change-Id: Icdf0d136a9b820cfaec534e2604204da9ea42092
2019-08-29 18:02:04 +02:00
Vadim Yanitskiy 171773b3e8 trx_toolkit/data_msg.py: also print burst length in desc_hdr()
Change-Id: Ia0036cbf70a3736a7f9779e030e05221cba8add9
2019-08-29 18:02:00 +02:00
Vadim Yanitskiy 59903772fa trx_toolkit/data_msg.py: fix: make sure header version is known
Before using DATA_MSG.HDR_LEN, we need to make sure that a parsed
header version is known and supported. Otherwise we will get an
IndexError exception.

Change-Id: Ie1887aa8709da1a2a287aa58a7873e72c0b4ed33
2019-08-29 15:09:40 +02:00
Vadim Yanitskiy df86074abe trx_toolkit/data_msg.py: fix message length check in parse_msg()
Unlike DATA_MSG.HDR_LEN, the CHDR_LEN is a constant that defines
length of the common header, which is mandatory for every version.
DATA_MSG.HDR_LEN in its turn defines length of the whole header,
including the version specific fields. Thus we need to know the
header version before using it.

In DATA_MSG.parse_msg() we need to parse the common header first,
so then we know the version and length of the whole header. After
that we can safely use DATA_MSG.HDR_LEN.

Change-Id: I2809f5f96209eed64bdabf7a15575144313f7cc9
2019-08-29 15:04:28 +02:00
Vadim Yanitskiy 5fed799df3 trx_toolkit/trx_sniff.py: also print header for incorrect messages
Change-Id: I376f1e7af46750e53305109cf4a9f64427b9960c
2019-08-27 21:13:31 +02:00
Vadim Yanitskiy 83a41a63b2 trx_toolkit/trx_sniff.py: also validate() sniffed messages
Change-Id: Ica3e4702fdabfdae0c1025b650ff32c8e85a6edf
2019-08-27 21:06:58 +02:00
Vadim Yanitskiy 78199f4f7b trx_toolkit/trx_sniff.py: print exact message parsing error
For sure, the following message is much more informative:

  Ignoring an incorrect message: Unhandled version 12

than:

  Failed to parse message, dropping...

NOTE: since the way of printing exceptions is different in both
Python versions, I had to drop Python 2 support.

Change-Id: I5fb02ce508c58ff94e47accc0ed655939eb53062
2019-08-27 21:04:47 +02:00
Vadim Yanitskiy 6af5d8da2c trx_toolkit/data_msg.py: raise exceptions from validate() methods
Raising exceptions is a Pythonic way to handle errors, which in this
particular case will help us to know *why* exactly a given message
is incorrect or incomplete.

Change-Id: Ia961f83c717066af61699c80536468392b8ce064
2019-08-27 20:30:23 +02:00