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
a84966ca
Commit
a84966ca
authored
Feb 20, 2021
by
aligungr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UE executable refactor
parent
30cbc8e7
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
81 additions
and
64 deletions
+81
-64
src/ue.cpp
src/ue.cpp
+8
-5
src/ue/app/cmd_handler.cpp
src/ue/app/cmd_handler.cpp
+44
-34
src/ue/app/cmd_handler.hpp
src/ue/app/cmd_handler.hpp
+16
-5
src/ue/app/task.cpp
src/ue/app/task.cpp
+2
-1
src/ue/nts.hpp
src/ue/nts.hpp
+2
-13
src/ue/types.hpp
src/ue/types.hpp
+1
-0
src/ue/ue.cpp
src/ue/ue.cpp
+5
-4
src/ue/ue.hpp
src/ue/ue.hpp
+3
-2
No files found.
src/ue.cpp
View file @
a84966ca
...
...
@@ -289,7 +289,7 @@ static void ReceiveCommand(app::CliMessage &msg)
}
auto
*
ue
=
g_ueMap
[
msg
.
nodeName
];
ue
->
pushCommand
(
std
::
move
(
cmd
),
msg
.
clientAddr
,
g_cliRespTask
);
ue
->
pushCommand
(
std
::
move
(
cmd
),
msg
.
clientAddr
);
}
static
void
Loop
()
...
...
@@ -357,19 +357,22 @@ int main(int argc, char **argv)
std
::
cout
<<
cons
::
Name
<<
std
::
endl
;
if
(
!
g_options
.
disableCmd
)
{
g_cliServer
=
new
app
::
CliServer
{};
g_cliRespTask
=
new
app
::
CliResponseTask
(
g_cliServer
);
}
for
(
int
i
=
0
;
i
<
g_options
.
count
;
i
++
)
{
auto
*
config
=
GetConfigByUe
(
i
);
auto
*
ue
=
new
nr
::
ue
::
UserEquipment
(
config
,
&
g_ueController
,
nullptr
);
auto
*
ue
=
new
nr
::
ue
::
UserEquipment
(
config
,
&
g_ueController
,
nullptr
,
g_cliRespTask
);
g_ueMap
[
config
->
getNodeName
()]
=
ue
;
}
if
(
!
g_options
.
disableCmd
)
{
g_cliServer
=
new
app
::
CliServer
{};
app
::
CreateProcTable
(
g_ueMap
,
g_cliServer
->
assignedAddress
().
getPort
());
g_cliRespTask
=
new
app
::
CliResponseTask
(
g_cliServer
);
g_cliRespTask
->
start
();
}
...
...
src/ue/app/cmd_handler.cpp
View file @
a84966ca
...
...
@@ -22,34 +22,44 @@
namespace
nr
::
ue
{
void
UeCmdHandler
::
PauseTasks
(
TaskBase
&
base
)
void
UeCmdHandler
::
sendResult
(
const
InetAddress
&
address
,
const
std
::
string
&
output
)
{
base
.
mrTask
->
requestPause
();
base
.
nasTask
->
requestPause
();
base
.
rrcTask
->
requestPause
();
m_base
->
cliCallbackTask
->
push
(
new
app
::
NwCliSendResponse
(
address
,
output
,
false
));
}
void
UeCmdHandler
::
UnpauseTasks
(
TaskBase
&
base
)
void
UeCmdHandler
::
sendError
(
const
InetAddress
&
address
,
const
std
::
string
&
output
)
{
base
.
mrTask
->
requestUnpause
();
base
.
nasTask
->
requestUnpause
();
base
.
rrcTask
->
requestUnpause
();
m_base
->
cliCallbackTask
->
push
(
new
app
::
NwCliSendResponse
(
address
,
output
,
true
));
}
bool
UeCmdHandler
::
IsAllPaused
(
TaskBase
&
base
)
void
UeCmdHandler
::
pauseTasks
(
)
{
if
(
!
base
.
mrTask
->
isPauseConfirmed
())
m_base
->
mrTask
->
requestPause
();
m_base
->
nasTask
->
requestPause
();
m_base
->
rrcTask
->
requestPause
();
}
void
UeCmdHandler
::
unpauseTasks
()
{
m_base
->
mrTask
->
requestUnpause
();
m_base
->
nasTask
->
requestUnpause
();
m_base
->
rrcTask
->
requestUnpause
();
}
bool
UeCmdHandler
::
isAllPaused
()
{
if
(
!
m_base
->
mrTask
->
isPauseConfirmed
())
return
false
;
if
(
!
base
.
nasTask
->
isPauseConfirmed
())
if
(
!
m_base
->
nasTask
->
isPauseConfirmed
())
return
false
;
if
(
!
base
.
rrcTask
->
isPauseConfirmed
())
if
(
!
m_base
->
rrcTask
->
isPauseConfirmed
())
return
false
;
return
true
;
}
void
UeCmdHandler
::
HandleCmd
(
TaskBase
&
base
,
NwUeCliCommand
&
msg
)
void
UeCmdHandler
::
handleCmd
(
NwUeCliCommand
&
msg
)
{
PauseTasks
(
base
);
pauseTasks
(
);
uint64_t
currentTime
=
utils
::
CurrentTimeMillis
();
uint64_t
endTime
=
currentTime
+
PAUSE_CONFIRM_TIMEOUT
;
...
...
@@ -58,7 +68,7 @@ void UeCmdHandler::HandleCmd(TaskBase &base, NwUeCliCommand &msg)
while
(
currentTime
<
endTime
)
{
currentTime
=
utils
::
CurrentTimeMillis
();
if
(
IsAllPaused
(
base
))
if
(
isAllPaused
(
))
{
isPaused
=
true
;
break
;
...
...
@@ -68,24 +78,24 @@ void UeCmdHandler::HandleCmd(TaskBase &base, NwUeCliCommand &msg)
if
(
!
isPaused
)
{
msg
.
sendError
(
"UE is unable process command due to pausing timeout"
);
sendError
(
msg
.
address
,
"UE is unable process command due to pausing timeout"
);
}
else
{
HandleCmdImpl
(
base
,
msg
);
handleCmdImpl
(
msg
);
}
UnpauseTasks
(
base
);
unpauseTasks
(
);
}
void
UeCmdHandler
::
HandleCmdImpl
(
TaskBase
&
base
,
NwUeCliCommand
&
msg
)
void
UeCmdHandler
::
handleCmdImpl
(
NwUeCliCommand
&
msg
)
{
switch
(
msg
.
cmd
->
present
)
{
case
app
:
:
UeCliCommand
::
STATUS
:
{
std
::
vector
<
Json
>
pduSessions
{};
int
index
=
0
;
for
(
auto
&
pduSession
:
base
.
appTask
->
m_statusInfo
.
pduSessions
)
for
(
auto
&
pduSession
:
m_base
->
appTask
->
m_statusInfo
.
pduSessions
)
{
if
(
pduSession
.
has_value
())
{
...
...
@@ -96,33 +106,33 @@ void UeCmdHandler::HandleCmdImpl(TaskBase &base, NwUeCliCommand &msg)
}
Json
json
=
Json
::
Obj
({
{
"cm-state"
,
ToJson
(
base
.
nasTask
->
mm
->
m_cmState
)},
{
"rm-state"
,
ToJson
(
base
.
nasTask
->
mm
->
m_rmState
)},
{
"mm-state"
,
ToJson
(
base
.
nasTask
->
mm
->
m_mmSubState
)},
{
"sim-inserted"
,
base
.
nasTask
->
mm
->
m_validSim
},
{
"stored-suci"
,
ToJson
(
base
.
nasTask
->
mm
->
m_storedSuci
)},
{
"stored-guti"
,
ToJson
(
base
.
nasTask
->
mm
->
m_storedGuti
)},
{
"cm-state"
,
ToJson
(
m_base
->
nasTask
->
mm
->
m_cmState
)},
{
"rm-state"
,
ToJson
(
m_base
->
nasTask
->
mm
->
m_rmState
)},
{
"mm-state"
,
ToJson
(
m_base
->
nasTask
->
mm
->
m_mmSubState
)},
{
"sim-inserted"
,
m_base
->
nasTask
->
mm
->
m_validSim
},
{
"stored-suci"
,
ToJson
(
m_base
->
nasTask
->
mm
->
m_storedSuci
)},
{
"stored-guti"
,
ToJson
(
m_base
->
nasTask
->
mm
->
m_storedGuti
)},
{
"pdu-sessions"
,
Json
::
Arr
(
std
::
move
(
pduSessions
))},
});
msg
.
sendResult
(
json
.
dumpYaml
());
sendResult
(
msg
.
address
,
json
.
dumpYaml
());
break
;
}
case
app
:
:
UeCliCommand
::
INFO
:
{
msg
.
sendResult
(
ToJson
(
*
base
.
config
).
dumpYaml
());
sendResult
(
msg
.
address
,
ToJson
(
*
m_base
->
config
).
dumpYaml
());
break
;
}
case
app
:
:
UeCliCommand
::
TIMERS
:
{
msg
.
sendResult
(
ToJson
(
base
.
nasTask
->
timers
).
dumpYaml
());
sendResult
(
msg
.
address
,
ToJson
(
m_base
->
nasTask
->
timers
).
dumpYaml
());
break
;
}
case
app
:
:
UeCliCommand
::
DE_REGISTER
:
{
base
.
nasTask
->
mm
->
sendDeregistration
(
msg
.
cmd
->
isSwitchOff
?
nas
::
ESwitchOff
::
SWITCH_OFF
:
nas
::
ESwitchOff
::
NORMAL_DE_REGISTRATION
,
msg
.
cmd
->
dueToDisable5g
);
m_base
->
nasTask
->
mm
->
sendDeregistration
(
msg
.
cmd
->
isSwitchOff
?
nas
::
ESwitchOff
::
SWITCH_OFF
:
nas
::
ESwitchOff
::
NORMAL_DE_REGISTRATION
,
msg
.
cmd
->
dueToDisable5g
);
if
(
!
msg
.
cmd
->
isSwitchOff
)
msg
.
sendResult
(
"De-registration procedure triggered"
);
sendResult
(
msg
.
address
,
"De-registration procedure triggered"
);
else
msg
.
sendResult
(
"De-registration procedure triggered. UE device will be switched off."
);
sendResult
(
msg
.
address
,
"De-registration procedure triggered. UE device will be switched off."
);
break
;
}
}
...
...
src/ue/app/cmd_handler.hpp
View file @
a84966ca
...
...
@@ -17,15 +17,26 @@ namespace nr::ue
class
UeCmdHandler
{
private:
static
void
PauseTasks
(
TaskBase
&
base
);
static
void
UnpauseTasks
(
TaskBase
&
base
);
static
bool
IsAllPaused
(
TaskBase
&
base
);
TaskBase
*
m_base
;
public:
static
void
HandleCmd
(
TaskBase
&
base
,
NwUeCliCommand
&
msg
);
explicit
UeCmdHandler
(
TaskBase
*
base
)
:
m_base
(
base
)
{
}
void
handleCmd
(
NwUeCliCommand
&
msg
);
private:
void
pauseTasks
();
void
unpauseTasks
();
bool
isAllPaused
();
private:
void
handleCmdImpl
(
NwUeCliCommand
&
msg
);
private:
static
void
HandleCmdImpl
(
TaskBase
&
base
,
NwUeCliCommand
&
msg
);
void
sendResult
(
const
InetAddress
&
address
,
const
std
::
string
&
output
);
void
sendError
(
const
InetAddress
&
address
,
const
std
::
string
&
output
);
};
}
// namespace nr::ue
src/ue/app/task.cpp
View file @
a84966ca
...
...
@@ -103,7 +103,8 @@ void UeAppTask::onLoop()
}
case
NtsMessageType
:
:
UE_CLI_COMMAND
:
{
auto
*
w
=
dynamic_cast
<
NwUeCliCommand
*>
(
msg
);
UeCmdHandler
::
HandleCmd
(
*
m_base
,
*
w
);
UeCmdHandler
handler
{
m_base
};
handler
.
handleCmd
(
*
w
);
break
;
}
case
NtsMessageType
:
:
TIMER_EXPIRED
:
{
...
...
src/ue/nts.hpp
View file @
a84966ca
...
...
@@ -254,22 +254,11 @@ struct NwUeCliCommand : NtsMessage
{
std
::
unique_ptr
<
app
::
UeCliCommand
>
cmd
;
InetAddress
address
;
NtsTask
*
callbackTask
;
NwUeCliCommand
(
std
::
unique_ptr
<
app
::
UeCliCommand
>
cmd
,
InetAddress
address
,
NtsTask
*
callbackTask
)
:
NtsMessage
(
NtsMessageType
::
UE_CLI_COMMAND
),
cmd
(
std
::
move
(
cmd
)),
address
(
address
)
,
callbackTask
(
callbackTask
)
NwUeCliCommand
(
std
::
unique_ptr
<
app
::
UeCliCommand
>
cmd
,
InetAddress
address
)
:
NtsMessage
(
NtsMessageType
::
UE_CLI_COMMAND
),
cmd
(
std
::
move
(
cmd
)),
address
(
address
)
{
}
void
sendResult
(
const
std
::
string
&
output
)
const
{
callbackTask
->
push
(
new
app
::
NwCliSendResponse
(
address
,
output
,
false
));
}
void
sendError
(
const
std
::
string
&
output
)
const
{
callbackTask
->
push
(
new
app
::
NwCliSendResponse
(
address
,
output
,
true
));
}
};
}
// namespace nr::ue
\ No newline at end of file
src/ue/types.hpp
View file @
a84966ca
...
...
@@ -101,6 +101,7 @@ struct TaskBase
LogBase
*
logBase
{};
app
::
IUeController
*
ueController
{};
app
::
INodeListener
*
nodeListener
{};
NtsTask
*
cliCallbackTask
{};
UeAppTask
*
appTask
{};
UeMrTask
*
mrTask
{};
...
...
src/ue/ue.cpp
View file @
a84966ca
...
...
@@ -16,13 +16,15 @@
namespace
nr
::
ue
{
UserEquipment
::
UserEquipment
(
UeConfig
*
config
,
app
::
IUeController
*
ueController
,
app
::
INodeListener
*
nodeListener
)
UserEquipment
::
UserEquipment
(
UeConfig
*
config
,
app
::
IUeController
*
ueController
,
app
::
INodeListener
*
nodeListener
,
NtsTask
*
cliCallbackTask
)
{
auto
*
base
=
new
TaskBase
();
base
->
config
=
config
;
base
->
logBase
=
new
LogBase
(
"logs/ue-"
+
config
->
getNodeName
()
+
".log"
);
base
->
ueController
=
ueController
;
base
->
nodeListener
=
nodeListener
;
base
->
cliCallbackTask
=
cliCallbackTask
;
base
->
nasTask
=
new
NasTask
(
base
);
base
->
rrcTask
=
new
UeRrcTask
(
base
);
...
...
@@ -57,10 +59,9 @@ void UserEquipment::start()
taskBase
->
appTask
->
start
();
}
void
UserEquipment
::
pushCommand
(
std
::
unique_ptr
<
app
::
UeCliCommand
>
cmd
,
const
InetAddress
&
address
,
NtsTask
*
callbackTask
)
void
UserEquipment
::
pushCommand
(
std
::
unique_ptr
<
app
::
UeCliCommand
>
cmd
,
const
InetAddress
&
address
)
{
taskBase
->
appTask
->
push
(
new
NwUeCliCommand
(
std
::
move
(
cmd
),
address
,
callbackTask
));
taskBase
->
appTask
->
push
(
new
NwUeCliCommand
(
std
::
move
(
cmd
),
address
));
}
}
// namespace nr::ue
src/ue/ue.hpp
View file @
a84966ca
...
...
@@ -23,12 +23,13 @@ class UserEquipment
TaskBase
*
taskBase
;
public:
UserEquipment
(
UeConfig
*
config
,
app
::
IUeController
*
ueController
,
app
::
INodeListener
*
nodeListener
);
UserEquipment
(
UeConfig
*
config
,
app
::
IUeController
*
ueController
,
app
::
INodeListener
*
nodeListener
,
NtsTask
*
cliCallbackTask
);
virtual
~
UserEquipment
();
public:
void
start
();
void
pushCommand
(
std
::
unique_ptr
<
app
::
UeCliCommand
>
cmd
,
const
InetAddress
&
address
,
NtsTask
*
callbackTask
);
void
pushCommand
(
std
::
unique_ptr
<
app
::
UeCliCommand
>
cmd
,
const
InetAddress
&
address
);
};
}
// namespace nr::ue
\ 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