Commit cffae166 authored by aligungr's avatar aligungr

Performance improvements

parent 1564ad57
......@@ -16,9 +16,7 @@
#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 RECEIVE_TIMEOUT = 200;
static constexpr const int HEARTBEAT_THRESHOLD = 2000; // (LOOP_PERIOD + RECEIVE_TIMEOUT)'dan büyük olmalı
namespace nr::ue
......@@ -30,7 +28,7 @@ RlsUdpTask::RlsUdpTask(TaskBase *base, RlsSharedContext *shCtx, const std::vecto
{
m_logger = base->logBase->makeUniqueLogger(base->config->getLoggerPrefix() + "rls-udp");
m_server = new udp::UdpServer();
m_server = new udp::UdpServerTask(this);
for (auto &ip : searchSpace)
m_searchSpace.emplace_back(ip, cons::RadioLinkPort);
......@@ -40,6 +38,7 @@ RlsUdpTask::RlsUdpTask(TaskBase *base, RlsSharedContext *shCtx, const std::vecto
void RlsUdpTask::onStart()
{
m_server->start();
}
void RlsUdpTask::onLoop()
......@@ -51,22 +50,25 @@ void RlsUdpTask::onLoop()
heartbeatCycle(current, m_simPos);
}
uint8_t buffer[BUFFER_SIZE];
InetAddress peerAddress;
auto msg = take();
int size = m_server->Receive(buffer, BUFFER_SIZE, RECEIVE_TIMEOUT, peerAddress);
if (size > 0)
if (msg)
{
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));
if (msg->msgType == NtsMessageType::UDP_SERVER_RECEIVE)
{
auto& w = dynamic_cast<udp::NwUdpServerReceive &>(*msg);
auto rlsMsg = rls::DecodeRlsMessage(OctetView{w.packet});
if (rlsMsg == nullptr)
m_logger->err("Unable to decode RLS message");
else
receiveRlsPdu(w.fromAddress, std::move(rlsMsg));
}
}
}
void RlsUdpTask::onQuit()
{
m_server->quit();
delete m_server;
}
......@@ -75,7 +77,7 @@ 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()));
m_server->send(addr, stream);
}
void RlsUdpTask::send(int cellId, const rls::RlsMessage &msg)
......
......@@ -14,6 +14,7 @@
#include <lib/rls/rls_pdu.hpp>
#include <lib/udp/server.hpp>
#include <lib/udp/server_task.hpp>
#include <ue/types.hpp>
#include <utils/nts.hpp>
......@@ -33,9 +34,9 @@ class RlsUdpTask : public NtsTask
private:
std::unique_ptr<Logger> m_logger;
udp::UdpServer *m_server;
udp::UdpServerTask *m_server;
NtsTask *m_mainTask;
RlsSharedContext* m_shCtx;
RlsSharedContext *m_shCtx;
std::vector<InetAddress> m_searchSpace;
std::unordered_map<uint64_t, CellInfo> m_cells;
std::unordered_map<int, uint64_t> m_cellIdToSti;
......@@ -46,7 +47,7 @@ class RlsUdpTask : public NtsTask
friend class UeCmdHandler;
public:
explicit RlsUdpTask(TaskBase *base, RlsSharedContext* shCtx, const std::vector<std::string> &searchSpace);
explicit RlsUdpTask(TaskBase *base, RlsSharedContext *shCtx, const std::vector<std::string> &searchSpace);
~RlsUdpTask() override = default;
protected:
......
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