In openairinterface5g many definitions in many layers of UE or eNB NB_MAX.
We created a file called openairinterface5g_limits.h
located at openairinterface5g_dir/targets/COMMON/ declaring the number max
of UE and eNB to be used in ALL layers depending on launching conditions
(LARGE_SCALE for example).
When using abstraction mode, layer2_init_UE() and openair_rrc_ue_init()
are called according to first_sync state and only without MME support.
We added the global variable abstraction_flag to allow abstraction mode
when MME is enabled.
Openair2 is also used in lte-softmodem, so it must have a global variable
abstraction_flag. So we moved it out from the main() scope.
The previous version did not seem to work properly with
several UEs. I too often ended up with a list 'next' where
next[i] = i, leading to an infinite loop, crashing the
processing.
The sorting functions were hard to understand and too slow
anyway (O(n*n)).
We now use qsort_r and comparison functions, that should
define the same order as the previous version.
One important point is that the "next" lists and the "head"
variable are now considered invalid before calling sort_UE.
So all the code (coming before sort_UE) that looped using those
variables has been rewritten to loop over all possible UEs and
the first instruction of the loop is to exit the loop if the UE
is not 'active'. There is room for improvement here. We will
reintroduce a list of some kind at some point. Let's first
have something that works and then optimize. Today NUMBER_OF_UE_MAX
is 16, that's not a big deal.
Consequently, the add_new_ue and rrc_mac_remove_ue have also
been rewritten, hopefully for the better.
This commit is not a basic work and may introduce some
problems.
The RA process may be in the state:
RA_active == FALSE and wait_ack_Msg4 == 1
Testing only the rnti should be enough, if everything else works
properly.
Also, don't break, just in case. (Not sure it makes a
difference.)
The previous version was calling taus(), which
may return any value in [0..65535].
The new version restricts it to [1024..59999]
(arbitrary values, big enough, and in the valid range).
It also checks that the new RNTI is not already present
in the MAC.
I think we should also check that it's not used by a RA
process.
The "loop" thing may not be the best solution either.
To be refined.
A RA process is not available if
and RA_template[i].wait_ack_Msg4 != 0
We can have RA_active==FALSE and wait_ack_Msg4==1,
in which case the RA process is in use and cannot
be reassigned.
RRC does not work very well when one UE goes away and comes
back in some situations.
This commit is an attempt at making things work better.
It is probably not the end of the story.
Modern UEs have very long UE capabilities.
It disrupts realtime behaviour of the modem.
Let's put a simple log message indicating we got the
UE capabilities.