Commit Graph

2641 Commits

Author SHA1 Message Date
Harald Welte 05d95a46fd Merge 'fixeria/trx' into master
Change-Id: I5586fd8c9eb281285f4a59e63cb17dbc3641e1c1
2018-04-07 19:35:24 +02:00
Pau Espin 00bfb39d6c trxcon/l1ctl.c: hexdump content of unhandled messages
Change-Id: Iec8fc6d49d1e35fe101960dd969de559e37a6a75
2018-04-04 17:14:26 +00:00
Pau Espin 55afe0072b trx_toolkit: Add cmdline arg to set bind addr
Previous hardcoded default of 0.0.0.0 was inappropiate in some
scenarios, as it sets the SRC addr of the packets sent through the
socket based on the routing.

For instance, if iface IF1 has assigned two IP addresses A and B,
A being the first addr of the interface, and osmo-bts-trx is
configured with "osmotrx ip local A" and "osmotrx ip remote B",
the following happens:

  CMD POWER OFF src=A:5801 dst=B:5701
  RSP POWER OFF src=A:5701 dst=A:5701 <-- A is assigned as src addr.

But osmo-bts-trx is waiting for packets from B:5701, and the packet
is dropped with ICMP Unreachable. If addr binding is forced in
fake_trx to B, then everthing's fine.

Let's extend the UDPLink in order to allow manual, but optional
setting of bind address, and add a corresponding cmdline
argument to all executables.

Change-Id: I7be18fef40967fb7551f4115f22cbbd9cdb0840d
2018-04-04 17:14:26 +00:00
Harald Welte 9d90d1907b trxcon: Respect the tch_mode field of DM_EST_REQ
the initial tch_mode is not always 0 (signalling) but can very well
be directly a codec mode, if the initial activation of the channel
is in speech mode as opposed to signalling

Change-Id: I96e4c89da1165e9c5287d863e0e65d811460c606
2018-04-02 19:57:55 +02:00
Vadim Yanitskiy 96a8f288c6 trxcon/scheduler: add CHAN_IS_SACCH macro
Change-Id: I2fc90d4732433f221c628058c9812815edf9c8cb
2018-03-22 23:04:16 +07:00
Vadim Yanitskiy e05f690102 trxcon/scheduler: share lchan link identifiers
Change-Id: Ie1632f274b2ae6147a8e918ebfea60eeeb6a234c
2018-03-22 23:02:25 +07:00
Vadim Yanitskiy 02abbe5420 trxcon/sched_prim.c: fix: correct the first padding byte
According to TS 144.006, section 5.2, the first octet containing
fill bits shall be set to the binary value "00101011" == 0x2b.

Change-Id: I8f0304bf84613a2dc07cb78aff0cb8bb4c5adf6c
2018-03-22 20:54:23 +07:00
Pau Espin f9ac7eb36e virt_phy: Add missing gprs related entries to l1ctlPrimNames
Change-Id: Ia59e22cda9cf5e25b5e2b1fe38f8ec3937b16f80
2018-03-21 16:35:07 +00:00
Vadim Yanitskiy d49a748cbb common/l1ctl.c move TCH bit-ordering to the firmware
Previously, TCH frames coming from L1 were reordered to the RTP
format. Moreover, the implementation had a few problems:

  - L1CTL is not the best place for such manipulations;
  - payloads with other than FR codec were corrupted.

Let's use RTP-ordered payloads on the L1CTL interface,
performing TCH frame reordering at the firmware.

Please note, that actual FR reordering was moved to the firmware
as is, without any codec determination. This could be fixed in
a separate change.

Change-Id: I81ec8ed3c9e72a62b22c1720c299cdc68b733cf1
2018-03-14 22:22:43 +07:00
Vadim Yanitskiy a4d255269a L1CTL/L1CTL_CRYPTO_REQ: add key length and channel info
Previously, the L1CTL_CRYPTO_REQ message contained only a ciphering
algorithm and actual Kc key to be used. The key length was
calculated manually using the MSGB API.

Let's avoid manual calculations here, as it may cause unexpected
behavior if the message structure is changed. Also, let's fill
the UL header with minimal information about a channel, which
is going to be encrypted.

Change-Id: I5fab079907c5276322d3ec2b46cab81f10c7ed09
2018-03-14 22:22:39 +07:00
Vadim Yanitskiy 23914b9cf8 Rename 'fake_trx' to 'trx_toolkit'
This toolkit has branched out into several different tools for
TRX interface hacking, and creating a virtual Um-interface
(FakeTRX) is only one of its potential applications.

Change-Id: I56bcbc76b9c273d6b469a2bb68ddc46f3980e835
2018-03-13 02:10:02 +07:00
Vadim Yanitskiy c08ddc7383 fake_trx: unify the GPL license header
There is no need to manually put the license header as a variable
in each application in order to print it. Let's use a common one.

Change-Id: I1a6e8716a9069e7ade3ae15f2c04fd45d18e223c
2018-03-13 02:08:29 +07:00
Vadim Yanitskiy 4ccb2261b1 trxcon/sched_lchan_tchf.c: always send traffic indications
We shall always send traffic frame indications, even if received
frame is incomplete or decoding was failed. This is required
for proper Measurement Reporting.

Change-Id: I99e134699796c7075299459e96b2f2d462636619
2018-03-11 17:38:29 +07:00
Vadim Yanitskiy 40e71126ab trxcon/sched_lchan_xcch.c: always send data indications
We shall always send data frame indications, even if received
frame is incomplete or decoding was failed. This is required
for proper Measurement Reporting.

Change-Id: I7beee7e797f488d04c3b59bee9501ce823717092
2018-03-11 17:38:29 +07:00
Vadim Yanitskiy 47aaf962fb trxcon/scheduler: enforce lchan handlers to set message type
Since this change, each lchan handler shall manually indicate
a type of both message indications and confirmations.

Change-Id: I02e0b87d61c127d2f6f5b9532909af78332bf707
2018-03-11 17:38:29 +07:00
Vadim Yanitskiy caebbebd16 trxcon/sched_lchan_common.c: use static memory allocation
There is no need to allocate the DL header for each new message.

Change-Id: Id7ad815c6b403f5c3d15fc02022397188f1d87fd
2018-03-11 17:38:29 +07:00
Vadim Yanitskiy 633c806a2b trxcon: clean up DATA / TRAFFIC indication API
- change 'l1ctl_tx_data_ind' symbol to 'l1ctl_tx_dt_ind' in
    order to indicate that it's used for both DATA and TRAFFIC;

  - introduce a 'traffic' flag, which is used to define either
    TRAFFIC or DATA indication type;

  - pass L2 payload and its length separately from the
    Downlink info header.

Change-Id: I9fe65ee9b2d772576b86b7bc85d53518530d1579
2018-03-11 17:38:29 +07:00
Vadim Yanitskiy ddddf9e0c4 trxcon: clean up DATA / TRAFFIC confirmation API
- change 'l1ctl_tx_data_conf' symbol to 'l1ctl_tx_dt_conf' in
    order to indicate that it's used for both DATA and TRAFFIC;

  - introduce a 'traffic' flag, which is used to define either
    TRAFFIC or DATA confirmation type;

Change-Id: Iedd569086a264dc7d8740abea5c6e5ca21e299f6
2018-03-11 17:38:29 +07:00
Vadim Yanitskiy d316b84413 trxcon/l1ctl.c: combine both DATA and TRAFFIC REQ handlers
Both functions are almost identical, and the only difference is
the message type they set. Let's combine them into a single
function and introduce a 'traffic' flag, which can be
used to define a message type.

Change-Id: I288f5d7b6cd242c4793973dcb3d2b1b6925d61a7
2018-03-11 10:34:28 +00:00
Vadim Yanitskiy eb3a1cde8c trxcon/l1ctl_link.c: allocate msgb after its length is read
Change-Id: I2b941c5ed91097c4ed2d859634bbe89f44546061
2018-03-11 10:05:48 +00:00
Vadim Yanitskiy 2136891b7b trxcon: clarify L1CTL message length field
Each L1CTL message gets its own length pushed in front before
sending. This isn't specified in the 'l1ctl_proto.h', but
assumed in the code. Let's clarify this.

