Commit Graph

1421 Commits

Author SHA1 Message Date
Vadim Yanitskiy 2df561cfa2 srsue/extnas: write NAS frames to the given PCAP file 2022-01-31 17:18:02 +06:00
Vadim Yanitskiy fbb2ed3aa9 srsue/extnas: implement encryption and signing of NAS messages 2022-01-31 17:18:02 +06:00
Vadim Yanitskiy 19ed00e9bb srsue/extnas: move EEA/EIA API from 'nas' to 'nas_base'
This way 'nas_ext' would also be able to use it.
2022-01-31 17:18:02 +06:00
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 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 465c3d9186 proc_sr: remove info log when starting SR proc
this was a very noisy log that was printed in pretty much
every TTI because the BSR procedure starts a SR whenever
it needs to send a regular BSR. The SR is canceled when a UL
grant arrives but the log line stays there.

Since we are printing a log when we actually signal a SR
to the PHY, this line is not needed.
2020-10-28 12:05:53 +01:00
Andre Puschmann 1e3ad5b0dc proc_bsr: fix high priority channel trigger logic
this fixes the trigger logic for periodic BSRs. Previously we
would always trigger the "new data for highest priority LCID"
whenever new data becomes available for a LCID for which
a BSR has already been sent.

However, a BSR should only be sent if the priority is in fact higher
(lower int number).
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
Andre Puschmann d1ef5bd915 demux: log DL PDUs
instead of just printing the LCIDs that contain SDUs,
we use the to_string() function to log the entire MAC DL-SCH PDU
2020-10-28 12:05:53 +01:00
Andre Puschmann 0740154bff rrc,sync: fix two uninit vars
detected by Valgrind when running UE with TDD cell
2020-10-25 14:42:30 +01:00
Andre Puschmann 58776bc227
ue,sync: increase timeout for entering IDLE to 2s (#1941)
in ZMQ runs we've seen that entering idle could take quite
a bit of time depending how quickly workers get their samples
sent or reconfigurations done.

In one example up to ~160ms

this patch increases the maximum wait time to 2s.
2020-10-22 22:13:03 +02:00
Francisco Paisana 514deaf25b fix resetting of phy and mac during reestablishment 2020-10-22 19:55:46 +02:00
Xavier Arteaga caf37b8e62 Added serving cell index in UCI/CSI report trace 2020-10-20 11:53:28 +02:00
Francisco Paisana 0842ed9db1 fixed phy cell selection state update for the fail path 2020-10-16 15:54:42 +01: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 287c653755 proc_bsr: improve BSR logging to print name of triggered BSR instead of enum 2020-10-16 09:16:54 +02:00
Andre Puschmann 3994407f46 proc_bsr: fix BSR insertion in UL PDUs
the BSR trigger wasn't reset after includinga regular or periodic
BSR inside a PDU. This caused the muxing to include another BSR in the
next UL grant. For very small grants, for example with 6 PRBs, this
causes the UE to send way too many BSRs.
2020-10-15 11:52:13 +02: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 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
Francisco Paisana cae116932b rewrite the rrc::leave_connected() function to better match the standard. The measurements should not stop while in RRC_IDLE. 2020-10-08 10:51:18 +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
Xavier Arteaga 08e24d00af Fix TA console trace 2020-10-08 09:21:00 +02: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
Andre Puschmann 5e95fd4a43 ul_harq: reduce log level for new_grant_ul() if RNTI isn't found
this avoid logging a warning on UE shutdown if the MAC is already reset
but one of the PHY workers still decodes an UL grant for the old RTNI

21:30:29.254844 [RRC ] [I] Going RRC_IDLE
21:30:29.254848 [RRC ] [I] Proc "Go Idle" - Left connected state
21:30:29.259499 [PHY0] [I] [ 3865] Finished setting new PHY configuration cc_idx=0
21:30:29.259512 [PHY0] [I] [ 3865] Setting new PHY configuration cc_idx=0...
21:30:29.264190 [PHY0] [I] [ 3867] Finished setting new PHY configuration cc_idx=0
21:30:29.275036 [PHY1] [I] [ 3872] PHICH: hi=1, corr=1.0, I_lowest=1, n_dmrs=0, I_phich=0
21:30:29.275050 [MAC ] [W] [ 3872] Received grant for unknown rnti=0x46
2020-10-06 20:51:46 +02:00
Andre Puschmann 362461329a rrc: improve log message when detecting RLF 2020-10-06 20:51:46 +02:00
Andre Puschmann 76c648106f rrc: remove varMeasState for unknown neighbor cells
this fixes issue #1846 that appears to be related
to the enter/exit state for measurements that is kept
even after a cell disappears from the neighbor list
2020-10-06 16:28:09 +02:00
Andre Puschmann 829dfc4e60 metrics_stdout: fix precision calculation for 100%
the precision for 100% was causing the default value of -1 which in turn
cause to print the full precision resulting in ugly stdout plots.

before:
--------Signal--------------DL-------------------------------------UL----------------------
cc pci  rsrp    pl    cfo   mcs   snr turbo  brate   bler   ta_us  mcs   buff  brate   bler
 0   0   -10    74    0.0   0.0   0.0   0.0   200k     0%   0.0   0.0    0.0    0.0     0%
 1   0   0.0   0.0    0.0   0.0   0.0   0.0   150k100.000000%   0.0   0.0    0.0    0.0     0%

after:
--------Signal--------------DL-------------------------------------UL----------------------
cc pci  rsrp    pl    cfo   mcs   snr turbo  brate   bler   ta_us  mcs   buff  brate   bler
 0   0   -10    74    0.0   0.0   0.0   0.0   200k     0%   0.0   0.0    0.0    0.0     0%
 1   0   0.0   0.0    0.0   0.0   0.0   0.0   150k   100%   0.0   0.0    0.0    0.0     0%
2020-10-05 22:42:04 +02:00
Andre Puschmann e72219789e ul_harq: don't clear payload buffer during HARQ reset
this fixes #1791 which was caused by a race between
the PHY workers preparing a new UL-SCH PDU and the Stack resetting
the MAC, which in turn resets the HARQ processeses, which cleared
the buffer and set the length to zero.

Not explicitly clearing the buffer on a HARQ reset seems to be
fine since the PHY worker clears the buffer before starting to
pack a new PDU anyway.
2020-10-05 22:41:12 +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 8a917bdd06 fix RRC phy controller call to phy->set_config. Only the PCell was being configured 2020-10-05 12:08:16 +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 cfc77118d3 disable console print of scell activation command during handover 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 d02e8135fb metrics_stdout: reset n_reports var after writing intermediate table header 2020-10-02 17:00:19 +02:00