Commit Graph

286 Commits

Author SHA1 Message Date
Vadim Yanitskiy b594b15e79 srsue/extnas: handle (U)SIM GenAuthResp.Request 2022-01-31 17:18:02 +06:00
Vadim Yanitskiy 27344af7f0 srsue/rrctl: make codec::enc_hdr() return proto::msg_hdr 2022-01-31 17:18:02 +06:00
Vadim Yanitskiy 796a6df0df srsue/rrctl: add Security Mode messages for EEA/EIA 2022-01-31 17:18:02 +06:00
Vadim Yanitskiy 510bd4ee02 srsue/rrctl: add (U)SIM specific protocol extensions 2022-01-31 17:18:02 +06:00
Vadim Yanitskiy aeee4da73c srsue/rrctl: reserve a range for RRCTL protocol extensions
The idea is to group protocol extensions and have one message
type (with 4 variations: Req/Ind/Cnf/Err) per group.  Similar
to the stack and heap allocation model in Linux, new entries
shall be added to the 'RRCTL_MsgType' list as follows:

  - regular messages - from bottom to the end,
  - extension groups - from the end towards the bottom

The mask '11xxxx'B gives us 16 unique messages, one is reserved.
2022-01-31 17:18:02 +06:00
Vadim Yanitskiy f68931f6e8 srsue/rrctl: add RFU (Reserved for Further Use) message type 2022-01-31 17:18:01 +06:00
Vadim Yanitskiy 7b38286864 srsue/extnas: implement RRCTL codec and message handling
RRCTL is a simple protocol (inspired by Osmocom's L1CTL) that allows
an external NAS entity to control the RRC layer of srsUE. The most
notable primitives are PLMN search, selection, and PDU transfer.

The protocol assumes traditional master-slave communication, where
one side (an external NAS entity) initiates various processes,
while the other (srsUE) executes them and indicates the outcome.

Each RRCTL message starts with a header that can be defined as follows:

  +-------------------------------+--------------------------+
  | Message type                  | 6 bits                   |
  +-------------------------------+--------------------------+
  | Message sub-type              | 2 bits                   |
  +-------------------------------+--------------------------+
  | Spare (RFU)                   | 8 bits                   |
  +-------------------------------+--------------------------+
  | Payload length                | 2 octets (big endian)    |
  +-------------------------------+--------------------------+
  | Payload (optional)            | (see payload length)     |
  +-------------------------------+--------------------------+

The following message types are defined at the moment:

  - RRCTL_RESET - reset internal state of the external NAS interface
                  (does nothing for now, may be useful in the future);

  - RRCTL_PLMN_SEARCH - initiates PLMN (carrier) search on pre-configured
                        EARFCN (Absolute Radio Freqency Number);

  - RRCTL_PLMN_SELECT - binds the UE to one of the previously detected
                        carriers (see RRCTL_PLMN_SEARCH) defined by a
                        given pair of MCC and MNC;

  - RRCTL_CONN_ESTABLISH - establishes connection to the serving cell
                           (previously selected using RRCTL_PLMN_SELECT)
                           with a given cause and NAS PDU;

  - RRCTL_CONN_RELEASE - releases previously established dedicated connection
                         (currently does nothing because the RRC layer does
                          not expose any API for that);

  - RRCTL_DATA - encapsulates a received (Downlink) or to be transmitted
                 (Uplink) NAS PDU (the former also contains LCID).

Each message type has at least two of the following sub-types:

  - RRCTL_REQ - request (usually comes from an external NAS entity),
                used to initiate some process (e.g. PLMN search);

  - RRCTL_IND - indication that something has happened without a prior
                request (for example, a Downlink NAS PDU was received);

  - RRCTL_CNF - confirmation (positive conslusion) of the requested task;

  - RRCTL_ERR - negative conslusion of the requested task (error).

The protocol definition (enums ans structs) and codec functions are
defined in a separate namespaces: 'rrctl::proto' and 'rrctl::codec'
respectively. The codec functions may throw exceptions of type
'rrctl::codec::error' if something goes wrong.
2022-01-31 17:17:57 +06:00
Vadim Yanitskiy 74b2c5c711 srsue/extnas: add a possibility to enable the external NAS interface
The new configuration section '[extnas]' allows to disable the
built-in NAS implementation, and provide the interface (UNIX
domain socket) to an external entity. The interface itself will
be implemented in the follow up commits.
2020-11-09 06:31:45 +07:00
Vadim Yanitskiy 900ad92912 srsue/extnas: implement a simple UNIX domain socket server
Unfortunately, the existing networking API (common/network_utils.h)
lacks the UNIX domain socket support, and it turned to be easier
to implement a simple, single client server using Boost.Asio.

The server runs in its own thread with a blocking Tx queue, and
calls a user definted callback on receipt of any data from client.
Multiple client connections are not supported and will be rejected.
2020-11-09 06:31:45 +07:00
Vadim Yanitskiy 8bc72d44b9 srsue/extnas: introduce draft implementation of 'nas_ext' class
This commit introduces a skeleton class (child of 'nas_base') for
the upcoming implementation of an external NAS interface, as well
as the implementation-specific configuration container.
2020-11-09 06:31:45 +07:00
Vadim Yanitskiy 2b1ded220e srsue/extnas: derive abstract 'nas_base' class from 'nas'
This is the first step towards the goal of having an external NAS
interface.  The new 'nas_base' class becomes a parent of 'nas',
combining all interfaces and the basic (common) API.

The 'ue_stack_lte' now holds a unique_ptr of type 'srsue::nas_base',
so the underlying NAS implementation (built-in or external) can
be choosen at run-time depending on configuration.

The implementation specific configuration now needs to be passed
to the constructor instead, not to the init() method as was before.
2020-11-09 05:34:03 +07:00
Andre Puschmann fd5cde525c proc_bsr: fix race condition in BSR reporting
fix for #1934

This fixes a race condition between Stack thread and DL
PDU processing that lead to updates of the RLC buffer that
are undetected by the BSR routine.

What happens is that in a UL SCH PDU all outstanding data is transmitted
and and a LBSR with all zero buffers is sent.

14:39:47.327301 [MAC ] [D] [ 3793] BSR:   LCID=3 old_buffer=59
14:39:47.330600 [MAC ] [I] [ 3793] UL LCID=3 len=58 LBSR: b=0 0 0 0

Note that "old_buffer" isn't set to zero here.

At the same time (same TTI), the MAC PDU processing thread handles DL-SCH PDUs
that may generate new UL PDUs:

14:39:47.330749 [RLC ] [I] DRB1 Tx SDU (54 B, tx_sdu_queue_len=1)
14:39:47.330762 [RLC ] [I] DRB1 Tx SDU (54 B, tx_sdu_queue_len=2)
14:39:47.330775 [RLC ] [I] DRB1 Tx SDU (54 B, tx_sdu_queue_len=3)
..

Those PDUs are "new data" since the previous buffer state was zero.

Here is the race now between the threads, at the end of the bsr::step() function
old_buffer of each LCG is updated with the previous new_buffer, so
the buffer state of LCG=2 is now 59.

Now MAC starts the next TTI:

14:39:47.331910 [MAC ] [D] [ 3794] Running MAC tti=3794
14:39:47.331928 [MAC ] [D] [ 3794] Update Bj: lcid=0, Bj=0
14:39:47.331934 [MAC ] [D] [ 3794] Update Bj: lcid=1, Bj=0
14:39:47.331938 [MAC ] [D] [ 3794] Update Bj: lcid=2, Bj=0
14:39:47.331941 [MAC ] [D] [ 3794] Update Bj: lcid=3, Bj=-1752
14:39:47.331951 [MAC ] [D] [ 3794] BSR:   LCID=0 update new buffer=0
14:39:47.331960 [MAC ] [D] [ 3794] BSR:   LCID=1 update new buffer=0
14:39:47.331964 [MAC ] [D] [ 3794] BSR:   LCID=2 update new buffer=0
14:39:47.331971 [MAC ] [D] [ 3794] BSR:   LCID=3 update new buffer=335
14:39:47.331976 [MAC ] [D] [ 3794] BSR:    check_new_data() -> get_buffer_state_lcg(0)=0
14:39:47.331980 [MAC ] [D] [ 3794] BSR:    check_new_data() -> get_buffer_state_lcg(1)=0
14:39:47.331984 [MAC ] [D] [ 3794] BSR:    check_new_data() -> get_buffer_state_lcg(2)=59
14:39:47.331988 [MAC ] [D] [ 3794] BSR:    check_new_data() -> get_buffer_state_lcg(3)=0
14:39:47.331993 [MAC ] [D] [ 3794] BSR:   LCID=0 old_buffer=0
14:39:47.332000 [MAC ] [D] [ 3794] BSR:   LCID=1 old_buffer=0
14:39:47.332003 [MAC ] [D] [ 3794] BSR:   LCID=2 old_buffer=0
14:39:47.332007 [MAC ] [D] [ 3794] BSR:   LCID=3 old_buffer=335

And since the buffer state of LCG=2 isn't zero, the new data for LCID=3 of that LCG is considered.
So effectivly, the BSR missed the "empty" buffer state for a fraction of time and doesn't
consider the outgoing data generated in the same TTI as new. It therefore
doesn't transmit a BSR.

in which a BSR wasn't
2020-10-28 12:05:53 +01:00
Andre Puschmann d5286e70aa proc_bsr: refactor and add extra print_state() method
allows to call the print_state() routine from other places in the BSR
2020-10-28 12:05:53 +01:00
Francisco Paisana 514deaf25b fix resetting of phy and mac during reestablishment 2020-10-22 19:55:46 +02:00
Andre Puschmann a366500a78 rrc_proc: init cs_result to none
detected by Coverity CID 363053
2020-10-18 15:56:16 +02:00
Francisco Paisana 665b3996bb now the phy controller handles the scenario where the phy cell selection failed to be initialized 2020-10-16 15:54:42 +01:00
Andre Puschmann 937067a205 proc_phr: rename start_periodic_timer() and make sure its only started if a valid config is present 2020-10-13 17:38:45 +02:00
Andre Puschmann fab86382c1 mac,rrc: add interface to set SR config explicitly without touching any other MAC function
when releasing PUCCH/SRS (see 5.3.13 in 36.331) we need to reset the SR config as well.
In our case, SR is handled by MAC so we need to (re-)configure MAC, not all of
MAC though, just SR.
2020-10-13 17:38:45 +02:00
Francisco Paisana e7239163e9 silence noisy unhandled in_sync_ev logs 2020-10-12 18:24:14 +01:00
Francisco Paisana f185272367 added comments explaining the meaning of the cell reselection procedures 2020-10-12 13:42:46 +01:00
Francisco Paisana 49e7b8e36e - Change periodicity of cell reselection after a new serving cell has been selected
- Enable PHY intra measurements during RRC_IDLE
2020-10-12 13:42:46 +01:00
Francisco Paisana 585d7c923a refactor and simplification of cell selection procedure. Using now a SIB3 threshold to decide whether to select neighbor cell while in RRC_IDLE 2020-10-12 13:42:46 +01:00
Pedro Alvarez 5a4e71a6e4 Created k_enb_context structure that holds k_enb, NCC and NH to make it easier to restore context from failed handover. 2020-10-08 09:46:34 +01:00
Pedro Alvarez bcb422736c Save and restore NH on handover and handover failure. 2020-10-08 09:46:34 +01:00
Pedro Alvarez 3eb525563a Fix issue reading MNC length in USIM. 2020-10-07 10:04:50 +01:00
Xavier Arteaga 6ae47b6510 SRSUE: Deafult PUCCH/SRS does not imply full PHY dedicated defaults 2020-10-07 09:58:23 +02:00
Pedro Alvarez 22a6dc305f Moved common variables and functions from the usim and pcsc_usim classes into usim_base class. 2020-10-05 12:14:46 +01:00
Francisco Paisana 4ebe92f6a3 refactor phy configuration in the rrc to keep track of activated scells, and cells configurations 2020-10-02 18:50:29 +01:00
Francisco Paisana d910c910a4 rrc::meas_cell now uses stack timers instead of system timers. 2020-10-02 17:53:02 +01:00
Francisco Paisana 023d32975a avoid use of pointers to meas_cells in ho_proc as they may become dangling 2020-10-02 17:53:02 +01:00
Francisco Paisana 072b7be582 renamed rrc::cell_t to rrc::meas_cell 2020-10-02 17:53:02 +01:00
Andre Puschmann 0ef8e1fdac rrc: include pci when logging serving cell measurement
this should facilitate easier log parsing and plotting
if the cell measurements _always_ include the PCI, even
in the case of the serving cell

15:49:11.357447 [RRC ] [I] MEAS:  New measurement serving cell: earfcn=0, pci=1, rsrp=-11.52 dBm, cfo=+0.1 Hz
15:49:11.391610 [RRC ] [I] MEAS:  New measurement serving cell: earfcn=0, pci=1, rsrp=-11.52 dBm, cfo=-0.4 Hz
15:49:11.427325 [RRC ] [I] MEAS:  New measurement serving cell: earfcn=0, pci=1, rsrp=-11.52 dBm, cfo=-0.6 Hz
15:49:11.463101 [RRC ] [I] MEAS:  New measurement serving cell: earfcn=0, pci=1, rsrp=-11.52 dBm, cfo=-0.7 Hz
15:49:11.499817 [RRC ] [I] MEAS:  New measurement serving cell: earfcn=0, pci=1, rsrp=-11.51 dBm, cfo=+0.1 Hz
15:49:11.499828 [RRC ] [I] MEAS:  New measurement neighbour cell: earfcn=2850, pci=0, rsrp=-12.16 dBm, cfo=-0.8 Hz
15:49:11.535027 [RRC ] [I] MEAS:  New measurement serving cell: earfcn=0, pci=1, rsrp=-11.46 dBm, cfo=-0.8 Hz
15:49:11.571707 [RRC ] [I] MEAS:  New measurement serving cell: earfcn=0, pci=1, rsrp=-11.46 dBm, cfo=-0.9 Hz
15:49:11.607932 [RRC ] [I] MEAS:  New measurement serving cell: earfcn=0, pci=1, rsrp=-11.52 dBm, cfo=-0.8 Hz
2020-10-01 20:15:41 +02:00
Pedro Alvarez 2f0125ef4e Fix issue recovering key state, when the first HO fails (specifically, is_first_ncc was not recovered). Minor improvements in key logging. 2020-10-01 18:48:07 +01:00
Francisco Paisana 1f2cca8909 in the rrc reconf procedure, handle the scenario where the rrc reconfiguration message does not config the phy 2020-10-01 11:25:21 +01:00
Francisco Paisana c6f4776a6f send the nassdus sooner in the rrc reconf procedure 2020-10-01 11:25:21 +01:00
Francisco Paisana fc49b5a030 implemented rrc reconfiguration procedure that includes a continuation when phy configuration is complete 2020-10-01 11:25:21 +01:00
Francisco Paisana b3eb9651d6 disable cqi in scells during handover procedure 2020-09-29 12:10:42 +01:00
Francisco Paisana 8a9a95a937 ensure sibs are acquired if cell selection calls cell search 2020-09-29 11:06:32 +01:00
Francisco Paisana 045f647914 fix edge case where serving cell is good enough for reestablishment but the sibs are not yet acquired 2020-09-28 23:45:13 +01:00
Francisco Paisana 5ecbe8fb17 cleanup of the reestablishment procedure state machine. It does not need to wait for the serving cell configuration because such procedure is already included in the cell selection procedure 2020-09-28 18:39:28 +01:00
Pedro Alvarez b3bfe336a9 Make sure that remote address test has a ip mask 2020-09-28 16:08:28 +02:00
Sylvain Munaut 5783c01cbb tf_packet_filter: Improve support for the different filter types 2020-09-28 16:08:28 +02:00
Francisco Paisana 0997daa7a0 now the handover procedure in the srsUE does not wait for the phy cell selection result. It only waits for the RA result 2020-09-25 13:03:50 +01:00
Pedro Alvarez 86f4d469c6 Added some functions to save and restore AS keys for the case of failed handover in the USIM 2020-09-24 13:30:08 +01:00
Francisco Paisana cf89d6645b add comments explaining each function of the reest procedure 2020-09-23 14:59:38 +01:00
Francisco Paisana d068d594af implemented rrc reestablishment procedure part after sending reest request 2020-09-23 14:59:38 +01:00
Francisco Paisana 73e21daeb2 refactor reestablishment procedure to more closely follow TS. 2020-09-23 14:59:38 +01:00
Andre Puschmann 1afc137032
[REBASE] Make PHY non-blocking and fefactor HO procedure (#1753)
* Make PHY non-blocking and fefactor HO procedure

* makes entire PHY non-blocking through command interface
* adds dedicated queue for cell_search/cell_select commands
* refactor HO procedure to run faster, in one stack cycle. Looks closer to the specs
* force ue to always apply SIB2 configuration during reestablishment
* Run update_measurements in all workers

Co-authored-by: Ismael Gomez <ismagom@gmail.com>
2020-09-22 21:47:16 +02:00
Francisco Paisana 7f8af023b8 added a callback that always gets triggered when the phy cell selection completes. This callback checks if cell selection failed, and if so, sets the rsrp of the selected cell to -infinity 2020-09-22 17:09:18 +01:00
Andre Puschmann b616944a13 ue,rrc: fix security config during HO/reestablishment
we fix a number of very related issues for HO/reestablishment
in the success/error case:

* this patch removes the hard-coded check that intra-cell HO aren't
allowed. There are cases where eNBs use this method to update
the security context.

* the patch also fixes an issue after failed HO where the security context
of the source eNB should be used for the reestablishment.

* update security keys according to specs when mobilitycontrol
indicated change of key
2020-09-21 09:27:07 +02:00