Change-Id: I118d00613aeaf5ff0bad1188fa5f7450d4ca8122
2018-03-11 10:05:48 +00:00
Vadim Yanitskiy a92fd3388c trxcon: use meaningful names for L1CTL messages
There are two types of L1CTL messages: received and to be
transmitted. Let's use proper names to indicate this.

Change-Id: I7c17687579282fa389bca35dc7edbc3582e55701
2018-03-11 10:05:46 +00:00
Vadim Yanitskiy 5eae19098a trxcon/scheduler: transmit dummy frames on CBTX lchans
If at the moment of transmission there are no frames in TX buffer,
then either a dummy LAPDm frame (0x01, 0x03, 0x01, 0x2b ...) or a
silence frame (depending on a codec in use) shall be transmitted.
This is required for proper measurements on the BTS side.

Change-Id: Ie590990f2274ea476678f6b2079f90eeadab6501
2018-03-11 15:03:35 +07:00
Vadim Yanitskiy 4cf722364b trxcon/scheduler: introduce a new CBTX lchan flag
This new flag is intended to indicate that continuous burst
transmission is assumed on particular logical channel. In other
words, if a logical channel has this flag, but there is nothing
to transmit in a TX buffer, then either a dummy LAPDm frame or
a silence frame shall be sent.

Change-Id: I25fcf9eeb787ffe5378d92532439e67d7d42fa65
2018-03-11 14:59:43 +07:00
Vadim Yanitskiy c00985bf99 trxcon/sched_trx.h: clarify lchan flags meaning
Change-Id: I51b663dd16e46a4523488c3d3000922a7c3640d1
2018-03-11 14:59:43 +07:00
Vadim Yanitskiy 2778e4ef43 trxcon/sched_trx.c: fix: omit inactive logical channels
The sched_frame_clck_cb() is responsible for UL burst transmission.
Iterating over each timeslot, it chooses a proper lchan handler
according to a current frame number and a multiframe layout in use,
takes a L2 UL frame from a TX buffer, and finally calls the chosen
handler in order to to encode and transmit a taken frame.

A handler should be called only for activated logical channels...
but for some long time, there was a bug, so each lchan was
processed, including inactive ones. It's time to fix this.

Change-Id: I33e3ecc14be3ae64dfd02789c7f0970c945582c9
2018-03-11 14:59:38 +07:00
Vadim Yanitskiy f06f31fdf7 trxcon/sched_trx.c: fix: properly deallocate lchans
The llist_for_each_entry_safe() should be used instead of the
llist_for_each_entry(), because it's safe against removal
of llist entry.

Found using Valgrind's memcheck tool.

Change-Id: I65234971ec152df038c5388da537a503060c215b
2018-03-11 14:18:22 +07:00
Vadim Yanitskiy cbf818d4dc trxcon/configure.ac: add --enable-sanitize option
Change-Id: I099de726f9d67213c56d996039b4207f80a727c6
2018-03-11 14:14:51 +07:00
Vadim Yanitskiy 7fd8ef2d3f fake_trx/ctrl_cmd.py: use a random bind port by default
Since it is not required to specify a bind port to the UDPLink
constructor manually, let's use a random one by default, and
also allow user to set it from command line.

Change-Id: Ib4965ebeec83d9a99b2f026156eb5f5cb20875bf
2018-03-06 22:54:21 +07:00
Vadim Yanitskiy 2812cb7f80 fake_trx/udp_link.py: use a random bind port by default
This allows one to obtain a random available port from the
OS, instead of enforcing to pick a static value manually.

Change-Id: Ie8b60134239c5447d0b4373c6cca2f3a6ee3ec73
2018-03-06 22:53:28 +07:00
Vadim Yanitskiy c20f9bb5cd fake_trx/ctrl_if.py: remove incorrect isdigit() check
Previously, we used to check if all arguments of a command are
numeric. This was done in a wrong way, so parsing a *valid*
command with at least one negative argument could fail.

Let's remove this check, allowing the command handlers to
deal with argument types themselves.

Change-Id: If31295274a09102c414b5a7aec5dd85d88b2e514
2018-03-06 02:28:37 +07:00
Vadim Yanitskiy 59d054906d fake_trx/ctrl_if.py: reduce code branch nasting
Let's use the inverted condition to avoid additional code nasting.

Change-Id: I8a62b39d9d9a597c612f9a576e98dc05e37cd25b
2018-03-06 02:28:37 +07:00
Vadim Yanitskiy f97e3cd788 fake_trx/ctrl_if.py: remove forgotten debug print
Change-Id: I4886828fb0f927c59c5eb1945a3c2873687de7b3
2018-03-06 02:28:37 +07:00
Vadim Yanitskiy c066787fd5 host/trxcon: use integer math for ToA (Timing of Arrival)
There's no need to express ToA value as a float. Let's turn it into
an int16_t with 1/256 symbol period accuracy throughout the code to
avoid both float arithmetic as well as loosing any precision.

Inspired by Idce4178e0b1f7e940ebc22b3e2f340fcd544d4ec.

Change-Id: I99c0f38db08a530d5846c474aba352aa0b68fe86
2018-03-02 21:24:57 +07:00
Harald Welte ff233256e1 fake_trx/ctrl_if_(bb|bts).py: log link info at start-up
Change-Id: I4ebeed7271d91ab2e45199e0fb59776c00ad833c
2018-03-02 05:04:59 +07:00
Harald Welte 0d3030c764 trxcon: Fix '-i' to specify the "TRX IP address"
The command line help states '-i' is for 'TRX IP address', which is
the remote IP address at which the TRX is to be found.  Hoewever, it
was used as the local (bind) IP address of the socket used towards
the TRX.  This is my attempt at fixing this.  A more complete solution
probably allows to specify both local (bind) and remote (connect)
address, just to be clear.

Change-Id: If0252b15e9c7942687c6dc470951d777f7af651c
2018-03-01 14:42:25 +01:00
Harald Welte 380dc7e768 fake_trx: Increase TOA256 value ranges
In theory, the maximum TA value is 63 symbols, i.e. 63*256 in this
context.  However, our test cases want to test the BTS behavior is
correct if ever a larger timing offset is reported from TRX to the BTS,
to ensure it is rejected in the BTS.  Let's hence increase the values
to rather large min/max limits.  We could also remove them completely.

Change-Id: I691d081256e8c6d18ef2836299ed8f7d502da3ee
2018-03-01 11:50:22 +01:00
Harald Welte cc447afe34 fake_trx: Send positive response to FAKE_TOA commands
Now that ctrl_if.py is capable of sending back the response to where
the command originated from, we can just as well send a positive
response back after executing the related commands.

Change-Id: Icba138835149a7264f4db3a6b05f54ca501c4d54
2018-03-01 11:49:15 +01:00
Harald Welte 4e74311b00 fake_trx: Always send control responses to where commands are from
fake_trx is using locally bound and not connected UDP sockets for
control commands.

When we receive a control command, we should not simply send the
response to the default destination, but send it back to the exact
ip+prt from which the command originated.  This ensures correct routing
of responses even in case multiple programs are interfacing concurrently
with a control socket.

Change-Id: I24a0bba6eed059b101af95dac7d059f34dd715fc
2018-03-01 11:49:15 +01:00
Harald Welte b1b1162019 trxcon: Define event names for osmo_fsm's
Change-Id: Id3279e99966a0ab236923c497ac0abbc9ed2c93c
2018-02-28 23:18:09 +01:00
Vadim Yanitskiy 6fa80f274e fake_trx/burst_fwd.py: FIX: apply TA value correctly
If field randomization is disabled, Timing Advance value
indicated by MS would be ignored. Let's fix this by
separating the TA calculation code.

Change-Id: If43d5823fc33efc2f1649ea941ab6f619bb6f5e7
2018-03-01 01:52:04 +07:00
Harald Welte 5ab622d2b7 fake_trx/ctrl_if_(bb|bts).py: add FAKE_TOA command
FAKE_TOA is an auxilary CTRL command, which may be used to update
the ToA (Timing of Arrival) value of forwarded bursts at runtime.
This is useful for testing the measurement processing
code in OsmoBTS.

The command is implemented for both BTS and BB CTRL interfaces
in two absolute and relative forms:

  CMD FAKE_TOA <BASE> <THRESH>
  CMD FAKE_TOA <+-BASE_DELTA>

The first form overwrites both ToA value and its treshold.
The second one is relative, and applies a delta
to the current ToA value.

The command affects Downlink bursts if sent on BTS CTRL
interface, and Uplink bursts if sent on the BB CTRL.

Change-Id: Ia23becec4104d47e7b22350db67b8834d6f1ad1b
2018-03-01 00:17:24 +07:00
Vadim Yanitskiy 7de70009f6 fake_trx/fake_trx.py: add options to enable field randomization
By default, both RSSI and ToA fields randomization is disabled.
Let's add command line options, which allow one to enable it.

Change-Id: Ieac63cc3aadef397906479a6179ba54a53a5311a
2018-02-28 22:39:01 +07:00
Vadim Yanitskiy 81896a8328 fake_trx/burst_fwd.py: disable field randomization by default
Both RSSI and ToA fields randomization is only required in some
specific test / use cases, so let's disable it by default.

Change-Id: I94835a840b6239f2c05197292825cb26977d0216
2018-02-28 22:37:41 +07:00
Vadim Yanitskiy 3da6166111 fake_trx/burst_fwd.py: calculate both RSSI and ToA separately
In order to be able to simulate and randomize both RSSI and ToA
values for Uplink and Downlink separately, let's calculate them
in separate methods of the BurstForwarder.

Change-Id: Ia2031f22f2b549c799c782d0c8c8d0691fb6f18c
2018-02-28 22:36:53 +07:00
Vadim Yanitskiy f09989b1fb fake_trx: handle SETTA (Timing Advance) indicated by MS
Timing Advance value is a timing correction value, indicated by
the network to MS, which is used to compensate UL signal delay.
In other words, the network instructs a phone to transmit bursts
N=TA symbol periods earlier than expected.

Since we are in virtual environment, let's use TA value to
calculate the ToA (Timing of Arrival) value for BTS.

Change-Id: Ie5833a9f221587bbcac10f0b223ead9c1cbda72b
2018-02-28 22:34:36 +07:00
Vadim Yanitskiy d9cb065417 fake_trx/data_msg.py: implement ToA parsing support
This change implements ToA (Timing of Arrival) parsing, which
was missing in the DATAMSG_TRX2L1. Since we use integer math,
a ToA value is represented in units of 1/256 symbol periods.

Change-Id: Ib11482c06b977c4cf01b0644f5845a2e49d059fb
2018-02-28 22:34:27 +07:00
Vadim Yanitskiy 9fc30a4102 fake_trx/data_msg.py: use integer math for ToA
In order to avoid both float arithmetic as well as loosing any
precision, let's use integer math fot ToA (Timing of Arrival),
i.e. let's express ToA values in units of 1/256 symbol periods.

Change-Id: I56b88740f4d782ac7591fc096d1969514784a4e1
2018-02-28 22:33:35 +07:00
Vadim Yanitskiy cbd3d76df9 fake_trx/burst_fwd.py: drop useless set_slot() method
Change-Id: I721c87758f04a1962427341eb1b2d47cfdd3f780
2018-02-28 22:33:35 +07:00
Vadim Yanitskiy 7881fd6001 fake_trx/data_msg.py: use a single unified constructor
There are no message specific initialization parts, excepting
the header specific fields setting. Let's us a common constructor,
dropping custom fields from its arguments.

Change-Id: I13a3e4b2f6a1f443ebe7d809df62736e3c43f56f
2018-02-28 15:18:16 +07:00