Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
UERANSIM
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
UERANSIM
Commits
9dfe831f
Commit
9dfe831f
authored
May 17, 2021
by
aligungr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RRC developments
parent
510cbb63
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
173 additions
and
7 deletions
+173
-7
src/ue/rrc/idle.cpp
src/ue/rrc/idle.cpp
+124
-0
src/ue/rrc/state.cpp
src/ue/rrc/state.cpp
+11
-2
src/ue/rrc/task.hpp
src/ue/rrc/task.hpp
+5
-0
src/ue/types.cpp
src/ue/types.cpp
+5
-0
src/ue/types.hpp
src/ue/types.hpp
+11
-0
src/utils/common_types.hpp
src/utils/common_types.hpp
+2
-3
src/utils/locked.hpp
src/utils/locked.hpp
+15
-2
No files found.
src/ue/rrc/idle.cpp
0 → 100644
View file @
9dfe831f
//
// This file is a part of UERANSIM open source project.
// Copyright (c) 2021 ALİ GÜNGÖR.
//
// The software and all associated files are licensed under GPL-3.0
// and subject to the terms and conditions defined in LICENSE file.
//
#include "task.hpp"
#include <algorithm>
#include <lib/asn/rrc.hpp>
#include <lib/asn/utils.hpp>
#include <lib/rrc/encode.hpp>
#include <ue/nas/task.hpp>
namespace
nr
::
ue
{
void
UeRrcTask
::
performCellSelection
()
{
if
(
m_state
==
ERrcState
::
RRC_CONNECTED
)
return
;
if
(
!
lookForSuitableCell
())
lookForAcceptableCell
();
}
bool
UeRrcTask
::
lookForSuitableCell
()
{
Plmn
selectedPlmn
=
m_base
->
shCtx
.
selectedPlmn
.
get
();
if
(
!
selectedPlmn
.
hasValue
())
return
false
;
int
lastCell
=
m_base
->
shCtx
.
currentCell
.
get
<
int
>
([](
auto
&
value
)
{
return
value
.
cellId
;
});
int
outOfPlmnCells
=
0
;
int
sib1MissingCells
=
0
;
int
barredCells
=
0
;
int
reservedCells
=
0
;
std
::
vector
<
int
>
candidates
;
for
(
auto
&
item
:
m_cellDesc
)
{
auto
&
cell
=
item
.
second
;
if
(
!
cell
.
sib1
.
hasSib1
)
{
sib1MissingCells
++
;
continue
;
}
if
(
cell
.
sib1
.
plmn
!=
selectedPlmn
)
{
outOfPlmnCells
++
;
continue
;
}
if
(
cell
.
mib
.
hasMib
)
{
if
(
cell
.
mib
.
isBarred
)
{
barredCells
++
;
continue
;
}
}
if
(
cell
.
sib1
.
isReserved
)
{
reservedCells
++
;
continue
;
}
// TODO: Check TAI if forbidden by service area or forbidden list
// TODO: Do we need to check by access identity
// It seems suitable
candidates
.
push_back
(
item
.
first
);
}
if
(
candidates
.
empty
())
{
m_logger
->
err
(
"Cell selection failed in [%d] cells. [%d] out of PLMN, [%d] no SI, [%d] reserved, [%d] barred"
,
static_cast
<
int
>
(
m_cellDesc
.
size
()),
outOfPlmnCells
,
sib1MissingCells
,
reservedCells
,
barredCells
);
return
false
;
}
// Order candidates by signal strength
std
::
sort
(
candidates
.
begin
(),
candidates
.
end
(),
[
this
](
int
a
,
int
b
)
{
auto
&
cellA
=
m_cellDesc
[
a
];
auto
&
cellB
=
m_cellDesc
[
b
];
return
cellB
.
dbm
<
cellA
.
dbm
;
});
auto
&
selectedId
=
candidates
[
0
];
auto
&
selectedCell
=
m_cellDesc
[
selectedId
];
CurrentCellInfo
cellInfo
;
cellInfo
.
cellId
=
selectedId
;
cellInfo
.
plmn
=
selectedCell
.
sib1
.
plmn
;
cellInfo
.
tac
=
selectedCell
.
sib1
.
tac
;
cellInfo
.
category
=
ECellCategory
::
SUITABLE_CELL
;
m_base
->
shCtx
.
currentCell
.
set
(
cellInfo
);
if
(
lastCell
!=
selectedId
)
{
m_logger
->
info
(
"Selected cell id[%d] category[SUITABLE]"
,
selectedId
);
// TODO: Notify RLS
m_base
->
nasTask
->
push
(
new
NwUeRrcToNas
(
NwUeRrcToNas
::
NAS_NOTIFY
));
}
return
true
;
}
bool
UeRrcTask
::
lookForAcceptableCell
()
{
// TODO
return
false
;
}
}
// namespace nr::ue
\ No newline at end of file
src/ue/rrc/state.cpp
View file @
9dfe831f
...
...
@@ -18,8 +18,17 @@ namespace nr::ue
void
UeRrcTask
::
performCycle
()
{
// TODO
if
(
m_state
==
ERrcState
::
RRC_CONNECTED
)
{
}
else
if
(
m_state
==
ERrcState
::
RRC_IDLE
)
{
performCellSelection
();
}
else
if
(
m_state
==
ERrcState
::
RRC_INACTIVE
)
{
performCellSelection
();
}
}
}
// namespace nr::ue
\ No newline at end of file
src/ue/rrc/task.hpp
View file @
9dfe831f
...
...
@@ -100,6 +100,11 @@ class UeRrcTask : public NtsTask
/* State Management */
void
performCycle
();
/* Idle Mode Operations */
void
performCellSelection
();
bool
lookForSuitableCell
();
bool
lookForAcceptableCell
();
/* Cell Management */
void
handleCellSignalChange
(
int
cellId
,
int
dbm
);
void
notifyCellDetected
(
int
cellId
,
int
dbm
);
...
...
src/ue/types.cpp
View file @
9dfe831f
...
...
@@ -274,4 +274,9 @@ Json ToJson(const EServiceReqCause &v)
}
}
bool
CurrentCellInfo
::
hasValue
()
const
{
return
cellId
!=
0
;
}
}
// namespace nr::ue
src/ue/types.hpp
View file @
9dfe831f
...
...
@@ -138,10 +138,21 @@ struct UeConfig
}
};
struct
CurrentCellInfo
{
int
cellId
{};
ECellCategory
category
{};
Plmn
plmn
{};
int
tac
{};
[[
nodiscard
]]
bool
hasValue
()
const
;
};
struct
UeSharedContext
{
Locked
<
std
::
unordered_set
<
Plmn
>>
availablePlmns
;
Locked
<
Plmn
>
selectedPlmn
;
Locked
<
CurrentCellInfo
>
currentCell
;
};
struct
TaskBase
...
...
src/utils/common_types.hpp
View file @
9dfe831f
...
...
@@ -146,11 +146,10 @@ struct GlobalNci
enum
class
ECellCategory
{
UNDEFINED
,
ACCEPTABLE_CELL
,
SUITABLE_CELL
,
BARRED_CELL
,
RESERVED_CELL
,
ACCEPTABLE_CELL
,
SUITABLE_CELL
,
};
struct
UeCellMeasurement
...
...
src/utils/locked.hpp
View file @
9dfe831f
...
...
@@ -33,14 +33,14 @@ class Locked
Locked
&
operator
=
(
Locked
&&
)
=
delete
;
template
<
typename
Func
>
inline
void
access
(
Func
&&
fun
)
inline
void
access
(
Func
&&
fun
)
{
// Şimdilik access ve mutate aynı, optimizasyon adına read-write lock kullanılabilir
mutate
(
fun
);
}
template
<
typename
Func
>
inline
void
mutate
(
Func
&&
fun
)
inline
void
mutate
(
Func
&&
fun
)
{
std
::
lock_guard
lk
(
m_mutex
);
fun
(
m_value
);
...
...
@@ -53,8 +53,21 @@ class Locked
return
copy
;
}
template
<
typename
U
,
typename
Func
>
inline
U
get
(
Func
&&
fun
)
{
U
copy
{};
access
([
&
copy
,
&
fun
](
auto
&
value
)
{
copy
=
fun
(
value
);
});
return
copy
;
}
inline
void
set
(
const
T
&
value
)
{
mutate
([
&
value
](
auto
&
v
)
{
v
=
value
;
});
}
inline
void
set
(
T
&&
value
)
{
mutate
([
&
value
](
auto
&
v
)
{
v
=
std
::
move
(
value
);
});
}
};
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment