Commit Graph

101 Commits

Author SHA1 Message Date
Pau Espin 57c2e68da2 vty: Allow setting LAC as hexadecimal value
The LAC value currently configured is now printed as hexadecimal value
too.
It can still be entered as a decimal value in order to keep backward
compatibility, though the hexadecimal one is now preferred.

Related: OS#5631
Depends: libosmocore.git Ia2b7fbbf5502c28374c21dbff548232680da27d4
Change-Id: I9090d73ae9d39244b79b9dbafa1b164faebabc52
2022-09-19 08:44:25 +00:00
Pau Espin 3d0fbe387f split lchan specific defines and code to its own file
It is really difficult right now to find out where all the different
stuff relative to operation and lifecycle of an lchan is. Let's move
everything to its own file to have all the related defines and logic
together.

Change-Id: Idd855d126c43ac6576c5f3ba7e0b8014127a65e1
2022-08-09 08:38:51 +00:00
Vadim Yanitskiy a019e9af8b lchan_select: implement dynamic selection mode for assignment
This change implements an additional channel allocation mode, which
can be employed during a TCH channel allocation for assignment.
Selection between ascending and descending order is performed
depending on pre-configured parameters:

* Uplink RxLev threshold and number of samples for averaging,
* C0 (BCCH carrier) channel load threshold.

This is useful in setups where Tx power of the RF carriers cannot be
adjusted +dynamically at run-time and thus BS Power Control cannot
be performed.  In such setups the BCCH carrier is transmitting at
relatively higher power than the other RF carriers.  The key idea
is to allocate channels in a smarter way, so that UEs with poor signal
would get channels on carriers with high Tx power, while UEs with good
signal could use carriers with lower Tx power.

Change-Id: I1b7a0d706976b73cc5c30a8714b830811addfe8d
Related: osmo-ttcn3-hacks.git Ia522f37c1c001b3a36f5145b8875fbb88311c2e5
Related: SYS#5460
2022-06-30 16:36:55 +00:00
Vadim Yanitskiy c2928ac269 lchan_select: allow different alloc order for assignment and handover
A follow-up patch implements a special channel allocation mode, which is
only working for assignment (basically TCH selection for a voice call).
This mode cannot be employed for initial CHANNEL REQUEST or handover due
to the absence of an already established lchan.

Adding this mode to the existing VTY command syntax would be confusing:

  channel allocator (ascending|desscending|dynamic)
                                           ^^^^^^^

so this patch extends the VTY syntax in a way that it becomes possible
to configure different channel allocator modes for different cases:

  OsmoBSC(config-net-bts)# channel allocator mode ?
    set-all     Set a single mode for all variants
    chan-req    Channel allocation for CHANNEL REQUEST (RACH)
    assignment  Channel allocation for assignment
    handover    Channel allocation for handover

The old command syntax, which is basically 'set-all', is kept for
backwards compatibility, but marked as deprecated.

Change-Id: I3ae73b36ee9433cc768376b56f0765e5f416162f
Related: SYS#5460
2022-06-30 16:36:41 +00:00
Neels Hofmeyr c1bfc88b6b fix performance for chan_counts and all_allocated stats
The all_allocated_update_bsc() does inefficient iterating to count
active/inactive lchans, which scales badly for high numbers of TRX
managed by osmo-bsc.

We need to update the all_allocated flags immediately (periodic counting
alone would suffer from undersampling), so, until now, we are calling
this inefficient function every time a channel state changes.

Instead of iterating all channels for any chan state changes anywhere,
keep global state of the current channel counts, and on channel state
change only update those ts, trx, bts counts that actually change.

A desirable side effect: for connection stats and handover decision 2,
we can now also use the globally updated channel counts and save a bunch
of inefficient iterations.

To get accurate channel counts at all times, spread around some
chan_counts_ts_update() calls in pivotal places. It re-counts the given
timeslot and cascades counter changes, iff required.

Just in case I missed some channel accounting, still run an inefficient
iterating count regularly that detects errors, logs them and fixes them.
No real harm done if such error appears. None show in ttcn3 BSC_Tests.
It is fine to do the inefficient iteration once per second; channel
state changes can realistically happen hundreds of times per second.

