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
9ec57471
Commit
9ec57471
authored
May 10, 2021
by
aligungr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RLS improvements
parent
3acfc31e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
263 additions
and
4 deletions
+263
-4
src/lib/rls/rls_pdu.hpp
src/lib/rls/rls_pdu.hpp
+26
-3
src/ue/nts.hpp
src/ue/nts.hpp
+24
-1
src/ue/rls/udp_task.cpp
src/ue/rls/udp_task.cpp
+149
-0
src/ue/rls/udp_task.hpp
src/ue/rls/udp_task.hpp
+63
-0
src/utils/nts.hpp
src/utils/nts.hpp
+1
-0
No files found.
src/lib/rls/rls_pdu.hpp
View file @
9ec57471
...
...
@@ -21,9 +21,14 @@ namespace rls
enum
class
EMessageType
:
uint8_t
{
RESERVED
=
0
,
CELL_INFO_REQUEST
,
CELL_INFO_RESPONSE
,
PDU_DELIVERY
CELL_INFO_REQUEST
=
1
,
CELL_INFO_RESPONSE
=
2
,
PDU_DELIVERY
=
3
,
HEARTBEAT
=
4
,
HEARTBEAT_ACK
=
5
,
};
enum
class
EPduType
:
uint8_t
...
...
@@ -43,6 +48,24 @@ struct RlsMessage
}
};
struct
RlsHeartBeat
:
RlsMessage
{
Vector3
simPos
;
explicit
RlsHeartBeat
(
uint64_t
sti
)
:
RlsMessage
(
EMessageType
::
HEARTBEAT
,
sti
)
{
}
};
struct
RlsHeartBeatAck
:
RlsMessage
{
int
dbm
{};
explicit
RlsHeartBeatAck
(
uint64_t
sti
)
:
RlsMessage
(
EMessageType
::
HEARTBEAT_ACK
,
sti
)
{
}
};
struct
RlsCellInfoRequest
:
RlsMessage
{
Vector3
simPos
{};
...
...
src/ue/nts.hpp
View file @
9ec57471
...
...
@@ -10,10 +10,13 @@
#include "types.hpp"
#include "ue.hpp"
#include <utility>
#include <lib/app/cli_base.hpp>
#include <lib/nas/timer.hpp>
#include <lib/rls/rls_pdu.hpp>
#include <lib/rrc/rrc.hpp>
#include <utility>
#include <utils/network.hpp>
#include <utils/nts.hpp>
#include <utils/octet_string.hpp>
...
...
@@ -239,6 +242,26 @@ struct NwUeRlsToApp : NtsMessage
}
};
struct
NwRlsToRls
:
NtsMessage
{
enum
PR
{
RECEIVE_RLS_MESSAGE
,
SIGNAL_CHANGED
,
}
present
;
// SIGNAL_CHANGED
uint64_t
sti
{};
int
dbm
{};
// RECEIVE_RLS_MESSAGE
std
::
unique_ptr
<
rls
::
RlsMessage
>
msg
{};
explicit
NwRlsToRls
(
PR
present
)
:
NtsMessage
(
NtsMessageType
::
UE_RLS_TO_RLS
),
present
(
present
)
{
}
};
struct
NwUeStatusUpdate
:
NtsMessage
{
static
constexpr
const
int
SESSION_ESTABLISHMENT
=
1
;
...
...
src/ue/rls/udp_task.cpp
0 → 100644
View file @
9ec57471
//
// Created by ali on 10.05.2021.
//
#include "udp_task.hpp"
#include <cstdint>
#include <cstring>
#include <set>
#include <ue/nts.hpp>
#include <utils/common.hpp>
#include <utils/constants.hpp>
static
constexpr
const
int
BUFFER_SIZE
=
16384
;
static
constexpr
const
int
LOOP_PERIOD
=
1000
;
static
constexpr
const
int
HEARTBEAT_THRESHOLD
=
2000
;
namespace
nr
::
ue
{
RlsUdpTask
::
RlsUdpTask
(
TaskBase
*
base
,
uint64_t
sti
,
const
std
::
vector
<
std
::
string
>
&
searchSpace
)
:
m_ctlTask
{},
m_sti
{
sti
},
m_searchSpace
{},
m_cells
{},
m_lastLoop
{}
{
m_logger
=
base
->
logBase
->
makeUniqueLogger
(
base
->
config
->
getLoggerPrefix
()
+
"rls-udp"
);
m_server
=
new
udp
::
UdpServer
();
for
(
auto
&
ip
:
searchSpace
)
m_searchSpace
.
emplace_back
(
ip
,
cons
::
PortalPort
);
m_simPos
=
Vector3
{};
}
void
RlsUdpTask
::
onStart
()
{
}
void
RlsUdpTask
::
onLoop
()
{
auto
current
=
utils
::
CurrentTimeMillis
();
if
(
current
-
m_lastLoop
>
LOOP_PERIOD
)
{
m_lastLoop
=
current
;
heartbeatCycle
(
current
,
m_simPos
);
}
uint8_t
buffer
[
BUFFER_SIZE
];
InetAddress
peerAddress
;
int
size
=
m_server
->
Receive
(
buffer
,
BUFFER_SIZE
,
LOOP_PERIOD
,
peerAddress
);
if
(
size
>
0
)
{
auto
rlsMsg
=
rls
::
DecodeRlsMessage
(
OctetView
{
buffer
,
static_cast
<
size_t
>
(
size
)});
if
(
rlsMsg
==
nullptr
)
m_logger
->
err
(
"Unable to decode RLS message"
);
else
receiveRlsPdu
(
peerAddress
,
std
::
move
(
rlsMsg
));
}
}
void
RlsUdpTask
::
onQuit
()
{
delete
m_server
;
}
void
RlsUdpTask
::
sendRlsPdu
(
const
InetAddress
&
addr
,
const
rls
::
RlsMessage
&
msg
)
{
OctetString
stream
;
rls
::
EncodeRlsMessage
(
msg
,
stream
);
m_server
->
Send
(
addr
,
stream
.
data
(),
static_cast
<
size_t
>
(
stream
.
length
()));
}
void
RlsUdpTask
::
send
(
uint64_t
sti
,
const
rls
::
RlsMessage
&
msg
)
{
if
(
m_cells
.
count
(
sti
))
sendRlsPdu
(
m_cells
[
sti
].
address
,
msg
);
}
void
RlsUdpTask
::
receiveRlsPdu
(
const
InetAddress
&
addr
,
std
::
unique_ptr
<
rls
::
RlsMessage
>
&&
msg
)
{
if
(
msg
->
msgType
==
rls
::
EMessageType
::
HEARTBEAT_ACK
)
{
int
oldDbm
=
INT32_MIN
;
if
(
m_cells
.
count
(
msg
->
sti
))
oldDbm
=
m_cells
[
msg
->
sti
].
dbm
;
m_cells
[
msg
->
sti
].
address
=
addr
;
m_cells
[
msg
->
sti
].
lastSeen
=
utils
::
CurrentTimeMillis
();
int
newDbm
=
((
const
rls
::
RlsHeartBeatAck
&
)
msg
).
dbm
;
m_cells
[
msg
->
sti
].
dbm
=
newDbm
;
if
(
oldDbm
!=
newDbm
)
onSignalChangeOrLost
(
msg
->
sti
);
return
;
}
if
(
!
m_cells
.
count
(
msg
->
sti
))
{
// if no HB-ACK received yet, and the message is not HB-ACK, then ignore the message
return
;
}
auto
*
w
=
new
NwRlsToRls
(
NwRlsToRls
::
RECEIVE_RLS_MESSAGE
);
w
->
msg
=
std
::
move
(
msg
);
m_ctlTask
->
push
(
w
);
}
void
RlsUdpTask
::
onSignalChangeOrLost
(
uint64_t
sti
)
{
auto
*
w
=
new
NwRlsToRls
(
NwRlsToRls
::
SIGNAL_CHANGED
);
w
->
sti
=
sti
;
w
->
dbm
=
m_cells
.
count
(
sti
)
?
m_cells
[
sti
].
dbm
:
INT32_MIN
;
m_ctlTask
->
push
(
w
);
}
void
RlsUdpTask
::
heartbeatCycle
(
uint64_t
time
,
const
Vector3
&
simPos
)
{
std
::
set
<
uint64_t
>
stiToRemove
;
for
(
auto
&
cell
:
m_cells
)
{
auto
delta
=
time
-
cell
.
second
.
lastSeen
;
if
(
delta
>
HEARTBEAT_THRESHOLD
)
stiToRemove
.
insert
(
cell
.
first
);
}
for
(
auto
sti
:
stiToRemove
)
m_cells
.
erase
(
sti
);
for
(
auto
sti
:
stiToRemove
)
onSignalChangeOrLost
(
sti
);
for
(
auto
&
addr
:
m_searchSpace
)
{
rls
::
RlsHeartBeat
msg
{
m_sti
};
msg
.
simPos
=
simPos
;
sendRlsPdu
(
addr
,
msg
);
}
}
void
RlsUdpTask
::
initialize
(
NtsTask
*
ctlTask
)
{
m_ctlTask
=
ctlTask
;
}
}
// namespace nr::ue
src/ue/rls/udp_task.hpp
0 → 100644
View file @
9ec57471
//
// 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.
//
#pragma once
#include <cstdint>
#include <unordered_map>
#include <vector>
#include <lib/rls/rls_pdu.hpp>
#include <lib/udp/server.hpp>
#include <ue/types.hpp>
#include <utils/nts.hpp>
namespace
nr
::
ue
{
class
RlsUdpTask
:
public
NtsTask
{
private:
struct
CellInfo
{
InetAddress
address
;
int64_t
lastSeen
{};
int
dbm
{};
};
private:
std
::
unique_ptr
<
Logger
>
m_logger
;
NtsTask
*
m_ctlTask
;
udp
::
UdpServer
*
m_server
;
uint64_t
m_sti
;
std
::
vector
<
InetAddress
>
m_searchSpace
;
std
::
unordered_map
<
uint64_t
,
CellInfo
>
m_cells
;
int64_t
m_lastLoop
;
Vector3
m_simPos
;
public:
explicit
RlsUdpTask
(
TaskBase
*
base
,
uint64_t
sti
,
const
std
::
vector
<
std
::
string
>
&
searchSpace
);
~
RlsUdpTask
()
override
=
default
;
protected:
void
onStart
()
override
;
void
onLoop
()
override
;
void
onQuit
()
override
;
private:
void
sendRlsPdu
(
const
InetAddress
&
addr
,
const
rls
::
RlsMessage
&
msg
);
void
receiveRlsPdu
(
const
InetAddress
&
addr
,
std
::
unique_ptr
<
rls
::
RlsMessage
>
&&
msg
);
void
onSignalChangeOrLost
(
uint64_t
sti
);
void
heartbeatCycle
(
uint64_t
time
,
const
Vector3
&
simPos
);
public:
void
initialize
(
NtsTask
*
ctlTask
);
void
send
(
uint64_t
sti
,
const
rls
::
RlsMessage
&
msg
);
};
}
// namespace nr::ue
src/utils/nts.hpp
View file @
9ec57471
...
...
@@ -54,6 +54,7 @@ enum class NtsMessageType
UE_NAS_TO_NAS
,
UE_RLS_TO_RRC
,
UE_RLS_TO_APP
,
UE_RLS_TO_RLS
,
UE_NAS_TO_APP
,
};
...
...
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