diff --git a/1-BigNetwork_nearby.mp4 b/1-BigNetwork_nearby.mp4 deleted file mode 100644 index f5d55a51df86476d6b669755f715df52fe21114d..0000000000000000000000000000000000000000 Binary files a/1-BigNetwork_nearby.mp4 and /dev/null differ diff --git a/4.0.0/.gitkeep b/4.0.0/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/ASD 3.6.4.1/.gitkeep b/ASD 3.6.4.1/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/ASD 4.0.0/.gitkeep b/ASD 4.0.0/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 16db630dbbf134220c8b79d50338917ad5c93b4a..0000000000000000000000000000000000000000 --- a/LICENSE +++ /dev/null @@ -1,31 +0,0 @@ -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. - diff --git a/README.md b/README.md deleted file mode 100644 index 9624de46f35b7baa499865532a799e6524b1ac11..0000000000000000000000000000000000000000 --- a/README.md +++ /dev/null @@ -1,39 +0,0 @@ -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 - diff --git a/SimulationResults/.gitkeep b/SimulationResults/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/SimulationResults/1-BigNetwork_no_results.zip b/SimulationResults/1-BigNetwork_no_results.zip deleted file mode 100644 index 2efa8d6bd026b4a2586f28efe46d1ba0eb2b82b5..0000000000000000000000000000000000000000 Binary files a/SimulationResults/1-BigNetwork_no_results.zip and /dev/null differ diff --git a/SimulationResults/2-BigNetwork_nearby.zip b/SimulationResults/2-BigNetwork_nearby.zip deleted file mode 100644 index 96d095f6724101a3011102a14a058b36d3385a65..0000000000000000000000000000000000000000 Binary files a/SimulationResults/2-BigNetwork_nearby.zip and /dev/null differ diff --git a/SimulationResults/3-BigNetwork_multiple_result.zip b/SimulationResults/3-BigNetwork_multiple_result.zip deleted file mode 100644 index b5248a479c787abf14d6b0cecb0bc4a3dfa78c17..0000000000000000000000000000000000000000 Binary files a/SimulationResults/3-BigNetwork_multiple_result.zip and /dev/null differ diff --git a/SimulationResults/4-BigNetwork_mixed_results.zip b/SimulationResults/4-BigNetwork_mixed_results.zip deleted file mode 100644 index a47390f17a54f6e948611e267472f3f17b22adb2..0000000000000000000000000000000000000000 Binary files a/SimulationResults/4-BigNetwork_mixed_results.zip and /dev/null differ diff --git a/src/.gitignore b/src/.gitignore deleted file mode 100644 index d607ee3831bfaa53af2b8d508a9077a15a7901c5..0000000000000000000000000000000000000000 --- a/src/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/CSE_Network_V3.6.3.exe diff --git a/src/.qtenvrc b/src/.qtenvrc deleted file mode 100644 index 105c1e4addef1ff05b701b29069270711ad7f153..0000000000000000000000000000000000000000 --- a/src/.qtenvrc +++ /dev/null @@ -1,15 +0,0 @@ -[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 diff --git a/src/AE.cpp b/src/AE.cpp deleted file mode 100644 index 41ece21b5e0b2243eb0727cd1ad144a78fcbd6f6..0000000000000000000000000000000000000000 --- a/src/AE.cpp +++ /dev/null @@ -1,139 +0,0 @@ -#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; -} diff --git a/src/AE.h b/src/AE.h deleted file mode 100644 index bafd3e47769dcc76dabb1dce69af5d6de6330508..0000000000000000000000000000000000000000 --- a/src/AE.h +++ /dev/null @@ -1,59 +0,0 @@ -#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_ */ diff --git a/src/AEMessage.msg b/src/AEMessage.msg deleted file mode 100644 index 4f23312b2d1a263c6383ce59c79824abca93ab00..0000000000000000000000000000000000000000 --- a/src/AEMessage.msg +++ /dev/null @@ -1,23 +0,0 @@ -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 - -} - diff --git a/src/AEMessage_m.cpp b/src/AEMessage_m.cpp deleted file mode 100644 index 377fbd83295c50370e6d89ebf8f2ae0521dfb026..0000000000000000000000000000000000000000 --- a/src/AEMessage_m.cpp +++ /dev/null @@ -1,559 +0,0 @@ -// -// 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::setOp_code(int op_code) -{ - this->op_code = op_code; -} - -int AEMessage::getMaxHop() const -{ - return this->maxHop; -} - -void AEMessage::setMaxHop(int maxHop) -{ - this->maxHop = maxHop; -} - -class AEMessageDescriptor : public omnetpp::cClassDescriptor -{ - private: - mutable const char **propertynames; - public: - AEMessageDescriptor(); - virtual ~AEMessageDescriptor(); - - virtual bool doesSupport(omnetpp::cObject *obj) const override; - virtual const char **getPropertyNames() const override; - virtual const char *getProperty(const char *propertyname) const override; - virtual int getFieldCount() const override; - virtual const char *getFieldName(int field) const override; - virtual int findField(const char *fieldName) const override; - virtual unsigned int getFieldTypeFlags(int field) const override; - virtual const char *getFieldTypeString(int field) const override; - virtual const char **getFieldPropertyNames(int field) const override; - virtual const char *getFieldProperty(int field, const char *propertyname) const override; - virtual int getFieldArraySize(void *object, int field) const override; - - virtual const char *getFieldDynamicTypeString(void *object, int field, int i) const override; - virtual std::string getFieldValueAsString(void *object, int field, int i) const override; - virtual bool setFieldValueAsString(void *object, int field, int i, const char *value) const override; - - virtual const char *getFieldStructName(int field) const override; - virtual void *getFieldStructValuePointer(void *object, int field, int i) const override; -}; - -Register_ClassDescriptor(AEMessageDescriptor) - -AEMessageDescriptor::AEMessageDescriptor() : omnetpp::cClassDescriptor("AEMessage", "omnetpp::cMessage") -{ - propertynames = nullptr; -} - -AEMessageDescriptor::~AEMessageDescriptor() -{ - delete[] propertynames; -} - -bool AEMessageDescriptor::doesSupport(omnetpp::cObject *obj) const -{ - return dynamic_cast<AEMessage *>(obj)!=nullptr; -} - -const char **AEMessageDescriptor::getPropertyNames() const -{ - if (!propertynames) { - static const char *names[] = { nullptr }; - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - const char **basenames = basedesc ? basedesc->getPropertyNames() : nullptr; - propertynames = mergeLists(basenames, names); - } - return propertynames; -} - -const char *AEMessageDescriptor::getProperty(const char *propertyname) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - return basedesc ? basedesc->getProperty(propertyname) : nullptr; -} - -int AEMessageDescriptor::getFieldCount() const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - return basedesc ? 6+basedesc->getFieldCount() : 6; -} - -unsigned int AEMessageDescriptor::getFieldTypeFlags(int field) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldTypeFlags(field); - field -= basedesc->getFieldCount(); - } - static unsigned int fieldTypeFlags[] = { - FD_ISEDITABLE, - FD_ISEDITABLE, - FD_ISEDITABLE, - FD_ISEDITABLE, - FD_ISEDITABLE, - FD_ISEDITABLE, - }; - return (field>=0 && field<6) ? fieldTypeFlags[field] : 0; -} - -const char *AEMessageDescriptor::getFieldName(int field) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldName(field); - field -= basedesc->getFieldCount(); - } - static const char *fieldNames[] = { - "queryID", - "URI", - "feature_type", - "data", - "op_code", - "maxHop", - }; - return (field>=0 && field<6) ? fieldNames[field] : nullptr; -} - -int AEMessageDescriptor::findField(const char *fieldName) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - int base = basedesc ? basedesc->getFieldCount() : 0; - if (fieldName[0]=='q' && strcmp(fieldName, "queryID")==0) return base+0; - if (fieldName[0]=='U' && strcmp(fieldName, "URI")==0) return base+1; - if (fieldName[0]=='f' && strcmp(fieldName, "feature_type")==0) return base+2; - if (fieldName[0]=='d' && strcmp(fieldName, "data")==0) return base+3; - if (fieldName[0]=='o' && strcmp(fieldName, "op_code")==0) return base+4; - if (fieldName[0]=='m' && strcmp(fieldName, "maxHop")==0) return base+5; - return basedesc ? basedesc->findField(fieldName) : -1; -} - -const char *AEMessageDescriptor::getFieldTypeString(int field) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldTypeString(field); - field -= basedesc->getFieldCount(); - } - static const char *fieldTypeStrings[] = { - "int", - "int", - "string", - "int", - "int", - "int", - }; - return (field>=0 && field<6) ? fieldTypeStrings[field] : nullptr; -} - -const char **AEMessageDescriptor::getFieldPropertyNames(int field) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldPropertyNames(field); - field -= basedesc->getFieldCount(); - } - switch (field) { - default: return nullptr; - } -} - -const char *AEMessageDescriptor::getFieldProperty(int field, const char *propertyname) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldProperty(field, propertyname); - field -= basedesc->getFieldCount(); - } - switch (field) { - default: return nullptr; - } -} - -int AEMessageDescriptor::getFieldArraySize(void *object, int field) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldArraySize(object, field); - field -= basedesc->getFieldCount(); - } - AEMessage *pp = (AEMessage *)object; (void)pp; - switch (field) { - default: return 0; - } -} - -const char *AEMessageDescriptor::getFieldDynamicTypeString(void *object, int field, int i) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldDynamicTypeString(object,field,i); - field -= basedesc->getFieldCount(); - } - AEMessage *pp = (AEMessage *)object; (void)pp; - switch (field) { - default: return nullptr; - } -} - -std::string AEMessageDescriptor::getFieldValueAsString(void *object, int field, int i) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldValueAsString(object,field,i); - field -= basedesc->getFieldCount(); - } - AEMessage *pp = (AEMessage *)object; (void)pp; - switch (field) { - case 0: return long2string(pp->getQueryID()); - case 1: return long2string(pp->getURI()); - case 2: return oppstring2string(pp->getFeature_type()); - case 3: return long2string(pp->getData()); - case 4: return long2string(pp->getOp_code()); - case 5: return long2string(pp->getMaxHop()); - default: return ""; - } -} - -bool AEMessageDescriptor::setFieldValueAsString(void *object, int field, int i, const char *value) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->setFieldValueAsString(object,field,i,value); - field -= basedesc->getFieldCount(); - } - AEMessage *pp = (AEMessage *)object; (void)pp; - switch (field) { - case 0: pp->setQueryID(string2long(value)); return true; - case 1: pp->setURI(string2long(value)); return true; - case 2: pp->setFeature_type((value)); return true; - case 3: pp->setData(string2long(value)); return true; - case 4: pp->setOp_code(string2long(value)); return true; - case 5: pp->setMaxHop(string2long(value)); return true; - default: return false; - } -} - -const char *AEMessageDescriptor::getFieldStructName(int field) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldStructName(field); - field -= basedesc->getFieldCount(); - } - switch (field) { - default: return nullptr; - }; -} - -void *AEMessageDescriptor::getFieldStructValuePointer(void *object, int field, int i) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldStructValuePointer(object, field, i); - field -= basedesc->getFieldCount(); - } - AEMessage *pp = (AEMessage *)object; (void)pp; - switch (field) { - default: return nullptr; - } -} - - diff --git a/src/AEMessage_m.h b/src/AEMessage_m.h deleted file mode 100644 index fbfb6f9bc7a66a78d82d76cb5d2db882a27c493e..0000000000000000000000000000000000000000 --- a/src/AEMessage_m.h +++ /dev/null @@ -1,94 +0,0 @@ -// -// Generated file, do not edit! Created by nedtool 5.6 from AEMessage.msg. -// - -#ifndef __AEMESSAGE_M_H -#define __AEMESSAGE_M_H - -#if defined(__clang__) -# pragma clang diagnostic ignored "-Wreserved-id-macro" -#endif -#include <omnetpp.h> - -// nedtool version check -#define MSGC_VERSION 0x0506 -#if (MSGC_VERSION!=OMNETPP_VERSION) -# error Version mismatch! Probably this file was generated by an earlier version of nedtool: 'make clean' should help. -#endif - - - -/** - * Class generated from <tt>AEMessage.msg:2</tt> by nedtool. - * <pre> - * 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 - * - * } - * </pre> - */ -class AEMessage : public ::omnetpp::cMessage -{ - protected: - int queryID; - int URI; - ::omnetpp::opp_string feature_type; - int data; - int op_code; - int maxHop; - - private: - void copy(const AEMessage& other); - - protected: - // protected and unimplemented operator==(), to prevent accidental usage - bool operator==(const AEMessage&); - - public: - AEMessage(const char *name=nullptr, short kind=0); - AEMessage(const AEMessage& other); - virtual ~AEMessage(); - AEMessage& operator=(const AEMessage& other); - virtual AEMessage *dup() const override {return new AEMessage(*this);} - virtual void parsimPack(omnetpp::cCommBuffer *b) const override; - virtual void parsimUnpack(omnetpp::cCommBuffer *b) override; - - // field getter/setter methods - virtual int getQueryID() const; - virtual void setQueryID(int queryID); - virtual int getURI() const; - virtual void setURI(int URI); - virtual const char * getFeature_type() const; - virtual void setFeature_type(const char * feature_type); - virtual int getData() const; - virtual void setData(int data); - virtual int getOp_code() const; - virtual void setOp_code(int op_code); - virtual int getMaxHop() const; - virtual void setMaxHop(int maxHop); -}; - -inline void doParsimPacking(omnetpp::cCommBuffer *b, const AEMessage& obj) {obj.parsimPack(b);} -inline void doParsimUnpacking(omnetpp::cCommBuffer *b, AEMessage& obj) {obj.parsimUnpack(b);} - - -#endif // ifndef __AEMESSAGE_M_H - diff --git a/src/CSE.cpp b/src/CSE.cpp deleted file mode 100644 index a3e40d5119379749439d86bb8db2cd13aeca8ab4..0000000000000000000000000000000000000000 --- a/src/CSE.cpp +++ /dev/null @@ -1,869 +0,0 @@ -#include "CSE.h" -#include "declarative.h" -#include <algorithm> - -bool prefix(const char *pre, const char *str) -{ - return strncmp(pre, str, strlen(pre)) == 0; -} - - -void CSE::initialize() { - this->Uri = getId(); // this is the omnet id which is given when creating the module in the NED file (sequential numbering ) - - EV << "URI II " << Uri << "\n"; - this->NotificationDepth = par("notification_depth"); - - this->multicastAlpha = par("alpha"); - this->multicastBeta = par("beta"); - this->multicastGamma = par("gamma"); - this->multicastDelta = par("delta"); - this->queryBufferTTL = par("queryBufferTTL"); - this->maxHops = par("maxHops"); - - number_of_packets = 0; - totalpacketsSignal = registerSignal("packet_size"); - delay = par("delayTime"); - - number_of_hops= 0; - latency= registerSignal("hop_count"); - - number_of_messages= 0; - flood= registerSignal("flood"); - - success= 0; - success_rate= registerSignal("success"); - -} - -/* - * routeQuery - * Used to perform semantic routing - * Function returns the list of CSEs to redirect query to. - * It returns the list of URIs of the same relationship type, - * e.g. Customer, Sibling, Peer, Provider. - * - * */ -std::vector<URI> CSE::routeQuery(discoveryMessage *msg) { - std::string feature_type = msg->getFeature_type(); - std::vector<URI> URI_Found; - auto it = this->SemanticRoutingTable.find(feature_type); - if (it == this->SemanticRoutingTable.end()) { - EV << "feature Type not exist" << "\n"; - return URI_Found; - } - - if (it->second.CSECustomer.size() > 0) { - for (auto cit = it->second.CSECustomer.begin(); - cit != it->second.CSECustomer.end(); cit++) { - URI_Found.push_back(cit->first); - } - return URI_Found; - } - if (it->second.CSESibling.size() > 0) { - for (auto sit = it->second.CSESibling.begin(); - sit != it->second.CSESibling.end(); sit++) { - URI_Found.push_back(sit->first); - } - return URI_Found; - } - if (it->second.CSEPeer.size() > 0) { - for (auto sit = it->second.CSEPeer.begin(); - sit != it->second.CSEPeer.end(); sit++) { - URI_Found.push_back(sit->first); - } - return URI_Found; - } - if (it->second.CSEProvider.size() > 0) { - for (auto pit = it->second.CSEProvider.begin(); - pit != it->second.CSEProvider.end(); pit++) { - URI_Found.push_back(pit->first); - } - return URI_Found; - } - - return URI_Found; -} - -/* - * processQuery is used to route query if local DB lookup failed. - * It tries to perform semantic routing, and if no records satisfying query were found, - * if uses a so-called fallback routing to multicast query to the best match neighbors. - */ -void CSE::processQuery(discoveryMessage *msg) { - EV << "The Message is a query \n"; - EV << "DB Lookup not Successful" << "\n"; - if (msg->getHopCount() <= 0) { - bubble("TTL: expired"); - //Respond to the URI_init that the discovery ends - // TODO: DBLookup part to be added here - msg->setOp_code(RESPONSE); - // TODO: set the message op_codes according to result from DBLookup - //You extract from the top of the list the gate that has to be used - EV << "Hop count is 0 so we generate a self response message \n"; - number_of_messages++; - generateResponseMessage(msg, ResultCode::NOT_FOUND); - return; - } - - // decrease the hop count - EV << "we are in the else : hop count is currently " << msg->getHopCount() - << "\n"; - msg->setHopCount(msg->getHopCount() - 1); - number_of_hops++; - emit(latency, number_of_hops); - // TODO: signal for hop count - - - EV << "New HopCount=" << msg->getHopCount() << "\n"; - - auto res = routeQuery(msg); - - if (res.size() > 0) { - for (auto it : res) { - auto gateit = this->Gates[it]; - int gateindex = gateit.second; - std::string gateName = gateit.first + "$o"; - bubble("Semantic record found"); - number_of_messages++; - sendDelayed(msg->dup(), delay, gateName.c_str(), gateindex); - } - - return; - } - fallbackRouteQuery(msg); -} - -/* - * fallbackRouteQuery is used when semantic routing fails - * (i.e. semantic routing table lookup returns no results) - * It multicasts query with coefficients. - * It routes query in valley-free manner. - */ -void CSE::fallbackRouteQuery(discoveryMessage *msg) { - int D = msg->getDirection(); - - bool successful = false; - - /* - * We need to send response only if all of the broadcasts have failed - * - * Thus, we are performing logical AND between all invocations of broadcast - * - * If all of them fail - we will send response - * */ - switch (D) { - case DOWN: { - successful = multicast("customer", msg, this->multicastAlpha); - number_of_messages++; - successful = - !successful ? - multicast("sibling", msg, this->multicastGamma) : true; - break; - } - case SIDE_SIBLING: { - successful = multicast("sibling", msg, this->multicastGamma); - number_of_messages++; - successful &= multicast("customer", msg, this->multicastAlpha); - break; - } - case SIDE_PEER: { - number_of_messages++; - break; - } - case UP: { - successful = multicast("provider", msg, this->multicastBeta); - number_of_messages++; - successful = - !successful ? - multicast("sibling", msg, this->multicastGamma) : true; - number_of_messages++; - successful &= multicast("customer", msg, this->multicastDelta); - number_of_messages++; - break; - } - default: - break; - } - - if (!successful) { - bubble("No result"); - number_of_messages++; - generateResponseMessage(msg, ResultCode::NOT_FOUND); - } -} - -/* - * seenQuery is used to check whether the query being processed was previously processed. - * It checks the local query buffer for the query ID. - * Also, performs cleanup of stale buffer records. - */ -bool CSE::seenQuery(discoveryMessage *msg) { - std::map<queryKey, int64_t> newProcessed(this->processedQueries); - for (auto record : newProcessed) { - if (record.second < simTime().inUnit(SimTimeUnit::SIMTIME_S)) { - this->processedQueries.erase(record.first); - } - } - - queryKey key; - key.second = msg->getQueryID(); - key.first = msg->getURI_init(); - - if (this->processedQueries.find(key) != this->processedQueries.end()) { - return true; - } - - return false; -} - -/* - * handleQuery is used to handle message of type QUERY. - * - * It memorizes distinct queries and omits duplicate ones. - */ -void CSE::handleQuery(discoveryMessage *msg) { - auto cse = msg->getURI_route(); - std::string inputGate = msg->getArrivalGate()->getBaseName(); - this->Gates[cse] = std::make_pair(inputGate, - msg->getArrivalGate()->getIndex()); - - if (seenQuery(msg)) { - bubble("Dropping seen query"); - return; - } - - int64_t ttl = SimTime(this->queryBufferTTL).inUnit(SimTimeUnit::SIMTIME_S); - ttl = ttl + msg->getArrivalTime().inUnit(SimTimeUnit::SIMTIME_S); - queryKey key; - key.first = msg->getURI_init(); - key.second = msg->getQueryID(); - - this->processedQueries[key] = ttl; - - auto res = DBLookup(msg); - // If we find the index "NOT_FOUND" in the map, it means that - // the feature is not present in the database - if (res == NOT_FOUND) { - processQuery(msg); - return; - } - DBresult dbres = std::map<int, int>(); - dbres[res] = 0; - EV << "DB Lookup Successful" << "\n"; - msg->setDbResult(dbres); - - number_of_messages++; - generateResponseMessage(msg); -} - -/* - * handleDiscoveryMessage is used to handle `discoveryMessage`. - */ -void CSE::handleDiscoveryMessage(cMessage *msg) { - EV << "entering the CSE part " << "\n"; -// if the message comes from another resource that an AE - discoveryMessage *discoveryMsg = check_and_cast<discoveryMessage*>(msg); - EV << "The Message is of type : " << discoveryMsg->getOp_code() << "\n"; - if (msg->isSelfMessage()) { - //the discovery message comes from the AE and should be forwarded - EV << "It is a self Message " << "\n"; - if (discoveryMsg->getOp_code() == QUERY) { - processQuery(discoveryMsg); - delete discoveryMsg; - return; - } - } - - EV << "It is not a self Message "; - if (discoveryMsg->getOp_code() == QUERY) { - EV << "of type query\n"; - std::vector<cGate*> tempGateVector; - // You put on top of the list the name of the gate to be used in the return path (getOtherHalf) - tempGateVector = discoveryMsg->getGateVector(); - tempGateVector.push_back(msg->getArrivalGate()->getOtherHalf()); - discoveryMsg->setGateVector(tempGateVector); - EV << "A new gate is added = " << tempGateVector.back()->getFullName() - << "\n"; - } else { - EV << "of type response so no new gate added\n"; - } // end if self-message - -// switch on 2 possible opcodes between CSEs : QUERY or RESPONSE - - int op_code = discoveryMsg->getOp_code(); - EV << "Switch OPCODE \n"; - switch (op_code) { - case NOTIFY: - handleNotify(discoveryMsg); - break; - case QUERY: - handleQuery(discoveryMsg); - break; - case RESPONSE: { - returnResponse(discoveryMsg); - break; - } - } - - delete discoveryMsg; -} - -/* - * returnResponse is used to return response in predefined manner, i.e. - * unfolding path step by step and sending messages back. - */ -void CSE::returnResponse(discoveryMessage *msg) { - EV << "The Message is a response \n"; - int i = msg->getGateVector().size(); - if (i <= 0) { - EV << "We are in the last gate Message Delivered" << "\n"; - return; - } - - EV << "Size of Gate vector is " << i << "\n"; - std::vector<cGate*> tempGateVector; - // You put on top of the list the name of the gate to be used in the return path (getOtherHalf) - tempGateVector = msg->getGateVector(); - const char *returnGate = tempGateVector.back()->getName(); - int returnIndex = tempGateVector.back()->getIndex(); - - tempGateVector.pop_back(); - msg->setGateVector(tempGateVector); - EV << "gate removed = " << returnGate << "of index " << returnIndex << "\n"; - i = msg->getGateVector().size(); - EV << "New Size of Gate vector is " << i << "\n"; - EV << "<Module Name" << msg->getName() << "gate name" << returnGate << "\n" - << "gateIndex" << returnIndex << "\n"; - sendDelayed(msg->dup(), delay, returnGate, returnIndex); -} - -/* - * handleAEMessage is used to process message from Application Entities (AEs) - * Messages include registration, cancellation and queries. - */ -void CSE::handleAEMessage(cMessage *msg) { - EV << "entering the AE part of the IF " << "\n"; - AEMessage *aeMsg = check_and_cast<AEMessage*>(msg); -// Create message object and set source and destination field. - - int op_code = aeMsg->getOp_code(); // op_code contains the type of message - - switch (op_code) { - case REGISTRATION: { - - handleAERegistration(aeMsg); - break; - } - case CANCELLATION: { - - handleAECancellation(aeMsg); - break; - } - case QUERY: { - // if it is a query msg we create a discovery msg and we start ASDR - number_of_messages++; - generateDiscoveryMessage(aeMsg); - break; - } - default: - break; - } - - delete aeMsg; -} -/* - * saveAEData is used to save AE data into CSE local database - */ -void CSE::saveAEData(std::string feature_type, URI uri, int data) { -// we create an internal map - std::map<URI, int> internalMap; -// we create an Iterator on the database - std::map<std::string, std::map<URI, int>>::iterator it; -// we search for the feature_type in the database - it = database.find(feature_type); -// if we don't find it - if (it == database.end()) { - // putting data in the internal map as a new entry - internalMap[uri] = data; - } -// if we find the feature_type - else { - internalMap = database[feature_type]; // we put the internal map inside the DataBase map next to the feature_type - internalMap[uri] = data; - } - database[feature_type] = internalMap; - - EV << "feature type added in Database" << feature_type << "\n"; - -} - -/* - * handleAERegistration is used to perform Application Entity (AE) registration at parent CSE. - * Also, it invokes CSE neighbors notification as a result of new entity registration. - */ -void CSE::handleAERegistration(AEMessage *msg) { -// we extract the feature_type; URI_route; data from the AEmessage - std::string feature_type = msg->getFeature_type(); - int URI_route = msg->getURI(); - int data = msg->getData(); - - bubble(feature_type.c_str()); - - registerAE(feature_type, URI_route); - - saveAEData(feature_type, URI_route, data); - - notifyCSE(feature_type, 1); -} - -/* - * handleAECancellation is used to perform Application Entity (AE) deregistration at parent CSE. - * Also, it invokes CSE neighbors notification as a result of new entity deregistration (cancellation). - */ -void CSE::handleAECancellation(AEMessage *msg) { - - std::string feature_type = msg->getFeature_type(); - int URI_route = msg->getURI(); - - deregisterAE(feature_type, URI_route); - - notifyCSE(feature_type, -1); - -} - -/* - * registerAE is used to update semantic routing table to accustom for AE registration. - */ -void CSE::registerAE(std::string feature_type, URI uri) { - auto entry = getOrCreateRoutingEntry(feature_type); - entry.database.insert(std::pair<URI, int>(uri, 1)); - - this->SemanticRoutingTable[feature_type] = entry; -} - -/* - * deregisterAE is used to update semantic routing table to accustom for AE cancellation. - */ -void CSE::deregisterAE(std::string feature_type, URI uri) { - auto entry = mustGetRoutingEntry(feature_type); - auto it = entry.database.find(uri); - if (it == entry.database.end()) { - EV_FATAL << "Expected routing entry to exist\n"; - } - - if (it->second < 1) { - EV_FATAL << "Expected to have at least one AE registered\n"; - } - - entry.database.erase(it); - - this->SemanticRoutingTable[feature_type] = entry; -} - -/* - * handleMessage is and entry point for message handling. - */ -void CSE::handleMessage(cMessage *msg) { -// SWITCH ON THE 5 operational codes - number_of_packets++; - // assigning the values to the signal - emit(totalpacketsSignal, number_of_packets); - EV << "URI " << msg->getSenderModuleId() << "\n"; - -// if the message comes from the AE - if (prefix("AE", msg->getSenderModule()->getName())) { - handleAEMessage(msg); - } else { - handleDiscoveryMessage(msg); - emit(flood, number_of_messages); - } - -} // end of handle message - -/* - * generateResponseMessage is used to generate query response message (scheduling self-message) - * to be redirected to the source of the query - */ -void CSE::generateResponseMessage(discoveryMessage *msg, ResultCode result) { - EV << "inside generateResponseMessage Procedure" << "\n"; - - auto responseMsg = generateMessage(RESPONSE); -//These data may change during the routing of the query -// we set the direction to NODIR - responseMsg->setDirection(NODIR); - responseMsg->setFeature_type(msg->getFeature_type()); - responseMsg->setGateVector(msg->getGateVector()); - responseMsg->setReturnCode(result); - responseMsg->setURI_init(this->Uri); - - cancelEvent(responseMsg); - scheduleAt(simTime(), responseMsg); -} - -// this method forward the initial query to CSE -// void CSE::parseRouting(AEMessage *msg) { -// this function is transforming a query message to a discovery message - -void CSE::generateDiscoveryMessage(AEMessage *msg) { -// this function transforms a query message to a discovery message -// these data should not change during the routing between CSEs -// TODO lets consider if the URI parameter is useful ?? - -// we created a discovery message - discoveryMessage *queryMsg = new discoveryMessage("QUERY"); -// we extract the URI from the AE URI_init of the message - queryMsg->setURI_init(msg->getURI()); -// we extract the msg feature_type from AEmessage and we set it in the discovery Message - queryMsg->setFeature_type(msg->getFeature_type()); - -// we set op_code to QUERY - queryMsg->setOp_code(QUERY); - queryMsg->setQueryID(msg->getQueryID()); - -//These data may change during the routing of the query - -// set the hop count - queryMsg->setHopCount(msg->getMaxHop()); - -// we set the direction UP - queryMsg->setDirection(UP); - -// create a omnet vector of type cGate* named gateVector - std::vector<cGate*> gateVector = queryMsg->getGateVector(); -//You update the discoveryMessage with this object - queryMsg->setGateVector(gateVector); -// You put on top of the list the name of the gate to be used in the return path (getOtherHalf) - gateVector.push_back(msg->getArrivalGate()->getOtherHalf()); - - EV << "back cse event7 " << gateVector.back()->getFullName(); - EV << "front " << gateVector.front()->getFullName(); - -// We update the query msg with this vector - queryMsg->setGateVector(gateVector); - EV << "back cse event7 " - << queryMsg->getGateVector().back()->getFullName(); - EV << "front " << queryMsg->getGateVector().front()->getFullName(); - -// we schedule this query message to be sent asap in the simulation schedule - number_of_messages++; - scheduleAt(simTime(), queryMsg); - -// delete the AE message -} - -/* - * multicast is used to send messages in a multicast manner through the specified gate, - * optionally restricting maximal number of messages. - */ -bool CSE::multicast(std::string gateName, discoveryMessage *discoveryMsg, - int maxMessages) { - - auto dir = gateToDirection[gateName]; - std::string outGate = gateName + "$o"; - // checking the size of gate - int t = gateSize(gateName.c_str()); - //if it is greater than zero means if we have customer - if (t <= 0) { - return false; - } - - // it detects the size of the customer gates - int Uri = gate(outGate.c_str(), 0)->getId(); - EV << "uri of destination " << Uri << "\n"; - int vectSize = gate(outGate.c_str(), 0)->getVectorSize(); - // it register in the scheduler map the UR of the CSE and the parameters of the gate - // we will forward through the vectSize of customer gate which have all the customer - - int sent = 0; - - for (int i = 0; i < vectSize; i++) { - if (sent >= maxMessages) { - break; - } - - auto gateVector = discoveryMsg->getGateVector(); - bool visited = false; - cGate *gateToSend = gate(outGate.c_str(), i); - for (auto g : gateVector) { - auto gID = g->getConnectionId(); - auto sID = gateToSend->getConnectionId(); - if (gID == sID) { - visited = true; - break; - } - } - if (visited) { - continue; - } - - auto msg = discoveryMsg->dup(); - msg->setDirection(dir); - sendDelayed(msg, delay, outGate.c_str(), i); - sent++; - } -// delete discoveryMsg; - return sent > 0; -} - -/*std::vector<URI> CSE::UpdateBucket(discoveryMessage *msg) { - std::string feature_type = msg->getFeature_type(); - auto entry = getOrCreateRoutingEntry(feature_type); - int uri = msg->getSenderModuleId(); - auto f = std::find(entry.CSEBucket.begin(), entry.CSEBucket.end(), uri); -// if the response is positive, we check the URI in the - if (f != entry.CSEBucket.end()) { - entry.CSEBucket.insert(entry.CSEBucket.begin(), - msg->getSenderModuleId()); - return entry.CSEBucket.second; - } - //otherwise - if (entry.CSEBucket.size() <= 100) { - entry.CSEBucket.insert(entry.CSEBucket.begin(), - msg->getSenderModuleId()); - return entry.CSEBucket; - } - // otherwise - int i = entry.CSEBucket - auto it = this->Gates[i]; - int gateIndex = it.second; - std::string gateName = it.first + "$o"; - pingMessage *pingMsg = new pingMessage("ping"); - pingMsg->setURI(uri); - pingMsg->setFeature_type(feature_type); - pingMsg->setFlag(PING); - // ping message - send(pingMsg, gateName.c_str(), gateIndex); - - // after receiving ping - - if() - entry.CSEBucket.pop_back(); - entry.CSEBucket.insert(entry.CSEBucket.begin(), msg->getSenderModuleId()); - return entry.CSEBucket; - // save the data in Routing Table - this->SemanticRoutingTable[feature_type] = entry; -}*/ - -/* - * getOrCreateRoutingEntry is a primitive to avoid cumbersome map access and entry creation - * if map element with such key is missing - * - */ -RoutingEntry CSE::getOrCreateRoutingEntry(std::string feature_type) { - auto it = this->SemanticRoutingTable.find(feature_type); - if (it == this->SemanticRoutingTable.end()) { - return RoutingEntry { }; - } - - return it->second; -} - -/* - * mustGetRoutingEntry is used to always get non-empty routing entry by key. - * If it fails, fatal error will be thrown. - */ -RoutingEntry CSE::mustGetRoutingEntry(std::string feature_type) { - auto it = this->SemanticRoutingTable.find(feature_type); - if (it == this->SemanticRoutingTable.end()) { - EV_INFO<< "Expected routing entry to exist\n"; - return RoutingEntry { }; - } - - return it->second; -} - -/* - * handleNotify is used to process `discoveryMessage` of type NOTIFY. - * It updates sematic routing table for specific relationship type - * (e.g. Customer, Peer, Sibling, Provider) - */ -void CSE::handleNotify(discoveryMessage *msg) { - std::string feature_type = msg->getFeature_type(); - URI cse = msg->getURI_route(); - int delta = msg->getDelta(); - int direction = msg->getDirection(); - - auto entry = getOrCreateRoutingEntry(feature_type); - - std::string inputGate = msg->getArrivalGate()->getBaseName(); - this->Gates[cse] = std::make_pair(inputGate, - msg->getArrivalGate()->getIndex()); - - switch (direction) { - case UP: - entry.CSECustomer[cse] += delta; - break; - case DOWN: - entry.CSEProvider[cse] += delta; - break; - case SIDE_SIBLING: - entry.CSESibling[cse] += delta; - break; - case SIDE_PEER: - entry.CSEPeer[cse] += delta; - break; - } - - this->SemanticRoutingTable[feature_type] = entry; - - // notification depth reached - if (msg->getHopCount() >= this->NotificationDepth) { - return; - } - - EV << "Redirecting notify\n"; - - // notify - msg->setHopCount(msg->getHopCount() + 1); - msg->setURI_route(this->Uri); - notifyNeighbors(msg->dup()); -} - -/* - * notifyCSE is used to create and broadcast notification message to the neighbors. - */ -void CSE::notifyCSE(std::string feature_type, int delta) { - - EV << "inside notify\n"; -//assemble message - auto msg = generateMessage(NOTIFY); - msg->setFeature_type(feature_type.c_str()); - msg->setDelta(delta); - -// send to CSEs - notifyNeighbors(msg); -} - -/* - * notifyNeighbors is used to broadcast notification to all neighbors, - * excluding the neighbor that sent the message to the current CSE. - * Also, populates gate vector of the message with the arrival gate. - */ - // TODO: change the name of the notify message -void CSE::notifyNeighbors(discoveryMessage *msg) { - std::vector<cGate*> gateVector = msg->getGateVector(); - //You update the discoveryMessage with this object - msg->setGateVector(gateVector); - - if (msg->getArrivalGate() != nullptr) { - gateVector.push_back(msg->getArrivalGate()->getOtherHalf()); - msg->setGateVector(gateVector); - } - - EV << "sending messages to downstream\n"; - multicast("customer", msg); - - EV << "sending messages to sidestream\n"; - multicast("peer", msg); - multicast("sibling", msg); - - EV << "sending messages to upsteam\n"; - multicast("provider", msg); - delete msg; -} - -/* - * DBLookup is used to perform lookup in the semantic routing table for - * AEs children of the current CSE. - */ -URI CSE::DBLookup(discoveryMessage *msg) -{ - - auto feature_type = msg->getFeature_type(); -// extracting the feature_type - auto it = this->SemanticRoutingTable.find(feature_type); -// if we find the data correspond to the feature_type - if (it == this->SemanticRoutingTable.end()) { - return NOT_FOUND; - } - - if (it->second.database.size() == 0) { - return NOT_FOUND; - } - - bubble("Success"); - return it->second.database.begin()->first; -} - -/* - * generateMessage is used to generate message of specified type. - */ -discoveryMessage* CSE::generateMessage(int op_code) { - switch (op_code) { - case QUERY: { - // Produce source and destination addresses. - int URI_route = getId(); - char msgname[20]; - sprintf(msgname, "Q"); - // Create message object and set source and destination field. - discoveryMessage *msg = new discoveryMessage(msgname); - msg->setDirection(DOWN); - msg->setOp_code(QUERY); - msg->setURI_route(URI_route); - return msg; - break; - } - case RESPONSE: { - int URI_route = getId(); - char msgname[20]; - sprintf(msgname, "Rsp"); - // Create message object and set source and destination field. - discoveryMessage *msg = new discoveryMessage(msgname); - //msg->setPayload("thermometer"); - msg->setDirection(DOWN); - msg->setOp_code(RESPONSE); - msg->setURI_route(URI_route); - return msg; - break; - } - case NOTIFY: { - int URI_route = getId(); - char msgname[20]; - sprintf(msgname, "N"); - // Create message object and set source and destination field. - discoveryMessage *msg = new discoveryMessage(msgname); - //msg->setPayload("thermometer"); - msg->setDirection(DOWN); - msg->setOp_code(NOTIFY); - msg->setURI_route(URI_route); - msg->setURI_init(URI_route); - return msg; - break; - } - case REGISTRATION: { - int URI_route = getId(); - char msgname[20]; - sprintf(msgname, "Rg"); - // Create message object and set source and destination field. - discoveryMessage *msg = new discoveryMessage(msgname); - //msg->setPayload("thermometer"); - msg->setDirection(DOWN); - msg->setOp_code(REGISTRATION); - msg->setURI_route(URI_route); - return msg; - break; - } - case CANCELLATION: { - int URI_route = getId(); - char msgname[20]; - sprintf(msgname, "C"); - // Create message object and set source and destination field. - discoveryMessage *msg = new discoveryMessage(msgname); - //msg->setPayload("thermometer"); - msg->setDirection(DOWN); - msg->setOp_code(REGISTRATION); - msg->setURI_route(URI_route); - return msg; - break; - } - default: - break; - } - - return nullptr; -} - -void CSE::orderingMap(std::map<int, int>) { - return; -} diff --git a/src/CSE.h b/src/CSE.h deleted file mode 100644 index d67708602ccd32ccdf09183088810e7355eb8c7c..0000000000000000000000000000000000000000 --- a/src/CSE.h +++ /dev/null @@ -1,153 +0,0 @@ -#ifndef CSE_H_ -#define CSE_H_ - -#include <stdio.h> -#include <string.h> -#include <omnetpp.h> -#include "discoveryMessage_m.h" -#include "AEMessage_m.h" -#include "pingMessage_m.h" -#include <list> -#include "utils.h" -#include "types.h" - - - -#define EXPIRATION_TIME 300 - -using namespace omnetpp; - -//using namespace std; - - - -class CSE: public cSimpleModule { -public: - RoutingTable SemanticRoutingTable; - -protected: - // by default in omnet methods - virtual void initialize() override; - virtual void handleMessage(cMessage *msg) override; - // application specific method - virtual discoveryMessage* generateMessage(int op_code); -private: - - bool seenQuery(discoveryMessage *msg); - - // application specific for exploring and updating the local database - URI DBLookup(discoveryMessage *msg); - void updateDatabase(AEMessage *msg, int op_code); - // this method forward the initial query to CSEs - // MAPchg void parseRouting(AEMessage *msg); - void generateDiscoveryMessage(AEMessage *msg); - void generateResponseMessage(discoveryMessage *discoveryMsg, ResultCode result = ResultCode::SUCCESS); - // not yet used - // TODO this function organize the map by value-ordering - void orderingMap(std::map<int, int>); - - // Routing table update - RoutingEntry getOrCreateRoutingEntry(std::string feature_type); - RoutingEntry mustGetRoutingEntry(std::string feature_type); - void registerAE(std::string feature_type, URI uri); - void deregisterAE(std::string feature_type, URI uri); - - void notifyCSE(std::string feature_type, int delta); - void notifyNeighbors(discoveryMessage *msg); - bool multicast(std::string gateName, discoveryMessage *msg, int maxMessages = INT_MAX); - void broadcast(std::string gateName, discoveryMessage *msg); - - // Save AE data - - void saveAEData(std::string feature_type, URI uri, int data); - - //Messages handling - void handleAEMessage(cMessage *msg); - void handleAERegistration(AEMessage *msg); - void handleAEQuery(AEMessage *msg); - void handleAECancellation(AEMessage *msg); - - void handleDiscoveryMessage(cMessage *msg); - void handleNotify(discoveryMessage *msg); - - void handleQuery(discoveryMessage *msg); - void fallbackRouteQuery(discoveryMessage *msg); - - void processQuery(discoveryMessage *msg); - - void returnResponse(discoveryMessage * msg); - - std::vector<URI> routeQuery(discoveryMessage *msg); - std::vector<URI> UpdateBucket(discoveryMessage*msg); - - - /* WE ARE IN THE NOTIFY SWITCH CASE - before orderingMap - <(1,30),(2,40),(5,33),(6,12)> - call orderingMap - <(2,40),(5,33),(1,30),(6,12)> - notify +5 1 - <(2,40),(5,33),(1,35),(6,12)> - call orderingMap - <(2,40),(1,35),(5,33),(6,12)> - notify +22 6 - <(2,40),(5,33),(1,35),(6,34)> - call orderingMap (will take log(n) - <(6,34),(2,40),(5,33),(1,35)>*/ - -/// DATA structures definitions - // this is the omnet++ ledger - // that collect some data useful for measuring experiments - // and is also useful for replying the query. - // this is composed as follow - // <URI ,<gateIndex,simTime,direction>> - std::map<URI, std::tuple<int, simtime_t, int>> schedulerMap; - - - std::map<std::string,std::map<URI,int>> database; - - GateMapping Gates; - - URI Uri; - - // How many times to retransmit `Notify` - int NotificationDepth; - - // Alpha - is the multicast parameter for customer; - int multicastAlpha; - // Beta - is the multicast parameter for provider - int multicastBeta; - //Gamma - is the multicast parameter for sibling - int multicastGamma; - //Delta - is the multicast parameter for peer - int multicastDelta; - - // Max hops for message/query - int maxHops; - - simtime_t queryBufferTTL; - - std::map<queryKey, int64_t> processedQueries; - - int number_of_packets; - int number_of_hops; - simtime_t delay; - int number_of_messages; - int success; -protected: - simsignal_t totalpacketsSignal; - simsignal_t latency; - simsignal_t flood; - simsignal_t success_rate; - - - - -}; -Define_Module(CSE); - -#endif /* CSE_H_ */ - - - - diff --git a/src/CSE_Network_V3.6.4.1 b/src/CSE_Network_V3.6.4.1 deleted file mode 100644 index 6233525f71061ae0308747665e6cdf8e1af3887e..0000000000000000000000000000000000000000 Binary files a/src/CSE_Network_V3.6.4.1 and /dev/null differ diff --git a/src/CSE_Network_V3.6.4.1_dbg b/src/CSE_Network_V3.6.4.1_dbg deleted file mode 100644 index f898a2f3f110e06b401b32b453620e35855cb232..0000000000000000000000000000000000000000 Binary files a/src/CSE_Network_V3.6.4.1_dbg and /dev/null differ diff --git a/src/LargeNetwork.ned b/src/LargeNetwork.ned deleted file mode 100644 index 698871c090e8d25db671ce8a01d0b6d764108be5..0000000000000000000000000000000000000000 --- a/src/LargeNetwork.ned +++ /dev/null @@ -1,94 +0,0 @@ -network LargeNetwork -{ - parameters: - - @signal[flood](type="long"); - @statistic[flood](title="number_of_messages"; source="flood"; record= vector,last); - - @signal[packet_size](type="long"); - @statistic[throughput](title="total_number_of_packets"; source="packet_size"; record=vector,last); - - @signal[hop_count](type="long"); - @statistic[latency](title="latency"; source="hop_count"; record= vector,last); - - @signal[number_replies](type="long"); - @statistic[successRate](title="total_number_of_replies"; source="number_replies"; record=vector,last); - @display("bgb=583,467"); -// parameters: - int cse_in; // - int ae_in; // - int ae_adn; // - int cse_asn; // - int ae_asn; - int mn_cse; -// int mnt_cse; - int adn; - int mn_ae; -// - int ae_in_count = cse_in * ae_in; - int ae_adn_count = cse_in * ae_adn; - int cse_asn_count = cse_asn * cse_in; - int ae_asn_count = cse_asn_count * ae_asn; - int mn_cse_count = cse_in * mn_cse; - int mn_ae_count = mn_cse_count * mn_ae; - int adn_count = mn_cse_count * adn; - - types: - channel Channel extends ned.DelayChannel - { - delay = 100ms; - } - submodules: - CSE_in[cse_in]: CSE; - AE_in[ae_in_count]: AE; - AE_adn[ae_adn_count]: AE; - CSE_asn[cse_asn_count]: CSE; - AE_asn[ae_asn_count]: AE; - AE_ad[adn_count]: AE; - CSE_mn[mn_cse_count]: CSE; - AE_mn[mn_ae_count]: AE; - - - connections allowunconnected: - // Top level connections - for i=0..(int(cse_in/2)-1), for j=int(cse_in/2)..(cse_in-1) { - CSE_in[i].sibling++ <--> Channel <--> CSE_in[j].sibling++; - } - - // AE-IN - for i=0..(cse_in-1), for j = 0..(ae_in-1) { - CSE_in[i].ae++ <--> Channel <--> AE_in[ae_in*i + j].cse++; - } - //AE-ADN to CSE-IN - for i=0..(cse_in-1), for j = 0..(ae_adn-1) { - CSE_in[i].ae++ <--> Channel <--> AE_adn[ae_adn*i + j].cse++; - } - // CSE-ASN to CSE_IN - for i=0..(cse_in-1), for j = 0..(cse_asn-1) { - CSE_in[i].customer++ <--> Channel <--> CSE_asn[cse_asn*i + j].provider++; - } - //AE-ASN to CSE-ASN - for i=0..(cse_asn_count-1), for j = 0..(ae_asn-1) { - CSE_asn[i].ae++ <--> Channel <--> AE_asn[ae_asn*i + j].cse++; - } - - //CSE-MN to CSE-IN - for i=0..(cse_in-1), for j = 0..(mn_cse-1) { - CSE_in[i].customer++ <--> Channel <--> CSE_mn[mn_cse*i + j].provider++; - } - - //CSE-MN to ADN - for i=0..(mn_cse_count-1), for j = 0..(adn-1) { - CSE_mn[i].ae++ <--> Channel <--> AE_ad[adn*i + j].cse++; - } - - //CSE-MN to AE-MN - for i=0..(mn_cse_count-1), for j = 0..(mn_ae-1) { - CSE_mn[i].ae++ <--> Channel <--> AE_mn[mn_ae*i + j].cse++; - } - - - - - -} diff --git a/src/Makefile b/src/Makefile deleted file mode 100644 index ad3ba12f9ce443234b2ad3f210a7c8871f33b9f6..0000000000000000000000000000000000000000 --- a/src/Makefile +++ /dev/null @@ -1,134 +0,0 @@ -# -# OMNeT++/OMNEST Makefile for CSE_Network_V3.6.4.1 -# -# This file was generated with the command: -# opp_makemake -f --deep -# - -# Name of target to be created (-o option) -TARGET = CSE_Network_V3.6.4.1$(D)$(EXE_SUFFIX) -TARGET_DIR = . - -# User interface (uncomment one) (-u option) -USERIF_LIBS = $(ALL_ENV_LIBS) # that is, $(TKENV_LIBS) $(QTENV_LIBS) $(CMDENV_LIBS) -#USERIF_LIBS = $(CMDENV_LIBS) -#USERIF_LIBS = $(TKENV_LIBS) -#USERIF_LIBS = $(QTENV_LIBS) - -# C++ include paths (with -I) -INCLUDE_PATH = - -# Additional object and library files to link with -EXTRA_OBJS = - -# Additional libraries (-L, -l options) -LIBS = - -# Output directory -PROJECT_OUTPUT_DIR = ../out -PROJECTRELATIVE_PATH = src -O = $(PROJECT_OUTPUT_DIR)/$(CONFIGNAME)/$(PROJECTRELATIVE_PATH) - -# Object files for local .cpp, .msg and .sm files -OBJS = $O/AE.o $O/CSE.o $O/AEMessage_m.o $O/discoveryMessage_m.o $O/pingMessage_m.o - -# Message files -MSGFILES = \ - AEMessage.msg \ - discoveryMessage.msg \ - pingMessage.msg - -# SM files -SMFILES = - -#------------------------------------------------------------------------------ - -# Pull in OMNeT++ configuration (Makefile.inc) - -ifneq ("$(OMNETPP_CONFIGFILE)","") -CONFIGFILE = $(OMNETPP_CONFIGFILE) -else -ifneq ("$(OMNETPP_ROOT)","") -CONFIGFILE = $(OMNETPP_ROOT)/Makefile.inc -else -CONFIGFILE = $(shell opp_configfilepath) -endif -endif - -ifeq ("$(wildcard $(CONFIGFILE))","") -$(error Config file '$(CONFIGFILE)' does not exist -- add the OMNeT++ bin directory to the path so that opp_configfilepath can be found, or set the OMNETPP_CONFIGFILE variable to point to Makefile.inc) -endif - -include $(CONFIGFILE) - -# Simulation kernel and user interface libraries -OMNETPP_LIBS = $(OPPMAIN_LIB) $(USERIF_LIBS) $(KERNEL_LIBS) $(SYS_LIBS) - -COPTS = $(CFLAGS) $(IMPORT_DEFINES) $(INCLUDE_PATH) -I$(OMNETPP_INCL_DIR) -MSGCOPTS = $(INCLUDE_PATH) -SMCOPTS = - -# we want to recompile everything if COPTS changes, -# so we store COPTS into $COPTS_FILE and have object -# files depend on it (except when "make depend" was called) -COPTS_FILE = $O/.last-copts -ifneq ("$(COPTS)","$(shell cat $(COPTS_FILE) 2>/dev/null || echo '')") -$(shell $(MKPATH) "$O" && echo "$(COPTS)" >$(COPTS_FILE)) -endif - -#------------------------------------------------------------------------------ -# User-supplied makefile fragment(s) -# >>> -# <<< -#------------------------------------------------------------------------------ - -# Main target -all: $(TARGET_DIR)/$(TARGET) - -$(TARGET_DIR)/% :: $O/% - @mkdir -p $(TARGET_DIR) - $(Q)$(LN) $< $@ -ifeq ($(TOOLCHAIN_NAME),clangc2) - $(Q)-$(LN) $(<:%.dll=%.lib) $(@:%.dll=%.lib) -endif - -$O/$(TARGET): $(OBJS) $(wildcard $(EXTRA_OBJS)) Makefile $(CONFIGFILE) - @$(MKPATH) $O - @echo Creating executable: $@ - $(Q)$(CXX) $(LDFLAGS) -o $O/$(TARGET) $(OBJS) $(EXTRA_OBJS) $(AS_NEEDED_OFF) $(WHOLE_ARCHIVE_ON) $(LIBS) $(WHOLE_ARCHIVE_OFF) $(OMNETPP_LIBS) - -.PHONY: all clean cleanall depend msgheaders smheaders - -.SUFFIXES: .cpp - -$O/%.o: %.cpp $(COPTS_FILE) | msgheaders smheaders - @$(MKPATH) $(dir $@) - $(qecho) "$<" - $(Q)$(CXX) -c $(CXXFLAGS) $(COPTS) -o $@ $< - -%_m.cpp %_m.h: %.msg - $(qecho) MSGC: $< - $(Q)$(MSGC) -s _m.cpp -MD -MP -MF $O/$(basename $<)_m.h.d $(MSGCOPTS) $? - -%_sm.cpp %_sm.h: %.sm - $(qecho) SMC: $< - $(Q)$(SMC) -c++ -suffix cpp $(SMCOPTS) $? - -msgheaders: $(MSGFILES:.msg=_m.h) - -smheaders: $(SMFILES:.sm=_sm.h) - -clean: - $(qecho) Cleaning $(TARGET) - $(Q)-rm -rf $O - $(Q)-rm -f $(TARGET_DIR)/$(TARGET) - $(Q)-rm -f $(TARGET_DIR)/$(TARGET:%.dll=%.lib) - $(Q)-rm -f $(call opp_rwildcard, . , *_m.cpp *_m.h *_sm.cpp *_sm.h) - -cleanall: - $(Q)$(MAKE) -s clean MODE=release - $(Q)$(MAKE) -s clean MODE=debug - $(Q)-rm -rf $(PROJECT_OUTPUT_DIR) - -# include all dependencies --include $(OBJS:%=%.d) $(MSGFILES:%.msg=$O/%_m.h.d) diff --git a/src/Notes.md b/src/Notes.md deleted file mode 100644 index c23e7e9c9dfc49d1f99673b147e601aa8985f213..0000000000000000000000000000000000000000 --- a/src/Notes.md +++ /dev/null @@ -1,9 +0,0 @@ -# Notes - -## To figure out - -* Message scheduling - `sendDelayed` vs multistage init -* GUI choice - QT vs TKenv -* Customize GUI naming of entities in the network, e.g.: - `AE[3]` vs. `AE_3_thm` -* Variable text on display phase diff --git a/src/ResourceDiscovery.ex_ b/src/ResourceDiscovery.ex_ deleted file mode 100644 index 06d2cf958dc23e043b1908ceb6ee7377dec35c36..0000000000000000000000000000000000000000 Binary files a/src/ResourceDiscovery.ex_ and /dev/null differ diff --git a/src/ResourceDiscovery_dbg.ex_ b/src/ResourceDiscovery_dbg.ex_ deleted file mode 100644 index 5b229ef248c501a152fa83e5621db2b178e3ccf5..0000000000000000000000000000000000000000 Binary files a/src/ResourceDiscovery_dbg.ex_ and /dev/null differ diff --git a/src/SmallNetwork.ned b/src/SmallNetwork.ned deleted file mode 100644 index d17e0aae9ecd1dd0abfd6d7f8a904e0e4494b775..0000000000000000000000000000000000000000 --- a/src/SmallNetwork.ned +++ /dev/null @@ -1,54 +0,0 @@ -network SmallNetwork -{ - parameters: - @signal[flood](type="long"); - @statistic[flood](title="number_of_messages"; source="flood"; record= vector,last); - - @signal[packet_size](type="long"); - @statistic[throughput](title="total_number_of_packets"; source="packet_size"; record=vector,last); - - @signal[hop_count](type="long"); - @statistic[latency](title="latency"; source="hop_count"; record= vector,last); - - @signal[number_replies](type="long"); - @statistic[successRate](title="total_number_of_replies"; source="number_replies"; record=vector,last); - types: - channel Channel extends ned.DelayChannel { - delay = 100ms; - } - submodules: - CSE_in[3]: CSE; - CSE_mn[6]: CSE; - AE [12]: AE; - connections allowunconnected : - for i=0..2 { - CSE_in[i].sibling++ <--> Channel <--> CSE_in[(i+1)%3].sibling++; - } - for j=0..1 { - CSE_mn[j].provider++ <--> Channel <--> CSE_in[0].customer++; - } - for j=2..3 { - CSE_mn[j].provider++ <--> Channel <--> CSE_in[1].customer++; - } - for j=4..5 { - CSE_mn[j].provider++<--> Channel <--> CSE_in[2].customer++; - } - for j=0..1 { - CSE_mn[0].ae++ <--> Channel <--> AE[j].cse++; - } - for j=2..3 { - CSE_mn[1].ae++ <--> Channel <--> AE[j].cse++; - } - for j=4..5 { - CSE_mn[2].ae++ <--> Channel <--> AE[j].cse++; - } - for j=6..7 { - CSE_mn[3].ae++ <--> Channel <--> AE[j].cse++; - } - for j=8..9 { - CSE_mn[4].ae++ <--> Channel <--> AE[j].cse++; - } - for j=10..11 { - CSE_mn[5].ae++ <--> Channel <--> AE[j].cse++; - } -} \ No newline at end of file diff --git a/src/big_network.ned b/src/big_network.ned deleted file mode 100644 index 3a2beb5df0bb2c9c642a4edd3a0403149d0ed8e9..0000000000000000000000000000000000000000 --- a/src/big_network.ned +++ /dev/null @@ -1,131 +0,0 @@ -network BigNetwork -{ - parameters: - @signal[flood](type="long"); - @statistic[flood](title="number_of_messages"; source="flood"; record= vector,last); - - @signal[packet_size](type="long"); - @statistic[throughput](title="total_number_of_packets"; source="packet_size"; record=vector,last); - - @signal[hop_count](type="long"); - @statistic[latency](title="latency"; source="hop_count"; record= vector,last); - - @signal[number_replies](type="long"); - @statistic[successRate](title="total_number_of_replies"; source="number_replies"; record=vector,last); - // @todo statistics - // num of resources found - // no of hops - // number of messages - // distribution of the resource - // number of Notification messages - // processing time for the messages. - types: - channel Channel extends ned.DelayChannel { - delay = 50ms; - } - submodules: - CSE_in[3]: CSE; - CSE_mn[18]: CSE; - AE [42]: AE; - connections allowunconnected : - for i=0..2 { - CSE_in[i].sibling++ <--> Channel <--> CSE_in[(i+1)%3].sibling++; - } - for j=0..1 { - CSE_mn[j].provider++ <--> Channel <--> CSE_in[0].customer++; - } - for j=2..3 { - CSE_mn[j].provider++ <--> Channel <--> CSE_in[1].customer++; - } - for j=4..5 { - CSE_mn[j].provider++ <--> Channel <--> CSE_in[2].customer++; - } - for j=6..7 { - CSE_mn[j].provider++ <--> Channel <--> CSE_mn[0].customer++; - } - for j=8..9 { - CSE_mn[j].provider++ <--> Channel <--> CSE_mn[1].customer++; - } - for j=10..11 { - CSE_mn[j].provider++ <--> Channel <--> CSE_mn[2].customer++; - } - for j=12..13 { - CSE_mn[j].provider++ <--> Channel <--> CSE_mn[3].customer++; - } - for j=14..15 { - CSE_mn[j].provider++ <--> Channel <--> CSE_mn[4].customer++; - } - for j=16..17 { - CSE_mn[j].provider++ <--> Channel <--> CSE_mn[5].customer++; - } - for j=0..1 { - CSE_mn[0].ae++ <--> Channel <--> AE[j].cse++; - } - for j=2..3 { - CSE_mn[1].ae++ <--> Channel <--> AE[j].cse++; - } - for j=4..5 { - CSE_mn[2].ae++ <--> Channel <--> AE[j].cse++; - } - for j=6..7 { - CSE_mn[3].ae++ <--> Channel <--> AE[j].cse++; - } - for j=8..9 { - CSE_mn[4].ae++ <--> Channel <--> AE[j].cse++; - } - for j=10..11 { - CSE_mn[5].ae++ <--> Channel <--> AE[j].cse++; - } - for j=12..13 { - CSE_in[0].ae++ <--> Channel <--> AE[j].cse++; - } - for j=14..15 { - CSE_in[1].ae++ <--> Channel <--> AE[j].cse++; - } - for j=16..17 { - CSE_in[2].ae++ <--> Channel <--> AE[j].cse++; - } - for j=18..19{ - CSE_mn[6].ae++ <--> Channel <--> AE[j].cse++; - } - for j=20..21{ - CSE_mn[7].ae++ <--> Channel <--> AE[j].cse++; - } - for j=22..23{ - CSE_mn[8].ae++ <--> Channel <--> AE[j].cse++; - } - for j=24..25{ - CSE_mn[9].ae++ <--> Channel <--> AE[j].cse++; - } - for j=26..27{ - CSE_mn[10].ae++ <--> Channel <--> AE[j].cse++; - } - for j=28..29{ - CSE_mn[11].ae++ <--> Channel <--> AE[j].cse++; - } - for j=30..31{ - CSE_mn[12].ae++ <--> Channel <--> AE[j].cse++; - } - for j=32..33{ - CSE_mn[13].ae++ <--> Channel <--> AE[j].cse++; - } - for j=34..35{ - CSE_mn[14].ae++<--> Channel <--> AE[j].cse++; - } - for j=36..37{ - CSE_mn[15].ae++ <--> Channel <--> AE[j].cse++; - } - for j=38..39{ - CSE_mn[16].ae++ <--> Channel <--> AE[j].cse++; - } - for j=40..41{ - CSE_mn[17].ae++ <--> Channel <--> AE[j].cse++; - } - - - - - - - -} \ No newline at end of file diff --git a/src/components.ned b/src/components.ned deleted file mode 100644 index 013862d596ed0e3d282f0fc59f0920c0ed7ab96e..0000000000000000000000000000000000000000 --- a/src/components.ned +++ /dev/null @@ -1,46 +0,0 @@ -simple CSE -{ - parameters: - @display("i=abstract/router,blue,9"); - //TODO: to add signal for hopcount and multicast parameter - int notification_depth = default(1); - int alpha = default(1); - int beta = default(1); - int gamma = default(2); - int delta = default(1); - int queryBufferTTL = default(2); - int maxHops = default(10); - //volatile double sendInterval @unit(s); - volatile double delayTime @unit(s); - - //@signal[packet_size](type="long"); - //@statistic[throughput](title="total_number_of_packets"; source="packet_size"; record=vector,last); - - - //@signal[flood](type="long"); - //@statistic[flood](title="number_of_messages"; source="flood"; record= vector,last); - - //@signal[success](type="long"); - //@statistic[success_rate](title="Success_rate"; source="success"; record= vector,last); - - //@signal[hop_count](type="long"); - //@statistic[latency](title="latency"; source="hop_count"; record= vector,last); - - gates: - inout provider[] @loose; - inout customer[] @loose; - inout sibling[] @loose; - inout peer[] @loose; - inout ae[] @loose; -} -simple AE -{ - parameters: - @display("i=misc/node,#0080FF,23;is=s"); - int warmup = default(60); - int maxHops = default(10); - int resource_pool_size = default(10); - - gates: - inout cse[] @loose; -} diff --git a/src/declarative.h b/src/declarative.h deleted file mode 100644 index d69a8944b134d8364719595841367ac19aae2ad8..0000000000000000000000000000000000000000 --- a/src/declarative.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef DECLARATIVE_H_ -#define DECLARATIVE_H_ - -#ifndef TYPES_H_ -#include "types.h" -#endif - -std::map<std::string, Direction> gateToDirection = -{ - {"customer",DOWN}, - {"sibling", SIDE_SIBLING}, - {"peer", SIDE_PEER}, - {"provider", UP}, -}; - -#endif diff --git a/src/discoveryMessage.msg b/src/discoveryMessage.msg deleted file mode 100644 index 18120aa7159608885550ecbea19d303ff5aa2f8e..0000000000000000000000000000000000000000 --- a/src/discoveryMessage.msg +++ /dev/null @@ -1,46 +0,0 @@ -cplusplus{{ - #include <map> - #include <vector> - //using namespace omnetpp; - typedef std::map<int,int> DBresult; - - // this has a problem - - typedef std::vector<omnetpp::cGate *> GateVector; -}} - -class noncobject DBresult; -class noncobject GateVector; - -message discoveryMessage -{ - // ID assigned to QUERY - int queryID; - // this is the identifer of the very first AE generating Discovery QUERY - int URI_init; - // this is identifer of in route CSE, sending the message to another CSE - int URI_route; - // this is type of Resource CSE is looking for. Values can be "waterValve","thermometer","airStation","ATM","smartLock" - string feature_type; - - //this can be Registration, update, cancellation, Query, Response, Notify - int op_code; - // Indicates result of query - int returnCode; - // Used with depth of Notify - int delta; - // this value lists the number of remaining hopes before end of forwarding QUERY - int hopCount; - // this will be UP (customer to provider) or DOWN (Provider to Customer) - // or SIDE (Sibling to Sibling and Peer to Peer). direction where the message has been sent - int direction; - // this is the index of the gate from which the request has been sent originator gate. - int initialGateIndex; - //This is the result obtained when looking in the local database - DBresult dbResult; - // this is the list that contains the discovery path (list of CSE that forward the query) - GateVector gateVector; - - - -} \ No newline at end of file diff --git a/src/discoveryMessage_m.cpp b/src/discoveryMessage_m.cpp deleted file mode 100644 index 66e5a04398634f428d2871c9fee4c734848745d0..0000000000000000000000000000000000000000 --- a/src/discoveryMessage_m.cpp +++ /dev/null @@ -1,679 +0,0 @@ -// -// Generated file, do not edit! Created by nedtool 5.6 from discoveryMessage.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 "discoveryMessage_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(discoveryMessage) - -discoveryMessage::discoveryMessage(const char *name, short kind) : ::omnetpp::cMessage(name,kind) -{ - this->queryID = 0; - this->URI_init = 0; - this->URI_route = 0; - this->op_code = 0; - this->returnCode = 0; - this->delta = 0; - this->hopCount = 0; - this->direction = 0; - this->initialGateIndex = 0; -} - -discoveryMessage::discoveryMessage(const discoveryMessage& other) : ::omnetpp::cMessage(other) -{ - copy(other); -} - -discoveryMessage::~discoveryMessage() -{ -} - -discoveryMessage& discoveryMessage::operator=(const discoveryMessage& other) -{ - if (this==&other) return *this; - ::omnetpp::cMessage::operator=(other); - copy(other); - return *this; -} - -void discoveryMessage::copy(const discoveryMessage& other) -{ - this->queryID = other.queryID; - this->URI_init = other.URI_init; - this->URI_route = other.URI_route; - this->feature_type = other.feature_type; - this->op_code = other.op_code; - this->returnCode = other.returnCode; - this->delta = other.delta; - this->hopCount = other.hopCount; - this->direction = other.direction; - this->initialGateIndex = other.initialGateIndex; - this->dbResult = other.dbResult; - this->gateVector = other.gateVector; -} - -void discoveryMessage::parsimPack(omnetpp::cCommBuffer *b) const -{ - ::omnetpp::cMessage::parsimPack(b); - doParsimPacking(b,this->queryID); - doParsimPacking(b,this->URI_init); - doParsimPacking(b,this->URI_route); - doParsimPacking(b,this->feature_type); - doParsimPacking(b,this->op_code); - doParsimPacking(b,this->returnCode); - doParsimPacking(b,this->delta); - doParsimPacking(b,this->hopCount); - doParsimPacking(b,this->direction); - doParsimPacking(b,this->initialGateIndex); - doParsimPacking(b,this->dbResult); - doParsimPacking(b,this->gateVector); -} - -void discoveryMessage::parsimUnpack(omnetpp::cCommBuffer *b) -{ - ::omnetpp::cMessage::parsimUnpack(b); - doParsimUnpacking(b,this->queryID); - doParsimUnpacking(b,this->URI_init); - doParsimUnpacking(b,this->URI_route); - doParsimUnpacking(b,this->feature_type); - doParsimUnpacking(b,this->op_code); - doParsimUnpacking(b,this->returnCode); - doParsimUnpacking(b,this->delta); - doParsimUnpacking(b,this->hopCount); - doParsimUnpacking(b,this->direction); - doParsimUnpacking(b,this->initialGateIndex); - doParsimUnpacking(b,this->dbResult); - doParsimUnpacking(b,this->gateVector); -} - -int discoveryMessage::getQueryID() const -{ - return this->queryID; -} - -void discoveryMessage::setQueryID(int queryID) -{ - this->queryID = queryID; -} - -int discoveryMessage::getURI_init() const -{ - return this->URI_init; -} - -void discoveryMessage::setURI_init(int URI_init) -{ - this->URI_init = URI_init; -} - -int discoveryMessage::getURI_route() const -{ - return this->URI_route; -} - -void discoveryMessage::setURI_route(int URI_route) -{ - this->URI_route = URI_route; -} - -const char * discoveryMessage::getFeature_type() const -{ - return this->feature_type.c_str(); -} - -void discoveryMessage::setFeature_type(const char * feature_type) -{ - this->feature_type = feature_type; -} - -int discoveryMessage::getOp_code() const -{ - return this->op_code; -} - -void discoveryMessage::setOp_code(int op_code) -{ - this->op_code = op_code; -} - -int discoveryMessage::getReturnCode() const -{ - return this->returnCode; -} - -void discoveryMessage::setReturnCode(int returnCode) -{ - this->returnCode = returnCode; -} - -int discoveryMessage::getDelta() const -{ - return this->delta; -} - -void discoveryMessage::setDelta(int delta) -{ - this->delta = delta; -} - -int discoveryMessage::getHopCount() const -{ - return this->hopCount; -} - -void discoveryMessage::setHopCount(int hopCount) -{ - this->hopCount = hopCount; -} - -int discoveryMessage::getDirection() const -{ - return this->direction; -} - -void discoveryMessage::setDirection(int direction) -{ - this->direction = direction; -} - -int discoveryMessage::getInitialGateIndex() const -{ - return this->initialGateIndex; -} - -void discoveryMessage::setInitialGateIndex(int initialGateIndex) -{ - this->initialGateIndex = initialGateIndex; -} - -DBresult& discoveryMessage::getDbResult() -{ - return this->dbResult; -} - -void discoveryMessage::setDbResult(const DBresult& dbResult) -{ - this->dbResult = dbResult; -} - -GateVector& discoveryMessage::getGateVector() -{ - return this->gateVector; -} - -void discoveryMessage::setGateVector(const GateVector& gateVector) -{ - this->gateVector = gateVector; -} - -class discoveryMessageDescriptor : public omnetpp::cClassDescriptor -{ - private: - mutable const char **propertynames; - public: - discoveryMessageDescriptor(); - virtual ~discoveryMessageDescriptor(); - - virtual bool doesSupport(omnetpp::cObject *obj) const override; - virtual const char **getPropertyNames() const override; - virtual const char *getProperty(const char *propertyname) const override; - virtual int getFieldCount() const override; - virtual const char *getFieldName(int field) const override; - virtual int findField(const char *fieldName) const override; - virtual unsigned int getFieldTypeFlags(int field) const override; - virtual const char *getFieldTypeString(int field) const override; - virtual const char **getFieldPropertyNames(int field) const override; - virtual const char *getFieldProperty(int field, const char *propertyname) const override; - virtual int getFieldArraySize(void *object, int field) const override; - - virtual const char *getFieldDynamicTypeString(void *object, int field, int i) const override; - virtual std::string getFieldValueAsString(void *object, int field, int i) const override; - virtual bool setFieldValueAsString(void *object, int field, int i, const char *value) const override; - - virtual const char *getFieldStructName(int field) const override; - virtual void *getFieldStructValuePointer(void *object, int field, int i) const override; -}; - -Register_ClassDescriptor(discoveryMessageDescriptor) - -discoveryMessageDescriptor::discoveryMessageDescriptor() : omnetpp::cClassDescriptor("discoveryMessage", "omnetpp::cMessage") -{ - propertynames = nullptr; -} - -discoveryMessageDescriptor::~discoveryMessageDescriptor() -{ - delete[] propertynames; -} - -bool discoveryMessageDescriptor::doesSupport(omnetpp::cObject *obj) const -{ - return dynamic_cast<discoveryMessage *>(obj)!=nullptr; -} - -const char **discoveryMessageDescriptor::getPropertyNames() const -{ - if (!propertynames) { - static const char *names[] = { nullptr }; - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - const char **basenames = basedesc ? basedesc->getPropertyNames() : nullptr; - propertynames = mergeLists(basenames, names); - } - return propertynames; -} - -const char *discoveryMessageDescriptor::getProperty(const char *propertyname) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - return basedesc ? basedesc->getProperty(propertyname) : nullptr; -} - -int discoveryMessageDescriptor::getFieldCount() const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - return basedesc ? 12+basedesc->getFieldCount() : 12; -} - -unsigned int discoveryMessageDescriptor::getFieldTypeFlags(int field) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldTypeFlags(field); - field -= basedesc->getFieldCount(); - } - static unsigned int fieldTypeFlags[] = { - FD_ISEDITABLE, - FD_ISEDITABLE, - FD_ISEDITABLE, - FD_ISEDITABLE, - FD_ISEDITABLE, - FD_ISEDITABLE, - FD_ISEDITABLE, - FD_ISEDITABLE, - FD_ISEDITABLE, - FD_ISEDITABLE, - FD_ISCOMPOUND, - FD_ISCOMPOUND, - }; - return (field>=0 && field<12) ? fieldTypeFlags[field] : 0; -} - -const char *discoveryMessageDescriptor::getFieldName(int field) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldName(field); - field -= basedesc->getFieldCount(); - } - static const char *fieldNames[] = { - "queryID", - "URI_init", - "URI_route", - "feature_type", - "op_code", - "returnCode", - "delta", - "hopCount", - "direction", - "initialGateIndex", - "dbResult", - "gateVector", - }; - return (field>=0 && field<12) ? fieldNames[field] : nullptr; -} - -int discoveryMessageDescriptor::findField(const char *fieldName) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - int base = basedesc ? basedesc->getFieldCount() : 0; - if (fieldName[0]=='q' && strcmp(fieldName, "queryID")==0) return base+0; - if (fieldName[0]=='U' && strcmp(fieldName, "URI_init")==0) return base+1; - if (fieldName[0]=='U' && strcmp(fieldName, "URI_route")==0) return base+2; - if (fieldName[0]=='f' && strcmp(fieldName, "feature_type")==0) return base+3; - if (fieldName[0]=='o' && strcmp(fieldName, "op_code")==0) return base+4; - if (fieldName[0]=='r' && strcmp(fieldName, "returnCode")==0) return base+5; - if (fieldName[0]=='d' && strcmp(fieldName, "delta")==0) return base+6; - if (fieldName[0]=='h' && strcmp(fieldName, "hopCount")==0) return base+7; - if (fieldName[0]=='d' && strcmp(fieldName, "direction")==0) return base+8; - if (fieldName[0]=='i' && strcmp(fieldName, "initialGateIndex")==0) return base+9; - if (fieldName[0]=='d' && strcmp(fieldName, "dbResult")==0) return base+10; - if (fieldName[0]=='g' && strcmp(fieldName, "gateVector")==0) return base+11; - return basedesc ? basedesc->findField(fieldName) : -1; -} - -const char *discoveryMessageDescriptor::getFieldTypeString(int field) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldTypeString(field); - field -= basedesc->getFieldCount(); - } - static const char *fieldTypeStrings[] = { - "int", - "int", - "int", - "string", - "int", - "int", - "int", - "int", - "int", - "int", - "DBresult", - "GateVector", - }; - return (field>=0 && field<12) ? fieldTypeStrings[field] : nullptr; -} - -const char **discoveryMessageDescriptor::getFieldPropertyNames(int field) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldPropertyNames(field); - field -= basedesc->getFieldCount(); - } - switch (field) { - default: return nullptr; - } -} - -const char *discoveryMessageDescriptor::getFieldProperty(int field, const char *propertyname) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldProperty(field, propertyname); - field -= basedesc->getFieldCount(); - } - switch (field) { - default: return nullptr; - } -} - -int discoveryMessageDescriptor::getFieldArraySize(void *object, int field) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldArraySize(object, field); - field -= basedesc->getFieldCount(); - } - discoveryMessage *pp = (discoveryMessage *)object; (void)pp; - switch (field) { - default: return 0; - } -} - -const char *discoveryMessageDescriptor::getFieldDynamicTypeString(void *object, int field, int i) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldDynamicTypeString(object,field,i); - field -= basedesc->getFieldCount(); - } - discoveryMessage *pp = (discoveryMessage *)object; (void)pp; - switch (field) { - default: return nullptr; - } -} - -std::string discoveryMessageDescriptor::getFieldValueAsString(void *object, int field, int i) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldValueAsString(object,field,i); - field -= basedesc->getFieldCount(); - } - discoveryMessage *pp = (discoveryMessage *)object; (void)pp; - switch (field) { - case 0: return long2string(pp->getQueryID()); - case 1: return long2string(pp->getURI_init()); - case 2: return long2string(pp->getURI_route()); - case 3: return oppstring2string(pp->getFeature_type()); - case 4: return long2string(pp->getOp_code()); - case 5: return long2string(pp->getReturnCode()); - case 6: return long2string(pp->getDelta()); - case 7: return long2string(pp->getHopCount()); - case 8: return long2string(pp->getDirection()); - case 9: return long2string(pp->getInitialGateIndex()); - case 10: {std::stringstream out; out << pp->getDbResult(); return out.str();} - case 11: {std::stringstream out; out << pp->getGateVector(); return out.str();} - default: return ""; - } -} - -bool discoveryMessageDescriptor::setFieldValueAsString(void *object, int field, int i, const char *value) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->setFieldValueAsString(object,field,i,value); - field -= basedesc->getFieldCount(); - } - discoveryMessage *pp = (discoveryMessage *)object; (void)pp; - switch (field) { - case 0: pp->setQueryID(string2long(value)); return true; - case 1: pp->setURI_init(string2long(value)); return true; - case 2: pp->setURI_route(string2long(value)); return true; - case 3: pp->setFeature_type((value)); return true; - case 4: pp->setOp_code(string2long(value)); return true; - case 5: pp->setReturnCode(string2long(value)); return true; - case 6: pp->setDelta(string2long(value)); return true; - case 7: pp->setHopCount(string2long(value)); return true; - case 8: pp->setDirection(string2long(value)); return true; - case 9: pp->setInitialGateIndex(string2long(value)); return true; - default: return false; - } -} - -const char *discoveryMessageDescriptor::getFieldStructName(int field) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldStructName(field); - field -= basedesc->getFieldCount(); - } - switch (field) { - case 10: return omnetpp::opp_typename(typeid(DBresult)); - case 11: return omnetpp::opp_typename(typeid(GateVector)); - default: return nullptr; - }; -} - -void *discoveryMessageDescriptor::getFieldStructValuePointer(void *object, int field, int i) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldStructValuePointer(object, field, i); - field -= basedesc->getFieldCount(); - } - discoveryMessage *pp = (discoveryMessage *)object; (void)pp; - switch (field) { - case 10: return (void *)(&pp->getDbResult()); break; - case 11: return (void *)(&pp->getGateVector()); break; - default: return nullptr; - } -} - - diff --git a/src/discoveryMessage_m.h b/src/discoveryMessage_m.h deleted file mode 100644 index 3e9e93decc37fc500a99d2b01ae12bedaba4bd9e..0000000000000000000000000000000000000000 --- a/src/discoveryMessage_m.h +++ /dev/null @@ -1,135 +0,0 @@ -// -// Generated file, do not edit! Created by nedtool 5.6 from discoveryMessage.msg. -// - -#ifndef __DISCOVERYMESSAGE_M_H -#define __DISCOVERYMESSAGE_M_H - -#if defined(__clang__) -# pragma clang diagnostic ignored "-Wreserved-id-macro" -#endif -#include <omnetpp.h> - -// nedtool version check -#define MSGC_VERSION 0x0506 -#if (MSGC_VERSION!=OMNETPP_VERSION) -# error Version mismatch! Probably this file was generated by an earlier version of nedtool: 'make clean' should help. -#endif - - - -// cplusplus {{ - #include <map> - #include <vector> - //using namespace omnetpp; - typedef std::map<int,int> DBresult; - - // this has a problem - - typedef std::vector<omnetpp::cGate *> GateVector; -// }} - -/** - * Class generated from <tt>discoveryMessage.msg:16</tt> by nedtool. - * <pre> - * message discoveryMessage - * { - * // ID assigned to QUERY - * int queryID; - * // this is the identifer of the very first AE generating Discovery QUERY - * int URI_init; - * // this is identifer of in route CSE, sending the message to another CSE - * int URI_route; - * // this is type of Resource CSE is looking for. Values can be "waterValve","thermometer","airStation","ATM","smartLock" - * string feature_type; - * - * //this can be Registration, update, cancellation, Query, Response, Notify - * int op_code; - * // Indicates result of query - * int returnCode; - * // Used with depth of Notify - * int delta; - * // this value lists the number of remaining hopes before end of forwarding QUERY - * int hopCount; - * // this will be UP (customer to provider) or DOWN (Provider to Customer) - * // or SIDE (Sibling to Sibling and Peer to Peer). direction where the message has been sent - * int direction; - * // this is the index of the gate from which the request has been sent originator gate. - * int initialGateIndex; - * //This is the result obtained when looking in the local database - * DBresult dbResult; - * // this is the list that contains the discovery path (list of CSE that forward the query) - * GateVector gateVector; - * - * - * - * } - * </pre> - */ -class discoveryMessage : public ::omnetpp::cMessage -{ - protected: - int queryID; - int URI_init; - int URI_route; - ::omnetpp::opp_string feature_type; - int op_code; - int returnCode; - int delta; - int hopCount; - int direction; - int initialGateIndex; - DBresult dbResult; - GateVector gateVector; - - private: - void copy(const discoveryMessage& other); - - protected: - // protected and unimplemented operator==(), to prevent accidental usage - bool operator==(const discoveryMessage&); - - public: - discoveryMessage(const char *name=nullptr, short kind=0); - discoveryMessage(const discoveryMessage& other); - virtual ~discoveryMessage(); - discoveryMessage& operator=(const discoveryMessage& other); - virtual discoveryMessage *dup() const override {return new discoveryMessage(*this);} - virtual void parsimPack(omnetpp::cCommBuffer *b) const override; - virtual void parsimUnpack(omnetpp::cCommBuffer *b) override; - - // field getter/setter methods - virtual int getQueryID() const; - virtual void setQueryID(int queryID); - virtual int getURI_init() const; - virtual void setURI_init(int URI_init); - virtual int getURI_route() const; - virtual void setURI_route(int URI_route); - virtual const char * getFeature_type() const; - virtual void setFeature_type(const char * feature_type); - virtual int getOp_code() const; - virtual void setOp_code(int op_code); - virtual int getReturnCode() const; - virtual void setReturnCode(int returnCode); - virtual int getDelta() const; - virtual void setDelta(int delta); - virtual int getHopCount() const; - virtual void setHopCount(int hopCount); - virtual int getDirection() const; - virtual void setDirection(int direction); - virtual int getInitialGateIndex() const; - virtual void setInitialGateIndex(int initialGateIndex); - virtual DBresult& getDbResult(); - virtual const DBresult& getDbResult() const {return const_cast<discoveryMessage*>(this)->getDbResult();} - virtual void setDbResult(const DBresult& dbResult); - virtual GateVector& getGateVector(); - virtual const GateVector& getGateVector() const {return const_cast<discoveryMessage*>(this)->getGateVector();} - virtual void setGateVector(const GateVector& gateVector); -}; - -inline void doParsimPacking(omnetpp::cCommBuffer *b, const discoveryMessage& obj) {obj.parsimPack(b);} -inline void doParsimUnpacking(omnetpp::cCommBuffer *b, discoveryMessage& obj) {obj.parsimUnpack(b);} - - -#endif // ifndef __DISCOVERYMESSAGE_M_H - diff --git a/src/omnetpp.ini b/src/omnetpp.ini deleted file mode 100644 index ad4065bf9f47eb8f72d0d43fab42548f7d98f528..0000000000000000000000000000000000000000 --- a/src/omnetpp.ini +++ /dev/null @@ -1,61 +0,0 @@ -[Config SmallNetwork] -network = SmallNetwork -##SmallNetwork.*.sendInterval= exponential(6s) -SmallNetwork.**.delayTime = exponential(3s) - - -[Config SmallNetwork_Alpha_2] -network = SmallNetwork -SmallNetwork.CSE_in[*].alpha = 2 - -[Config BigNetwork] -network = BigNetwork -BigNetwork.**.delayTime = 0 -BigNetwork.**.notification_depth = 2 -BigNetwork.**.queryBufferTTL = 5 - -[Config BigNetworkMultiRun] -network = BigNetwork -BigNetwork.**.delayTime = exponential(3s) -BigNetwork.**.notification_depth = ${1 .. 3 step 1} -repeat = 5 -warmup-period = 20s - - -[Config LargeNetworkOnce] -network = LargeNetwork -LargeNetwork.**.delayTime = 100ms -LargeNetwork.**.notification_depth = 2 -LargeNetwork.**.alpha = 3 -LargeNetwork.**.beta = 3 -warmup-period = 60s -LargeNetwork.**.warmup = 60 -LargeNetwork.cse_in = 20 -LargeNetwork.ae_in = 10 -LargeNetwork.ae_adn = 20 -LargeNetwork.cse_asn = 10 -LargeNetwork.ae_asn = 10 -LargeNetwork.mn_cse = 10 -LargeNetwork.mn_ae = 12 -LargeNetwork.adn = 20 -LargeNetwork.**.maxHops = 10 - - -[Config LargeNetwork] -network = LargeNetwork -LargeNetwork.**.delayTime = 100ms -LargeNetwork.**.notification_depth = ${1 .. 2 step 1} -LargeNetwork.**.alpha = ${1 .. 3 step 2} -warmup-period = 60s -LargeNetwork.**.warmup = 60 -LargeNetwork.cse_in = 20 -LargeNetwork.ae_in = 100 -LargeNetwork.ae_adn = 20 -LargeNetwork.cse_asn = 20 -LargeNetwork.ae_asn = 50 -LargeNetwork.mn_cse = 10 -LargeNetwork.mn_ae = 12 -LargeNetwork.adn = 20 -LargeNetwork.**.maxHops = ${6..10 step 2} -LargeNetwork.**.resource_pool_size = 10000 - diff --git a/src/pingMessage.msg b/src/pingMessage.msg deleted file mode 100644 index 106cd0db76d365a640c937805fa9cec86f116577..0000000000000000000000000000000000000000 --- a/src/pingMessage.msg +++ /dev/null @@ -1,6 +0,0 @@ -message pingMessage -{ - int URI; - string feature_type; - int flag; // 0 for ping 1 for response -} diff --git a/src/pingMessage_m.cpp b/src/pingMessage_m.cpp deleted file mode 100644 index 7ebf7b165d0ef8532bb883c1d50a8d7ad19864bb..0000000000000000000000000000000000000000 --- a/src/pingMessage_m.cpp +++ /dev/null @@ -1,499 +0,0 @@ -// -// Generated file, do not edit! Created by nedtool 5.6 from pingMessage.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 "pingMessage_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(pingMessage) - -pingMessage::pingMessage(const char *name, short kind) : ::omnetpp::cMessage(name,kind) -{ - this->URI = 0; - this->flag = 0; -} - -pingMessage::pingMessage(const pingMessage& other) : ::omnetpp::cMessage(other) -{ - copy(other); -} - -pingMessage::~pingMessage() -{ -} - -pingMessage& pingMessage::operator=(const pingMessage& other) -{ - if (this==&other) return *this; - ::omnetpp::cMessage::operator=(other); - copy(other); - return *this; -} - -void pingMessage::copy(const pingMessage& other) -{ - this->URI = other.URI; - this->feature_type = other.feature_type; - this->flag = other.flag; -} - -void pingMessage::parsimPack(omnetpp::cCommBuffer *b) const -{ - ::omnetpp::cMessage::parsimPack(b); - doParsimPacking(b,this->URI); - doParsimPacking(b,this->feature_type); - doParsimPacking(b,this->flag); -} - -void pingMessage::parsimUnpack(omnetpp::cCommBuffer *b) -{ - ::omnetpp::cMessage::parsimUnpack(b); - doParsimUnpacking(b,this->URI); - doParsimUnpacking(b,this->feature_type); - doParsimUnpacking(b,this->flag); -} - -int pingMessage::getURI() const -{ - return this->URI; -} - -void pingMessage::setURI(int URI) -{ - this->URI = URI; -} - -const char * pingMessage::getFeature_type() const -{ - return this->feature_type.c_str(); -} - -void pingMessage::setFeature_type(const char * feature_type) -{ - this->feature_type = feature_type; -} - -int pingMessage::getFlag() const -{ - return this->flag; -} - -void pingMessage::setFlag(int flag) -{ - this->flag = flag; -} - -class pingMessageDescriptor : public omnetpp::cClassDescriptor -{ - private: - mutable const char **propertynames; - public: - pingMessageDescriptor(); - virtual ~pingMessageDescriptor(); - - virtual bool doesSupport(omnetpp::cObject *obj) const override; - virtual const char **getPropertyNames() const override; - virtual const char *getProperty(const char *propertyname) const override; - virtual int getFieldCount() const override; - virtual const char *getFieldName(int field) const override; - virtual int findField(const char *fieldName) const override; - virtual unsigned int getFieldTypeFlags(int field) const override; - virtual const char *getFieldTypeString(int field) const override; - virtual const char **getFieldPropertyNames(int field) const override; - virtual const char *getFieldProperty(int field, const char *propertyname) const override; - virtual int getFieldArraySize(void *object, int field) const override; - - virtual const char *getFieldDynamicTypeString(void *object, int field, int i) const override; - virtual std::string getFieldValueAsString(void *object, int field, int i) const override; - virtual bool setFieldValueAsString(void *object, int field, int i, const char *value) const override; - - virtual const char *getFieldStructName(int field) const override; - virtual void *getFieldStructValuePointer(void *object, int field, int i) const override; -}; - -Register_ClassDescriptor(pingMessageDescriptor) - -pingMessageDescriptor::pingMessageDescriptor() : omnetpp::cClassDescriptor("pingMessage", "omnetpp::cMessage") -{ - propertynames = nullptr; -} - -pingMessageDescriptor::~pingMessageDescriptor() -{ - delete[] propertynames; -} - -bool pingMessageDescriptor::doesSupport(omnetpp::cObject *obj) const -{ - return dynamic_cast<pingMessage *>(obj)!=nullptr; -} - -const char **pingMessageDescriptor::getPropertyNames() const -{ - if (!propertynames) { - static const char *names[] = { nullptr }; - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - const char **basenames = basedesc ? basedesc->getPropertyNames() : nullptr; - propertynames = mergeLists(basenames, names); - } - return propertynames; -} - -const char *pingMessageDescriptor::getProperty(const char *propertyname) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - return basedesc ? basedesc->getProperty(propertyname) : nullptr; -} - -int pingMessageDescriptor::getFieldCount() const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - return basedesc ? 3+basedesc->getFieldCount() : 3; -} - -unsigned int pingMessageDescriptor::getFieldTypeFlags(int field) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldTypeFlags(field); - field -= basedesc->getFieldCount(); - } - static unsigned int fieldTypeFlags[] = { - FD_ISEDITABLE, - FD_ISEDITABLE, - FD_ISEDITABLE, - }; - return (field>=0 && field<3) ? fieldTypeFlags[field] : 0; -} - -const char *pingMessageDescriptor::getFieldName(int field) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldName(field); - field -= basedesc->getFieldCount(); - } - static const char *fieldNames[] = { - "URI", - "feature_type", - "flag", - }; - return (field>=0 && field<3) ? fieldNames[field] : nullptr; -} - -int pingMessageDescriptor::findField(const char *fieldName) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - int base = basedesc ? basedesc->getFieldCount() : 0; - if (fieldName[0]=='U' && strcmp(fieldName, "URI")==0) return base+0; - if (fieldName[0]=='f' && strcmp(fieldName, "feature_type")==0) return base+1; - if (fieldName[0]=='f' && strcmp(fieldName, "flag")==0) return base+2; - return basedesc ? basedesc->findField(fieldName) : -1; -} - -const char *pingMessageDescriptor::getFieldTypeString(int field) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldTypeString(field); - field -= basedesc->getFieldCount(); - } - static const char *fieldTypeStrings[] = { - "int", - "string", - "int", - }; - return (field>=0 && field<3) ? fieldTypeStrings[field] : nullptr; -} - -const char **pingMessageDescriptor::getFieldPropertyNames(int field) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldPropertyNames(field); - field -= basedesc->getFieldCount(); - } - switch (field) { - default: return nullptr; - } -} - -const char *pingMessageDescriptor::getFieldProperty(int field, const char *propertyname) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldProperty(field, propertyname); - field -= basedesc->getFieldCount(); - } - switch (field) { - default: return nullptr; - } -} - -int pingMessageDescriptor::getFieldArraySize(void *object, int field) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldArraySize(object, field); - field -= basedesc->getFieldCount(); - } - pingMessage *pp = (pingMessage *)object; (void)pp; - switch (field) { - default: return 0; - } -} - -const char *pingMessageDescriptor::getFieldDynamicTypeString(void *object, int field, int i) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldDynamicTypeString(object,field,i); - field -= basedesc->getFieldCount(); - } - pingMessage *pp = (pingMessage *)object; (void)pp; - switch (field) { - default: return nullptr; - } -} - -std::string pingMessageDescriptor::getFieldValueAsString(void *object, int field, int i) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldValueAsString(object,field,i); - field -= basedesc->getFieldCount(); - } - pingMessage *pp = (pingMessage *)object; (void)pp; - switch (field) { - case 0: return long2string(pp->getURI()); - case 1: return oppstring2string(pp->getFeature_type()); - case 2: return long2string(pp->getFlag()); - default: return ""; - } -} - -bool pingMessageDescriptor::setFieldValueAsString(void *object, int field, int i, const char *value) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->setFieldValueAsString(object,field,i,value); - field -= basedesc->getFieldCount(); - } - pingMessage *pp = (pingMessage *)object; (void)pp; - switch (field) { - case 0: pp->setURI(string2long(value)); return true; - case 1: pp->setFeature_type((value)); return true; - case 2: pp->setFlag(string2long(value)); return true; - default: return false; - } -} - -const char *pingMessageDescriptor::getFieldStructName(int field) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldStructName(field); - field -= basedesc->getFieldCount(); - } - switch (field) { - default: return nullptr; - }; -} - -void *pingMessageDescriptor::getFieldStructValuePointer(void *object, int field, int i) const -{ - omnetpp::cClassDescriptor *basedesc = getBaseClassDescriptor(); - if (basedesc) { - if (field < basedesc->getFieldCount()) - return basedesc->getFieldStructValuePointer(object, field, i); - field -= basedesc->getFieldCount(); - } - pingMessage *pp = (pingMessage *)object; (void)pp; - switch (field) { - default: return nullptr; - } -} - - diff --git a/src/pingMessage_m.h b/src/pingMessage_m.h deleted file mode 100644 index 0ead9a69347680f8cc5c9fadf8bbd426e9209c6c..0000000000000000000000000000000000000000 --- a/src/pingMessage_m.h +++ /dev/null @@ -1,69 +0,0 @@ -// -// Generated file, do not edit! Created by nedtool 5.6 from pingMessage.msg. -// - -#ifndef __PINGMESSAGE_M_H -#define __PINGMESSAGE_M_H - -#if defined(__clang__) -# pragma clang diagnostic ignored "-Wreserved-id-macro" -#endif -#include <omnetpp.h> - -// nedtool version check -#define MSGC_VERSION 0x0506 -#if (MSGC_VERSION!=OMNETPP_VERSION) -# error Version mismatch! Probably this file was generated by an earlier version of nedtool: 'make clean' should help. -#endif - - - -/** - * Class generated from <tt>pingMessage.msg:2</tt> by nedtool. - * <pre> - * message pingMessage - * { - * int URI; - * string feature_type; - * int flag; // 0 for ping 1 for response - * } - * </pre> - */ -class pingMessage : public ::omnetpp::cMessage -{ - protected: - int URI; - ::omnetpp::opp_string feature_type; - int flag; - - private: - void copy(const pingMessage& other); - - protected: - // protected and unimplemented operator==(), to prevent accidental usage - bool operator==(const pingMessage&); - - public: - pingMessage(const char *name=nullptr, short kind=0); - pingMessage(const pingMessage& other); - virtual ~pingMessage(); - pingMessage& operator=(const pingMessage& other); - virtual pingMessage *dup() const override {return new pingMessage(*this);} - virtual void parsimPack(omnetpp::cCommBuffer *b) const override; - virtual void parsimUnpack(omnetpp::cCommBuffer *b) override; - - // field getter/setter methods - virtual int getURI() const; - virtual void setURI(int URI); - virtual const char * getFeature_type() const; - virtual void setFeature_type(const char * feature_type); - virtual int getFlag() const; - virtual void setFlag(int flag); -}; - -inline void doParsimPacking(omnetpp::cCommBuffer *b, const pingMessage& obj) {obj.parsimPack(b);} -inline void doParsimUnpacking(omnetpp::cCommBuffer *b, pingMessage& obj) {obj.parsimUnpack(b);} - - -#endif // ifndef __PINGMESSAGE_M_H - diff --git a/src/types.h b/src/types.h deleted file mode 100644 index 3237595c343248735af03596a76e392d86173897..0000000000000000000000000000000000000000 --- a/src/types.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef TYPES_H_ -#define TYPES_H_ - -using namespace omnetpp; - - -typedef int URI; // luigi suggestion - -typedef std::pair<URI, int> queryKey; - -//Routing Entry -/* - * Routing entry represents single entry in semantic routing table. - * In contains mappings with number of AEs by link type. - * */ - -struct RoutingEntryStruct { - // URIs of AEs of the proper type directly connected to said CSE. - std::map<URI,int> database; - // don't forget to take into account filter criteria - std::map<URI,int> CSECustomer; - // key is the CSE_URI Customer - // value is the number of AE feature type - // e.g. (URI_CSE,#23),... - std::map<URI,int> CSEProvider; - // the same but CSE_URI Providers - std::map<URI,int> CSESibling; - // the same but CSE_URI Sibling - std::map<URI,int> CSEPeer; - // the same but CSE_URI Peer - std::map<URI,int> CSEBucket; - // key is the CSE_URI - // value is the % of successful query result -}; - -typedef struct RoutingEntryStruct RoutingEntry; - -/* - * Semantic routing table model. - * - * Represents full routing table model, with mapping by AE type. - * - * */ -typedef std::map<std::string, RoutingEntry> RoutingTable; - - -typedef std::map<URI, std::pair<std::string, int>> GateMapping; - -#endif diff --git a/src/utils.h b/src/utils.h deleted file mode 100644 index 066ee1a77610a3e5596a6557d5305a7ecca9cfba..0000000000000000000000000000000000000000 --- a/src/utils.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef UTILS_H_ -#define UTILS_H_ -// -enum Direction { - UP = 0, DOWN = 1, SIDE_SIBLING = 2, SIDE_PEER = 3, NODIR = 4 -}; -enum PingMessage{ - PING= 0, - PING_RESPONSE = 1 - -}; -enum ResultCode { - SUCCESS = 0, NOT_FOUND = -1 -}; - -enum OpCode { - REGISTRATION = 0, - UPDATE = 1, - CANCELLATION = 2, - QUERY = 3, - PUT = 4, - GET = 5, - REPLY = 6, - RESPONSE = 7, - NOTIFY = 8 -}; - - -#endif