Related: SYS#5976
Change-Id: I580bfae329aac8d4552723164741536af6512011
2022-06-02 14:24:30 +02:00
Vadim Yanitskiy 7fb4817b78 struct gsm_encr: store alg_id in human-readable format
I find it weird that we store the A5 algorithm ID in a format that
is used on the wire: N + 1 (valid for both A-bis and A interfaces).
What confused me even more is that in some functions we print it
as if it was in a normal, human-readable format.  And this is
also why one can see weird constructions like:

  if (lchan->encr.alg_id > ALG_A5_NR_TO_RSL(0)) { ... }

Let's ensure that our internal structures use the A5/N format:

  alg_id=0: A5/0   (0x01 on the A-bis/A interface)
  alg_id=1: A5/1   (0x02 on the A-bis/A interface)
  alg_id=2: A5/2   (0x03 on the A-bis/A interface)
  ...
  alg_id=7: A5/7   (0x08 on the A-bis/A interface)

so that we can print and compare the value of alg_id without using
additional arithmetics.  Let's also rename 'alg_id' to 'alg_a5_n'
as it most clearly indicates which representation it is storing.

This is how the above code snippet would look like:

  if (lchan->encr.alg_a5_n > 0) { ... }

Change-Id: Ieb50c9a352cfa5481aebac2379e0a461663543ec
2022-03-29 11:50:12 +00:00
Neels Hofmeyr 53b23c252e fix gscon clear 3/n: separate state for SCCP RLSD
Properly implement the separate conn release stages in separate FSM
states:

x) sent Clear Request, wait for a Clear Command from the MSC.
   Timeout after a configurable 60s.

y) after a Clear Command and sending a Clear Complete, wait for the SCCP
   RLSD. Timeout after a configurable 60s.

z) terminate after the RLSD is received / after timeout.

handover_test.c needs a little tweak to make the MGCP release work with
its fake MGCP client, because cleanup now ensures to invoke
gscon_forget_mgw_endpoint() in all cases.

Related: I680ec4ed866aa5f0b1ff29e7e98322615cfb288d (osmo-ttcn3-hacks)
Related: OS#5337
Change-Id: Ie975117d37f38ba853589dc7f8d3e94f8f9586b2
2022-01-12 22:41:33 +06:00
Pau Espin eb36819b4d Get rid of lots of stubs [4/4]
These are not needed anymore since we re-introduced libbsc, specially to
avoid all this churn.

Some specific methods are explicitly required to be overwritten by
tests, so we specificially mark those with __attribute__((weak)) in
order to be able to overwrite them.

This is the last step towards fixing interdependency mess of symbols and
stubs, and requires previous patches in order to have tests apssing
fine.

Change-Id: Ic7401b8a6eb903882e30fda1cf091ac99a254ef0
2021-10-07 14:08:29 +02:00
Pau Espin 40c7410f9e Move ts_fsm_init to static constructor [3/4]
This allows having it initialized automatically, as we usually do with
this type of code. As a result, tests or other apps importing libbsc
don't need to take care of calling it.

NOTE: This fix is required by follow-up patches where some stubs are removed
and hence some tests start using FSMs internally. Since tests were not
using those FSMs before, there was no need to call ts_fsm_init().

This is one further step towards fixing interdependency mess of symbols
and stubs.

Change-Id: I0e4b95b5e73fbb3844d83ba33e66786831088e1f
2021-10-07 14:08:22 +02:00
Pau Espin 12adbeaba3 Move global var bsc_gsmnet into libbsc [2/4]
This is used inside group of files forming libbsc (shared files used by
several apps). Let's instantie only once inside a file from libbsc
instead of doing so on each binary.

This is one further step towards fixing interdependency mess of symbols
and stubs.

Change-Id: I9b287aa492ca6aae5fc56133e1510aff3146fe25
2021-10-07 14:08:15 +02:00
Philipp Maier 8d22e68706 osmo_bsc_main: integrate MGW pooling into osmo-bsc
Since the libosmo-mgcp-client now supports MGW pooling, lets use this
feature in osmo-bsc. Large RAN installations may benefit from
distributing the RTP voice stream load on multiple media gateways.

Depends: osmo-mgw Icaaba0e470e916eefddfee750b83f5f65291a6b0
Change-Id: I8f33ab2cea04b545c403a6fe479aa963a0fc0d0d
Related: SYS#5091
2021-09-03 15:03:38 +00:00
Neels Hofmeyr f8bed50e05 vty: add "msc N bssmap reset" command
Allow resetting the BSSMAP link from VTY, for BSC_Tests.ttcn.

