diff --git a/omnet-asd-network-simulation-master.zip b/omnet-asd-network-simulation-master.zip
deleted file mode 100644
index 7df819f059eff44807e3471517c16f00c034b896..0000000000000000000000000000000000000000
Binary files a/omnet-asd-network-simulation-master.zip and /dev/null differ
diff --git a/omnet-asd-network-simulation-master/.DS_Store b/omnet-asd-network-simulation-master/.DS_Store
new file mode 100644
index 0000000000000000000000000000000000000000..27062d960212da3d57d893742438f76aa43f368e
Binary files /dev/null and b/omnet-asd-network-simulation-master/.DS_Store differ
diff --git a/omnet-asd-network-simulation-master/LICENSE.md b/omnet-asd-network-simulation-master/LICENSE.md
new file mode 100644
index 0000000000000000000000000000000000000000..16db630dbbf134220c8b79d50338917ad5c93b4a
--- /dev/null
+++ b/omnet-asd-network-simulation-master/LICENSE.md
@@ -0,0 +1,31 @@
+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/omnet-asd-network-simulation-master/VERSION_HISTORY.md b/omnet-asd-network-simulation-master/VERSION_HISTORY.md
new file mode 100644
index 0000000000000000000000000000000000000000..ffc4d3178bd9ce3bdf10a7bd20477fe7e6914ece
--- /dev/null
+++ b/omnet-asd-network-simulation-master/VERSION_HISTORY.md
@@ -0,0 +1,2 @@
+- July 2021: 		Version 3.6.4.1: 	Official release, associated with TASK 3 of STF 589
+- October 2021: 	Version 4.0.0: 		New release (follow up STF 589) by INRIA (Luigi Liquori and Behrad Shirmard)
\ No newline at end of file
diff --git a/omnet-asd-network-simulation-master/asd_v3.6.4.1/.DS_Store b/omnet-asd-network-simulation-master/asd_v3.6.4.1/.DS_Store
new file mode 100644
index 0000000000000000000000000000000000000000..2b67016555536f1fcca8f05d31a4777e6f5e2db8
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v3.6.4.1/.DS_Store differ
diff --git a/omnet-asd-network-simulation-master/asd_v3.6.4.1/.gitkeep b/omnet-asd-network-simulation-master/asd_v3.6.4.1/.gitkeep
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/omnet-asd-network-simulation-master/asd_v3.6.4.1/README.md b/omnet-asd-network-simulation-master/asd_v3.6.4.1/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..516a12b063345c0846d340b450d903a46ec33475
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/README.md
@@ -0,0 +1,39 @@
+This repository contains the source code of a simulator developed 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 SmartM2M/oneM2M framework.
+
+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.
+
+The current repository contains two folders : 
+ 
+*  *simulation_results* is a well-named folder that contains an extract of the different simulation runs. 
+*  *src* contains the source code of the OMNeT++ simulator and the different topologies (*.ned* files). 
+* The development has been conducted with OMNeT++ V5.6.2. 
+
+Here is a fast install procedure to run the simulator: 
+
+1-Download and install 
+- OMNeT++ on https://omnetpp.org.
+- the code contained in the *src* directory 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 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 (SmallNetwork, bigNetwork, BigNetwork multi runs, LargeNetwork...)
+
+Enjoy! 
+
+The STF589 teams 
diff --git a/omnet-asd-network-simulation-master/asd_v3.6.4.1/simulation_results/.DS_Store b/omnet-asd-network-simulation-master/asd_v3.6.4.1/simulation_results/.DS_Store
new file mode 100644
index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v3.6.4.1/simulation_results/.DS_Store differ
diff --git a/omnet-asd-network-simulation-master/asd_v3.6.4.1/simulation_results/.gitkeep b/omnet-asd-network-simulation-master/asd_v3.6.4.1/simulation_results/.gitkeep
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/omnet-asd-network-simulation-master/asd_v3.6.4.1/simulation_results/1-BigNetwork_nearby.mp4 b/omnet-asd-network-simulation-master/asd_v3.6.4.1/simulation_results/1-BigNetwork_nearby.mp4
new file mode 100644
index 0000000000000000000000000000000000000000..f5d55a51df86476d6b669755f715df52fe21114d
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v3.6.4.1/simulation_results/1-BigNetwork_nearby.mp4 differ
diff --git a/omnet-asd-network-simulation-master/asd_v3.6.4.1/simulation_results/BigNetwork_mixed_results.mp4 b/omnet-asd-network-simulation-master/asd_v3.6.4.1/simulation_results/BigNetwork_mixed_results.mp4
new file mode 100644
index 0000000000000000000000000000000000000000..4275da4cc41dd5d2e81b34b6bed7817f77b0e551
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v3.6.4.1/simulation_results/BigNetwork_mixed_results.mp4 differ
diff --git a/omnet-asd-network-simulation-master/asd_v3.6.4.1/simulation_results/BigNetwork_multiple_result.mp4 b/omnet-asd-network-simulation-master/asd_v3.6.4.1/simulation_results/BigNetwork_multiple_result.mp4
new file mode 100644
index 0000000000000000000000000000000000000000..11f8218cdd79db488eb3969142f2f002aa81126a
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v3.6.4.1/simulation_results/BigNetwork_multiple_result.mp4 differ
diff --git a/omnet-asd-network-simulation-master/asd_v3.6.4.1/simulation_results/BigNetwork_no_results.mp4 b/omnet-asd-network-simulation-master/asd_v3.6.4.1/simulation_results/BigNetwork_no_results.mp4
new file mode 100644
index 0000000000000000000000000000000000000000..6d05ded7f6474a9e11986a59486061817fbe1565
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v3.6.4.1/simulation_results/BigNetwork_no_results.mp4 differ
diff --git a/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/.gitignore b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d607ee3831bfaa53af2b8d508a9077a15a7901c5
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/.gitignore
@@ -0,0 +1 @@
+/CSE_Network_V3.6.3.exe
diff --git a/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/.qtenvrc b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/.qtenvrc
new file mode 100644
index 0000000000000000000000000000000000000000..105c1e4addef1ff05b701b29069270711ad7f153
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/.qtenvrc
@@ -0,0 +1,15 @@
+[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/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/AE.cpp b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/AE.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..41ece21b5e0b2243eb0727cd1ad144a78fcbd6f6
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/AE.cpp
@@ -0,0 +1,139 @@
+#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/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/AE.h b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/AE.h
new file mode 100644
index 0000000000000000000000000000000000000000..bafd3e47769dcc76dabb1dce69af5d6de6330508
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/AE.h
@@ -0,0 +1,59 @@
+#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/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/AEMessage.msg b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/AEMessage.msg
new file mode 100644
index 0000000000000000000000000000000000000000..4f23312b2d1a263c6383ce59c79824abca93ab00
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/AEMessage.msg
@@ -0,0 +1,23 @@
+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/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/AEMessage_m.cpp b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/AEMessage_m.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..377fbd83295c50370e6d89ebf8f2ae0521dfb026
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/AEMessage_m.cpp
@@ -0,0 +1,559 @@
+//
+// 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/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/AEMessage_m.h b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/AEMessage_m.h
new file mode 100644
index 0000000000000000000000000000000000000000..fbfb6f9bc7a66a78d82d76cb5d2db882a27c493e
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/AEMessage_m.h
@@ -0,0 +1,94 @@
+//
+// 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/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/CSE.cpp b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/CSE.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a3e40d5119379749439d86bb8db2cd13aeca8ab4
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/CSE.cpp
@@ -0,0 +1,869 @@
+#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/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/CSE.h b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/CSE.h
new file mode 100644
index 0000000000000000000000000000000000000000..d67708602ccd32ccdf09183088810e7355eb8c7c
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/CSE.h
@@ -0,0 +1,153 @@
+#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/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/CSE_Network_V3.6.4.1 b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/CSE_Network_V3.6.4.1
new file mode 100644
index 0000000000000000000000000000000000000000..6233525f71061ae0308747665e6cdf8e1af3887e
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/CSE_Network_V3.6.4.1 differ
diff --git a/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/CSE_Network_V3.6.4.1_dbg b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/CSE_Network_V3.6.4.1_dbg
new file mode 100644
index 0000000000000000000000000000000000000000..f898a2f3f110e06b401b32b453620e35855cb232
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/CSE_Network_V3.6.4.1_dbg differ
diff --git a/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/LargeNetwork.ned b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/LargeNetwork.ned
new file mode 100644
index 0000000000000000000000000000000000000000..698871c090e8d25db671ce8a01d0b6d764108be5
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/LargeNetwork.ned
@@ -0,0 +1,94 @@
+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/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/Makefile b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..ad3ba12f9ce443234b2ad3f210a7c8871f33b9f6
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/Makefile
@@ -0,0 +1,134 @@
+#
+# 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/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/Notes.md b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/Notes.md
new file mode 100644
index 0000000000000000000000000000000000000000..c23e7e9c9dfc49d1f99673b147e601aa8985f213
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/Notes.md
@@ -0,0 +1,9 @@
+# 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/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/ResourceDiscovery.ex_ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/ResourceDiscovery.ex_
new file mode 100644
index 0000000000000000000000000000000000000000..06d2cf958dc23e043b1908ceb6ee7377dec35c36
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/ResourceDiscovery.ex_ differ
diff --git a/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/ResourceDiscovery_dbg.ex_ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/ResourceDiscovery_dbg.ex_
new file mode 100644
index 0000000000000000000000000000000000000000..5b229ef248c501a152fa83e5621db2b178e3ccf5
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/ResourceDiscovery_dbg.ex_ differ
diff --git a/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/SmallNetwork.ned b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/SmallNetwork.ned
new file mode 100644
index 0000000000000000000000000000000000000000..d17e0aae9ecd1dd0abfd6d7f8a904e0e4494b775
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/SmallNetwork.ned
@@ -0,0 +1,54 @@
+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/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/big_network.ned b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/big_network.ned
new file mode 100644
index 0000000000000000000000000000000000000000..3a2beb5df0bb2c9c642a4edd3a0403149d0ed8e9
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/big_network.ned
@@ -0,0 +1,131 @@
+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/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/components.ned b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/components.ned
new file mode 100644
index 0000000000000000000000000000000000000000..013862d596ed0e3d282f0fc59f0920c0ed7ab96e
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/components.ned
@@ -0,0 +1,46 @@
+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/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/declarative.h b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/declarative.h
new file mode 100644
index 0000000000000000000000000000000000000000..d69a8944b134d8364719595841367ac19aae2ad8
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/declarative.h
@@ -0,0 +1,16 @@
+#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/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/discoveryMessage.msg b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/discoveryMessage.msg
new file mode 100644
index 0000000000000000000000000000000000000000..18120aa7159608885550ecbea19d303ff5aa2f8e
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/discoveryMessage.msg
@@ -0,0 +1,46 @@
+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/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/discoveryMessage_m.cpp b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/discoveryMessage_m.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..66e5a04398634f428d2871c9fee4c734848745d0
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/discoveryMessage_m.cpp
@@ -0,0 +1,679 @@
+//
+// 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/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/discoveryMessage_m.h b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/discoveryMessage_m.h
new file mode 100644
index 0000000000000000000000000000000000000000..3e9e93decc37fc500a99d2b01ae12bedaba4bd9e
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/discoveryMessage_m.h
@@ -0,0 +1,135 @@
+//
+// 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/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/omnetpp.ini b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/omnetpp.ini
new file mode 100644
index 0000000000000000000000000000000000000000..ad4065bf9f47eb8f72d0d43fab42548f7d98f528
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/omnetpp.ini
@@ -0,0 +1,61 @@
+[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/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/pingMessage.msg b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/pingMessage.msg
new file mode 100644
index 0000000000000000000000000000000000000000..106cd0db76d365a640c937805fa9cec86f116577
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/pingMessage.msg
@@ -0,0 +1,6 @@
+message pingMessage
+{
+    int URI;
+    string feature_type;
+    int flag;  // 0 for ping   1 for response
+}
diff --git a/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/pingMessage_m.cpp b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/pingMessage_m.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7ebf7b165d0ef8532bb883c1d50a8d7ad19864bb
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/pingMessage_m.cpp
@@ -0,0 +1,499 @@
+//
+// 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/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/pingMessage_m.h b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/pingMessage_m.h
new file mode 100644
index 0000000000000000000000000000000000000000..0ead9a69347680f8cc5c9fadf8bbd426e9209c6c
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/pingMessage_m.h
@@ -0,0 +1,69 @@
+//
+// 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/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/types.h b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/types.h
new file mode 100644
index 0000000000000000000000000000000000000000..3237595c343248735af03596a76e392d86173897
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/types.h
@@ -0,0 +1,49 @@
+#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/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/utils.h b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/utils.h
new file mode 100644
index 0000000000000000000000000000000000000000..066ee1a77610a3e5596a6557d5305a7ecca9cfba
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v3.6.4.1/src/utils.h
@@ -0,0 +1,29 @@
+#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
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/.DS_Store b/omnet-asd-network-simulation-master/asd_v4.0.0/.DS_Store
new file mode 100644
index 0000000000000000000000000000000000000000..3eb55927b1d2b73fb135f3be14fefbeec947af41
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v4.0.0/.DS_Store differ
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/.gitkeep b/omnet-asd-network-simulation-master/asd_v4.0.0/.gitkeep
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/README.md b/omnet-asd-network-simulation-master/asd_v4.0.0/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..bf8d82b8bc2beacc7a2f3d6f682e755e2221d525
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/README.md
@@ -0,0 +1,66 @@
+This repository contains the source code of the ETSI oneM2M Advanced Semantic Discovery protocol simulator developed in OMNeT++ with the goal of providing a *proof of concept* and a *performance evaluation* of the powerful resource discovery that will be included in the release 4 of oneM2M standard
+(see https://member.onem2m.org/Application/documentapp/downloadLatestRevision/default.aspx?docID=34123).
+
+This work has been conducted in the STF 589 (see https://portal.etsi.org/STF/STFs/STF-HomePages/STF589) of SmartM2M/oneM2M: 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 
+(https://www.etsi.org/deliver/etsi_tr/103700_103799/103716/01.01.01_60/tr_103716v010101p.pdf)
+
+Version History:
+
+**ASDQ version 4.0.0**
+- Capability to describe different network topology with respect to the previous version: AsdqNetwork.ned and AsdqNetworkSub.ned with separated *.ini* files;
+- Capability to run simulation on a Cluster platform;
+- Reduced number of notification messages which were flooding the network in previous release;
+- Optimised *.cpp* source code for modules to run smoothly;
+- Modified *.cpp* and *.ned* and *.ini* files to run without graphical user interface (GUI); 
+- New notification method for AEs in order to be registered in CSEs;
+- New registration method in advanced routing tables embedded in each CSE; 
+- Modified method for semantic discovery and query based on four multicast parameters related to the Semantic Discovery Agreements (SDA) between CSEs (CustomerToProvider, ProviderToCustomer, PeerToPeer, SiblingToSibling), those latter agreement strongly inspired to the BGP Internet protocol.
+
+**Here is the installation procedure and how to run the simulation:** 
+
+1-Download and Install OMNeT++
+- Open https://omnetpp.org;
+- Download the installation files for Linux/Win/Mac;
+- Extract the files;
+- Inside the *doc* folder open the InstallGuide.pdf file and follow the instructions. 
+
+2-Download the simulation source codes.
+- Open ETSI Labs website;
+- Go to the IoT > SmartM2M-Semantic and Query > OMNET-ASD-Network-Simulation > Repository;
+- And download the desired version and source codes.
+
+2-Start the OMNeT++ platform and follow the steps below.
+- 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. 
+
+3-Build your project.
+- Click right on the package -> Build Project.
+
+4-Run a simulation.
+- Choose the desired *.ini* file as configuration file; 
+- Run the simulation.
+- You can run the simulation either with or without OMNeT++ GUI;
+- For more information refer to the OMNeT++ SimulationManual.pdf inside the doc folder located in *omnetpp* folder. 
+
+**How to run OMNeT++ on a Cluster environment and How to compile the project:**
+
+- Download the OMNeT++ installation source file;
+- Without extracting the file, upload it on the target Cluster;
+- Extract the file on cluster based on the which OS your cluster is using;
+- Configure OMNeT++ on cluster by following the steps in installation guide file;
+- Compile the simulation by *make* command;
+- Run the simulation in command line mode by uploading and passing the compiled file on cluster to the OMNeT++;
+- Every Cluster has its own commands for passing the job to the nodes on cluster, so follow the target cluster user manual.
+
+Enjoy! 
+
+Luigi Liquori and Behrad Shirmard
+INRIA Sophia Antipolis-Méditerranée and Université Côte d'Azur.
+Contact: Luigi.Liquori@inria.fr and b.shirmard@gmail.com
+
+
+ 
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/simulation_results/.DS_Store b/omnet-asd-network-simulation-master/asd_v4.0.0/simulation_results/.DS_Store
new file mode 100644
index 0000000000000000000000000000000000000000..e567ccda5a98105cbbb9f7ccccba207383c0be87
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v4.0.0/simulation_results/.DS_Store differ
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/simulation_results/.gitkeep b/omnet-asd-network-simulation-master/asd_v4.0.0/simulation_results/.gitkeep
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/.DS_Store b/omnet-asd-network-simulation-master/asd_v4.0.0/src/.DS_Store
new file mode 100644
index 0000000000000000000000000000000000000000..89f917bb1fe104982866f4ad7908a02773ede618
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v4.0.0/src/.DS_Store differ
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/AE.cpp b/omnet-asd-network-simulation-master/asd_v4.0.0/src/AE.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..11d2af5463bed15199e73be86af63bac7d9654d5
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/AE.cpp
@@ -0,0 +1,158 @@
+#include "AE.h"
+#include "discoveryMessage_m.h"
+#include "utils.h"
+#include "types.h"
+
+AE::AE()
+{
+    // Set the pointer to nullptr, so that the destructor won't crash
+    // even if initialize() doesn't get called because of a runtime
+    // error or user cancellation during the startup process.
+//    canMsg = regMsg = queryMsg = nullptr;
+}
+
+AE::~AE()
+{
+    // Dispose of dynamically allocated the objects
+//    delete canMsg;
+//    delete regMsg;
+//    delete queryMsg;
+}
+
+
+int AE::numInitStages() const {
+    return 2;
+}
+
+
+void AE::initialize(int stage) {
+
+    numOfFound = 0;
+    canMsg = regMsg = queryMsg = nullptr;
+    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::registration() {
+//    this->queryIndex = 0;
+    // 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 and feature type
+    data = uniform(0, 100);
+    int ran_number = std::rand() % 100;
+    EV << "Random Number" << ran_number << "\n";
+
+    for (auto it : resourceFrequency) {
+        auto ft = it.first;
+        auto range = it.second;
+        if (ran_number >= range.first && ran_number < range.second) {
+            feature_type = ft;
+            break;
+        }
+    }
+
+    EV << "AE with Id number " << URI << " is " << feature_type << endl;
+    // send an AE message with op_code Registration
+        sendAEMessage(REGISTRATION);
+
+}
+
+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 (getIndex() == 10) {
+        // send the AE message with op_code QUERY
+        EV << "AE of URI 28 is Searching for waterValve" << "\n";
+        sendAEMessage(QUERY);
+    }
+}
+
+
+
+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: {
+        canMsg = new AEMessage("C");
+        // set the message fields
+        canMsg->setURI(URI);
+        canMsg->setData(data);
+        canMsg->setOp_code(CANCELLATION);
+        canMsg->setFeature_type(feature_type.c_str());
+        sendDelayed(canMsg, simTime() + 5, "cse$o");
+        break;
+    }
+
+    case REGISTRATION: {
+        regMsg = new AEMessage("Reg");
+        // set the message fields
+        regMsg->setURI(URI);
+        regMsg->setFeature_type(feature_type.c_str());
+//        regMsg->setFeature_type("waterValve");
+        regMsg->setData(data);
+        regMsg->setOp_code(REGISTRATION);
+        send(regMsg, "cse$o");
+        break;
+
+
+    }
+    case QUERY: {
+        queryMsg = new AEMessage("Q");
+        queryMsg->setURI(URI);
+//        queryMsg->setQueryID(queryIndex++);
+        queryMsg->setFeature_type("waterValve");
+        queryMsg->setOp_code(QUERY);
+        sendDelayed(queryMsg, simTime() + 2, "cse$o");
+        break;
+    }
+
+    default:
+        break;
+    }
+}
+
+void AE::handleMessage(cMessage *msg) {
+
+        //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";
+
+        if (responseMsg->getReturnCode() == ResultCode::SUCCESS) {
+//        NumOfReplies++;
+        numOfFound++;
+        EV << "Resource of type " << responseMsg->getFeature_type()
+                  << " found in URI " << responseMsg->getURI_init() << "\n";
+
+        }
+
+        if (responseMsg->getReturnCode() == ResultCode::NOT_FOUND) {
+
+            EV << "Resource of type " << responseMsg->getFeature_type()
+                  << " not found in URI " << responseMsg->getURI_init() << "\n";
+        }
+//    EV << "Number of Resource of type found: " << NumOfReplies << "\n";
+
+        delete responseMsg;
+}
+
+
+
+void AE::finish()
+{
+    if(getIndex()==10){
+        EV << "The number of requested Resources are found is: " << numOfFound << endl;
+    }
+}
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/AE.h b/omnet-asd-network-simulation-master/asd_v4.0.0/src/AE.h
new file mode 100644
index 0000000000000000000000000000000000000000..75b711da401d970fc07b7fac83684eafb92e42ad
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/AE.h
@@ -0,0 +1,70 @@
+#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
+{
+
+public:
+    AE();
+    virtual ~AE();
+
+  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;
+      virtual void finish() override;
+
+  private:
+
+      AEMessage *canMsg;
+      AEMessage *regMsg;
+      AEMessage *queryMsg;
+
+
+      long numOfFound;
+      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"
+      };
+
+      std::map<std::string, std::pair<int, int>> resourceFrequency =
+      {
+              {"thermometer", {0, 30}},
+              {"airStation", {30, 60}},
+              {"ATM", {60, 80}},
+              {"smartLock", {80, 95}},
+              {"waterValve", {95, 100}},
+      };
+
+
+};
+
+
+Define_Module(AE);
+
+
+#endif
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/AEMessage.msg b/omnet-asd-network-simulation-master/asd_v4.0.0/src/AEMessage.msg
new file mode 100644
index 0000000000000000000000000000000000000000..2835f9943b5dc169364a5675d22471a4827a9eb8
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/AEMessage.msg
@@ -0,0 +1,21 @@
+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       
+}
+
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/AsdqNetwork.ini b/omnet-asd-network-simulation-master/asd_v4.0.0/src/AsdqNetwork.ini
new file mode 100644
index 0000000000000000000000000000000000000000..aa808d07286b9978cdbe1a4cd2c978fda574bfc1
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/AsdqNetwork.ini
@@ -0,0 +1,8 @@
+#[Config MainNetwork]
+[General]
+network = AsdqNetwork
+#AsdqNetwork.**.delayTime = exponential(3s)
+
+#[Config SubNetwork]
+#network = AsdqNetworkSub
+#AsdqNetworkSub.**.delayTime = exponential(3s)
\ No newline at end of file
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/AsdqNetwork.ned b/omnet-asd-network-simulation-master/asd_v4.0.0/src/AsdqNetwork.ned
new file mode 100644
index 0000000000000000000000000000000000000000..4debe5798470ada9569f17ecf3079f6f35ef32e9
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/AsdqNetwork.ned
@@ -0,0 +1,90 @@
+
+
+//==================================================NETWORK==========================================================
+
+
+network AsdqNetwork
+{       
+    types:
+        channel Channel extends ned.DelayChannel
+        {
+            delay = 100ms;
+        }
+        
+    submodules:
+        IN_CSE[100]: CSE {
+            parameters:
+                @display("p=700,600,ring");
+        }
+
+        MN_CSE[2400]: CSE;
+        ASN_CSE[110000]: CSE;
+               
+        IN_AE[300]: AE;
+        ADN_AE[12000]: AE;
+        ASN_AE[200000]: AE;
+        MN_AE[24000]: AE;
+
+    connections allowunconnected:
+
+        for i=0..98, for j=(i+1)..99 {
+            IN_CSE[i].sibling++ <--> Channel <--> IN_CSE[j].sibling++; //top-level mesh IN_CSE network (Extendable)
+        }
+
+        for i=0..99, for j=0..9999 {
+            IN_CSE[i].ae++ <--> Channel <--> ADN_AE[j].cse if j>=(i*100) && j<(i*100)+100; // ADN_AE which are connected to top level IN_CSEs (Extendable) and 100 here is the number of ADN_AEs for each IN_CSE
+        }
+
+        for i=0..99, for j=0..299 {
+            IN_CSE[i].ae++ <--> Channel <--> IN_AE[j].cse if j>=(i*3) && j<(i*3)+3; // IN_AE which are connected to top level IN_CSEs (Extendable) and 3 here is the number of IN_AEs for each IN_CSE
+        }
+
+        for i=0..99, for j=0..9999 {
+            IN_CSE[i].customer++ <--> Channel <--> ASN_CSE[j].provider++ if j>=(i*100) && j<(i*100)+100; // ASN_CSE which are connected to top level IN_CSEs (Extendable) and 100 here is the number of ASN_CSE for each IN_CSE
+        }
+
+        for i=0..4999, for j=0..99999 {
+            ASN_CSE[i].ae++ <--> Channel <--> ASN_AE[j].cse if j>=(i*20) && j<(i*20)+20;
+        }
+
+        for i=0..99, for j=0..1999 {
+            IN_CSE[i].customer++ <--> Channel <--> MN_CSE[j].provider++ if j>=(i*20) && j<(i*20)+20; // MN_CSE which are connected to top level IN_CSEs (Extendable) and 20 here is the number of MN_CSE for each IN_CSE
+        }
+
+        for i=0..199, for j=2000..2399 {                                          // 10% of MN_CSEs have another level of MN_CSEs
+            MN_CSE[i*10].customer++ <--> Channel <--> MN_CSE[j].provider++ if j>=(2*i)+2000 && j<(i*2)+2002;
+        }
+       
+//        for i=10..11 {
+//            MN_CSE[i].peer++ <--> Channel <--> MN_CSE[i+1].peer++;
+//            MN_CSE[12].peer++ <--> Channel <--> MN_CSE[10].peer++;
+//        }
+//        
+//        for i=13..14 {
+//            MN_CSE[i].peer++ <--> Channel <--> MN_CSE[i+1].peer++;
+//            MN_CSE[15].peer++ <--> Channel <--> MN_CSE[13].peer++;
+//        }
+//        
+//        for i=16..17 {
+//            MN_CSE[i].peer++ <--> Channel <--> MN_CSE[i+1].peer++;
+//            MN_CSE[18].peer++ <--> Channel <--> MN_CSE[16].peer++;
+//        }
+        
+
+        for i=0..2399, for j=0..23999 {
+            MN_CSE[i].ae++ <--> Channel <--> MN_AE[j].cse if j>=(i*10) && j<(i*10)+10;
+        }
+
+        for i=0..999, for j=10000..109999 {
+            MN_CSE[i].provider++ <--> Channel <--> ASN_CSE[j].customer++ if j>=(i*100)+10000 && j<(i*100)+10100;
+        }
+        
+        for i=0..99999, for j=100000..199999 {
+            ASN_CSE[i+10000].ae++ <--> Channel <--> ASN_AE[j].cse if j>=(i*2)+100000 && j<(i*2)+100002;
+        }
+        
+        for i=0..999, for j=10000..11999 {
+            MN_CSE[i].ae++ <--> Channel <--> ADN_AE[j].cse if j>=(i*2)+10000 && j<(i*2)+10002;
+        } 
+        
+}
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/AsdqNetworkSub.ini b/omnet-asd-network-simulation-master/asd_v4.0.0/src/AsdqNetworkSub.ini
new file mode 100644
index 0000000000000000000000000000000000000000..b21eab1c16775ce80f63f036b74fb826e8c1b6a0
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/AsdqNetworkSub.ini
@@ -0,0 +1,2 @@
+[General]
+network = AsdqNetworkSub
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/AsdqNetworkSub.ned b/omnet-asd-network-simulation-master/asd_v4.0.0/src/AsdqNetworkSub.ned
new file mode 100644
index 0000000000000000000000000000000000000000..b23cb4889436bdfb8fa424b41ba54bb24b12a035
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/AsdqNetworkSub.ned
@@ -0,0 +1,89 @@
+
+//==================================================NETWORK==========================================================
+
+
+network AsdqNetworkSub
+{       
+    types:
+        channel Channel extends ned.DelayChannel
+        {
+            delay = 100ms;
+        }
+        
+    submodules:
+        IN_CSE[5]: CSE {
+            parameters:
+                @display("p=700,600,ring");
+        }
+
+        MN_CSE[12]: CSE;
+        ASN_CSE[75]: CSE;
+               
+        IN_AE[10]: AE;
+        ADN_AE[70]: AE;
+        ASN_AE[550]: AE;
+        MN_AE[60]: AE;
+
+    connections allowunconnected:
+
+        for i=0..3, for j=(i+1)..4 {
+            IN_CSE[i].sibling++ <--> Channel <--> IN_CSE[j].sibling++; //top-level mesh IN_CSE network (Extendable)
+        }
+
+        for i=0..4, for j=0..49 {
+            IN_CSE[i].ae++ <--> Channel <--> ADN_AE[j].cse if j>=(i*10) && j<(i*10)+10; // ADN_AE which are connected to top level IN_CSEs (Extendable) and 100 here is the number of ADN_AEs for each IN_CSE
+        }
+
+        for i=0..4, for j=0..9 {
+            IN_CSE[i].ae++ <--> Channel <--> IN_AE[j].cse if j>=(i*2) && j<(i*2)+2; // IN_AE which are connected to top level IN_CSEs (Extendable) and 3 here is the number of IN_AEs for each IN_CSE
+        }
+
+        for i=0..4, for j=0..49 {
+            IN_CSE[i].customer++ <--> Channel <--> ASN_CSE[j].provider++ if j>=(i*10) && j<(i*10)+10; // ASN_CSE which are connected to top level IN_CSEs (Extendable) and 100 here is the number of ASN_CSE for each IN_CSE
+        }
+
+        for i=0..49, for j=0..499 {
+            ASN_CSE[i].ae++ <--> Channel <--> ASN_AE[j].cse if j>=(i*10) && j<(i*10)+10;
+        }
+
+        for i=0..4, for j=0..9 {
+            IN_CSE[i].customer++ <--> Channel <--> MN_CSE[j].provider++ if j>=(i*2) && j<(i*2)+2; // MN_CSE which are connected to top level IN_CSEs (Extendable) and 20 here is the number of MN_CSE for each IN_CSE
+        }
+
+        for i=10..11 {                                          // 10% of MN_CSEs have another level of MN_CSEs
+            MN_CSE[6].customer++ <--> Channel <--> MN_CSE[i].provider++;
+        }
+       
+//        for i=10..11 {
+//            MN_CSE[i].peer++ <-->prompt Channel <--> MN_CSE[i+1].peer++;
+//            MN_CSE[12].peer++ <--> Channel <--> MN_CSE[10].peer++;
+//        }
+//        
+//        for i=13..14 {
+//            MN_CSE[i].peer++ <--> Channel <--> MN_CSE[i+1].peer++;
+//            MN_CSE[15].peer++ <--> Channel <--> MN_CSE[13].peer++;
+//        }
+//        
+//        for i=16..17 {
+//            MN_CSE[i].peer++ <--> Channel <--> MN_CSE[i+1].peer++;
+//            MN_CSE[18].peer++ <--> Channel <--> MN_CSE[16].peer++;
+//        }
+        
+
+        for i=0..11, for j=0..59 {
+            MN_CSE[i].ae++ <--> Channel <--> MN_AE[j].cse if j>=(i*5) && j<(i*5)+5;
+        }
+
+        for i=0..4, for j=50..74 {
+            MN_CSE[i].provider++ <--> Channel <--> ASN_CSE[j].customer++ if j>=(i*5)+50 && j<(i*5)+55;
+        }
+        
+        for i=0..74, for j=500..549 {
+            ASN_CSE[i+50].ae++ <--> Channel <--> ASN_AE[j].cse if j>=(i*2)+500 && j<(i*2)+502;
+        }
+        
+        for i=0..9, for j=50..69 {
+            MN_CSE[i].ae++ <--> Channel <--> ADN_AE[j].cse if j>=(i*2)+50 && j<(i*2)+52;
+        } 
+        
+}
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/CSE.cpp b/omnet-asd-network-simulation-master/asd_v4.0.0/src/CSE.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..59691ff3424e58d5bf84ee481c74289567491725
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/CSE.cpp
@@ -0,0 +1,830 @@
+#include "CSE.h"
+#include "declarative.h"
+#include <algorithm>
+
+// Constructor for Messages
+CSE::CSE() {
+        // Set the pointer to nullptr, so that the destructor won't crash
+        // even if initialize() doesn't get called because of a runtime
+        // error or user cancellation during the startup process.
+//    queryMsg = NotifMsg = ResMsg = nullptr;
+}
+
+// Destructor for Messages
+CSE::~CSE() {
+    // Dispose of dynamically allocated the objects
+//    delete queryMsg;
+//    delete NotifMsg;
+//    delete ResMsg;
+}
+
+
+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";
+    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");
+    this->delay = par("delayTime");
+
+    notif = 0;
+    WATCH(notif);
+}
+
+/*
+ * 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";
+
+    if (msg->getHopCount() <= 0) {
+        bubble("TTL expired");
+        //Respond to the URI_init that the discovery ends
+        msg->setOp_code(RESPONSE);
+        //You extract from the top of the list the gate that has to be used
+        EV << "TTL expired so we generate a response message \n";
+        generateResponseMessage(msg, ResultCode::NOT_FOUND);
+        return;
+    }
+
+    // Decreasing the hop count
+    msg->setHopCount(msg->getHopCount() - 1);
+
+//    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");
+////            sendDelayed(msg->dup(), delay, gateName.c_str(), gateindex);
+//            send(msg->dup(), 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);
+        successful =
+                !successful ?
+                        multicast("sibling", msg, this->multicastGamma) : true;
+        break;
+    }
+    case SIDE_SIBLING: {
+        successful = multicast("sibling", msg, this->multicastGamma);
+        successful &= multicast("customer", msg, this->multicastAlpha);
+        break;
+    }
+    case SIDE_PEER: {
+        break;
+    }
+    case UP: {
+        successful = multicast("provider", msg, this->multicastBeta);
+        successful =
+                !successful ?
+                        multicast("sibling", msg, this->multicastGamma) : true;
+        successful &= multicast("customer", msg, this->multicastDelta);
+        break;
+    }
+    default:
+        break;
+    }
+
+    if (!successful) {
+        bubble("No result");
+        generateResponseMessage(msg, ResultCode::NOT_FOUND);
+    }
+}
+
+/*
+ * seenQuery is used to check if the query processed previously or not.
+ * 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;
+    }
+    std::map<int, int> dbres;
+    dbres[res] = 0;
+    EV << "DB Lookup Successful" << "\n";
+    msg->setDbResult(dbres);
+
+    generateResponseMessage(msg);
+}
+
+/*
+ * handleDiscoveryMessage is used to handle `discoveryMessage`.
+*/
+void CSE::handleDiscoveryMessage(cMessage *msg) {
+
+    EV << "Entering into the CSE" << "\n";
+    discoveryMessage *discoveryMsg = check_and_cast<discoveryMessage*>(msg);
+    EV << "The Message type is : " << discoveryMsg->getOp_code() << "\n";
+
+// switch on 3 possible opcodes: Notify, Query and Response
+
+    int op_code = discoveryMsg->getOp_code();
+
+    switch (op_code) {
+    case NOTIFY:
+        notif++;
+        updatingRoutingTableAndNotify(discoveryMsg);
+        break;
+    case QUERY:
+    {
+        EV << "Message is a 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";
+        tempGateVector.clear();
+
+        handleQuery(discoveryMsg);
+
+        break;
+    }
+    case RESPONSE:
+        EV << "Message is type response so no new gate added\n";
+        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 message.\n";
+    std::vector<cGate*> tempGateVector;
+//  getting the return gate and index of return gate
+    tempGateVector = msg->getGateVector();
+    const char *returnGate = tempGateVector.back()->getName();
+    int returnIndex = tempGateVector.back()->getIndex();
+//  removing the used return gate
+    tempGateVector.pop_back();
+    msg->setGateVector(tempGateVector);
+    tempGateVector.clear();
+//  sending msg to the return gate
+    send(msg->dup(), returnGate, returnIndex);
+}
+
+/*
+ * handleAEMessage is used to process message from Application Entities (AEs)
+ * Messages are registration or cancellation or query.
+ */
+void CSE::handleAEMessage(cMessage *msg) {
+
+    AEMessage *aeMsg = check_and_cast<AEMessage*>(msg);
+
+    // Getting the type of message from AE
+    int op_code = aeMsg->getOp_code();  // op_code contains the type of message
+
+    switch (op_code) {
+    case REGISTRATION: {
+
+        registrationAndNotification(aeMsg);
+        break;
+    }
+    case CANCELLATION: {
+
+        cancelationAndNotification(aeMsg);
+        break;
+    }
+    case QUERY: {
+        // if it is a query msg first we look up the loacl devices then we create a discovery msg and to start ASDQ
+        localDBLookup(aeMsg);
+        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 for registering AEs in their parent CSE.
+ * And, notifying the other CSEs about existence of the AEs.
+ */
+void CSE::registrationAndNotification(AEMessage *msg) {
+
+    // we extract the feature_type; URI_route; and data from the AEmessage
+    std::string feature_type = msg->getFeature_type();
+
+    int URI_route = msg->getURI();
+
+//    int data = msg->getData();
+
+    // bubble is used to show the feature type on graphical mode when AE is registering in CSE.
+    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::cancelationAndNotification(AEMessage *msg) {
+
+    std::string feature_type = msg->getFeature_type();
+    int URI_route = msg->getURI();
+
+    deregisterAE(feature_type, URI_route);
+
+    notifyCSE(feature_type, -1);
+}
+
+
+// This method (registerAE) is for registering AEs in their parents CSEs local databases.
+
+void CSE::registerAE(std::string feature_type, URI uri) {
+
+  // auto entry = getOrCreateRoutingEntry(feature_type);
+
+    this->SemanticRoutingTable[feature_type].database.insert(std::pair<URI, int>(uri, 1));
+
+//    this->SemanticRoutingTable[feature_type] = RoutingStruct;
+
+//  This EV is just for testing the size of database contents :)
+    EV << "SemanticRoutingTable[feature_type].database.size() is " << this->SemanticRoutingTable[feature_type].database.size() << '\n';
+
+}
+
+// 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);
+
+    this->SemanticRoutingTable[feature_type].database.erase(this->SemanticRoutingTable[feature_type].database.find(uri));
+
+//    this->SemanticRoutingTable[feature_type] = RoutingStruct;
+
+//  This EV is just for testing the size of database contents :)
+    EV << "SemanticRoutingTable[feature_type].database.size() after deregitering is " << this->SemanticRoutingTable[feature_type].database.size() << '\n';
+}
+
+/*
+ * handleMessage is an entry point for messages in OMNeT++
+ */
+void CSE::handleMessage(cMessage *msg) {
+
+// Separating two kinds of messages, AEMessage and DiscoveryMessage
+// AEMessages are coming from AEs and Discovery messages are coming from other CSEs
+
+    if (strcmp(msg->getSenderModule()->getClassName(), "AE") == 0) {
+
+        handleAEMessage(msg);
+    }
+
+    else if(strcmp(msg->getSenderModule()->getClassName(), "CSE") == 0) {
+
+        handleDiscoveryMessage(msg);
+    }
+
+}
+
+/*
+ * generateResponseMessage is used to generate query response 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);
+
+    handleDiscoveryMessage(responseMsg);
+}
+
+/*
+ *This Method is creatinging a discovery message
+ */
+void CSE::generateDiscoveryMessage(AEMessage *msg) {
+// these data should not change during the routing between CSEs
+
+// we created a discovery message
+    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(maxHops);
+
+// we set the direction UP
+//    queryMsg->setDirection(UP);
+
+// create a omnet vector of type cGate* named gateVector
+    std::vector<cGate*> gateVector;
+// You put on top of the list  the name of the gates to use for the return path (getOtherHalf)
+    gateVector.push_back(msg->getArrivalGate()->getOtherHalf());
+// We  update the query msg with this vector
+    queryMsg->setGateVector(gateVector);
+    gateVector.clear();
+
+// Sending query message to processQuery in order to forward to the other CSEs in valley-free manner.
+    processQuery(queryMsg);
+//    handleDiscoveryMessage(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, it means we have the gate which we want to direct the message.
+    if (t <= 0) {
+        return false;
+    }
+
+    // if it detects the size of the target gate or 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 the gate which have all the target gates
+
+    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);
+        send(msg, 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;
+    }
+    //otherwise
+    if (entry.CSEBucket.size() <= 100) {
+        entry.CSEBucket.insert(entry.CSEBucket.begin(),
+                msg->getSenderModuleId());
+        return entry.CSEBucket;
+    }
+    // otherwise
+    int i = entry.CSEBucket.back();
+    auto it = this->Gates[i];
+    int gateIndex = it.second;
+    std::string gateName = it.first + "$o";
+
+
+    // ping message
+    send(ping, gateName.c_str(), gateIndex);
+
+    // after receiving ping
+    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;
+}
+
+/*
+ * updateRoutingTableAndNotify is used to update sematic routing table
+ * and notify other CSE neighbors (e.g. Customer, Peer, Sibling, Provider)
+ */
+void CSE::updatingRoutingTableAndNotify(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:
+        this->SemanticRoutingTable[feature_type].CSECustomer[cse] += delta;
+        break;
+    case DOWN:
+        this->SemanticRoutingTable[feature_type].CSEProvider[cse] += delta;
+        break;
+    case SIDE_SIBLING:
+        this->SemanticRoutingTable[feature_type].CSESibling[cse] += delta;
+        break;
+    case SIDE_PEER:
+        this->SemanticRoutingTable[feature_type].CSEPeer[cse] += delta;
+        break;
+    }
+
+//    notification depth reached
+    if (msg->getHopCount() >= NotificationDepth) {
+        EV << "notification depth reached\n";
+        return;
+    }
+
+    EV << "Redirecting notify\n";
+
+    // notify
+    msg->setHopCount(msg->getHopCount() + 1);
+    msg->setURI_route(this->Uri);
+    notifyNeighbors(msg->dup());
+}
+
+// This method (notifyCSE) is used for creating and broadcasting notification message to the neighbors with limited depth (NotificationDepth).
+
+void CSE::notifyCSE(std::string feature_type, int delta) {
+
+//  creating notification message to send to the neighbors.
+    auto msg = generateMessage(NOTIFY);
+
+    msg->setFeature_type(feature_type.c_str());
+    msg->setHopCount(NotificationDepth);
+    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.
+ */
+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 upstream\n";
+    multicast("provider", msg);
+
+    delete msg;
+}
+
+/* This method look up for the devices in the CSE in which there is AE which starts the query
+ * and returns the result directly
+ */
+void CSE::localDBLookup(AEMessage *msg) {
+
+    auto feature_type = msg->getFeature_type();
+
+    if(this->SemanticRoutingTable[feature_type].database.size() != 0){
+
+        auto localresponseMsg = generateMessage(RESPONSE);
+        localresponseMsg->setDirection(NODIR);
+        localresponseMsg->setFeature_type(feature_type);
+        localresponseMsg->setURI_init(getId());
+//        int lres = this->SemanticRoutingTable[feature_type].database.begin()->first;
+//        std::map<int, int> ldbres;
+//        ldbres[lres] = 0;
+//        EV << "DB Lookup Successful" << "\n";
+//        localresponseMsg->setDbResult(ldbres);
+        localresponseMsg->setReturnCode(ResultCode::SUCCESS);
+        send(localresponseMsg, msg->getArrivalGate()->getOtherHalf()->getId());
+        return;
+    }
+    else {
+        auto localresponseMsg = generateMessage(RESPONSE);
+        localresponseMsg->setDirection(NODIR);
+        localresponseMsg->setFeature_type(feature_type);
+        localresponseMsg->setURI_init(getId());
+        localresponseMsg->setReturnCode(ResultCode::NOT_FOUND);
+        send(localresponseMsg, msg->getArrivalGate()->getOtherHalf()->getId());
+        return;
+    }
+}
+
+/*
+ * 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
+// if we find the data correspond to the feature_type
+    if (this->SemanticRoutingTable[feature_type].database.size() != 0) {
+        bubble("Success in database");
+        return this->SemanticRoutingTable[feature_type].database.begin()->first;
+    }
+    else if(this->SemanticRoutingTable[feature_type].CSECustomer.size()!=0) {
+        bubble("Success in customer");
+        return this->SemanticRoutingTable[feature_type].CSECustomer.begin()->first;
+    }
+    else if(this->SemanticRoutingTable[feature_type].CSEPeer.size()!=0) {
+            bubble("Success in peer");
+            return this->SemanticRoutingTable[feature_type].CSEPeer.begin()->first;
+    }
+    else if(this->SemanticRoutingTable[feature_type].CSESibling.size()!=0) {
+            bubble("Success in sibiling");
+            return this->SemanticRoutingTable[feature_type].CSESibling.begin()->first;
+    }
+    else if(this->SemanticRoutingTable[feature_type].CSEProvider.size()!=0) {
+            bubble("Success in provider");
+            return this->SemanticRoutingTable[feature_type].CSEProvider.begin()->first;
+    }
+    else
+        return NOT_FOUND;
+}
+
+/*
+ * generateMessage is used to generate message of specified type.
+ */
+discoveryMessage *CSE::generateMessage(int op_code) {
+    switch (op_code) {
+
+    case RESPONSE: {
+        int URI_route = getId();
+        char msgname[20];
+        sprintf(msgname, "Rsp");
+        // Create message object and set source and destination field.
+        ResMsg = new discoveryMessage(msgname);
+        //msg->setPayload("thermometer");
+        ResMsg->setOp_code(RESPONSE);
+        ResMsg->setURI_route(URI_route);
+        return ResMsg;
+        break;
+    }
+    case NOTIFY: {
+        int URI_route = getId();
+        char msgname[20];
+        sprintf(msgname, "Notif");
+        // Create message object and set source and destination field.
+        NotifMsg = new discoveryMessage(msgname);
+        //msg->setPayload("thermometer");
+        NotifMsg->setDirection(DOWN);
+        NotifMsg->setOp_code(NOTIFY);
+        NotifMsg->setURI_route(URI_route);
+        NotifMsg->setURI_init(URI_route);
+        return NotifMsg;
+        break;
+    }
+    default:
+        break;
+    }
+    return nullptr;
+}
+
+
+//void CSE::orderingMap(std::map<int, int>) {
+//    return;
+//}
+
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/CSE.h b/omnet-asd-network-simulation-master/asd_v4.0.0/src/CSE.h
new file mode 100644
index 0000000000000000000000000000000000000000..69efded8383e9fcae2bad04f0b06c4692f1fc26c
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/CSE.h
@@ -0,0 +1,105 @@
+#ifndef CSE_H_
+#define CSE_H_
+
+#include <stdio.h>
+#include <string.h>
+#include <omnetpp.h>
+#include "discoveryMessage_m.h"
+#include "AEMessage_m.h"
+#include <list>
+#include "utils.h"
+#include "types.h"
+
+using namespace omnetpp;
+
+class CSE: public cSimpleModule {
+
+public:
+    CSE();
+    virtual ~CSE();
+
+    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:
+
+    discoveryMessage *queryMsg;
+    discoveryMessage *ResMsg;
+    discoveryMessage *NotifMsg;
+
+    int notif;
+    bool seenQuery(discoveryMessage *msg);
+    // application specific for exploring and updating the local database
+    URI DBLookup(discoveryMessage *msg);
+    void localDBLookup(AEMessage *msg);
+    void generateDiscoveryMessage(AEMessage *msg);
+    void generateResponseMessage(discoveryMessage *discoveryMsg, ResultCode result = ResultCode::SUCCESS);
+
+    // not yet implemented
+    // TODO this function organize the map by value-ordering
+//    void orderingMap(std::map<int, int>);
+
+    // Routing table update
+    void cancelationAndNotification(AEMessage *msg);
+    void registrationAndNotification(AEMessage *msg);
+    RoutingEntry mustGetRoutingEntry(std::string feature_type);
+    void registerAE(std::string feature_type, URI uri);
+    void deregisterAE(std::string feature_type, URI uri);
+    void updatingRoutingTableAndNotify(discoveryMessage *msg);
+    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 handleDiscoveryMessage(cMessage *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);
+
+    std::map<URI, std::tuple<int, simtime_t, int>> schedulerMap;
+
+    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;
+
+    simtime_t delay;
+
+};
+Define_Module(CSE);
+
+#endif
+
+
+
+
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/Components.ned b/omnet-asd-network-simulation-master/asd_v4.0.0/src/Components.ned
new file mode 100644
index 0000000000000000000000000000000000000000..acff034ad497feb2f89a7a6d869807bccafa5d73
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/Components.ned
@@ -0,0 +1,35 @@
+
+//===================================================COMPONENTS==================================================
+
+simple CSE
+{
+        parameters:
+        @signal[packet_size](type="long");
+        @statistic[throughput](title="total_number_of_packets"; source="packet_size"; record=vector,last);
+        @display("i=abstract/router,blue,9");
+        int notification_depth = default(1);
+        int alpha = default(0); // Sidestream multicast parameter (p2p)   ?? Peer
+        int beta = default(1);  // Upstream multicast parameter (c2p)     ?? Provider
+        int delta = default(1); // Downstream multicast parameter (p2c)   ?? Customer
+        int gamma = default(1); // Sidestream multicast parameter (s2s)   ?? Sibiling
+        int queryBufferTTL = default(2);
+        int maxHops = default(10);
+        //volatile double sendInterval @unit(s);
+        volatile double delayTime = default(0) @unit(s);
+
+    gates:
+        // TODO Peering links handling has to be implemented
+        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");
+    gates:
+        inout cse @loose;
+}
\ No newline at end of file
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/Makefile b/omnet-asd-network-simulation-master/asd_v4.0.0/src/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..65f7d7ec244abafa6be4849454e24acaa67f7df8
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/Makefile
@@ -0,0 +1,133 @@
+#
+# OMNeT++/OMNEST Makefile for asdqv4.0
+#
+# This file was generated with the command:
+#  opp_makemake -f --deep -O out -I.
+#
+
+# Name of target to be created (-o option)
+TARGET = asdqv4.0$(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 = -I.
+
+# Additional object and library files to link with
+EXTRA_OBJS =
+
+# Additional libraries (-L, -l options)
+LIBS =
+
+# Output directory
+PROJECT_OUTPUT_DIR = out
+PROJECTRELATIVE_PATH =
+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
+
+# Message files
+MSGFILES = \
+    AEMessage.msg \
+    discoveryMessage.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/omnet-asd-network-simulation-master/asd_v4.0.0/src/SmallNetwork.ned b/omnet-asd-network-simulation-master/asd_v4.0.0/src/SmallNetwork.ned
new file mode 100644
index 0000000000000000000000000000000000000000..fb0cd39fc7e458e0ddbb3301108d400f2f044140
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/SmallNetwork.ned
@@ -0,0 +1,42 @@
+network SmallNetwork
+{
+    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/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdq_dbg b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdq_dbg
new file mode 100755
index 0000000000000000000000000000000000000000..4432bc86ef39a326ccc064e9f9468a29d759479a
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdq_dbg differ
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/.DS_Store b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/.DS_Store
new file mode 100644
index 0000000000000000000000000000000000000000..fc43498828ed19006d2386d273c6415e7f727bca
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/.DS_Store differ
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/.cmdenv-log b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/.cmdenv-log
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/.cproject b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/.cproject
new file mode 100644
index 0000000000000000000000000000000000000000..ce36ff5b5ecc326fb65053fbc00c034cd2e8fa7e
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/.cproject
@@ -0,0 +1,210 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+    	
+    <storageModule moduleId="org.eclipse.cdt.core.settings">
+        		
+        <cconfiguration id="org.omnetpp.cdt.gnu.config.debug.1187371914">
+            			
+            <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.omnetpp.cdt.gnu.config.debug.1187371914" moduleId="org.eclipse.cdt.core.settings" name="debug">
+                				
+                <externalSettings/>
+                				
+                <extensions>
+                    					
+                    <extension id="org.eclipse.cdt.core.MachO64" point="org.eclipse.cdt.core.BinaryParser"/>
+                    					
+                    <extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
+                    					
+                    <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+                    					
+                    <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                    					
+                    <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                    					
+                    <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                    					
+                    <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+                    					
+                    <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                    				
+                </extensions>
+                			
+            </storageModule>
+            			
+            <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+                				
+                <configuration artifactName="${ProjName}" buildProperties="" description="" id="org.omnetpp.cdt.gnu.config.debug.1187371914" name="debug" parent="org.omnetpp.cdt.gnu.config.debug">
+                    					
+                    <folderInfo id="org.omnetpp.cdt.gnu.config.debug.1187371914." name="/" resourcePath="">
+                        						
+                        <toolChain id="org.omnetpp.cdt.gnu.toolchain.debug.328772127" name="C++ Toolchain for OMNeT++" superClass="org.omnetpp.cdt.gnu.toolchain.debug">
+                            							
+                            <targetPlatform binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.MachO64;org.eclipse.cdt.core.PE" id="org.omnetpp.cdt.targetPlatform.562203742" isAbstract="false" name="Windows, Linux, Mac" osList="win32,linux,macosx" superClass="org.omnetpp.cdt.targetPlatform"/>
+                            							
+                            <builder id="org.omnetpp.cdt.gnu.builder.debug.1721569894" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="OMNeT++ Make Builder (opp_makemake)" superClass="org.omnetpp.cdt.gnu.builder.debug"/>
+                            							
+                            <tool id="cdt.managedbuild.tool.gnu.archiver.base.281700131" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
+                            							
+                            <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.807728990" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base">
+                                								
+                                <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1839806746" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+                                							
+                            </tool>
+                            							
+                            <tool id="cdt.managedbuild.tool.gnu.c.compiler.base.1601816840" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base">
+                                								
+                                <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1453488305" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+                                							
+                            </tool>
+                            							
+                            <tool id="cdt.managedbuild.tool.gnu.c.linker.base.1338782930" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/>
+                            							
+                            <tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.494022034" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base">
+                                								
+                                <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1526477897" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+                                    									
+                                    <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+                                    									
+                                    <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+                                    								
+                                </inputType>
+                                							
+                            </tool>
+                            							
+                            <tool id="cdt.managedbuild.tool.gnu.assembler.base.1016432359" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base">
+                                								
+                                <inputType id="cdt.managedbuild.tool.gnu.assembler.input.839825061" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+                                							
+                            </tool>
+                            						
+                        </toolChain>
+                        					
+                    </folderInfo>
+                    				
+                </configuration>
+                			
+            </storageModule>
+            			
+            <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+            		
+        </cconfiguration>
+        		
+        <cconfiguration id="org.omnetpp.cdt.gnu.config.release.1049349140">
+            			
+            <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.omnetpp.cdt.gnu.config.release.1049349140" moduleId="org.eclipse.cdt.core.settings" name="release">
+                				
+                <externalSettings/>
+                				
+                <extensions>
+                    					
+                    <extension id="org.eclipse.cdt.core.MachO64" point="org.eclipse.cdt.core.BinaryParser"/>
+                    					
+                    <extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
+                    					
+                    <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+                    					
+                    <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                    					
+                    <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                    					
+                    <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                    					
+                    <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+                    					
+                    <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                    				
+                </extensions>
+                			
+            </storageModule>
+            			
+            <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+                				
+                <configuration artifactName="${ProjName}" buildProperties="" description="" id="org.omnetpp.cdt.gnu.config.release.1049349140" name="release" parent="org.omnetpp.cdt.gnu.config.release">
+                    					
+                    <folderInfo id="org.omnetpp.cdt.gnu.config.release.1049349140." name="/" resourcePath="">
+                        						
+                        <toolChain id="org.omnetpp.cdt.gnu.toolchain.release.911739157" name="C++ Toolchain for OMNeT++" superClass="org.omnetpp.cdt.gnu.toolchain.release">
+                            							
+                            <targetPlatform binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.MachO64;org.eclipse.cdt.core.PE" id="org.omnetpp.cdt.targetPlatform.259250382" isAbstract="false" name="Windows, Linux, Mac" osList="win32,linux,macosx" superClass="org.omnetpp.cdt.targetPlatform"/>
+                            							
+                            <builder id="org.omnetpp.cdt.gnu.builder.release.389046792" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="OMNeT++ Make Builder (opp_makemake)" superClass="org.omnetpp.cdt.gnu.builder.release"/>
+                            							
+                            <tool id="cdt.managedbuild.tool.gnu.archiver.base.1315710695" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
+                            							
+                            <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.1874557047" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base">
+                                								
+                                <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1773827044" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+                                							
+                            </tool>
+                            							
+                            <tool id="cdt.managedbuild.tool.gnu.c.compiler.base.2091606835" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base">
+                                								
+                                <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.134341012" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+                                							
+                            </tool>
+                            							
+                            <tool id="cdt.managedbuild.tool.gnu.c.linker.base.1755527148" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/>
+                            							
+                            <tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.475406291" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base">
+                                								
+                                <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.2060126824" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+                                    									
+                                    <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+                                    									
+                                    <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+                                    								
+                                </inputType>
+                                							
+                            </tool>
+                            							
+                            <tool id="cdt.managedbuild.tool.gnu.assembler.base.2119951778" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base">
+                                								
+                                <inputType id="cdt.managedbuild.tool.gnu.assembler.input.704884139" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+                                							
+                            </tool>
+                            						
+                        </toolChain>
+                        					
+                    </folderInfo>
+                    				
+                </configuration>
+                			
+            </storageModule>
+            			
+            <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+            		
+        </cconfiguration>
+        	
+    </storageModule>
+    	
+    <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+        		
+        <project id="asdq.org.omnetpp.cdt.omnetppProjectType.464329341" name="OMNeT++ Simulation" projectType="org.omnetpp.cdt.omnetppProjectType"/>
+        	
+    </storageModule>
+    	
+    <storageModule moduleId="scannerConfiguration">
+        		
+        <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+        		
+        <scannerConfigBuildInfo instanceId="org.omnetpp.cdt.gnu.config.release.1049349140">
+            			
+            <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.omnetpp.cdt.OmnetppGCCPerProjectProfile"/>
+            		
+        </scannerConfigBuildInfo>
+        		
+        <scannerConfigBuildInfo instanceId="org.omnetpp.cdt.gnu.config.debug.1187371914">
+            			
+            <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.omnetpp.cdt.OmnetppGCCPerProjectProfile"/>
+            		
+        </scannerConfigBuildInfo>
+        	
+    </storageModule>
+    	
+    <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+    	
+    <storageModule moduleId="refreshScope"/>
+    	
+    <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
+    
+</cproject>
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/.oppbuildspec b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/.oppbuildspec
new file mode 100644
index 0000000000000000000000000000000000000000..eb9400458b89924a8d7b35d88fabd7e6c4123364
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/.oppbuildspec
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<buildspec version="4.0">
+    <dir makemake-options="--deep -O out -I. --meta:recurse --meta:export-include-path --meta:use-exported-include-paths --meta:export-library --meta:use-exported-libs --meta:feature-cflags --meta:feature-ldflags" path="." type="makemake"/>
+</buildspec>
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/.project b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/.project
new file mode 100644
index 0000000000000000000000000000000000000000..ccb7cac06ee3b4d7c2b4cd45046e998d87ab08e3
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/.project
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>asdq 4.0</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.omnetpp.cdt.MakefileBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.omnetpp.scave.builder.vectorfileindexer</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+			<triggers>clean,full,incremental,</triggers>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+			<triggers>full,incremental,</triggers>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.cdt.core.cnature</nature>
+		<nature>org.eclipse.cdt.core.ccnature</nature>
+		<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+		<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+		<nature>org.omnetpp.main.omnetppnature</nature>
+	</natures>
+</projectDescription>
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/.qtenvrc b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/.qtenvrc
new file mode 100644
index 0000000000000000000000000000000000000000..b6f6785e418380f5a50b7adbb8abd89532d69f78
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/.qtenvrc
@@ -0,0 +1,15 @@
+[General]
+last-configname=MainNetwork
+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=14454.39770745928
+run-max-animation-speed=nan
+run-max-playback-speed=100
+run-min-animation-speed=nan
+run-min-playback-speed=0.01
+run-playback-speed=0.6165950018614822
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/.settings/language.settings.xml b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/.settings/language.settings.xml
new file mode 100644
index 0000000000000000000000000000000000000000..80c8741452e6fc09c3bfa278ea33666fe8d772db
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/.settings/language.settings.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<project>
+    	
+    <configuration id="org.omnetpp.cdt.gnu.config.debug.1187371914" name="debug">
+        		
+        <extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
+            			
+            <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
+            			
+            <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
+            			
+            <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
+            			
+            <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="185835312145810450" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
+                				
+                <language-scope id="org.eclipse.cdt.core.gcc"/>
+                				
+                <language-scope id="org.eclipse.cdt.core.g++"/>
+                			
+            </provider>
+            		
+        </extension>
+        	
+    </configuration>
+    	
+    <configuration id="org.omnetpp.cdt.gnu.config.release.1049349140" name="release">
+        		
+        <extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
+            			
+            <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
+            			
+            <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
+            			
+            <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
+            			
+            <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="185835312145810450" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
+                				
+                <language-scope id="org.eclipse.cdt.core.gcc"/>
+                				
+                <language-scope id="org.eclipse.cdt.core.g++"/>
+                			
+            </provider>
+            		
+        </extension>
+        	
+    </configuration>
+    
+</project>
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/AE.cpp b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/AE.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..11d2af5463bed15199e73be86af63bac7d9654d5
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/AE.cpp
@@ -0,0 +1,158 @@
+#include "AE.h"
+#include "discoveryMessage_m.h"
+#include "utils.h"
+#include "types.h"
+
+AE::AE()
+{
+    // Set the pointer to nullptr, so that the destructor won't crash
+    // even if initialize() doesn't get called because of a runtime
+    // error or user cancellation during the startup process.
+//    canMsg = regMsg = queryMsg = nullptr;
+}
+
+AE::~AE()
+{
+    // Dispose of dynamically allocated the objects
+//    delete canMsg;
+//    delete regMsg;
+//    delete queryMsg;
+}
+
+
+int AE::numInitStages() const {
+    return 2;
+}
+
+
+void AE::initialize(int stage) {
+
+    numOfFound = 0;
+    canMsg = regMsg = queryMsg = nullptr;
+    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::registration() {
+//    this->queryIndex = 0;
+    // 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 and feature type
+    data = uniform(0, 100);
+    int ran_number = std::rand() % 100;
+    EV << "Random Number" << ran_number << "\n";
+
+    for (auto it : resourceFrequency) {
+        auto ft = it.first;
+        auto range = it.second;
+        if (ran_number >= range.first && ran_number < range.second) {
+            feature_type = ft;
+            break;
+        }
+    }
+
+    EV << "AE with Id number " << URI << " is " << feature_type << endl;
+    // send an AE message with op_code Registration
+        sendAEMessage(REGISTRATION);
+
+}
+
+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 (getIndex() == 10) {
+        // send the AE message with op_code QUERY
+        EV << "AE of URI 28 is Searching for waterValve" << "\n";
+        sendAEMessage(QUERY);
+    }
+}
+
+
+
+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: {
+        canMsg = new AEMessage("C");
+        // set the message fields
+        canMsg->setURI(URI);
+        canMsg->setData(data);
+        canMsg->setOp_code(CANCELLATION);
+        canMsg->setFeature_type(feature_type.c_str());
+        sendDelayed(canMsg, simTime() + 5, "cse$o");
+        break;
+    }
+
+    case REGISTRATION: {
+        regMsg = new AEMessage("Reg");
+        // set the message fields
+        regMsg->setURI(URI);
+        regMsg->setFeature_type(feature_type.c_str());
+//        regMsg->setFeature_type("waterValve");
+        regMsg->setData(data);
+        regMsg->setOp_code(REGISTRATION);
+        send(regMsg, "cse$o");
+        break;
+
+
+    }
+    case QUERY: {
+        queryMsg = new AEMessage("Q");
+        queryMsg->setURI(URI);
+//        queryMsg->setQueryID(queryIndex++);
+        queryMsg->setFeature_type("waterValve");
+        queryMsg->setOp_code(QUERY);
+        sendDelayed(queryMsg, simTime() + 2, "cse$o");
+        break;
+    }
+
+    default:
+        break;
+    }
+}
+
+void AE::handleMessage(cMessage *msg) {
+
+        //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";
+
+        if (responseMsg->getReturnCode() == ResultCode::SUCCESS) {
+//        NumOfReplies++;
+        numOfFound++;
+        EV << "Resource of type " << responseMsg->getFeature_type()
+                  << " found in URI " << responseMsg->getURI_init() << "\n";
+
+        }
+
+        if (responseMsg->getReturnCode() == ResultCode::NOT_FOUND) {
+
+            EV << "Resource of type " << responseMsg->getFeature_type()
+                  << " not found in URI " << responseMsg->getURI_init() << "\n";
+        }
+//    EV << "Number of Resource of type found: " << NumOfReplies << "\n";
+
+        delete responseMsg;
+}
+
+
+
+void AE::finish()
+{
+    if(getIndex()==10){
+        EV << "The number of requested Resources are found is: " << numOfFound << endl;
+    }
+}
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/AE.h b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/AE.h
new file mode 100644
index 0000000000000000000000000000000000000000..75b711da401d970fc07b7fac83684eafb92e42ad
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/AE.h
@@ -0,0 +1,70 @@
+#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
+{
+
+public:
+    AE();
+    virtual ~AE();
+
+  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;
+      virtual void finish() override;
+
+  private:
+
+      AEMessage *canMsg;
+      AEMessage *regMsg;
+      AEMessage *queryMsg;
+
+
+      long numOfFound;
+      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"
+      };
+
+      std::map<std::string, std::pair<int, int>> resourceFrequency =
+      {
+              {"thermometer", {0, 30}},
+              {"airStation", {30, 60}},
+              {"ATM", {60, 80}},
+              {"smartLock", {80, 95}},
+              {"waterValve", {95, 100}},
+      };
+
+
+};
+
+
+Define_Module(AE);
+
+
+#endif
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/AEMessage.msg b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/AEMessage.msg
new file mode 100644
index 0000000000000000000000000000000000000000..2835f9943b5dc169364a5675d22471a4827a9eb8
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/AEMessage.msg
@@ -0,0 +1,21 @@
+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       
+}
+
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/AsdqNetwork.ini b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/AsdqNetwork.ini
new file mode 100644
index 0000000000000000000000000000000000000000..aa808d07286b9978cdbe1a4cd2c978fda574bfc1
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/AsdqNetwork.ini
@@ -0,0 +1,8 @@
+#[Config MainNetwork]
+[General]
+network = AsdqNetwork
+#AsdqNetwork.**.delayTime = exponential(3s)
+
+#[Config SubNetwork]
+#network = AsdqNetworkSub
+#AsdqNetworkSub.**.delayTime = exponential(3s)
\ No newline at end of file
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/AsdqNetwork.ned b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/AsdqNetwork.ned
new file mode 100644
index 0000000000000000000000000000000000000000..4debe5798470ada9569f17ecf3079f6f35ef32e9
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/AsdqNetwork.ned
@@ -0,0 +1,90 @@
+
+
+//==================================================NETWORK==========================================================
+
+
+network AsdqNetwork
+{       
+    types:
+        channel Channel extends ned.DelayChannel
+        {
+            delay = 100ms;
+        }
+        
+    submodules:
+        IN_CSE[100]: CSE {
+            parameters:
+                @display("p=700,600,ring");
+        }
+
+        MN_CSE[2400]: CSE;
+        ASN_CSE[110000]: CSE;
+               
+        IN_AE[300]: AE;
+        ADN_AE[12000]: AE;
+        ASN_AE[200000]: AE;
+        MN_AE[24000]: AE;
+
+    connections allowunconnected:
+
+        for i=0..98, for j=(i+1)..99 {
+            IN_CSE[i].sibling++ <--> Channel <--> IN_CSE[j].sibling++; //top-level mesh IN_CSE network (Extendable)
+        }
+
+        for i=0..99, for j=0..9999 {
+            IN_CSE[i].ae++ <--> Channel <--> ADN_AE[j].cse if j>=(i*100) && j<(i*100)+100; // ADN_AE which are connected to top level IN_CSEs (Extendable) and 100 here is the number of ADN_AEs for each IN_CSE
+        }
+
+        for i=0..99, for j=0..299 {
+            IN_CSE[i].ae++ <--> Channel <--> IN_AE[j].cse if j>=(i*3) && j<(i*3)+3; // IN_AE which are connected to top level IN_CSEs (Extendable) and 3 here is the number of IN_AEs for each IN_CSE
+        }
+
+        for i=0..99, for j=0..9999 {
+            IN_CSE[i].customer++ <--> Channel <--> ASN_CSE[j].provider++ if j>=(i*100) && j<(i*100)+100; // ASN_CSE which are connected to top level IN_CSEs (Extendable) and 100 here is the number of ASN_CSE for each IN_CSE
+        }
+
+        for i=0..4999, for j=0..99999 {
+            ASN_CSE[i].ae++ <--> Channel <--> ASN_AE[j].cse if j>=(i*20) && j<(i*20)+20;
+        }
+
+        for i=0..99, for j=0..1999 {
+            IN_CSE[i].customer++ <--> Channel <--> MN_CSE[j].provider++ if j>=(i*20) && j<(i*20)+20; // MN_CSE which are connected to top level IN_CSEs (Extendable) and 20 here is the number of MN_CSE for each IN_CSE
+        }
+
+        for i=0..199, for j=2000..2399 {                                          // 10% of MN_CSEs have another level of MN_CSEs
+            MN_CSE[i*10].customer++ <--> Channel <--> MN_CSE[j].provider++ if j>=(2*i)+2000 && j<(i*2)+2002;
+        }
+       
+//        for i=10..11 {
+//            MN_CSE[i].peer++ <--> Channel <--> MN_CSE[i+1].peer++;
+//            MN_CSE[12].peer++ <--> Channel <--> MN_CSE[10].peer++;
+//        }
+//        
+//        for i=13..14 {
+//            MN_CSE[i].peer++ <--> Channel <--> MN_CSE[i+1].peer++;
+//            MN_CSE[15].peer++ <--> Channel <--> MN_CSE[13].peer++;
+//        }
+//        
+//        for i=16..17 {
+//            MN_CSE[i].peer++ <--> Channel <--> MN_CSE[i+1].peer++;
+//            MN_CSE[18].peer++ <--> Channel <--> MN_CSE[16].peer++;
+//        }
+        
+
+        for i=0..2399, for j=0..23999 {
+            MN_CSE[i].ae++ <--> Channel <--> MN_AE[j].cse if j>=(i*10) && j<(i*10)+10;
+        }
+
+        for i=0..999, for j=10000..109999 {
+            MN_CSE[i].provider++ <--> Channel <--> ASN_CSE[j].customer++ if j>=(i*100)+10000 && j<(i*100)+10100;
+        }
+        
+        for i=0..99999, for j=100000..199999 {
+            ASN_CSE[i+10000].ae++ <--> Channel <--> ASN_AE[j].cse if j>=(i*2)+100000 && j<(i*2)+100002;
+        }
+        
+        for i=0..999, for j=10000..11999 {
+            MN_CSE[i].ae++ <--> Channel <--> ADN_AE[j].cse if j>=(i*2)+10000 && j<(i*2)+10002;
+        } 
+        
+}
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/AsdqNetworkSub.ini b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/AsdqNetworkSub.ini
new file mode 100644
index 0000000000000000000000000000000000000000..b21eab1c16775ce80f63f036b74fb826e8c1b6a0
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/AsdqNetworkSub.ini
@@ -0,0 +1,2 @@
+[General]
+network = AsdqNetworkSub
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/AsdqNetworkSub.ned b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/AsdqNetworkSub.ned
new file mode 100644
index 0000000000000000000000000000000000000000..b23cb4889436bdfb8fa424b41ba54bb24b12a035
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/AsdqNetworkSub.ned
@@ -0,0 +1,89 @@
+
+//==================================================NETWORK==========================================================
+
+
+network AsdqNetworkSub
+{       
+    types:
+        channel Channel extends ned.DelayChannel
+        {
+            delay = 100ms;
+        }
+        
+    submodules:
+        IN_CSE[5]: CSE {
+            parameters:
+                @display("p=700,600,ring");
+        }
+
+        MN_CSE[12]: CSE;
+        ASN_CSE[75]: CSE;
+               
+        IN_AE[10]: AE;
+        ADN_AE[70]: AE;
+        ASN_AE[550]: AE;
+        MN_AE[60]: AE;
+
+    connections allowunconnected:
+
+        for i=0..3, for j=(i+1)..4 {
+            IN_CSE[i].sibling++ <--> Channel <--> IN_CSE[j].sibling++; //top-level mesh IN_CSE network (Extendable)
+        }
+
+        for i=0..4, for j=0..49 {
+            IN_CSE[i].ae++ <--> Channel <--> ADN_AE[j].cse if j>=(i*10) && j<(i*10)+10; // ADN_AE which are connected to top level IN_CSEs (Extendable) and 100 here is the number of ADN_AEs for each IN_CSE
+        }
+
+        for i=0..4, for j=0..9 {
+            IN_CSE[i].ae++ <--> Channel <--> IN_AE[j].cse if j>=(i*2) && j<(i*2)+2; // IN_AE which are connected to top level IN_CSEs (Extendable) and 3 here is the number of IN_AEs for each IN_CSE
+        }
+
+        for i=0..4, for j=0..49 {
+            IN_CSE[i].customer++ <--> Channel <--> ASN_CSE[j].provider++ if j>=(i*10) && j<(i*10)+10; // ASN_CSE which are connected to top level IN_CSEs (Extendable) and 100 here is the number of ASN_CSE for each IN_CSE
+        }
+
+        for i=0..49, for j=0..499 {
+            ASN_CSE[i].ae++ <--> Channel <--> ASN_AE[j].cse if j>=(i*10) && j<(i*10)+10;
+        }
+
+        for i=0..4, for j=0..9 {
+            IN_CSE[i].customer++ <--> Channel <--> MN_CSE[j].provider++ if j>=(i*2) && j<(i*2)+2; // MN_CSE which are connected to top level IN_CSEs (Extendable) and 20 here is the number of MN_CSE for each IN_CSE
+        }
+
+        for i=10..11 {                                          // 10% of MN_CSEs have another level of MN_CSEs
+            MN_CSE[6].customer++ <--> Channel <--> MN_CSE[i].provider++;
+        }
+       
+//        for i=10..11 {
+//            MN_CSE[i].peer++ <-->prompt Channel <--> MN_CSE[i+1].peer++;
+//            MN_CSE[12].peer++ <--> Channel <--> MN_CSE[10].peer++;
+//        }
+//        
+//        for i=13..14 {
+//            MN_CSE[i].peer++ <--> Channel <--> MN_CSE[i+1].peer++;
+//            MN_CSE[15].peer++ <--> Channel <--> MN_CSE[13].peer++;
+//        }
+//        
+//        for i=16..17 {
+//            MN_CSE[i].peer++ <--> Channel <--> MN_CSE[i+1].peer++;
+//            MN_CSE[18].peer++ <--> Channel <--> MN_CSE[16].peer++;
+//        }
+        
+
+        for i=0..11, for j=0..59 {
+            MN_CSE[i].ae++ <--> Channel <--> MN_AE[j].cse if j>=(i*5) && j<(i*5)+5;
+        }
+
+        for i=0..4, for j=50..74 {
+            MN_CSE[i].provider++ <--> Channel <--> ASN_CSE[j].customer++ if j>=(i*5)+50 && j<(i*5)+55;
+        }
+        
+        for i=0..74, for j=500..549 {
+            ASN_CSE[i+50].ae++ <--> Channel <--> ASN_AE[j].cse if j>=(i*2)+500 && j<(i*2)+502;
+        }
+        
+        for i=0..9, for j=50..69 {
+            MN_CSE[i].ae++ <--> Channel <--> ADN_AE[j].cse if j>=(i*2)+50 && j<(i*2)+52;
+        } 
+        
+}
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/CSE.cpp b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/CSE.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..59691ff3424e58d5bf84ee481c74289567491725
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/CSE.cpp
@@ -0,0 +1,830 @@
+#include "CSE.h"
+#include "declarative.h"
+#include <algorithm>
+
+// Constructor for Messages
+CSE::CSE() {
+        // Set the pointer to nullptr, so that the destructor won't crash
+        // even if initialize() doesn't get called because of a runtime
+        // error or user cancellation during the startup process.
+//    queryMsg = NotifMsg = ResMsg = nullptr;
+}
+
+// Destructor for Messages
+CSE::~CSE() {
+    // Dispose of dynamically allocated the objects
+//    delete queryMsg;
+//    delete NotifMsg;
+//    delete ResMsg;
+}
+
+
+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";
+    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");
+    this->delay = par("delayTime");
+
+    notif = 0;
+    WATCH(notif);
+}
+
+/*
+ * 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";
+
+    if (msg->getHopCount() <= 0) {
+        bubble("TTL expired");
+        //Respond to the URI_init that the discovery ends
+        msg->setOp_code(RESPONSE);
+        //You extract from the top of the list the gate that has to be used
+        EV << "TTL expired so we generate a response message \n";
+        generateResponseMessage(msg, ResultCode::NOT_FOUND);
+        return;
+    }
+
+    // Decreasing the hop count
+    msg->setHopCount(msg->getHopCount() - 1);
+
+//    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");
+////            sendDelayed(msg->dup(), delay, gateName.c_str(), gateindex);
+//            send(msg->dup(), 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);
+        successful =
+                !successful ?
+                        multicast("sibling", msg, this->multicastGamma) : true;
+        break;
+    }
+    case SIDE_SIBLING: {
+        successful = multicast("sibling", msg, this->multicastGamma);
+        successful &= multicast("customer", msg, this->multicastAlpha);
+        break;
+    }
+    case SIDE_PEER: {
+        break;
+    }
+    case UP: {
+        successful = multicast("provider", msg, this->multicastBeta);
+        successful =
+                !successful ?
+                        multicast("sibling", msg, this->multicastGamma) : true;
+        successful &= multicast("customer", msg, this->multicastDelta);
+        break;
+    }
+    default:
+        break;
+    }
+
+    if (!successful) {
+        bubble("No result");
+        generateResponseMessage(msg, ResultCode::NOT_FOUND);
+    }
+}
+
+/*
+ * seenQuery is used to check if the query processed previously or not.
+ * 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;
+    }
+    std::map<int, int> dbres;
+    dbres[res] = 0;
+    EV << "DB Lookup Successful" << "\n";
+    msg->setDbResult(dbres);
+
+    generateResponseMessage(msg);
+}
+
+/*
+ * handleDiscoveryMessage is used to handle `discoveryMessage`.
+*/
+void CSE::handleDiscoveryMessage(cMessage *msg) {
+
+    EV << "Entering into the CSE" << "\n";
+    discoveryMessage *discoveryMsg = check_and_cast<discoveryMessage*>(msg);
+    EV << "The Message type is : " << discoveryMsg->getOp_code() << "\n";
+
+// switch on 3 possible opcodes: Notify, Query and Response
+
+    int op_code = discoveryMsg->getOp_code();
+
+    switch (op_code) {
+    case NOTIFY:
+        notif++;
+        updatingRoutingTableAndNotify(discoveryMsg);
+        break;
+    case QUERY:
+    {
+        EV << "Message is a 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";
+        tempGateVector.clear();
+
+        handleQuery(discoveryMsg);
+
+        break;
+    }
+    case RESPONSE:
+        EV << "Message is type response so no new gate added\n";
+        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 message.\n";
+    std::vector<cGate*> tempGateVector;
+//  getting the return gate and index of return gate
+    tempGateVector = msg->getGateVector();
+    const char *returnGate = tempGateVector.back()->getName();
+    int returnIndex = tempGateVector.back()->getIndex();
+//  removing the used return gate
+    tempGateVector.pop_back();
+    msg->setGateVector(tempGateVector);
+    tempGateVector.clear();
+//  sending msg to the return gate
+    send(msg->dup(), returnGate, returnIndex);
+}
+
+/*
+ * handleAEMessage is used to process message from Application Entities (AEs)
+ * Messages are registration or cancellation or query.
+ */
+void CSE::handleAEMessage(cMessage *msg) {
+
+    AEMessage *aeMsg = check_and_cast<AEMessage*>(msg);
+
+    // Getting the type of message from AE
+    int op_code = aeMsg->getOp_code();  // op_code contains the type of message
+
+    switch (op_code) {
+    case REGISTRATION: {
+
+        registrationAndNotification(aeMsg);
+        break;
+    }
+    case CANCELLATION: {
+
+        cancelationAndNotification(aeMsg);
+        break;
+    }
+    case QUERY: {
+        // if it is a query msg first we look up the loacl devices then we create a discovery msg and to start ASDQ
+        localDBLookup(aeMsg);
+        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 for registering AEs in their parent CSE.
+ * And, notifying the other CSEs about existence of the AEs.
+ */
+void CSE::registrationAndNotification(AEMessage *msg) {
+
+    // we extract the feature_type; URI_route; and data from the AEmessage
+    std::string feature_type = msg->getFeature_type();
+
+    int URI_route = msg->getURI();
+
+//    int data = msg->getData();
+
+    // bubble is used to show the feature type on graphical mode when AE is registering in CSE.
+    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::cancelationAndNotification(AEMessage *msg) {
+
+    std::string feature_type = msg->getFeature_type();
+    int URI_route = msg->getURI();
+
+    deregisterAE(feature_type, URI_route);
+
+    notifyCSE(feature_type, -1);
+}
+
+
+// This method (registerAE) is for registering AEs in their parents CSEs local databases.
+
+void CSE::registerAE(std::string feature_type, URI uri) {
+
+  // auto entry = getOrCreateRoutingEntry(feature_type);
+
+    this->SemanticRoutingTable[feature_type].database.insert(std::pair<URI, int>(uri, 1));
+
+//    this->SemanticRoutingTable[feature_type] = RoutingStruct;
+
+//  This EV is just for testing the size of database contents :)
+    EV << "SemanticRoutingTable[feature_type].database.size() is " << this->SemanticRoutingTable[feature_type].database.size() << '\n';
+
+}
+
+// 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);
+
+    this->SemanticRoutingTable[feature_type].database.erase(this->SemanticRoutingTable[feature_type].database.find(uri));
+
+//    this->SemanticRoutingTable[feature_type] = RoutingStruct;
+
+//  This EV is just for testing the size of database contents :)
+    EV << "SemanticRoutingTable[feature_type].database.size() after deregitering is " << this->SemanticRoutingTable[feature_type].database.size() << '\n';
+}
+
+/*
+ * handleMessage is an entry point for messages in OMNeT++
+ */
+void CSE::handleMessage(cMessage *msg) {
+
+// Separating two kinds of messages, AEMessage and DiscoveryMessage
+// AEMessages are coming from AEs and Discovery messages are coming from other CSEs
+
+    if (strcmp(msg->getSenderModule()->getClassName(), "AE") == 0) {
+
+        handleAEMessage(msg);
+    }
+
+    else if(strcmp(msg->getSenderModule()->getClassName(), "CSE") == 0) {
+
+        handleDiscoveryMessage(msg);
+    }
+
+}
+
+/*
+ * generateResponseMessage is used to generate query response 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);
+
+    handleDiscoveryMessage(responseMsg);
+}
+
+/*
+ *This Method is creatinging a discovery message
+ */
+void CSE::generateDiscoveryMessage(AEMessage *msg) {
+// these data should not change during the routing between CSEs
+
+// we created a discovery message
+    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(maxHops);
+
+// we set the direction UP
+//    queryMsg->setDirection(UP);
+
+// create a omnet vector of type cGate* named gateVector
+    std::vector<cGate*> gateVector;
+// You put on top of the list  the name of the gates to use for the return path (getOtherHalf)
+    gateVector.push_back(msg->getArrivalGate()->getOtherHalf());
+// We  update the query msg with this vector
+    queryMsg->setGateVector(gateVector);
+    gateVector.clear();
+
+// Sending query message to processQuery in order to forward to the other CSEs in valley-free manner.
+    processQuery(queryMsg);
+//    handleDiscoveryMessage(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, it means we have the gate which we want to direct the message.
+    if (t <= 0) {
+        return false;
+    }
+
+    // if it detects the size of the target gate or 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 the gate which have all the target gates
+
+    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);
+        send(msg, 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;
+    }
+    //otherwise
+    if (entry.CSEBucket.size() <= 100) {
+        entry.CSEBucket.insert(entry.CSEBucket.begin(),
+                msg->getSenderModuleId());
+        return entry.CSEBucket;
+    }
+    // otherwise
+    int i = entry.CSEBucket.back();
+    auto it = this->Gates[i];
+    int gateIndex = it.second;
+    std::string gateName = it.first + "$o";
+
+
+    // ping message
+    send(ping, gateName.c_str(), gateIndex);
+
+    // after receiving ping
+    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;
+}
+
+/*
+ * updateRoutingTableAndNotify is used to update sematic routing table
+ * and notify other CSE neighbors (e.g. Customer, Peer, Sibling, Provider)
+ */
+void CSE::updatingRoutingTableAndNotify(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:
+        this->SemanticRoutingTable[feature_type].CSECustomer[cse] += delta;
+        break;
+    case DOWN:
+        this->SemanticRoutingTable[feature_type].CSEProvider[cse] += delta;
+        break;
+    case SIDE_SIBLING:
+        this->SemanticRoutingTable[feature_type].CSESibling[cse] += delta;
+        break;
+    case SIDE_PEER:
+        this->SemanticRoutingTable[feature_type].CSEPeer[cse] += delta;
+        break;
+    }
+
+//    notification depth reached
+    if (msg->getHopCount() >= NotificationDepth) {
+        EV << "notification depth reached\n";
+        return;
+    }
+
+    EV << "Redirecting notify\n";
+
+    // notify
+    msg->setHopCount(msg->getHopCount() + 1);
+    msg->setURI_route(this->Uri);
+    notifyNeighbors(msg->dup());
+}
+
+// This method (notifyCSE) is used for creating and broadcasting notification message to the neighbors with limited depth (NotificationDepth).
+
+void CSE::notifyCSE(std::string feature_type, int delta) {
+
+//  creating notification message to send to the neighbors.
+    auto msg = generateMessage(NOTIFY);
+
+    msg->setFeature_type(feature_type.c_str());
+    msg->setHopCount(NotificationDepth);
+    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.
+ */
+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 upstream\n";
+    multicast("provider", msg);
+
+    delete msg;
+}
+
+/* This method look up for the devices in the CSE in which there is AE which starts the query
+ * and returns the result directly
+ */
+void CSE::localDBLookup(AEMessage *msg) {
+
+    auto feature_type = msg->getFeature_type();
+
+    if(this->SemanticRoutingTable[feature_type].database.size() != 0){
+
+        auto localresponseMsg = generateMessage(RESPONSE);
+        localresponseMsg->setDirection(NODIR);
+        localresponseMsg->setFeature_type(feature_type);
+        localresponseMsg->setURI_init(getId());
+//        int lres = this->SemanticRoutingTable[feature_type].database.begin()->first;
+//        std::map<int, int> ldbres;
+//        ldbres[lres] = 0;
+//        EV << "DB Lookup Successful" << "\n";
+//        localresponseMsg->setDbResult(ldbres);
+        localresponseMsg->setReturnCode(ResultCode::SUCCESS);
+        send(localresponseMsg, msg->getArrivalGate()->getOtherHalf()->getId());
+        return;
+    }
+    else {
+        auto localresponseMsg = generateMessage(RESPONSE);
+        localresponseMsg->setDirection(NODIR);
+        localresponseMsg->setFeature_type(feature_type);
+        localresponseMsg->setURI_init(getId());
+        localresponseMsg->setReturnCode(ResultCode::NOT_FOUND);
+        send(localresponseMsg, msg->getArrivalGate()->getOtherHalf()->getId());
+        return;
+    }
+}
+
+/*
+ * 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
+// if we find the data correspond to the feature_type
+    if (this->SemanticRoutingTable[feature_type].database.size() != 0) {
+        bubble("Success in database");
+        return this->SemanticRoutingTable[feature_type].database.begin()->first;
+    }
+    else if(this->SemanticRoutingTable[feature_type].CSECustomer.size()!=0) {
+        bubble("Success in customer");
+        return this->SemanticRoutingTable[feature_type].CSECustomer.begin()->first;
+    }
+    else if(this->SemanticRoutingTable[feature_type].CSEPeer.size()!=0) {
+            bubble("Success in peer");
+            return this->SemanticRoutingTable[feature_type].CSEPeer.begin()->first;
+    }
+    else if(this->SemanticRoutingTable[feature_type].CSESibling.size()!=0) {
+            bubble("Success in sibiling");
+            return this->SemanticRoutingTable[feature_type].CSESibling.begin()->first;
+    }
+    else if(this->SemanticRoutingTable[feature_type].CSEProvider.size()!=0) {
+            bubble("Success in provider");
+            return this->SemanticRoutingTable[feature_type].CSEProvider.begin()->first;
+    }
+    else
+        return NOT_FOUND;
+}
+
+/*
+ * generateMessage is used to generate message of specified type.
+ */
+discoveryMessage *CSE::generateMessage(int op_code) {
+    switch (op_code) {
+
+    case RESPONSE: {
+        int URI_route = getId();
+        char msgname[20];
+        sprintf(msgname, "Rsp");
+        // Create message object and set source and destination field.
+        ResMsg = new discoveryMessage(msgname);
+        //msg->setPayload("thermometer");
+        ResMsg->setOp_code(RESPONSE);
+        ResMsg->setURI_route(URI_route);
+        return ResMsg;
+        break;
+    }
+    case NOTIFY: {
+        int URI_route = getId();
+        char msgname[20];
+        sprintf(msgname, "Notif");
+        // Create message object and set source and destination field.
+        NotifMsg = new discoveryMessage(msgname);
+        //msg->setPayload("thermometer");
+        NotifMsg->setDirection(DOWN);
+        NotifMsg->setOp_code(NOTIFY);
+        NotifMsg->setURI_route(URI_route);
+        NotifMsg->setURI_init(URI_route);
+        return NotifMsg;
+        break;
+    }
+    default:
+        break;
+    }
+    return nullptr;
+}
+
+
+//void CSE::orderingMap(std::map<int, int>) {
+//    return;
+//}
+
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/CSE.h b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/CSE.h
new file mode 100644
index 0000000000000000000000000000000000000000..69efded8383e9fcae2bad04f0b06c4692f1fc26c
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/CSE.h
@@ -0,0 +1,105 @@
+#ifndef CSE_H_
+#define CSE_H_
+
+#include <stdio.h>
+#include <string.h>
+#include <omnetpp.h>
+#include "discoveryMessage_m.h"
+#include "AEMessage_m.h"
+#include <list>
+#include "utils.h"
+#include "types.h"
+
+using namespace omnetpp;
+
+class CSE: public cSimpleModule {
+
+public:
+    CSE();
+    virtual ~CSE();
+
+    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:
+
+    discoveryMessage *queryMsg;
+    discoveryMessage *ResMsg;
+    discoveryMessage *NotifMsg;
+
+    int notif;
+    bool seenQuery(discoveryMessage *msg);
+    // application specific for exploring and updating the local database
+    URI DBLookup(discoveryMessage *msg);
+    void localDBLookup(AEMessage *msg);
+    void generateDiscoveryMessage(AEMessage *msg);
+    void generateResponseMessage(discoveryMessage *discoveryMsg, ResultCode result = ResultCode::SUCCESS);
+
+    // not yet implemented
+    // TODO this function organize the map by value-ordering
+//    void orderingMap(std::map<int, int>);
+
+    // Routing table update
+    void cancelationAndNotification(AEMessage *msg);
+    void registrationAndNotification(AEMessage *msg);
+    RoutingEntry mustGetRoutingEntry(std::string feature_type);
+    void registerAE(std::string feature_type, URI uri);
+    void deregisterAE(std::string feature_type, URI uri);
+    void updatingRoutingTableAndNotify(discoveryMessage *msg);
+    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 handleDiscoveryMessage(cMessage *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);
+
+    std::map<URI, std::tuple<int, simtime_t, int>> schedulerMap;
+
+    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;
+
+    simtime_t delay;
+
+};
+Define_Module(CSE);
+
+#endif
+
+
+
+
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/Components.ned b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/Components.ned
new file mode 100644
index 0000000000000000000000000000000000000000..acff034ad497feb2f89a7a6d869807bccafa5d73
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/Components.ned
@@ -0,0 +1,35 @@
+
+//===================================================COMPONENTS==================================================
+
+simple CSE
+{
+        parameters:
+        @signal[packet_size](type="long");
+        @statistic[throughput](title="total_number_of_packets"; source="packet_size"; record=vector,last);
+        @display("i=abstract/router,blue,9");
+        int notification_depth = default(1);
+        int alpha = default(0); // Sidestream multicast parameter (p2p)   ?? Peer
+        int beta = default(1);  // Upstream multicast parameter (c2p)     ?? Provider
+        int delta = default(1); // Downstream multicast parameter (p2c)   ?? Customer
+        int gamma = default(1); // Sidestream multicast parameter (s2s)   ?? Sibiling
+        int queryBufferTTL = default(2);
+        int maxHops = default(10);
+        //volatile double sendInterval @unit(s);
+        volatile double delayTime = default(0) @unit(s);
+
+    gates:
+        // TODO Peering links handling has to be implemented
+        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");
+    gates:
+        inout cse @loose;
+}
\ No newline at end of file
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/Makefile b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..65f7d7ec244abafa6be4849454e24acaa67f7df8
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/Makefile
@@ -0,0 +1,133 @@
+#
+# OMNeT++/OMNEST Makefile for asdqv4.0
+#
+# This file was generated with the command:
+#  opp_makemake -f --deep -O out -I.
+#
+
+# Name of target to be created (-o option)
+TARGET = asdqv4.0$(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 = -I.
+
+# Additional object and library files to link with
+EXTRA_OBJS =
+
+# Additional libraries (-L, -l options)
+LIBS =
+
+# Output directory
+PROJECT_OUTPUT_DIR = out
+PROJECTRELATIVE_PATH =
+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
+
+# Message files
+MSGFILES = \
+    AEMessage.msg \
+    discoveryMessage.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/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/SmallNetwork.ned b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/SmallNetwork.ned
new file mode 100644
index 0000000000000000000000000000000000000000..fb0cd39fc7e458e0ddbb3301108d400f2f044140
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/SmallNetwork.ned
@@ -0,0 +1,42 @@
+network SmallNetwork
+{
+    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/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/asdq_dbg b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/asdq_dbg
new file mode 100755
index 0000000000000000000000000000000000000000..4432bc86ef39a326ccc064e9f9468a29d759479a
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/asdq_dbg differ
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/asdqv4.0_dbg b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/asdqv4.0_dbg
new file mode 100755
index 0000000000000000000000000000000000000000..f33aa34a06da24a82ced6707eea4f9938cebd145
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/asdqv4.0_dbg differ
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/bigNetwork.ini b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/bigNetwork.ini
new file mode 100644
index 0000000000000000000000000000000000000000..eed329bf8049b72f10eb490aa8da8637fec297bf
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/bigNetwork.ini
@@ -0,0 +1,2 @@
+[General]
+network = BigNetwork
\ No newline at end of file
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/big_network.ned b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/big_network.ned
new file mode 100644
index 0000000000000000000000000000000000000000..4fd58035c603afd939470ff65ca85c406176a7cc
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/big_network.ned
@@ -0,0 +1,125 @@
+network BigNetwork
+{
+    // @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:
+        IN_CSE[3]: CSE;
+        MN_CSE[20]: CSE;
+        AE [46]: AE;
+    connections allowunconnected :     
+        for i=0..2 {
+            IN_CSE[i].sibling++ <--> Channel <--> IN_CSE[(i+1)%3].sibling++;
+        }
+        for j=0..1 {
+            MN_CSE[j].provider++ <--> Channel <--> IN_CSE[0].customer++;
+        }
+        for j=2..3 {
+            MN_CSE[j].provider++ <--> Channel <--> IN_CSE[1].customer++;
+        }
+        for j=4..5 {
+            MN_CSE[j].provider++ <--> Channel <--> IN_CSE[2].customer++;
+        }
+        for j=6..7 {
+            MN_CSE[j].provider++ <--> Channel <--> MN_CSE[0].customer++;
+        }
+        for j=8..9 {
+            MN_CSE[j].provider++ <--> Channel <--> MN_CSE[1].customer++;
+        }
+        for j=10..11 {
+            MN_CSE[j].provider++ <--> Channel <--> MN_CSE[2].customer++;
+        }
+        for j=12..13 {
+            MN_CSE[j].provider++ <--> Channel <--> MN_CSE[3].customer++;
+        }
+        for j=14..15 {
+            MN_CSE[j].provider++ <--> Channel <--> MN_CSE[4].customer++;
+        }
+        for j=16..17 {
+            MN_CSE[j].provider++ <--> Channel <--> MN_CSE[5].customer++;
+        }
+        
+        for j=18..19 {
+            MN_CSE[j].provider++ <--> Channel <--> MN_CSE[5].customer++;
+        }
+        
+        for j=0..1 {
+            MN_CSE[0].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=2..3 {
+            MN_CSE[1].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=4..5 {
+            MN_CSE[2].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=6..7 {
+            MN_CSE[3].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=8..9 {
+            MN_CSE[4].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=10..11 {
+            MN_CSE[5].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=12..13 {
+            IN_CSE[0].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=14..15 {
+            IN_CSE[1].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=16..17 {
+            IN_CSE[2].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=18..19{
+            MN_CSE[6].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=20..21{
+            MN_CSE[7].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=22..23{
+            MN_CSE[8].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=24..25{
+            MN_CSE[9].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=26..27{
+            MN_CSE[10].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=28..29{
+            MN_CSE[11].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=30..31{
+            MN_CSE[12].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=32..33{
+            MN_CSE[13].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=34..35{
+            MN_CSE[14].ae++<--> Channel <--> AE[j].cse;
+        }
+        for j=36..37{
+            MN_CSE[15].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=38..39{
+            MN_CSE[16].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=40..41{
+            MN_CSE[17].ae++ <--> Channel <--> AE[j].cse;
+        }
+        
+        for j=42..43{
+            MN_CSE[18].ae++ <--> Channel <--> AE[j].cse;
+        }
+        
+        for j=44..45{
+            MN_CSE[19].ae++ <--> Channel <--> AE[j].cse;
+        } 
+}
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/declarative.h b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/declarative.h
new file mode 100644
index 0000000000000000000000000000000000000000..d69a8944b134d8364719595841367ac19aae2ad8
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/declarative.h
@@ -0,0 +1,16 @@
+#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/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/discoveryMessage.msg b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/discoveryMessage.msg
new file mode 100644
index 0000000000000000000000000000000000000000..2753e5b82ae6756cc7cda862a0ab48c3ea6be636
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/discoveryMessage.msg
@@ -0,0 +1,40 @@
+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; 
+  	// It can be set to +1 or -1 respectively to add or remove the AEs from routing table. 
+  	int delta;
+  	// It is used for notification for measuring the depth of notification 
+    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 which forward the query) 
+    GateVector gateVector;   
+}
\ No newline at end of file
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/.last-copts b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/.last-copts
new file mode 100644
index 0000000000000000000000000000000000000000..ae7ca01fbfba3b8862349c8a76f90bc5d8472450
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/.last-copts
@@ -0,0 +1 @@
+-g -Wall -MMD -MP -MF .d  -fPIC  -fno-omit-frame-pointer -DHAVE_SWAPCONTEXT -DWITH_MPI -DXMLPARSER=libxml -DPREFER_QTENV -DWITH_QTENV -DWITH_PARSIM -DWITH_NETBUILDER -DWITH_OSG -DWITH_OSGEARTH   -I. -I/home/inria/omnetpp-5.6.2/include
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/AE.o b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/AE.o
new file mode 100644
index 0000000000000000000000000000000000000000..257b23391af50e0ee302b246c6780798c422f537
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/AE.o differ
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/AE.o.d b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/AE.o.d
new file mode 100644
index 0000000000000000000000000000000000000000..1cad87c41c4c8f424b5e25d6f2b96473b96c6d0c
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/AE.o.d
@@ -0,0 +1,15 @@
+out/gcc-debug//AE.o: AE.cpp AE.h \
+ /home/inria/omnetpp-5.6.2/include/omnetpp.h AEMessage_m.h utils.h \
+ discoveryMessage_m.h types.h
+
+AE.h:
+
+/home/inria/omnetpp-5.6.2/include/omnetpp.h:
+
+AEMessage_m.h:
+
+utils.h:
+
+discoveryMessage_m.h:
+
+types.h:
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/AEMessage_m.o b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/AEMessage_m.o
new file mode 100644
index 0000000000000000000000000000000000000000..965d64127e1fbb1cba1237f289066e9162793c97
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/AEMessage_m.o differ
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/AEMessage_m.o.d b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/AEMessage_m.o.d
new file mode 100644
index 0000000000000000000000000000000000000000..456711936440365d20156ebe3c909cf9ded5a964
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/AEMessage_m.o.d
@@ -0,0 +1,6 @@
+out/gcc-debug//AEMessage_m.o: AEMessage_m.cpp AEMessage_m.h \
+ /home/inria/omnetpp-5.6.2/include/omnetpp.h
+
+AEMessage_m.h:
+
+/home/inria/omnetpp-5.6.2/include/omnetpp.h:
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/CSE.o b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/CSE.o
new file mode 100644
index 0000000000000000000000000000000000000000..f78c9f07beaeb8b4ea8124dc7cd14a2b41ff8b8f
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/CSE.o differ
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/CSE.o.d b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/CSE.o.d
new file mode 100644
index 0000000000000000000000000000000000000000..a1a4721a95fd66ba92c4f777d54741bace0e6659
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/CSE.o.d
@@ -0,0 +1,17 @@
+out/gcc-debug//CSE.o: CSE.cpp CSE.h \
+ /home/inria/omnetpp-5.6.2/include/omnetpp.h discoveryMessage_m.h \
+ AEMessage_m.h utils.h types.h declarative.h
+
+CSE.h:
+
+/home/inria/omnetpp-5.6.2/include/omnetpp.h:
+
+discoveryMessage_m.h:
+
+AEMessage_m.h:
+
+utils.h:
+
+types.h:
+
+declarative.h:
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/asdqv4.0_dbg b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/asdqv4.0_dbg
new file mode 100755
index 0000000000000000000000000000000000000000..f33aa34a06da24a82ced6707eea4f9938cebd145
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/asdqv4.0_dbg differ
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/discoveryMessage_m.o b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/discoveryMessage_m.o
new file mode 100644
index 0000000000000000000000000000000000000000..d3f754d00bfcf6c07450a17baa0d21ede7f25140
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/discoveryMessage_m.o differ
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/discoveryMessage_m.o.d b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/discoveryMessage_m.o.d
new file mode 100644
index 0000000000000000000000000000000000000000..383d7398136a639ac9d78883e60e014186a55f7f
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/out/gcc-debug/discoveryMessage_m.o.d
@@ -0,0 +1,6 @@
+out/gcc-debug//discoveryMessage_m.o: discoveryMessage_m.cpp \
+ discoveryMessage_m.h /home/inria/omnetpp-5.6.2/include/omnetpp.h
+
+discoveryMessage_m.h:
+
+/home/inria/omnetpp-5.6.2/include/omnetpp.h:
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/results/General-#0.sca b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/results/General-#0.sca
new file mode 100644
index 0000000000000000000000000000000000000000..0dbef40314d6deda09cd52c5b86a728d20ccf28d
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/results/General-#0.sca
@@ -0,0 +1,87 @@
+version 2
+run General-0-20211005-13:29:38-14180
+attr configname General
+attr datetime 20211005-13:29:38
+attr experiment General
+attr inifile bigNetwork.ini
+attr iterationvars ""
+attr iterationvarsf ""
+attr measurement ""
+attr network BigNetwork
+attr processid 14180
+attr repetition 0
+attr replication #0
+attr resultdir results
+attr runnumber 0
+attr seedset 0
+
+scalar BigNetwork.IN_CSE[0] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.IN_CSE[1] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.IN_CSE[2] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[0] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[1] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[2] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[3] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[4] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[5] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[6] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[7] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[8] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[9] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[10] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[11] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[12] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[13] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[14] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[15] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[16] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[17] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[18] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[19] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/smallNetwork.ini b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/smallNetwork.ini
new file mode 100644
index 0000000000000000000000000000000000000000..2e925635a057b5cd9db802b503f764e81d40fc6f
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/smallNetwork.ini
@@ -0,0 +1,2 @@
+[General]
+network = SmallNetwork
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/types.h b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/types.h
new file mode 100644
index 0000000000000000000000000000000000000000..a4c7a0be918b992ffc8872fe00488f885a067623
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/types.h
@@ -0,0 +1,49 @@
+#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 which are directly connected to the 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/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/utils.h b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/utils.h
new file mode 100644
index 0000000000000000000000000000000000000000..caad6a3bb852b3b30b745e66121c860ca9769e24
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0.0/utils.h
@@ -0,0 +1,31 @@
+#ifndef UTILS_H_
+#define UTILS_H_
+
+
+enum Direction {
+    UP = 0,
+    DOWN = 1,
+    SIDE_SIBLING = 2,
+    SIDE_PEER = 3,
+    NODIR = 4
+};
+
+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
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0_dbg b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0_dbg
new file mode 100755
index 0000000000000000000000000000000000000000..f33aa34a06da24a82ced6707eea4f9938cebd145
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v4.0.0/src/asdqv4.0_dbg differ
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/bigNetwork.ini b/omnet-asd-network-simulation-master/asd_v4.0.0/src/bigNetwork.ini
new file mode 100644
index 0000000000000000000000000000000000000000..eed329bf8049b72f10eb490aa8da8637fec297bf
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/bigNetwork.ini
@@ -0,0 +1,2 @@
+[General]
+network = BigNetwork
\ No newline at end of file
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/big_network.ned b/omnet-asd-network-simulation-master/asd_v4.0.0/src/big_network.ned
new file mode 100644
index 0000000000000000000000000000000000000000..4fd58035c603afd939470ff65ca85c406176a7cc
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/big_network.ned
@@ -0,0 +1,125 @@
+network BigNetwork
+{
+    // @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:
+        IN_CSE[3]: CSE;
+        MN_CSE[20]: CSE;
+        AE [46]: AE;
+    connections allowunconnected :     
+        for i=0..2 {
+            IN_CSE[i].sibling++ <--> Channel <--> IN_CSE[(i+1)%3].sibling++;
+        }
+        for j=0..1 {
+            MN_CSE[j].provider++ <--> Channel <--> IN_CSE[0].customer++;
+        }
+        for j=2..3 {
+            MN_CSE[j].provider++ <--> Channel <--> IN_CSE[1].customer++;
+        }
+        for j=4..5 {
+            MN_CSE[j].provider++ <--> Channel <--> IN_CSE[2].customer++;
+        }
+        for j=6..7 {
+            MN_CSE[j].provider++ <--> Channel <--> MN_CSE[0].customer++;
+        }
+        for j=8..9 {
+            MN_CSE[j].provider++ <--> Channel <--> MN_CSE[1].customer++;
+        }
+        for j=10..11 {
+            MN_CSE[j].provider++ <--> Channel <--> MN_CSE[2].customer++;
+        }
+        for j=12..13 {
+            MN_CSE[j].provider++ <--> Channel <--> MN_CSE[3].customer++;
+        }
+        for j=14..15 {
+            MN_CSE[j].provider++ <--> Channel <--> MN_CSE[4].customer++;
+        }
+        for j=16..17 {
+            MN_CSE[j].provider++ <--> Channel <--> MN_CSE[5].customer++;
+        }
+        
+        for j=18..19 {
+            MN_CSE[j].provider++ <--> Channel <--> MN_CSE[5].customer++;
+        }
+        
+        for j=0..1 {
+            MN_CSE[0].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=2..3 {
+            MN_CSE[1].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=4..5 {
+            MN_CSE[2].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=6..7 {
+            MN_CSE[3].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=8..9 {
+            MN_CSE[4].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=10..11 {
+            MN_CSE[5].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=12..13 {
+            IN_CSE[0].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=14..15 {
+            IN_CSE[1].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=16..17 {
+            IN_CSE[2].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=18..19{
+            MN_CSE[6].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=20..21{
+            MN_CSE[7].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=22..23{
+            MN_CSE[8].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=24..25{
+            MN_CSE[9].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=26..27{
+            MN_CSE[10].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=28..29{
+            MN_CSE[11].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=30..31{
+            MN_CSE[12].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=32..33{
+            MN_CSE[13].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=34..35{
+            MN_CSE[14].ae++<--> Channel <--> AE[j].cse;
+        }
+        for j=36..37{
+            MN_CSE[15].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=38..39{
+            MN_CSE[16].ae++ <--> Channel <--> AE[j].cse;
+        }
+        for j=40..41{
+            MN_CSE[17].ae++ <--> Channel <--> AE[j].cse;
+        }
+        
+        for j=42..43{
+            MN_CSE[18].ae++ <--> Channel <--> AE[j].cse;
+        }
+        
+        for j=44..45{
+            MN_CSE[19].ae++ <--> Channel <--> AE[j].cse;
+        } 
+}
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/declarative.h b/omnet-asd-network-simulation-master/asd_v4.0.0/src/declarative.h
new file mode 100644
index 0000000000000000000000000000000000000000..d69a8944b134d8364719595841367ac19aae2ad8
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/declarative.h
@@ -0,0 +1,16 @@
+#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/omnet-asd-network-simulation-master/asd_v4.0.0/src/discoveryMessage.msg b/omnet-asd-network-simulation-master/asd_v4.0.0/src/discoveryMessage.msg
new file mode 100644
index 0000000000000000000000000000000000000000..2753e5b82ae6756cc7cda862a0ab48c3ea6be636
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/discoveryMessage.msg
@@ -0,0 +1,40 @@
+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; 
+  	// It can be set to +1 or -1 respectively to add or remove the AEs from routing table. 
+  	int delta;
+  	// It is used for notification for measuring the depth of notification 
+    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 which forward the query) 
+    GateVector gateVector;   
+}
\ No newline at end of file
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/.last-copts b/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/.last-copts
new file mode 100644
index 0000000000000000000000000000000000000000..ae7ca01fbfba3b8862349c8a76f90bc5d8472450
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/.last-copts
@@ -0,0 +1 @@
+-g -Wall -MMD -MP -MF .d  -fPIC  -fno-omit-frame-pointer -DHAVE_SWAPCONTEXT -DWITH_MPI -DXMLPARSER=libxml -DPREFER_QTENV -DWITH_QTENV -DWITH_PARSIM -DWITH_NETBUILDER -DWITH_OSG -DWITH_OSGEARTH   -I. -I/home/inria/omnetpp-5.6.2/include
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/AE.o b/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/AE.o
new file mode 100644
index 0000000000000000000000000000000000000000..257b23391af50e0ee302b246c6780798c422f537
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/AE.o differ
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/AE.o.d b/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/AE.o.d
new file mode 100644
index 0000000000000000000000000000000000000000..1cad87c41c4c8f424b5e25d6f2b96473b96c6d0c
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/AE.o.d
@@ -0,0 +1,15 @@
+out/gcc-debug//AE.o: AE.cpp AE.h \
+ /home/inria/omnetpp-5.6.2/include/omnetpp.h AEMessage_m.h utils.h \
+ discoveryMessage_m.h types.h
+
+AE.h:
+
+/home/inria/omnetpp-5.6.2/include/omnetpp.h:
+
+AEMessage_m.h:
+
+utils.h:
+
+discoveryMessage_m.h:
+
+types.h:
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/AEMessage_m.o b/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/AEMessage_m.o
new file mode 100644
index 0000000000000000000000000000000000000000..965d64127e1fbb1cba1237f289066e9162793c97
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/AEMessage_m.o differ
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/AEMessage_m.o.d b/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/AEMessage_m.o.d
new file mode 100644
index 0000000000000000000000000000000000000000..456711936440365d20156ebe3c909cf9ded5a964
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/AEMessage_m.o.d
@@ -0,0 +1,6 @@
+out/gcc-debug//AEMessage_m.o: AEMessage_m.cpp AEMessage_m.h \
+ /home/inria/omnetpp-5.6.2/include/omnetpp.h
+
+AEMessage_m.h:
+
+/home/inria/omnetpp-5.6.2/include/omnetpp.h:
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/CSE.o b/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/CSE.o
new file mode 100644
index 0000000000000000000000000000000000000000..f78c9f07beaeb8b4ea8124dc7cd14a2b41ff8b8f
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/CSE.o differ
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/CSE.o.d b/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/CSE.o.d
new file mode 100644
index 0000000000000000000000000000000000000000..a1a4721a95fd66ba92c4f777d54741bace0e6659
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/CSE.o.d
@@ -0,0 +1,17 @@
+out/gcc-debug//CSE.o: CSE.cpp CSE.h \
+ /home/inria/omnetpp-5.6.2/include/omnetpp.h discoveryMessage_m.h \
+ AEMessage_m.h utils.h types.h declarative.h
+
+CSE.h:
+
+/home/inria/omnetpp-5.6.2/include/omnetpp.h:
+
+discoveryMessage_m.h:
+
+AEMessage_m.h:
+
+utils.h:
+
+types.h:
+
+declarative.h:
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/asdqv4.0_dbg b/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/asdqv4.0_dbg
new file mode 100755
index 0000000000000000000000000000000000000000..f33aa34a06da24a82ced6707eea4f9938cebd145
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/asdqv4.0_dbg differ
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/discoveryMessage_m.o b/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/discoveryMessage_m.o
new file mode 100644
index 0000000000000000000000000000000000000000..d3f754d00bfcf6c07450a17baa0d21ede7f25140
Binary files /dev/null and b/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/discoveryMessage_m.o differ
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/discoveryMessage_m.o.d b/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/discoveryMessage_m.o.d
new file mode 100644
index 0000000000000000000000000000000000000000..383d7398136a639ac9d78883e60e014186a55f7f
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/out/gcc-debug/discoveryMessage_m.o.d
@@ -0,0 +1,6 @@
+out/gcc-debug//discoveryMessage_m.o: discoveryMessage_m.cpp \
+ discoveryMessage_m.h /home/inria/omnetpp-5.6.2/include/omnetpp.h
+
+discoveryMessage_m.h:
+
+/home/inria/omnetpp-5.6.2/include/omnetpp.h:
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/results/General-#0.sca b/omnet-asd-network-simulation-master/asd_v4.0.0/src/results/General-#0.sca
new file mode 100644
index 0000000000000000000000000000000000000000..0dbef40314d6deda09cd52c5b86a728d20ccf28d
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/results/General-#0.sca
@@ -0,0 +1,87 @@
+version 2
+run General-0-20211005-13:29:38-14180
+attr configname General
+attr datetime 20211005-13:29:38
+attr experiment General
+attr inifile bigNetwork.ini
+attr iterationvars ""
+attr iterationvarsf ""
+attr measurement ""
+attr network BigNetwork
+attr processid 14180
+attr repetition 0
+attr replication #0
+attr resultdir results
+attr runnumber 0
+attr seedset 0
+
+scalar BigNetwork.IN_CSE[0] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.IN_CSE[1] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.IN_CSE[2] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[0] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[1] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[2] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[3] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[4] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[5] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[6] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[7] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[8] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[9] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[10] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[11] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[12] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[13] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[14] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[15] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[16] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[17] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[18] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+scalar BigNetwork.MN_CSE[19] throughput:last nan
+attr source packet_size
+attr title "total_number_of_packets, last"
+
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/smallNetwork.ini b/omnet-asd-network-simulation-master/asd_v4.0.0/src/smallNetwork.ini
new file mode 100644
index 0000000000000000000000000000000000000000..2e925635a057b5cd9db802b503f764e81d40fc6f
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/smallNetwork.ini
@@ -0,0 +1,2 @@
+[General]
+network = SmallNetwork
diff --git a/omnet-asd-network-simulation-master/asd_v4.0.0/src/types.h b/omnet-asd-network-simulation-master/asd_v4.0.0/src/types.h
new file mode 100644
index 0000000000000000000000000000000000000000..a4c7a0be918b992ffc8872fe00488f885a067623
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/types.h
@@ -0,0 +1,49 @@
+#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 which are directly connected to the 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/omnet-asd-network-simulation-master/asd_v4.0.0/src/utils.h b/omnet-asd-network-simulation-master/asd_v4.0.0/src/utils.h
new file mode 100644
index 0000000000000000000000000000000000000000..caad6a3bb852b3b30b745e66121c860ca9769e24
--- /dev/null
+++ b/omnet-asd-network-simulation-master/asd_v4.0.0/src/utils.h
@@ -0,0 +1,31 @@
+#ifndef UTILS_H_
+#define UTILS_H_
+
+
+enum Direction {
+    UP = 0,
+    DOWN = 1,
+    SIDE_SIBLING = 2,
+    SIDE_PEER = 3,
+    NODIR = 4
+};
+
+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