Commit 1564ad57 authored by aligungr's avatar aligungr

Performance improvements

parent 23c5afa0
......@@ -161,13 +161,10 @@ struct NmUeRlsToRls : NtsMessage
{
RECEIVE_RLS_MESSAGE,
SIGNAL_CHANGED,
UPLINK_DATA,
UPLINK_RRC,
DOWNLINK_DATA,
DOWNLINK_RRC,
RADIO_LINK_FAILURE,
TRANSMISSION_FAILURE,
ASSIGN_CURRENT_CELL,
} present;
// RECEIVE_RLS_MESSAGE
......
......@@ -69,14 +69,6 @@ void RlsCtlLayer::handleRlsMessage(int cellId, rls::RlsMessage &msg)
}
}
void RlsCtlLayer::handleSignalChange(int cellId, int dbm)
{
auto w = std::make_unique<NmUeRlsToRls>(NmUeRlsToRls::SIGNAL_CHANGED);
w->cellId = cellId;
w->dbm = dbm;
m_mainTask->push(std::move(w));
}
void RlsCtlLayer::handleUplinkRrcDelivery(int cellId, uint32_t pduId, rrc::RrcChannel channel, OctetString &&data)
{
if (pduId != 0)
......@@ -173,29 +165,9 @@ void RlsCtlLayer::onAckSendTimerExpired()
}
}
void RlsCtlLayer::handleSapMessage(NmUeRlsToRls &msg)
void RlsCtlLayer::assignCurrentCell(int cellId)
{
switch (msg.present)
{
case NmUeRlsToRls::SIGNAL_CHANGED:
handleSignalChange(msg.cellId, msg.dbm);
break;
case NmUeRlsToRls::RECEIVE_RLS_MESSAGE:
handleRlsMessage(msg.cellId, *msg.msg);
break;
case NmUeRlsToRls::UPLINK_DATA:
handleUplinkDataDelivery(msg.psi, std::move(msg.data));
break;
case NmUeRlsToRls::UPLINK_RRC:
handleUplinkRrcDelivery(msg.cellId, msg.pduId, msg.rrcChannel, std::move(msg.data));
break;
case NmUeRlsToRls::ASSIGN_CURRENT_CELL:
m_servingCell = msg.cellId;
break;
default:
m_logger->unhandledNts(msg);
break;
}
m_servingCell = cellId;
}
} // namespace nr::ue
\ No newline at end of file
......@@ -31,17 +31,12 @@ class RlsCtlLayer
public:
void onStart(NtsTask* mainTask, RlsUdpTask* udpTask);
void onQuit();
private:
void handleRlsMessage(int cellId, rls::RlsMessage &msg);
void handleSignalChange(int cellId, int dbm);
void handleUplinkRrcDelivery(int cellId, uint32_t pduId, rrc::RrcChannel channel, OctetString &&data);
void handleUplinkDataDelivery(int psi, OctetString &&data);
public:
void onAckControlTimerExpired();
void onAckSendTimerExpired();
void handleSapMessage(NmUeRlsToRls& msg);
void handleUplinkDataDelivery(int psi, OctetString &&data);
void handleUplinkRrcDelivery(int cellId, uint32_t pduId, rrc::RrcChannel channel, OctetString &&data);
void assignCurrentCell(int cellId);
void handleRlsMessage(int cellId, rls::RlsMessage &msg);
};
}
\ No newline at end of file
//
// 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.
//
#include "ctl_task.hpp"
#include <utils/common.hpp>
static constexpr const int TIMER_ID_ACK_CONTROL = 1;
static constexpr const int TIMER_ID_ACK_SEND = 2;
static constexpr const int TIMER_PERIOD_ACK_CONTROL = 1500;
static constexpr const int TIMER_PERIOD_ACK_SEND = 2250;
namespace nr::ue
{
RlsControlTask::RlsControlTask(TaskBase *base, RlsSharedContext *shCtx)
{
layer = std::make_unique<RlsCtlLayer>(base, shCtx);
mainTask = {};
udpTask = {};
}
void RlsControlTask::onStart()
{
layer->onStart(mainTask, udpTask);
setTimer(TIMER_ID_ACK_CONTROL, TIMER_PERIOD_ACK_CONTROL);
setTimer(TIMER_ID_ACK_SEND, TIMER_PERIOD_ACK_SEND);
}
void RlsControlTask::onQuit()
{
layer->onQuit();
}
void RlsControlTask::onLoop()
{
auto msg = take();
if (!msg)
return;
if (msg->msgType == NtsMessageType::TIMER_EXPIRED)
{
auto &w = dynamic_cast<NmTimerExpired &>(*msg);
if (w.timerId == TIMER_ID_ACK_CONTROL)
{
setTimer(TIMER_ID_ACK_CONTROL, TIMER_PERIOD_ACK_CONTROL);
layer->onAckControlTimerExpired();
}
else if (w.timerId == TIMER_ID_ACK_SEND)
{
setTimer(TIMER_ID_ACK_SEND, TIMER_PERIOD_ACK_SEND);
layer->onAckSendTimerExpired();
}
}
else if (msg->msgType == NtsMessageType::UE_RLS_TO_RLS)
{
layer->handleSapMessage(dynamic_cast<NmUeRlsToRls &>(*msg));
}
}
void RlsControlTask::initialize(NtsTask *mainTask, RlsUdpTask *udpTask)
{
this->mainTask = mainTask;
this->udpTask = udpTask;
}
} // namespace nr::ue
//
// 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 "ctl_layer.hpp"
namespace nr::ue
{
class RlsControlTask : public NtsTask
{
private:
std::unique_ptr<RlsCtlLayer> layer;
NtsTask *mainTask;
RlsUdpTask *udpTask;
public:
explicit RlsControlTask(TaskBase *base, RlsSharedContext *shCtx);
~RlsControlTask() override = default;
protected:
void onStart() override;
void onLoop() override;
void onQuit() override;
public:
void initialize(NtsTask *mainTask, RlsUdpTask *udpTask);
};
} // namespace nr::ue
\ No newline at end of file
......@@ -13,6 +13,11 @@
#include <utils/common.hpp>
#include <utils/random.hpp>
static constexpr const int TIMER_ID_ACK_CONTROL = 1;
static constexpr const int TIMER_ID_ACK_SEND = 2;
static constexpr const int TIMER_PERIOD_ACK_CONTROL = 1500;
static constexpr const int TIMER_PERIOD_ACK_SEND = 2250;
namespace nr::ue
{
......@@ -24,16 +29,18 @@ UeRlsTask::UeRlsTask(TaskBase *base) : m_base{base}
m_shCtx->sti = Random::Mixed(base->config->getNodeName()).nextL();
m_udpTask = new RlsUdpTask(base, m_shCtx, base->config->gnbSearchList);
m_ctlTask = new RlsControlTask(base, m_shCtx);
m_ctlLayer = std::make_unique<RlsCtlLayer>(base, m_shCtx);
m_udpTask->initialize(m_ctlTask);
m_ctlTask->initialize(this, m_udpTask);
m_udpTask->initialize(this);
}
void UeRlsTask::onStart()
{
m_udpTask->start();
m_ctlTask->start();
m_ctlLayer->onStart(this, m_udpTask);
setTimer(TIMER_ID_ACK_CONTROL, TIMER_PERIOD_ACK_CONTROL);
setTimer(TIMER_ID_ACK_SEND, TIMER_PERIOD_ACK_SEND);
}
void UeRlsTask::onLoop()
......@@ -42,12 +49,32 @@ void UeRlsTask::onLoop()
if (!msg)
return;
if (msg->msgType == NtsMessageType::TIMER_EXPIRED)
{
auto &w = dynamic_cast<NmTimerExpired &>(*msg);
if (w.timerId == TIMER_ID_ACK_CONTROL)
{
setTimer(TIMER_ID_ACK_CONTROL, TIMER_PERIOD_ACK_CONTROL);
m_ctlLayer->onAckControlTimerExpired();
}
else if (w.timerId == TIMER_ID_ACK_SEND)
{
setTimer(TIMER_ID_ACK_SEND, TIMER_PERIOD_ACK_SEND);
m_ctlLayer->onAckSendTimerExpired();
}
return;
}
switch (msg->msgType)
{
case NtsMessageType::UE_RLS_TO_RLS: {
auto &w = dynamic_cast<NmUeRlsToRls &>(*msg);
switch (w.present)
{
case NmUeRlsToRls::RECEIVE_RLS_MESSAGE: {
m_ctlLayer->handleRlsMessage(w.cellId, *w.msg);
break;
}
case NmUeRlsToRls::SIGNAL_CHANGED: {
auto m = std::make_unique<NmUeRlsToRrc>(NmUeRlsToRrc::SIGNAL_CHANGED);
m->cellId = w.cellId;
......@@ -92,18 +119,11 @@ void UeRlsTask::onLoop()
switch (w.present)
{
case NmUeRrcToRls::ASSIGN_CURRENT_CELL: {
auto m = std::make_unique<NmUeRlsToRls>(NmUeRlsToRls::ASSIGN_CURRENT_CELL);
m->cellId = w.cellId;
m_ctlTask->push(std::move(m));
m_ctlLayer->assignCurrentCell(w.cellId);
break;
}
case NmUeRrcToRls::RRC_PDU_DELIVERY: {
auto m = std::make_unique<NmUeRlsToRls>(NmUeRlsToRls::UPLINK_RRC);
m->cellId = w.cellId;
m->rrcChannel = w.channel;
m->pduId = w.pduId;
m->data = std::move(w.pdu);
m_ctlTask->push(std::move(m));
m_ctlLayer->handleUplinkRrcDelivery(w.cellId, w.pduId, w.channel, std::move(w.pdu));
break;
}
case NmUeRrcToRls::RESET_STI: {
......@@ -118,10 +138,7 @@ void UeRlsTask::onLoop()
switch (w.present)
{
case NmUeNasToRls::DATA_PDU_DELIVERY: {
auto m = std::make_unique<NmUeRlsToRls>(NmUeRlsToRls::UPLINK_DATA);
m->psi = w.psi;
m->data = std::move(w.pdu);
m_ctlTask->push(std::move(m));
m_ctlLayer->handleUplinkDataDelivery(w.psi, std::move(w.pdu));
break;
}
}
......@@ -136,11 +153,9 @@ void UeRlsTask::onLoop()
void UeRlsTask::onQuit()
{
m_udpTask->quit();
m_ctlTask->quit();
m_ctlLayer->onQuit();
delete m_udpTask;
delete m_ctlTask;
delete m_shCtx;
}
......
......@@ -8,7 +8,7 @@
#pragma once
#include "ctl_task.hpp"
#include "ctl_layer.hpp"
#include "udp_task.hpp"
#include <memory>
......@@ -36,7 +36,8 @@ class UeRlsTask : public NtsTask
RlsSharedContext* m_shCtx;
RlsUdpTask *m_udpTask;
RlsControlTask *m_ctlTask;
std::unique_ptr<RlsCtlLayer> m_ctlLayer;
friend class UeCmdHandler;
......
......@@ -25,7 +25,7 @@ namespace nr::ue
{
RlsUdpTask::RlsUdpTask(TaskBase *base, RlsSharedContext *shCtx, const std::vector<std::string> &searchSpace)
: m_server{}, m_ctlTask{}, m_shCtx{shCtx}, m_searchSpace{}, m_cells{}, m_cellIdToSti{}, m_lastLoop{},
: m_server{}, m_mainTask{}, m_shCtx{shCtx}, m_searchSpace{}, m_cells{}, m_cellIdToSti{}, m_lastLoop{},
m_cellIdCounter{}
{
m_logger = base->logBase->makeUniqueLogger(base->config->getLoggerPrefix() + "rls-udp");
......@@ -121,7 +121,7 @@ void RlsUdpTask::receiveRlsPdu(const InetAddress &addr, std::unique_ptr<rls::Rls
auto w = std::make_unique<NmUeRlsToRls>(NmUeRlsToRls::RECEIVE_RLS_MESSAGE);
w->cellId = m_cells[msg->sti].cellId;
w->msg = std::move(msg);
m_ctlTask->push(std::move(w));
m_mainTask->push(std::move(w));
}
void RlsUdpTask::onSignalChangeOrLost(int cellId)
......@@ -136,7 +136,7 @@ void RlsUdpTask::onSignalChangeOrLost(int cellId)
auto w = std::make_unique<NmUeRlsToRls>(NmUeRlsToRls::SIGNAL_CHANGED);
w->cellId = cellId;
w->dbm = dbm;
m_ctlTask->push(std::move(w));
m_mainTask->push(std::move(w));
}
void RlsUdpTask::heartbeatCycle(uint64_t time, const Vector3 &simPos)
......@@ -167,9 +167,9 @@ void RlsUdpTask::heartbeatCycle(uint64_t time, const Vector3 &simPos)
}
}
void RlsUdpTask::initialize(NtsTask *ctlTask)
void RlsUdpTask::initialize(NtsTask *mainTask)
{
m_ctlTask = ctlTask;
m_mainTask = mainTask;
}
} // namespace nr::ue
......@@ -34,7 +34,7 @@ class RlsUdpTask : public NtsTask
private:
std::unique_ptr<Logger> m_logger;
udp::UdpServer *m_server;
NtsTask *m_ctlTask;
NtsTask *m_mainTask;
RlsSharedContext* m_shCtx;
std::vector<InetAddress> m_searchSpace;
std::unordered_map<uint64_t, CellInfo> m_cells;
......@@ -61,7 +61,7 @@ class RlsUdpTask : public NtsTask
void heartbeatCycle(uint64_t time, const Vector3 &simPos);
public:
void initialize(NtsTask *ctlTask);
void initialize(NtsTask *mainTask);
void send(int cellId, const rls::RlsMessage &msg);
};
......
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