In the field, detecting that an MSC is lost is done by getting three
connection failures in a row. For the BSC_Tests, it is easier to just
provide a VTY command to reset an MSC's link status.

I want to add tests that verify the stat items reflecting the MSC
connection status. To be able to run a test expecting fewer connected
MSC after a test that launched more MSCs requires the links to be reset.

Related: SYS#5542
Related: Ice3056dc46c94f9399f8379db7aeb7193782f2f2 (osmo-ttcn3-hacks)
Change-Id: I1975941b790d2b30d0904d41e456220cba26ecff
2021-08-30 16:18:12 +00:00
Neels Hofmeyr ae0b737c62 separate 'interference-meas level-bounds' cfg and used
The VTY defun already indicates BSC_VTY_ATTR_RESTART_ABIS_OML_LINK
correctly, but so far we would immediately start using the new values
internally, and wrongly interpret interference levels. Fix that.

Have bts->interf_meas_params twice: interf_meas_params_cfg for the VTY
configured values, and interf_meas_params_used for the values that the
BTS actually knows about, after they were sent via OML.

In a running BSC, when changing the interference level boundaries on the
telnet VTY, the BTS is not immediately told about the change. That would
require a BTS restart. Hence store the cfg values separately in
interf_meas_params_cfg. For comparing/printing interference levels in a
running BTS, only employ the values that were actually sent via OML and
placed in interf_meas_params_used.

Related: SYS#5313
Change-Id: Iad8cf4151ff7f86dc0549158ed5d91d788d40b1f
2021-07-16 16:04:18 +00:00
Neels Hofmeyr b55ff05eb8 handover_test: add fake-time 'wait'
Add a 'wait' cmd that lets (fake) time pass.

An ucoming patch will show the
first use of this: "test_penalty_timer.ho_vty: show lchan recovery"
I8f7668b6d08a0dac9e90d2358955f9d5099d39fa

My actual original reason to add this follows in patches
- "handover tests: test passing of penalty timeout"
  I65e59cc7309778cf9d71612669ce84d101c8135e
- "hodec2: add low-rxqual-assignment penalty timer (2/2)"
  Id00a07313fe04eec509b336c0637b59c707760e0

Related: SYS#5198
Change-Id: Ia6b5696adef7e7bf649473b4d79b96acf3aa59e3
2021-07-15 09:28:18 +00:00
Neels Hofmeyr 1d9e758e76 handover_test: also show when an lchan is busy
In expect-ts-use, indicate a busy lchan with letter '!'.

The code is a bit complex because of the choice made earlier to show two
TCH/H subslots as "TCH/HH", "TCH/H-" or "TCH/-H" depending on the
subslot states:
- show "-" as a shorthand for "all subslots UNUSED"
- show a "TCH/" prefix only when there is any "H" or "F" following, i.e.
  when any subslot is actually established
- if a subslot is busy (any other state besides ESTABLISHED and UNUSED),
  indicate the subslot as '!'.

The spectrum of reported state strings for TCH/F is:

 TCH/F  !  -

For TCH/H:

 TCH/HH TCH/H- TCH/-H TCH/H! TCH/!H !- -! -

The only current test affected is test_penalty_timer.ho_vty, where a
failed handover leaves an lchan in LCHAN_ST_WAIT_AFTER_ERROR. Adjust
that test.

Rationale: I will soon add tests to verify the accurate timeout of a
handover2 penalty timer. While implementing, I noticed that immediate
retry of the handover ends up in timeslot 2, because timeslot 1 is still
in WAIT_AFTER_ERROR. Instead of working around that, I would like to
explicitly show the error state in the test -- it is an important
aspect.

Related: SYS#5198
Change-Id: I735ce7e2c3e0e450d3f76047d7e47691fe889cad
2021-07-15 09:28:18 +00:00
Oliver Smith e0c62bb9bd handover_test: fix ts_str may be uninitialized
Fix for:
  handover_test.c: In function 'res_ind':
  handover_test.c:1094:30: error: 'ts_str' may be used uninitialized in this function [-Werror=maybe-uninitialized]
       char subslot_val = ts_str[lchan->nr];

