Commit 79d9171f authored by aligungr's avatar aligungr

RLS improvements

parent 9f8f3847
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <lib/app/cli_base.hpp> #include <lib/app/cli_base.hpp>
#include <lib/app/cli_cmd.hpp> #include <lib/app/cli_cmd.hpp>
#include <lib/asn/utils.hpp> #include <lib/asn/utils.hpp>
#include <lib/rls/rls_pdu.hpp>
#include <lib/rrc/rrc.hpp> #include <lib/rrc/rrc.hpp>
#include <lib/sctp/sctp.hpp> #include <lib/sctp/sctp.hpp>
#include <utils/network.hpp> #include <utils/network.hpp>
...@@ -86,6 +87,27 @@ struct NwGnbGtpToRls : NtsMessage ...@@ -86,6 +87,27 @@ struct NwGnbGtpToRls : NtsMessage
} }
}; };
struct NwGnbRlsToRls : NtsMessage
{
enum PR
{
SIGNAL_DETECTED,
SIGNAL_LOST,
RECEIVE_RLS_MESSAGE
} present;
// SIGNAL_DETECTED
// SIGNAL_LOST
int ueId{};
// RECEIVE_RLS_MESSAGE
std::unique_ptr<rls::RlsMessage> msg{};
explicit NwGnbRlsToRls(PR present) : NtsMessage(NtsMessageType::GNB_RLS_TO_RLS), present(present)
{
}
};
struct NwGnbRrcToRls : NtsMessage struct NwGnbRrcToRls : NtsMessage
{ {
enum PR enum PR
......
...@@ -42,7 +42,7 @@ namespace nr::gnb ...@@ -42,7 +42,7 @@ namespace nr::gnb
{ {
RlsUdpTask::RlsUdpTask(TaskBase *base, uint64_t sti, Vector3 phyLocation) RlsUdpTask::RlsUdpTask(TaskBase *base, uint64_t sti, Vector3 phyLocation)
: m_sti{sti}, m_phyLocation{phyLocation}, m_lastLoop{}, m_stiToUe{}, m_ueMap{} : m_ctlTask{}, m_sti{sti}, m_phyLocation{phyLocation}, m_lastLoop{}, m_stiToUe{}, m_ueMap{}, m_newIdCounter{}
{ {
m_logger = base->logBase->makeUniqueLogger("rls"); m_logger = base->logBase->makeUniqueLogger("rls");
...@@ -109,13 +109,15 @@ void RlsUdpTask::receiveRlsPdu(const InetAddress &addr, std::unique_ptr<rls::Rls ...@@ -109,13 +109,15 @@ void RlsUdpTask::receiveRlsPdu(const InetAddress &addr, std::unique_ptr<rls::Rls
} }
else else
{ {
int ueId = static_cast<int>(m_stiToUe.size()) + 1; int ueId = ++m_newIdCounter;
m_stiToUe[msg->sti] = ueId; m_stiToUe[msg->sti] = ueId;
m_ueMap[ueId].address = addr; m_ueMap[ueId].address = addr;
m_ueMap[ueId].lastSeen = utils::CurrentTimeMillis(); m_ueMap[ueId].lastSeen = utils::CurrentTimeMillis();
// TODO notify upper layer new UE auto *w = new NwGnbRlsToRls(NwGnbRlsToRls::SIGNAL_DETECTED);
w->ueId = ueId;
m_ctlTask->push(w);
} }
rls::RlsHeartBeatAck ack{m_sti}; rls::RlsHeartBeatAck ack{m_sti};
...@@ -125,7 +127,16 @@ void RlsUdpTask::receiveRlsPdu(const InetAddress &addr, std::unique_ptr<rls::Rls ...@@ -125,7 +127,16 @@ void RlsUdpTask::receiveRlsPdu(const InetAddress &addr, std::unique_ptr<rls::Rls
return; return;
} }
// TODO notify upper layer new message if (!m_stiToUe.count(msg->sti))
{
// if no HB received yet, and the message is not HB, then ignore the message
return;
}
auto *w = new NwGnbRlsToRls(NwGnbRlsToRls::RECEIVE_RLS_MESSAGE);
w->ueId = m_stiToUe[msg->sti];
w->msg = std::move(msg);
m_ctlTask->push(w);
} }
void RlsUdpTask::sendRlsPdu(const InetAddress &addr, const rls::RlsMessage &msg) void RlsUdpTask::sendRlsPdu(const InetAddress &addr, const rls::RlsMessage &msg)
...@@ -158,8 +169,26 @@ void RlsUdpTask::heartbeatCycle(int64_t time) ...@@ -158,8 +169,26 @@ void RlsUdpTask::heartbeatCycle(int64_t time)
for (int ueId : lostUeId) for (int ueId : lostUeId)
{ {
// TODO: notify upper layer auto *w = new NwGnbRlsToRls(NwGnbRlsToRls::SIGNAL_LOST);
w->ueId = ueId;
m_ctlTask->push(w);
}
}
void RlsUdpTask::initialize(NtsTask *ctlTask)
{
m_ctlTask = ctlTask;
}
void RlsUdpTask::send(int ueId, const rls::RlsMessage &msg)
{
if (!m_ueMap.count(ueId))
{
// ignore the message
return;
} }
sendRlsPdu(m_ueMap[ueId].address, msg);
} }
} // namespace nr::gnb } // namespace nr::gnb
...@@ -33,11 +33,13 @@ class RlsUdpTask : public NtsTask ...@@ -33,11 +33,13 @@ class RlsUdpTask : public NtsTask
private: private:
std::unique_ptr<Logger> m_logger; std::unique_ptr<Logger> m_logger;
udp::UdpServer *m_server; udp::UdpServer *m_server;
NtsTask *m_ctlTask;
uint64_t m_sti; uint64_t m_sti;
Vector3 m_phyLocation; Vector3 m_phyLocation;
int64_t m_lastLoop; int64_t m_lastLoop;
std::unordered_map<uint64_t, int> m_stiToUe; std::unordered_map<uint64_t, int> m_stiToUe;
std::unordered_map<int, UeInfo> m_ueMap; std::unordered_map<int, UeInfo> m_ueMap;
int m_newIdCounter;
public: public:
explicit RlsUdpTask(TaskBase *base, uint64_t sti, Vector3 phyLocation); explicit RlsUdpTask(TaskBase *base, uint64_t sti, Vector3 phyLocation);
...@@ -52,6 +54,10 @@ class RlsUdpTask : public NtsTask ...@@ -52,6 +54,10 @@ class RlsUdpTask : public NtsTask
void receiveRlsPdu(const InetAddress &addr, std::unique_ptr<rls::RlsMessage> &&msg); void receiveRlsPdu(const InetAddress &addr, std::unique_ptr<rls::RlsMessage> &&msg);
void sendRlsPdu(const InetAddress &addr, const rls::RlsMessage &msg); void sendRlsPdu(const InetAddress &addr, const rls::RlsMessage &msg);
void heartbeatCycle(int64_t time); void heartbeatCycle(int64_t time);
public:
void initialize(NtsTask *ctlTask);
void send(int ueId, const rls::RlsMessage &msg);
}; };
} // namespace nr::gnb } // namespace nr::gnb
...@@ -39,6 +39,7 @@ enum class NtsMessageType ...@@ -39,6 +39,7 @@ enum class NtsMessageType
GNB_RLS_TO_GTP, GNB_RLS_TO_GTP,
GNB_GTP_TO_RLS, GNB_GTP_TO_RLS,
GNB_RRC_TO_RLS, GNB_RRC_TO_RLS,
GNB_RLS_TO_RLS,
GNB_NGAP_TO_RRC, GNB_NGAP_TO_RRC,
GNB_RRC_TO_NGAP, GNB_RRC_TO_NGAP,
GNB_NGAP_TO_GTP, GNB_NGAP_TO_GTP,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment