Commit 14f9233e authored by aligungr's avatar aligungr

RLS improvements

parent 739be8b1
...@@ -250,13 +250,13 @@ struct NwUeRlsToRls : NtsMessage ...@@ -250,13 +250,13 @@ struct NwUeRlsToRls : NtsMessage
SIGNAL_CHANGED, SIGNAL_CHANGED,
} present; } present;
// SIGNAL_CHANGED
uint64_t sti{};
int dbm{};
// RECEIVE_RLS_MESSAGE // RECEIVE_RLS_MESSAGE
int cellId{};
std::unique_ptr<rls::RlsMessage> msg{}; std::unique_ptr<rls::RlsMessage> msg{};
// SIGNAL_CHANGED
int dbm{};
explicit NwUeRlsToRls(PR present) : NtsMessage(NtsMessageType::UE_RLS_TO_RLS), present(present) explicit NwUeRlsToRls(PR present) : NtsMessage(NtsMessageType::UE_RLS_TO_RLS), present(present)
{ {
} }
......
...@@ -25,7 +25,7 @@ namespace nr::ue ...@@ -25,7 +25,7 @@ namespace nr::ue
{ {
RlsUdpTask::RlsUdpTask(TaskBase *base, uint64_t sti, const std::vector<std::string> &searchSpace) 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_ctlTask{}, m_sti{sti}, m_searchSpace{}, m_cells{}, m_cellIdToSti{}, m_lastLoop{}, m_cellIdCounter{}
{ {
m_logger = base->logBase->makeUniqueLogger(base->config->getLoggerPrefix() + "rls-udp"); m_logger = base->logBase->makeUniqueLogger(base->config->getLoggerPrefix() + "rls-udp");
...@@ -77,16 +77,25 @@ void RlsUdpTask::sendRlsPdu(const InetAddress &addr, const rls::RlsMessage &msg) ...@@ -77,16 +77,25 @@ void RlsUdpTask::sendRlsPdu(const InetAddress &addr, const rls::RlsMessage &msg)
m_server->Send(addr, stream.data(), static_cast<size_t>(stream.length())); m_server->Send(addr, stream.data(), static_cast<size_t>(stream.length()));
} }
void RlsUdpTask::send(uint64_t sti, const rls::RlsMessage &msg) void RlsUdpTask::send(int cellId, const rls::RlsMessage &msg)
{ {
if (m_cells.count(sti)) if (m_cellIdToSti.count(cellId))
{
auto sti = m_cellIdToSti[cellId];
sendRlsPdu(m_cells[sti].address, msg); sendRlsPdu(m_cells[sti].address, msg);
}
} }
void RlsUdpTask::receiveRlsPdu(const InetAddress &addr, std::unique_ptr<rls::RlsMessage> &&msg) void RlsUdpTask::receiveRlsPdu(const InetAddress &addr, std::unique_ptr<rls::RlsMessage> &&msg)
{ {
if (msg->msgType == rls::EMessageType::HEARTBEAT_ACK) if (msg->msgType == rls::EMessageType::HEARTBEAT_ACK)
{ {
if (!m_cells.count(msg->sti))
{
m_cells[msg->sti].cellId = ++m_cellIdCounter;
m_cellIdToSti[m_cells[msg->sti].cellId] = msg->sti;
}
int oldDbm = INT32_MIN; int oldDbm = INT32_MIN;
if (m_cells.count(msg->sti)) if (m_cells.count(msg->sti))
oldDbm = m_cells[msg->sti].dbm; oldDbm = m_cells[msg->sti].dbm;
...@@ -98,7 +107,7 @@ void RlsUdpTask::receiveRlsPdu(const InetAddress &addr, std::unique_ptr<rls::Rls ...@@ -98,7 +107,7 @@ void RlsUdpTask::receiveRlsPdu(const InetAddress &addr, std::unique_ptr<rls::Rls
m_cells[msg->sti].dbm = newDbm; m_cells[msg->sti].dbm = newDbm;
if (oldDbm != newDbm) if (oldDbm != newDbm)
onSignalChangeOrLost(msg->sti); onSignalChangeOrLost(m_cells[msg->sti].cellId);
return; return;
} }
...@@ -109,34 +118,45 @@ void RlsUdpTask::receiveRlsPdu(const InetAddress &addr, std::unique_ptr<rls::Rls ...@@ -109,34 +118,45 @@ void RlsUdpTask::receiveRlsPdu(const InetAddress &addr, std::unique_ptr<rls::Rls
} }
auto *w = new NwUeRlsToRls(NwUeRlsToRls::RECEIVE_RLS_MESSAGE); auto *w = new NwUeRlsToRls(NwUeRlsToRls::RECEIVE_RLS_MESSAGE);
w->cellId = m_cells[msg->sti].cellId;
w->msg = std::move(msg); w->msg = std::move(msg);
m_ctlTask->push(w); m_ctlTask->push(w);
} }
void RlsUdpTask::onSignalChangeOrLost(uint64_t sti) void RlsUdpTask::onSignalChangeOrLost(int cellId)
{ {
int dbm = INT32_MIN;
if (m_cellIdToSti.count(cellId))
{
auto sti = m_cellIdToSti[cellId];
dbm = m_cells[sti].dbm;
}
auto *w = new NwUeRlsToRls(NwUeRlsToRls::SIGNAL_CHANGED); auto *w = new NwUeRlsToRls(NwUeRlsToRls::SIGNAL_CHANGED);
w->sti = sti; w->cellId = cellId;
w->dbm = m_cells.count(sti) ? m_cells[sti].dbm : INT32_MIN; w->dbm = dbm;
m_ctlTask->push(w); m_ctlTask->push(w);
} }
void RlsUdpTask::heartbeatCycle(uint64_t time, const Vector3 &simPos) void RlsUdpTask::heartbeatCycle(uint64_t time, const Vector3 &simPos)
{ {
std::set<uint64_t> stiToRemove; std::set<std::pair<uint64_t, int>> toRemove;
for (auto &cell : m_cells) for (auto &cell : m_cells)
{ {
auto delta = time - cell.second.lastSeen; auto delta = time - cell.second.lastSeen;
if (delta > HEARTBEAT_THRESHOLD) if (delta > HEARTBEAT_THRESHOLD)
stiToRemove.insert(cell.first); toRemove.insert({cell.first, cell.second.cellId});
} }
for (auto sti : stiToRemove) for (auto cell : toRemove)
m_cells.erase(sti); {
m_cells.erase(cell.first);
m_cellIdToSti.erase(cell.second);
}
for (auto sti : stiToRemove) for (auto cell : toRemove)
onSignalChangeOrLost(sti); onSignalChangeOrLost(cell.second);
for (auto &addr : m_searchSpace) for (auto &addr : m_searchSpace)
{ {
......
...@@ -28,6 +28,7 @@ class RlsUdpTask : public NtsTask ...@@ -28,6 +28,7 @@ class RlsUdpTask : public NtsTask
InetAddress address; InetAddress address;
int64_t lastSeen{}; int64_t lastSeen{};
int dbm{}; int dbm{};
int cellId{};
}; };
private: private:
...@@ -37,8 +38,10 @@ class RlsUdpTask : public NtsTask ...@@ -37,8 +38,10 @@ class RlsUdpTask : public NtsTask
uint64_t m_sti; uint64_t m_sti;
std::vector<InetAddress> m_searchSpace; std::vector<InetAddress> m_searchSpace;
std::unordered_map<uint64_t, CellInfo> m_cells; std::unordered_map<uint64_t, CellInfo> m_cells;
std::unordered_map<int, uint64_t> m_cellIdToSti;
int64_t m_lastLoop; int64_t m_lastLoop;
Vector3 m_simPos; Vector3 m_simPos;
int m_cellIdCounter;
public: public:
explicit RlsUdpTask(TaskBase *base, uint64_t sti, const std::vector<std::string> &searchSpace); explicit RlsUdpTask(TaskBase *base, uint64_t sti, const std::vector<std::string> &searchSpace);
...@@ -52,12 +55,12 @@ class RlsUdpTask : public NtsTask ...@@ -52,12 +55,12 @@ class RlsUdpTask : public NtsTask
private: private:
void sendRlsPdu(const InetAddress &addr, const rls::RlsMessage &msg); void sendRlsPdu(const InetAddress &addr, const rls::RlsMessage &msg);
void receiveRlsPdu(const InetAddress &addr, std::unique_ptr<rls::RlsMessage> &&msg); void receiveRlsPdu(const InetAddress &addr, std::unique_ptr<rls::RlsMessage> &&msg);
void onSignalChangeOrLost(uint64_t sti); void onSignalChangeOrLost(int cellId);
void heartbeatCycle(uint64_t time, const Vector3 &simPos); void heartbeatCycle(uint64_t time, const Vector3 &simPos);
public: public:
void initialize(NtsTask *ctlTask); void initialize(NtsTask *ctlTask);
void send(uint64_t sti, const rls::RlsMessage &msg); void send(int cellId, const rls::RlsMessage &msg);
}; };
} // namespace nr::ue } // namespace nr::ue
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