Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Multi UE MEC applications #239

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/apps/mec/DeviceApp/DeviceApp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,14 @@ void DeviceApp::handleUALCMPMessage()
nlohmann::json appInfo = jsonResponseBody["appList"];
if(appName.compare(appInfo.at(i)["appName"]) == 0)
{
jsonRequestBody["associateDevAppId"] = std::to_string(getId());
// search fo the app name in the list of shared apps. if found, use the stored dev app id
auto sharedDevAppId = devAppIds.find(std::string(appName));
int associateDevAppId;
if (sharedDevAppId != devAppIds.end())
associateDevAppId = sharedDevAppId->second;
else
associateDevAppId = getId();
jsonRequestBody["associateDevAppId"] = std::to_string(associateDevAppId);
jsonRequestBody["appInfo"]["appDId"] = appInfo.at(i)["appDId"];// "WAMECAPP_External"; //startPk->getMecAppDId()
// jsonBody["appInfo"]["appPackageSource"] = "ApplicationDescriptors/WarningAlertApp.json";

Expand All @@ -82,7 +89,14 @@ void DeviceApp::handleUALCMPMessage()
if(found == false)
{
EV << "DeviceApp::handleUALCMPMessage: application descriptor for appName: " << appName << " not found." << endl;
jsonRequestBody["associateDevAppId"] = std::to_string(getId());
// search fo the app name in the list of shared apps. if found, use the stored dev app id
auto sharedDevAppId = devAppIds.find(std::string(appName));
int associateDevAppId;
if (sharedDevAppId != devAppIds.end())
associateDevAppId = sharedDevAppId->second;
else
associateDevAppId = getId();
jsonRequestBody["associateDevAppId"] = std::to_string(associateDevAppId);
jsonRequestBody["appInfo"]["appPackageSource"] = appPackageSource; //"ApplicationDescriptors/WarningAlertApp.json";

jsonRequestBody["appInfo"]["appName"] = appName;//"MEWarningAlertApp_rest";
Expand Down Expand Up @@ -383,6 +397,10 @@ void DeviceApp::sendStartAppContext(inet::Ptr<const DeviceAppPacket> pk)
* ask the proxy for the requested app, by appName
*/
appName = startPk->getMecAppName();
if (startPk->getShared()) {
// if this is a shared app, store the dev app id to be associated when sending the start request
devAppIds[std::string(appName)] = startPk->getAssociateDevAppId();
}

std::string uri("/example/dev_app/v1/app_list");
std::stringstream params;
Expand Down
2 changes: 2 additions & 0 deletions src/apps/mec/DeviceApp/DeviceApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class DeviceApp : public omnetpp::cSimpleModule, public inet::TcpSocket::ICallba

State appState;
std::string appName;
// mapping from app names to app dev id to use (only used for shared apps)
std::map<std::string, int> devAppIds;

// variable set in ned, if the appDescriptor is not in the MEC orchestrator
// std::string appProvider; not used
Expand Down
4 changes: 4 additions & 0 deletions src/apps/mec/DeviceApp/DeviceAppMessages/DeviceAppPacket.msg
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class DeviceAppStartPacket extends DeviceAppPacket
string mecAppName;
string mecAppProvider;
string appPackageSource;
// determines whether the instantiated app should be unique for every UE or shared among them
bool shared = false;
// if the MEC app is shared, determines which DevAppId should be used
int associateDevAppId = -1;
}

class DeviceAppStopPacket extends DeviceAppPacket
Expand Down
27 changes: 27 additions & 0 deletions src/apps/mec/MecApps/MultiUEMECApp.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//

#include "MultiUEMECApp.h"

namespace simu5g {

Define_Module(MultiUEMECApp);

void MultiUEMECApp::addNewUE(struct UE_MEC_CLIENT ueData)
{
throw cRuntimeError("Every MEC app inheriting from MultiUEMECApp must override and implement the addNewUE method");
}

}
48 changes: 48 additions & 0 deletions src/apps/mec/MecApps/MultiUEMECApp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//

#pragma once

#include <omnetpp.h>
#include "inet/networklayer/common/L3Address.h"
#include "apps/mec/MecApps/MecAppBase.h"

using namespace omnetpp;

namespace simu5g {

struct UE_MEC_CLIENT {
inet::L3Address address;
int port;
};

class MultiUEMECApp : public MecAppBase
{
protected:
virtual void handleSelfMessage(omnetpp::cMessage *msg) {};
virtual void handleServiceMessage(int connId) {};
virtual void handleMp1Message(int connId) {};
virtual void handleHttpMessage(int connId) {};
virtual void handleUeMessage(omnetpp::cMessage *msg) {};
virtual void established(int connId) {};
public:
/**
* Method used to notify the MEC app that a new UE would like to associate with that
* Every MEC app inheriting from this class, must implement this method
*/
virtual void addNewUE(struct UE_MEC_CLIENT ueData);
};

}
56 changes: 56 additions & 0 deletions src/apps/mec/MecApps/MultiUEMECApp.ned
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// Simu5G
//
// Authors: Giovanni Nardini, Giovanni Stea, Antonio Virdis (University of Pisa)
//
// This file is part of a software released under the license included in file
// "license.pdf". Please read LICENSE and README files before using it.
// The above files and the present reference are part of the software itself,
// and cannot be removed from it.
//

package simu5g.apps.mec.MecApps;

import inet.applications.contract.IApp;
import simu5g.nodes.mec.MECPlatform.IMECApp;

//
// This is an empty MEC app which is used as a model for MEC apps that should
// be shared among multiple UEs. Any shared MEC app that should extend this app
simple MultiUEMECApp like IMECApp, IApp
{
parameters:
@class(simu5g::MultiUEMECApp);
@display("i=block/app;is=s");

int packetSize @unit(B) = default(10B);
string interfaceTableModule = default("");

int mecAppIndex;
int mecAppId;
int localUePort;

string mp1Address = default("");
int mp1Port = default(10021);

//resource required info
double requiredRam @unit("B");
double requiredDisk @unit("B");
double requiredCpu;

// IApp parameters
int timeToLive = default(-1); // if not -1, set the TTL (IPv4) or Hop Limit (IPv6) field of sent packets to this value
int dscp = default(-1); // if not -1, set the DSCP (IPv4/IPv6) field of sent packets to this value
int tos = default(-1); // if not -1, set the Type Of Service (IPv4) / Traffic Class (IPv6) field of sent packets to this value

bool logger = default(false);

gates:
input mePlatformIn;
output mePlatformOut;

input socketIn;
output socketOut;

}

27 changes: 21 additions & 6 deletions src/nodes/mec/MECOrchestrator/MecOrchestrator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "nodes/mec/VirtualisationInfrastructureManager/VirtualisationInfrastructureManager.h"

#include "nodes/mec/MECPlatform/ServiceRegistry/ServiceRegistry.h"
#include "apps/mec/MecApps/MultiUEMECApp.h"

#include "nodes/mec/MECOrchestrator/MECOMessages/MECOrchestratorMessages_m.h"

Expand Down Expand Up @@ -133,11 +134,6 @@ void MecOrchestrator::startMECApp(UALCMPMessage* msg)

for(const auto& contextApp : meAppMap)
{
/*
* TODO
* set the check to provide multi UE to one mec application scenario.
* For now the scenario is one to one, since the device application ID is used
*/
if(contextApp.second.mecUeAppID == ueAppID && contextApp.second.appDId.compare(contAppMsg->getAppDId()) == 0)
{
// meAppMap[ueAppID].lastAckStartSeqNum = pkt->getSno();
Expand All @@ -147,7 +143,17 @@ void MecOrchestrator::startMECApp(UALCMPMessage* msg)
EV << "MecOrchestrator::startMECApp - \tWARNING: required MEC App instance ALREADY STARTED on MEC host: " << contextApp.second.mecHost->getName() << endl;
EV << "MecOrchestrator::startMECApp - sending ackMEAppPacket with "<< ACK_CREATE_CONTEXT_APP << endl;
sendCreateAppContextAck(true, contAppMsg->getRequestId(), contextApp.first);
return;
auto* existingMECApp = dynamic_cast<MultiUEMECApp*>(contextApp.second.reference);
if (existingMECApp) {
// if the app already exist and it is an app supporting multiple UEs, then notify the app about the new UE
struct UE_MEC_CLIENT newUE;
newUE.address = inet::L3Address(contAppMsg->getUeIpAddress());
// the UE port is not known at this stage
newUE.port = -1;
existingMECApp->addNewUE(newUE);
}
else
return;
}
}

Expand Down Expand Up @@ -266,6 +272,15 @@ void MecOrchestrator::startMECApp(UALCMPMessage* msg)
newMecApp.mecAppPort = appInfo->endPoint.port;
newMecApp.mecAppIsntanceId = appInfo->instanceId;
newMecApp.contextId = contextIdCounter;
newMecApp.reference = appInfo->reference;
auto multiUEMECApp = dynamic_cast<MultiUEMECApp*>(newMecApp.reference);
if (multiUEMECApp) {
struct UE_MEC_CLIENT newUE;
newUE.address = inet::L3Address(contAppMsg->getUeIpAddress());
// the UE port is not known at this stage
newUE.port = -1;
multiUEMECApp->addNewUE(newUE);
}
meAppMap[contextIdCounter] = newMecApp;

MECOrchestratorMessage *msg = new MECOrchestratorMessage("MECOrchestratorMessage");
Expand Down
1 change: 1 addition & 0 deletions src/nodes/mec/MECOrchestrator/MecOrchestrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct mecAppMapEntry
cModule* mecHost; // reference to the mecHost where the mec app has been deployed
cModule* vim; // for virtualisationInfrastructureManager methods
cModule* mecpm; // for mecPlatformManager methods
cModule* reference; // direct reference to mec app instance (omnet module)

std::string ueSymbolicAddres;
inet::L3Address ueAddress; //for downstream using UDP Socket
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ MecAppInstanceInfo* VirtualisationInfrastructureManager::instantiateMEApp(Create
EV << "VirtualisationInfrastructureManager::instantiateMEApp - currentMEApps: " << currentMEApps << " / " << maxMECApps << endl;

instanceInfo->status = true;
instanceInfo->reference = module;
return instanceInfo;
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct MecAppInstanceInfo
bool status;
std::string instanceId;
SockAddr endPoint;
cModule *reference;
};

// used to calculate processing time needed to execute a number of instructions
Expand Down