Skip to content

Commit

Permalink
NNSF refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
aligungr committed Feb 17, 2021
1 parent b797eb7 commit ed946b1
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 15 deletions.
19 changes: 6 additions & 13 deletions src/gnb/ngap/management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ void NgapTask::createUeContext(int ueId)

m_ueCtx[ctx->ctxId] = ctx;

// Select an AMF for the UE (if any)
for (auto &amf : m_amfCtx)
{
// todo: an arbitrary AMF is selected for now
ctx->associatedAmfId = amf.second->ctxId;
break;
}
// Perform AMF selection
auto *amf = selectAmf(ueId);
if (amf == nullptr)
m_logger->err("AMF selection for UE[%d] failed. Could not find a suitable AMF.", ueId);
else
ctx->associatedAmfId = amf->ctxId;
}

NgapUeContext *NgapTask::findUeContext(int ctxId)
Expand Down Expand Up @@ -134,12 +133,6 @@ NgapUeContext *NgapTask::findUeByNgapIdPair(int amfCtxId, const NgapIdPair &idPa
return ue;
}

NgapAmfContext *NgapTask::selectNewAmfForReAllocation(int initiatedAmfId, int amfSetId)
{
// TODO an arbitrary AMF is selected for now
return findAmfContext(initiatedAmfId);
}

void NgapTask::deleteUeContext(int ueId)
{
auto *ue = m_ueCtx[ueId];
Expand Down
2 changes: 1 addition & 1 deletion src/gnb/ngap/nas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void NgapTask::receiveRerouteNasRequest(int amfId, ASN_NGAP_RerouteNASRequest *m
}
}

auto *newAmf = selectNewAmfForReAllocation(amfId, asn::GetBitStringInt<10>(ieAmfSetId->AMFSetID));
auto *newAmf = selectNewAmfForReAllocation(ue->ctxId, amfId, asn::GetBitStringInt<10>(ieAmfSetId->AMFSetID));
if (newAmf == nullptr)
{
m_logger->err("AMF selection for re-allocation failed. Could not find a suitable AMF.");
Expand Down
28 changes: 28 additions & 0 deletions src/gnb/ngap/nnsf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// 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 "task.hpp"

namespace nr::gnb
{

NgapAmfContext *NgapTask::selectAmf(int ueId)
{
// todo:
for (auto &amf : m_amfCtx)
return amf.second; // return the first one
return nullptr;
}

NgapAmfContext *NgapTask::selectNewAmfForReAllocation(int ueId, int initiatedAmfId, int amfSetId)
{
// TODO an arbitrary AMF is selected for now
return findAmfContext(initiatedAmfId);
}

} // namespace nr::gnb
5 changes: 4 additions & 1 deletion src/gnb/ngap/task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class NgapTask : public NtsTask
NgapUeContext *findUeByRanId(long ranUeNgapId);
NgapUeContext *findUeByAmfId(long amfUeNgapId);
NgapUeContext *findUeByNgapIdPair(int amfCtxId, const NgapIdPair &idPair);
NgapAmfContext *selectNewAmfForReAllocation(int initiatedAmfId, int amfSetId);
void deleteUeContext(int ueId);
void deleteAmfContext(int amfId);

Expand Down Expand Up @@ -105,6 +104,10 @@ class NgapTask : public NtsTask
void receiveInitialContextSetup(int amfId, ASN_NGAP_InitialContextSetupRequest *msg);
void receiveContextRelease(int amfId, ASN_NGAP_UEContextReleaseCommand *msg);
void receiveContextModification(int amfId, ASN_NGAP_UEContextModificationRequest *msg);

/* NAS Node Selection */
NgapAmfContext *selectAmf(int ueId);
NgapAmfContext *selectNewAmfForReAllocation(int ueId, int initiatedAmfId, int amfSetId);
};

} // namespace nr::gnb

0 comments on commit ed946b1

Please sign in to comment.