Fixes: f76424 ("RES IND: add test_resource_indication.ho_vty")
Change-Id: I398ba24b945bad96896eeb5ddbaff9c48bacf8ab
2021-07-12 10:28:35 +02:00
Neels Hofmeyr f764248b03 RES IND: add test_resource_indication.ho_vty
Show that osmo-bsc does not yet take Resource Indication's reported
interference levels into account. (An upcoming patch will change that.)

This test is not actually doing any handover, but it is using the
handover/*.ho_vty scripting that was intended for handover testing.
(Like test_dyn_ts_favor_half_used_tch_h_as_target.ho_vty does.)

Related: SYS#5313
Change-Id: I56ec61196a1e103f0b4caf18d25d8222bb82cf87
2021-07-11 20:48:36 +02:00
Pau Espin cc75145131 Rename osmo dyn ts enums to contain SDCCH8
They will gain support to be activated as SDCCH/8 soon too.

Related: OS#5309
Depends: libosmocore.git I56dcfe4d17899630b17f80145c3ced72f1e91e68
Change-Id: Id5b89fe589a52ff88486435ac43809edb4b80f98
2021-07-06 07:16:15 +00:00
Neels Hofmeyr d37dcb9f68 RSL: rx and tx VAMOS Channel Number cbits for VAMOS lchans
Add the Osmocom-specific extension to indicate VAMOS shadow lchans in
RSL, in lchan lookup and RSL message transmission.

Note that RR messages containing cbits (Assignment Command, Handover
Command, ...) must *not* send Osmocom specific cbits to the MS. Only the
RSL messages directed to the BTS send Osmocom specific bits.

Related: SYS#5315 OS#4940
Depends: If33c1695922d110c0d2c60d5c0136caf2587194e (libosmocore)
Change-Id: I957eff0d2c33ec795eda75a4bff21965b0179f73
2021-06-10 16:15:35 +02:00
Neels Hofmeyr 43aeeaf05a RSL chan_nr: replace OSMO_ASSERT with error handling
It's bad to abort the program for an incompatible chan_nr.  Instead of
OSMO_ASSERT(), make sure that error handling happens all they way to the
original callers of gsm_lchan2chan_nr etc.

This is also preparation to add further error causes: Osmocom specific
cbits needed for a non-Osmo BTS.

Related: SYS#5315 OS#4940
Change-Id: I71ed6437c403a3f9336e17a94b4948fca295d853
2021-06-10 16:15:35 +02:00
Neels Hofmeyr 27c07690d9 replace ts_*_for_each_lchan() with ts_for_n_lchans()
So far we have a couple of macros iterating a specific number of lchans,
depending on dynamic timeslot state etc. With addition of VAMOS lchans,
this would become more complex and bloated.

Instead of separate iteration macros for each situation, only have one
that takes a number of lchans as argument. That allows to more clearly
pick the number of lchans, especially for non-trivial VAMOS scenarios.

Related: SYS#5315 OS#4940
Change-Id: Ib2c6baf73a81ba371143ba5adc912aef6f79238d
2021-05-31 05:20:03 +00:00
Neels Hofmeyr e262919892 add fields to reflect nr of lchans in ts struct
So far the number of usable lchans is determined on-the-fly by the
physical channel config. With VAMOS, this becomes more complex, namely
determining whether the BTS is vamos capable.

Instead of calling a function to determine the number of lchans for
every use, rather place the number of valid lchans in int members of the
timeslot struct, and initialize those during timeslot setup.

Actual use of these new fields will follow in a subsequent patch, which
introduces the ts_for_n_lchans() macro to replace current lchan
iteration macros.

Related: SYS#5315 OS#4940
Change-Id: I08027d79db71a23e874b729c4e6173b0f269ee4f
2021-05-31 05:20:03 +00:00
Neels Hofmeyr 1b277ec2a2 RSL link: explicitly select rsl_link based on lchan
Prepare for VAMOS, where there will be secondary "shadow" lchans serving
secondary MS on the same timeslots. For those, RSL messages will need to
reflect a different stream ID aka TEI, via an rsl_link_vamos.

Make sure that every code path that sends an RSL message for a specific
lchan selects the RSL link via the new function rsl_chan_link(). When
VAMOS is implemented, this function can select the proper RSL stream.

Rename gsm_bts_trx.rsl_link to rsl_link_primary. This makes sure I'm not
missing any uses of the RSL link, and clarifies the code.

Related: SYS#5315 OS#4940
Change-Id: Ifbf16bb296e91f151d19e15e39f5c953ad77ff17
2021-05-28 17:22:59 +00:00
Neels Hofmeyr 69def1f97e hodec 2: do intra-cell congestion resolution by Assignment
So far we do all channel reassignments by Handover Command. Since
osmo-bsc now supports rassignment of ongoing voice calls, do intra-cell
congestion resolution by Assignment Command.

In effect, add support for expecting an Assignment Command in
handover_test, and expect assignments instead of handovers for
intra-cell congestion resolution test cases.

Related: SYS#5330 OS#3277
Change-Id: Id56a890106b93fcee67ac9401b890e7b63bba421
2021-05-28 17:22:59 +00:00
Neels Hofmeyr 7470982968 handover_test: fix naming/wording: 'handover-req' should be 'handover-cmd'
Related: SYS#5315 OS#4940 OS#3277
Change-Id: I0c20971590e4b1a19f77ff3f15d58992eeebfbd9
2021-05-27 17:06:21 +02:00
Neels Hofmeyr 0951d75665 make sure channel mode and s15_s0 are updated only after an ACK
I noticed during testing that an lchan used as TCH/F in fact still had
its channel mode set to Signalling -- because on Assignment, the Speech
mode used to be placed in the *previous* lchan and the new lchan was
never updated after the Activ ACK. This is unbearable confusion which I
complained about numerous times, so far mostly for cosmetic reasons. But
implementing re-assignment properly actually requires this to be cleaned
up.

Keep all volatile chan mode settings in lchan->activate.* or
lchan->modify.*, and only update lchan->* members when an ACK has been
received for those settings. So a failed request keeps a sane state.

Make sure that those settings are in fact updated in the proper lchan,
upon an ACK, so that subsequent re-assignment or mode-modify know the
accurate lchan state.

Related are upcoming patches that sort out the AMR multirate
configuration in a similar fashion, see
Iebac2dc26412d877e5364f90d6f2ed7a7952351e
Ia7519d2fa9e7f0b61b222d27d077bde4660c40b9
Ie57f9d0e3912632903d9740291225bfd1634ed47.

Related: SYS#5315 OS#4940 OS#3787 OS#3833
Change-Id: Ie0da36124d73efc28a8809b63d7c96e2167fc412
2021-05-27 17:06:21 +02:00
Neels Hofmeyr 844dae033b handover_test: add bspower to meas-rep cmd
Subsequent patch will add a test that uses this to show a handover
oscillation problem in the presence of nonzero BS Power.

Related: SYS#5339
Change-Id: I158d4b27370ab19318f83018803853f423c89b79
2021-05-27 03:28:14 +02:00
Neels Hofmeyr f9fea61fa9 handover_test: ack release only when lchan is still waiting
Change-Id: I4c7596df06d7c211adcfcd110a1984903a0820e1
2021-05-21 15:43:30 +02:00
Neels Hofmeyr 18abd1a808 Lb: stop RESET FSM when sccp_user is unbound
A crash was reported in bssmap_le_tx_reset() sending a RESET with
sccp_user == NULL. Looking at the issue I noticed that when the
sccp_user is torn down, the RESET FSM should also be terminated.

Add bssmap_reset_term_and_free() to the generic RESET FSM implementation
and call from lb_stop() before sccp_user is set to NULL.

Related: OS#5134
Change-Id: If412ef990fcdde8ff88098a5169e86f05cd1c7f0
2021-04-27 17:34:23 +02:00
Pau Espin 5bc54d6ce8 Send EUTRAN neighs based on whether Common Id msg contained Last used E-UTRAN PLMN ID
From 3GPP TS 48.008 sec 3.1.30 "Common ID":
"""
If the SCCP connection is established due to CSFB from E-UTRAN and the MSC supports
return to the last used PLMN after CS fallback, then it should send the COMMON ID message
to the BSS including the Last used E-UTRAN PLMN ID information element if available at
the MSC immediately following the successful SCCP connection setup.
"""

Furthermore, 3GPP TS 48.008 version 16.0.0 Release 16 "3.2.1.21 CLEAR COMMAND",
for field CSFB Indication, states:
"""
NOTE: This information element doesn't serve any useful purpose. MSCs should not send the
information element unless it is required by the recipients (due to the need to interwork
with older versions of the protocol). It is expected that in future versions of the present
document, this information element will be deleted from this message.
"""

Hence, build up the EUTRAN neighbor list based on whether we received
the Last E-UTRAN PLMN ID IE during Common Id. In the future, we should
probably filter the list while populating it based on the received IE.

This change will also allow reusing same mechanism for SRVCC
EUTRAN->GERAN support, where te Last E-UTRAN PLMN ID IE can be found
inside "Old BSS to New BSS information" IE in msg HANDOVER REQUEST.

Related: SYS#5337
Change-Id: I5d290ac55eca5adde1c33396422f4c10b83c03d5
2021-04-19 12:12:31 +02:00
Neels Hofmeyr d88f9a5384 refactor handover penalty timers
So far the list of penalty timers was stored for an opaque target
pointer. That was either a gsm_bts pointer for a local BTS, or a cell
identifier list pointer for a remote-BSS cell.

Reasons to refactor penalty timers:

- The cell identifier list pointer came from the neighbor configuration
  storage, but the way cell neighbor config is stored will change in a
  subsequent patch. There will be no more cell identifier lists there.

- Storing object pointers is inherently unsafe -- if an object gets
  removed and another gets allocated, the penalty timer could
  theoretically remain in force for an unrelated object.

Rather store penalty timers for specific Cell IDs. Since remote-BSS
neighbors can be requested by a cell identifier *list*, use a
gsm0808_cell_id_list2 as key in the list of penalty timers.

Fix handover_test.c: have different CI for each local BTS. So far it was
the same LAC+CI for all BTSes, which now would make the test fail,
because any penalty timer would appear to apply to all local cells.

Related: OS#5018
Change-Id: I72dd6226a6d69c3f653a3174c6f55bf4eecc6885
2021-03-24 10:02:29 +01:00
Neels Hofmeyr b3f982fd91 handover_test: add lchan wildcards to meas-rep cmd
With 'set-ts-use', it is convenient to build a scenario of lchan usage,
but still inconvenient to send measurement reports to all lchans.

I need this for testing congestion-check, because each lchan needs to
have at least one measurement report, or congestion check is skipped.

Example:

 set-ts-use trx 0 0 states * TCH/F TCH/F - - TCH/HH TCH/HH TCH/H-
 meas-rep lchan * * * * rxlev 10 rxqual 0 ta 0

This patch adds the '*' for the lchan arguments, usually being bts idx,
trx idx, timeslot idx and subslot idx.

Use lchan wildcards at the appropriate places to shorten some tests.

Change-Id: I441f92348508d45e1069a3dfa1ff3842dbba97d6
2021-01-12 09:36:12 +01:00
Neels Hofmeyr 83952a7f71 handover_test: vty echo
Echo each handover_test command on the test output, to help with
understanding the exact point of a test failure.

Even nicer would be a general echo of all VTY commands, but the VTY
currently does not support that feature. Refraining from a libosmocore
patch just for these test scripts...

Change-Id: Ifc307a7d0b7e3caa355f8cee88778762b529ad71
2021-01-11 14:35:34 +00:00
Neels Hofmeyr b8f00fac4b handover_test: saner ho request handling
Similar to chan act handling, clarify and safeguard HO Request handling.
Ensure that each HO Request is handled by the test script.

Place unhandled HO Requests in new_ho_req pointer, moving to last_ho_req
upon handling it. Instead of the got_ho_req flag and additional
ho_req_lchan pointer, just keep a last_ho_req pointer.

Drop a bunch of utterly useless RSL message parsing code.

Fix unhandled HO Request in test_max_handovers.ho_vty.

Change-Id: I0a664f24d7dd3d7b254b29675fdc49cd70a1a480
2021-01-11 14:35:34 +00:00
Neels Hofmeyr 1a16580a39 handover_test: saner chan act handling
Do not clear pending chan act requests when sending a measurement report
or starting congestion check. This potentially left channel activations
unnoticed and dangling, e.g. for repeated meas-rep.

A typical test should indeed handle pending channel activation requests
before potentially triggering more, safeguard against this by asserting
that only one channel activation is pending.

Place unhandled channel activations in new_chan_req pointer, moving to
last_chan_req upon handling it. Instead of the got_chan_req flag and
additional chan_req_lchan pointer, just keep a last_chan_req pointer.

Change-Id: If06587058798d96afca86358030dc0c1c3c6df39
2021-01-11 14:35:34 +00:00
Neels Hofmeyr ba9d45badb handover_test: safeguard against unhandled chan req
Change-Id: Ib0d5c4647af23e6729cc19e98b1870cdde2fe994
2021-01-11 14:35:34 +00:00
Neels Hofmeyr 351e0f1002 handover_test: include ack-chan in expect-chan
Change-Id: Ic9f1e94b12334fed6bdce35beef94d8e2968f3ad
2021-01-11 14:35:34 +00:00
Neels Hofmeyr 5fb6b64732 handover_test: add 'meas-rep repeat N'
Some tests want to repeat the same measurement report, typically 10
times to fill the averaging window. Instead of 10 lines saying
'meas-rep ...', allow 'meas-rep repeat 10 ...'.

Change-Id: Ib2fa81a449fb73ec7c458b0e6877d6561c79a846
2021-01-05 23:27:26 +01:00
Neels Hofmeyr 58eceb06b5 handover_test.c: properly release lchans in set-ts-use
An upcoming test that uses set-ts-use to release used lchans uncovered
an incomplete release, keeping the lchans occupied due to a missing
release ack. Always ack the release.

Change-Id: Ia22906bfbfcc48b7bd08473a2b17f6b0554687d3
2021-01-05 23:27:26 +01:00
Neels Hofmeyr 1adf0386d3 handover_test: set a fake osmo_mgcpc_ep_ci pointer
The handover_fsm activates voice on a target lchan only when the source
lchan has an osmo_mgcpc_ep_ci pointer for the BTS side. Since that
struct is opaque, set a fake pointer and override the
osmo_mgcpc_ep_ci_name() function so that the pointer is never
dereferenced.

This more accurately models the RTP stream setup events during handover.

Change-Id: Ibc22001bf9e9874dd3f44f0acac8b6a4c1069aa7
2020-12-23 01:59:08 +00:00
Neels Hofmeyr edf3359205 handover_test: adjust logging for reproducability
Do not show source file and line numbers in the log, so that the log
output remains unchanged for unrelated changes.

Also show the log level.

Change-Id: I8ebcaf16cd14881a3a41616dcff175e173db9ae8
2020-12-23 01:59:08 +00:00
Neels Hofmeyr e0dfe96662 handover_test: send ho detection
So far we skipped the HO Detection message, because the FSM also accepts
a handover when the Handover Complete arrives without a Detection.
Rather model the real behavior.

Also send the EST IND message and RTP-ready events from the ho
detection.

Change-Id: Ib676e74f23ef9cd1b55262117822b0e110013bdc
2020-12-23 01:59:08 +00:00
Neels Hofmeyr 64982dda42 handover_test: log sending ho complete
Change-Id: I540e880f9aafb92be03c35086340de1968b26836
2020-12-23 01:59:08 +00:00
Neels Hofmeyr 1a3eaeff2e handover_test: implement as VTY shell
Drop the string arrays, and move the 32 handover tests to separate
script files. Instead of the peculiar implementation and instead of
cryptic commands, implement the handover test scripts as a VTY.

handover_test.c now sets up a VTY with handover testing VTY commands. It
also features the complete and unabridged VTY configuration nodes of
osmo-bsc itself. That allows dropping various ho script commands.

Before:

  static char *test_case_14[] = {
      "Handover to congested cell, if RX level is below minimum\n\n"
      "The better neighbor cell is congested, so no handover is performed.\n"
      "If the RX level of the current cell drops below minimum acceptable\n"
      "level, the handover is performed.\n",

      "create-n-bts", "2",
      "create-ms", "0", "TCH/F", "AMR",
      "expect-ts-use", "0", "0", "*", "TCH/F", "-", "-", "-", "-", "-", "-",
      "set-min-free", "1", "TCH/F", "4",
      "set-min-free", "1", "TCH/H", "4",
      "meas-rep", "0","0","1","0", "10","0", "1","0","30",
      "expect-no-chan",
      "meas-rep", "0","0","1","0", "9","0", "1","0","30",
      "expect-chan", "1", "1",
      "ack-chan",
      "expect-ho", "0", "1",
      "ho-complete",
      "expect-ts-use", "0", "0", "*", "-", "-", "-", "-", "-", "-", "-",
      "expect-ts-use", "1", "0", "*", "TCH/F", "-", "-", "-", "-", "-", "-",
  }

After:

  # Handover to congested cell, if RX level is below minimum
  # The better neighbor cell is congested, so no handover is performed.
  # If the RX level of the current cell drops below minimum acceptable
  # level, the handover is performed.

  create-n-bts 2
  set-ts-use trx 0 0 states * TCH/F - - - - - -
  network
   bts 1
    handover2 min-free-slots tch/f 4
    handover2 min-free-slots tch/h 4
  meas-rep lchan 0 0 1 0 rxlev 10 rxqual 0 ta 0 neighbors 30
  expect-no-chan
  meas-rep lchan 0 0 1 0 rxlev 9 rxqual 0 ta 0 neighbors 30
  expect-ho from lchan 0 0 1 0 to lchan 1 0 1 0
  expect-ts-use trx 0 0 states * - - - - - - -
  expect-ts-use trx 1 0 states * TCH/F - - - - - -

Note how osmo-bsc's stock vty config nodes seamlessly integrate in the
test steps: just enter a configuration node, modify some values, and
indenting trivially takes care of exiting nodes correctly.

Running a test manually:
	./handover_test test_0123.ho_vty

Instead of calling each test separately in testsuite.at, have a
handover_tests.sh script that picks up new tests just by presence of
files named test*.ho_vty.

Rationale:

It was considered to move handover tests to the TTCN suite, but there is
an advantage in having these C tests: they run super fast and catch bugs
even in the gerrit verification job, potentially saving a lot of time.

It is a reality that I need more of these tests, for dynamic timeslots
and TCH/F <-> TCH/H switches. The way the handover tests are written, as
arrays of strings containing cryptic fixed-argument script commands, has
been a pain to work with from the start, and now I am no longer willing
to endure that pain.

Change-Id: Ie238ebe41039d3fa44c9699937589e000883e052
2020-12-23 01:59:08 +00:00
Neels Hofmeyr ef65d3ddb4 hodec 2: prefer moving TCH/H from half-used dyn TS
Change-Id: I427dc9faa3790c24119127ae227d8cc802dd50e6
2020-12-09 11:35:16 +00:00
Neels Hofmeyr 2978e746b3 handover_test: add test 32: half used TCH/H on dyn TS
Shows undesired behavior of moving a TCH/H from a fully used dyn TS
leading to two half-used dyn TS, rather than moving the half-used dyn TS
that would lead to completely freeing a dyn TS.

Change-Id: I3beaa95d12ca0a19d4d1a732f3e22558e68ee29c
2020-11-18 15:28:15 +01:00
Neels Hofmeyr e0792fd342 handover test 30: play through filling up all lchans
Change-Id: I938ef9ebf77a4e72fc525f4f764daf34f17167ef
2020-11-18 14:50:25 +01:00
Neels Hofmeyr dc69da17ad hodec 2: favor moving dyn TS
When a used timeslot gets moved to another timeslot for load balancing, prefer
moving a dynamic timeslot, as illustrated by handover_test.c test 30.

Rationale: freeing up a dynamic timeslot is better for PDCH availability, as
well as for flexibility in timeslots. Test 30 shows that when freeing a static
TCH/F even though a dynamic one with identical ratings is in use, later
handovers to a TCH/H may become impossible, because no more dynamic timeslots
are available to switch to TCH/H. A freed dynamic timeslot allows congestion
resolution to continue and reduce more TCH/F to TCH/H.

The scope of this preference is per-TRX, where the RXLEV ratings used for
picking a target lchan are the same by definition. In other words, this never
overrules picking another lchan that has better RXLEV.

Among lchans on dynamic timeslots that could be moved, this code favors moving
later lchans; mainly because it makes for a simpler condition in the code.

Change-Id: Ic221b8d2687cdec0bf94410c84a4da43853f0900
2020-11-18 14:50:25 +01:00
Neels Hofmeyr dad4e7c3f7 fix TCH/H allocation: use half occupied dyn TS instead of switching more dyn TS
Change-Id: I5a8d943f31774af00664d037550be14e767d312a
2020-11-17 03:32:17 +01:00
Neels Hofmeyr b08ec40282 handover_test: add test 31: TCH/H: re-use dyn TS
Show undesired behavior of opening up another TCH/H timeslot even though
another TCH/H timeslot still has room for a second lchan. This is particularly
bad for dynamic timeslots, reducing PDCH as well as TCH/F resources.

Change-Id: If222835af92d832b848824e5466bdcaf9af8a614
2020-11-17 03:32:17 +01:00