Commit 6d52926f authored by Luigi Liquori's avatar Luigi Liquori
Browse files

Deleted 4.0.0/.gitkeep, ASD 3.6.4.1/.gitkeep, ASD 4.0.0/.gitkeep,...

Deleted 4.0.0/.gitkeep, ASD 3.6.4.1/.gitkeep, ASD 4.0.0/.gitkeep, SimulationResults/.gitkeep, SimulationResults/1-BigNetwork_no_results.zip, SimulationResults/2-BigNetwork_nearby.zip, SimulationResults/3-BigNetwork_multiple_result.zip, SimulationResults/4-BigNetwork_mixed_results.zip, src/.gitignore, src/.qtenvrc, src/AE.cpp, src/AE.h, src/AEMessage.msg, src/AEMessage_m.cpp, src/AEMessage_m.h, src/CSE.cpp, src/CSE.h, src/CSE_Network_V3.6.4.1, src/CSE_Network_V3.6.4.1_dbg, src/LargeNetwork.ned, src/Makefile, src/Notes.md, src/ResourceDiscovery.ex_, src/ResourceDiscovery_dbg.ex_, src/SmallNetwork.ned, src/big_network.ned, src/components.ned, src/declarative.h, src/discoveryMessage.msg, src/discoveryMessage_m.cpp, src/discoveryMessage_m.h, src/omnetpp.ini, src/pingMessage.msg, src/pingMessage_m.cpp, src/pingMessage_m.h, src/types.h, src/utils.h, 1-BigNetwork_nearby.mp4, LICENSE, README.md files
parent 9a92104d
This project is licensed under the BSD 3-clause "New" or "Revised" License. Learn more
LICENSE 1.5 KB BSD 3-Clause License
Copyright (c) 2021, IoT / SmartM2M - Semantic and Query
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This repository contains the source code of a simulator developped in Omnet++ with the goal of providing a proof of concept and a performance evaluation of the new concept of
Advanced Semantic Discovery to be contributed to oneM2M.
This work has been conducted in the STF 589 of SmartM2M : Task 3 : oneM2M Discovery and Query solution(s) simulation and performance evaluation
Documentation about the underlying concepts of the simulator can be found in the STF 589 - Final Draft of TR 103 716 v0.5.0
The current repository contains two folders :
* *SimulationResults* is a well-named folder that contains an extract of the dfferent simulation runs.
* *src* contains the source code of the Omnet++ simulator and the different topologies (.NED files). FYI : The development has been conducted with Omnetv5.6.2
Here is a fast install procedure to run the simulator :
1-Download and install
- Omnet++ https://omnetpp.org
- the src code from the current gitlab repository
2-Start the IDE OMNet++ see the installation guide https://doc.omnetpp.org/omnetpp/InstallGuide.pdf
3-Create an OMNet++ project
- Choose "Empty Project with src and simulations folders"
- Delete a "package.ned" file that has been generated in the project
- In the src folder -> Import code file system by selecting the local src folder that contains the gitlab code
4-Build your project
- click right on the package -> Build Project
5-Run a simulation
- Click right on the package -> Run As-> Run Simulation
- Choose the src/omnetpp.ini as configuration file
- You are now able to run multiple simulations by choosing different topologies namely (SmallNetwok, bigNetwork, BigNetwork mult runs, LargeNetwork...)
Enjoy !
The STF589 teams
/CSE_Network_V3.6.3.exe
[General]
last-configname=LargeNetwork
last-runnumber=0
[RunModeProfiles]
fast-max-animation-speed=nan
fast-max-playback-speed=1e+06
fast-min-animation-speed=nan
fast-min-playback-speed=1
fast-playback-speed=1000
run-max-animation-speed=nan
run-max-playback-speed=100
run-min-animation-speed=nan
run-min-playback-speed=0.01
run-playback-speed=1.5488166189124815
#include "AE.h"
#include "discoveryMessage_m.h"
#include "utils.h"
#include "types.h"
#include <iostream>
int AE::numInitStages() const {
return 2;
}
void AE::registration() {
this->queryIndex = 0;
this->warmup = par("warmup");
// get the id of the AE
URI = getId(); // this is the omnet id which is given when creating the module in the NED file (sequential numbering )
// assigning randomly the data
data = uniform(0, 100);
int ran_number = std::rand() % 100;
EV << "Random Number" << ran_number << "\n";
// maxhop set to 10
maxHop = par("maxHops");
resource_pool_size = par("resource_pool_size");
this->feature_type = std::to_string(std::rand() % resource_pool_size).c_str();
// send an AE message with op_code Registration
sendAEMessage(REGISTRATION);
//
// if (getIndex() % 5 == 1) {
// sendAEMessage(CANCELLATION);
// }
}
void AE::sendQuery() {
// getIndex is an omnet function that select in a vector of AE (in this case ) the index in the vector table.
if ((std::rand() % 5) == 1) {
// send the AE message with op_code QUERY
// EV << "AE of URI 28 is Searching for waterValve" << "\n";
sendAEMessage(QUERY);
}
if ((std::rand() % 15) == 1) {
// send the AE message with op_code QUERY
// EV << "AE of URI 28 is Searching for waterValve" << "\n";
sendAEMessage(CANCELLATION);
}
}
void AE::initialize(int stage) {
number_of_replies = 0;
successRate = registerSignal("number_replies");
switch (stage) {
case InitStage::INIT_REGISTRATION:
registration();
break;
case InitStage::INIT_QUERY:
sendQuery();
break;
default: {
EV_FATAL << "Unknown initialization phase!\n";
break;
}
}
} // end of initialize
void AE::sendAEMessage(int op_code) {
// this function we set the fields of an AEMessage with respect to op_code
switch (op_code) {
case CANCELLATION: {
AEMessage *regMsg = new AEMessage("C");
// set the message fields
regMsg->setURI(URI);
regMsg->setData(data);
regMsg->setOp_code(CANCELLATION);
regMsg->setFeature_type(feature_type.c_str());
//send to the output gate of the AE $o as output and 0 is the number
sendDelayed(regMsg, simTime() + this->warmup + (std::rand()%5), "cse$o", 0);
break;
}
case REGISTRATION: {
AEMessage *regMsg = new AEMessage("Rg");
// set the message fields
regMsg->setURI(URI);
regMsg->setFeature_type(feature_type.c_str());
regMsg->setData(data);
regMsg->setOp_code(REGISTRATION);
SimTime t;
t.setRaw(1);
//send to the output gate of the AE $o as output and 0 is the number
sendDelayed(regMsg, simTime() + exponential(t), "cse$o", 0);
break;
} // end of REGISTRATION case
case QUERY: {
AEMessage *queryMsg = new AEMessage("Q");
queryMsg->setURI(URI);
queryMsg->setQueryID(queryIndex++);
queryMsg->setFeature_type(std::to_string(std::rand() % resource_pool_size).c_str());
queryMsg->setOp_code(QUERY);
queryMsg->setMaxHop(maxHop);
sendDelayed(queryMsg, simTime() + this->warmup, "cse$o", 0);
break;
} // end of QUERY case
default:
break;
} // end of switch
} // end of function sendAEMessage
void AE::handleMessage(cMessage *msg) {
static int NumOfReplies = 0;
//AE will receive the response
//AEMessage *responseMsg = check_and_cast<AEMessage *>(msg);
discoveryMessage *responseMsg = check_and_cast<discoveryMessage*>(msg);
EV << "AE receives a response" << "\n";
int number_of_response=0;
number_of_response++;
if (responseMsg->getReturnCode() == ResultCode::SUCCESS) {
number_of_successfulResponse= 0;
number_of_successfulResponse++;
EV << "Resource of type " << responseMsg->getFeature_type()
<< " found in " << responseMsg->getURI_init() << "\n";
}
if (responseMsg->getReturnCode() == ResultCode::NOT_FOUND) {
EV << "Resource of type " << responseMsg->getFeature_type()
<< " not found in" << responseMsg->getURI_init() << "\n";
}
number_of_replies++;
emit(successRate, number_of_replies);
delete responseMsg;
}
#ifndef AE_H_
#define AE_H_
#include <stdio.h>
#include <string.h>
#include <omnetpp.h>
#include "AEMessage_m.h"
#include "utils.h"
using namespace omnetpp;
//using namespace std;
enum InitStage {
INIT_REGISTRATION = 0,
INIT_QUERY = 1
};
class AE : public cSimpleModule // one of the module type in omnet
{
protected:
// by default in omnet methods
virtual void initialize(int stage) override;
virtual void handleMessage(cMessage *msg) override;
// application specific
void sendAEMessage(int op_code);
void registration();
void sendQuery();
virtual int numInitStages() const;
private:
int warmup;
int queryIndex;
int URI;
int data;
int maxHop;
int ran_number;
std::string feature_type;
std::vector<std::string> feature_types {
"thermometer","airStation","ATM","smartLock", "waterValve"
};
int resource_pool_size;
int number_of_replies;
int number_of_successfulResponse;
protected:
simsignal_t successRate;
};
Define_Module(AE);
#endif /* AE_H_ */
message AEMessage
{
int queryID;
int URI; // this is the unique identifer of the AE, sending the message
string feature_type; // this is the feature type of the resource we are looking for; in this version of protocol
// we can just query one feature type per QUERY
int data; // this is the value concerning the resource we are looking for; Actually used in REGISTRATION.
// TO DO it will be used in UPDATE, PUT, GET, REPLY.
int op_code; // this can be
// REGISTRATION (when AE register to CSE), value =0
// UPDATE (when AE update every x minutes the CSE about the update in its value in local Database); value =1
// CANCELLATION (when AE wants to cancel the Resource inside CSE local Database) value =2
// QUERY (when AE wants to ask for resource), value =3
// PUT (CSE to AE: CSE gives some directive to the corresponding AE) value =4
// GET (CSE to AE: CSE ask some value from the corresponding AE) value =5
// REPLY (AE to CSE: AE reply to the CSE with a value normally in data) value =6
// RESPONSE (AE to CSE: AE reply to the CSE with a value normally in data) value =7
// NOTIFY between CSE to notify modifcations in route tables value =8
int maxHop; // used for a discovery query. Number of hops for the search
}
//
// Generated file, do not edit! Created by nedtool 5.6 from AEMessage.msg.
//
// Disable warnings about unused variables, empty switch stmts, etc:
#ifdef _MSC_VER
# pragma warning(disable:4101)
# pragma warning(disable:4065)
#endif
#if defined(__clang__)
# pragma clang diagnostic ignored "-Wshadow"
# pragma clang diagnostic ignored "-Wconversion"
# pragma clang diagnostic ignored "-Wunused-parameter"
# pragma clang diagnostic ignored "-Wc++98-compat"
# pragma clang diagnostic ignored "-Wunreachable-code-break"
# pragma clang diagnostic ignored "-Wold-style-cast"
#elif defined(__GNUC__)
# pragma GCC diagnostic ignored "-Wshadow"
# pragma GCC diagnostic ignored "-Wconversion"
# pragma GCC diagnostic ignored "-Wunused-parameter"
# pragma GCC diagnostic ignored "-Wold-style-cast"
# pragma GCC diagnostic ignored "-Wsuggest-attribute=noreturn"
# pragma GCC diagnostic ignored "-Wfloat-conversion"
#endif
#include <iostream>
#include <sstream>
#include "AEMessage_m.h"
namespace omnetpp {
// Template pack/unpack rules. They are declared *after* a1l type-specific pack functions for multiple reasons.
// They are in the omnetpp namespace, to allow them to be found by argument-dependent lookup via the cCommBuffer argument
// Packing/unpacking an std::vector
template<typename T, typename A>
void doParsimPacking(omnetpp::cCommBuffer *buffer, const std::vector<T,A>& v)
{
int n = v.size();
doParsimPacking(buffer, n);
for (int i = 0; i < n; i++)
doParsimPacking(buffer, v[i]);
}
template<typename T, typename A>
void doParsimUnpacking(omnetpp::cCommBuffer *buffer, std::vector<T,A>& v)
{
int n;
doParsimUnpacking(buffer, n);
v.resize(n);
for (int i = 0; i < n; i++)
doParsimUnpacking(buffer, v[i]);
}
// Packing/unpacking an std::list
template<typename T, typename A>
void doParsimPacking(omnetpp::cCommBuffer *buffer, const std::list<T,A>& l)
{
doParsimPacking(buffer, (int)l.size());
for (typename std::list<T,A>::const_iterator it = l.begin(); it != l.end(); ++it)
doParsimPacking(buffer, (T&)*it);
}
template<typename T, typename A>
void doParsimUnpacking(omnetpp::cCommBuffer *buffer, std::list<T,A>& l)
{
int n;
doParsimUnpacking(buffer, n);
for (int i=0; i<n; i++) {
l.push_back(T());
doParsimUnpacking(buffer, l.back());
}
}
// Packing/unpacking an std::set
template<typename T, typename Tr, typename A>
void doParsimPacking(omnetpp::cCommBuffer *buffer, const std::set<T,Tr,A>& s)
{
doParsimPacking(buffer, (int)s.size());
for (typename std::set<T,Tr,A>::const_iterator it = s.begin(); it != s.end(); ++it)
doParsimPacking(buffer, *it);
}
template<typename T, typename Tr, typename A>
void doParsimUnpacking(omnetpp::cCommBuffer *buffer, std::set<T,Tr,A>& s)
{
int n;
doParsimUnpacking(buffer, n);
for (int i=0; i<n; i++) {
T x;
doParsimUnpacking(buffer, x);
s.insert(x);
}
}
// Packing/unpacking an std::map
template<typename K, typename V, typename Tr, typename A>
void doParsimPacking(omnetpp::cCommBuffer *buffer, const std::map<K,V,Tr,A>& m)
{
doParsimPacking(buffer, (int)m.size());
for (typename std::map<K,V,Tr,A>::const_iterator it = m.begin(); it != m.end(); ++it) {
doParsimPacking(buffer, it->first);
doParsimPacking(buffer, it->second);
}
}
template<typename K, typename V, typename Tr, typename A>
void doParsimUnpacking(omnetpp::cCommBuffer *buffer, std::map<K,V,Tr,A>& m)
{
int n;
doParsimUnpacking(buffer, n);
for (int i=0; i<n; i++) {
K k; V v;
doParsimUnpacking(buffer, k);
doParsimUnpacking(buffer, v);
m[k] = v;
}
}
// Default pack/unpack function for arrays
template<typename T>
void doParsimArrayPacking(omnetpp::cCommBuffer *b, const T *t, int n)
{
for (int i = 0; i < n; i++)
doParsimPacking(b, t[i]);
}
template<typename T>
void doParsimArrayUnpacking(omnetpp::cCommBuffer *b, T *t, int n)
{
for (int i = 0; i < n; i++)
doParsimUnpacking(b, t[i]);
}
// Default rule to prevent compiler from choosing base class' doParsimPacking() function
template<typename T>
void doParsimPacking(omnetpp::cCommBuffer *, const T& t)
{
throw omnetpp::cRuntimeError("Parsim error: No doParsimPacking() function for type %s", omnetpp::opp_typename(typeid(t)));
}
template<typename T>
void doParsimUnpacking(omnetpp::cCommBuffer *, T& t)
{
throw omnetpp::cRuntimeError("Parsim error: No doParsimUnpacking() function for type %s", omnetpp::opp_typename(typeid(t)));
}
} // namespace omnetpp
// forward
template<typename T, typename A>
std::ostream& operator<<(std::ostream& out, const std::vector<T,A>& vec);
// Template rule which fires if a struct or class doesn't have operator<<
template<typename T>
inline std::ostream& operator<<(std::ostream& out,const T&) {return out;}
// operator<< for std::vector<T>
template<typename T, typename A>
inline std::ostream& operator<<(std::ostream& out, const std::vector<T,A>& vec)
{
out.put('{');
for(typename std::vector<T,A>::const_iterator it = vec.begin(); it != vec.end(); ++it)
{
if (it != vec.begin()) {
out.put(','); out.put(' ');
}
out << *it;
}
out.put('}');
char buf[32];
sprintf(buf, " (size=%u)", (unsigned int)vec.size());
out.write(buf, strlen(buf));
return out;
}
Register_Class(AEMessage)
AEMessage::AEMessage(const char *name, short kind) : ::omnetpp::cMessage(name,kind)
{
this->queryID = 0;
this->URI = 0;
this->data = 0;
this->op_code = 0;
this->maxHop = 0;
}
AEMessage::AEMessage(const AEMessage& other) : ::omnetpp::cMessage(other)
{
copy(other);
}
AEMessage::~AEMessage()
{
}
AEMessage& AEMessage::operator=(const AEMessage& other)
{
if (this==&other) return *this;
::omnetpp::cMessage::operator=(other);
copy(other);
return *this;
}
void AEMessage::copy(const AEMessage& other)
{
this->queryID = other.queryID;
this->URI = other.URI;
this->feature_type = other.feature_type;
this->data = other.data;
this->op_code = other.op_code;
this->maxHop = other.maxHop;
}
void AEMessage::parsimPack(omnetpp::cCommBuffer *b) const
{
::omnetpp::cMessage::parsimPack(b);
doParsimPacking(b,this->queryID);
doParsimPacking(b,this->URI);
doParsimPacking(b,this->feature_type);
doParsimPacking(b,this->data);
doParsimPacking(b,this->op_code);
doParsimPacking(b,this->maxHop);
}
void AEMessage::parsimUnpack(omnetpp::cCommBuffer *b)
{
::omnetpp::cMessage::parsimUnpack(b);
doParsimUnpacking(b,this->queryID);
doParsimUnpacking(b,this->URI);
doParsimUnpacking(b,this->feature_type);
doParsimUnpacking(b,this->data);
doParsimUnpacking(b,this->op_code);
doParsimUnpacking(b,this->maxHop);
}
int AEMessage::getQueryID() const
{
return this->queryID;
}
void AEMessage::setQueryID(int queryID)
{
this->queryID = queryID;
}
int AEMessage::getURI() const
{
return this->URI;
}
void AEMessage::setURI(int URI)
{
this->URI = URI;
}
const char * AEMessage::getFeature_type() const
{
return this->feature_type.c_str();
}
void AEMessage::setFeature_type(const char * feature_type)
{
this->feature_type = feature_type;
}
int AEMessage::getData() const
{
return this->data;
}
void AEMessage::setData(int data)
{
this->data = data;
}
int AEMessage::getOp_code() const
{
return this->op_code;
}
void AEMessage