Protocol integration - npapanik/Adyton GitHub Wiki

##Introduction

This tutorial covers all the required steps to add a new protocol in Adyton. It is assumed that the basic C++ files (.h,.cc) containing the protocol's functionality have already been developed. Further information on creating these files can be found in the section "Protocol implemenation". For illustration purposes, we use the same protocol ("RND_Routing") developed in that section.

###1. Modify src/core/Identification

The first step is to add a definition for our protocol inside the file src/core/Identification. In our case, we defined our protocol as RND_RT and number 17 was assigned as its identifier. The user is free to utilize any name of her preference as soon as the name is not already used. Also, we suggest to use the suffix _RT in order to differentiate routing protocols from other components of the simulator.

#define DELEGATION_RT 14
#define COORD_RT 15
#define OPTIMAL_RT 16
#define RND_RT 17
#define LAST_ENTRY_RT 18 //this should always be the last one

Note that, we have also changed the entry for the LAST_ENTRY_RT definition. This entry should always be the last one otherwise Adyton fails to execute successfully.

###2. Modify src/core/UserInteraction.cc

The second step is to bind the identifier created at step one with one or more arguments, given along with the -rt flag when user executes Adyton from the terminal. In other words, we have to specify that a specific argument given after -rt flag corresponds to our new protocol. To achieve this, we modify the method void UserInteraction::initRTnames() inside file src/core/UserInteraction.cc. More specifically, we add a new line as follows.

RTnames["RND"] = RND_RT;

The above command links the argument RND with the RND_RT identifier created at step one. Note that, Adyton converts all arguments after the -rt flags to uppercase automatically. For this reason, the argument should be given in uppercase. Furthermore, more than one arguments can be connected to the same identifier, i.e., RND_RT in our case. For example, the code below allows users to run experiments using the RND protocol using either -rt RND or -rt RND_ROUTING.

RTnames["RND"] = RND_RT;
RTnames["RND_ROUTING"] = RND_RT;

###3. Modify src/core/Settings.cc

Further information regarding our new protocol should be provided inside file src/core/Settings.cc. The first addition concerns the protocol's full name printed in statistics, simulation results, etc. Each protocol should have an entry inside the void Settings::setRT(int Rout) method that specifies its "official" name. For our protocol, we add the code below.

case RND_RT:
{
	RTname.assign("RND");
	break;
}

It is important to define whether our protocol is single-copy or multi-copy (i.e., if it uses packet replicas or not). This information is provided by the bool Settings::isSingleCopy(void) method. Our protocol is single-copy, so we add the code below.

case RND_RT:
{
	return true;
}

Finally, we have to provide whether our protocol uses limited replication or not (e.g., Spray & Wait protocol). In our case, our protocol is single-copy, so we add the code below in bool Settings::usesLimitedReplication(void).

case RND_RT:
{
	return false;
}

The last addition can be avoided for single-copy protocols. However, some code modification is required. More information can be found here

###4. Move source files into src/routing directory

In case that files RND_Routing.h and RND_Routing.cc ("Protocol implementation".) were not created inside directory src/routing, we should move them there.

###5. Modify src/routing/RoutingProtocols.h

File src/routing/RoutingProtocols.h contains a list with the header files of all routing protocols implemented in Adyton. In our case, we update the file as shown below.

#ifndef RND_ROUTING_H
	#define RND_ROUTING_H
	#include "RND_Routing.h"
#endif

###6. Modify src/core/Node.cc

The actual objects of our routing protocols are created inside the constructor of class Node (src/core/Node.cc). As a result, we add the following lines inside the constructor to enable our new routing protocol.

case RND_RT:
{
	this->RLogic = new RND_Routing(this->Pool, this->macLayer, this->Buffer, this->ID, this->Stat, this->SimSet, this->Gd);
	break;
}

###7. Update src/Makefile

The final step is to update Adyton's Makefile to compile the added code included in RND_Routing.h and RND_Routing.cc. In our case, we add a new entry in SOURCES_RP.

SOURCES_RP=$(rpPath)/Routing.cc $(rpPath)/Direct.cc $(rpPath)/Epidemic.cc $(rpPath)/Prophet.cc $(rpPath)/SimBet.cc $(rpPath)/SimBetTS.cc $(rpPath)/BubbleRap.cc $(rpPath)/SprayWait.cc $(rpPath)/LSFSpray.cc $(rpPath)/MSFSpray.cc $(rpPath)/ProphetSpray.cc $(rpPath)/LSFSprayFocus.cc $(rpPath)/CnR.cc $(rpPath)/EBR.cc $(rpPath)/Delegation.cc $(rpPath)/Optimal.cc $(rpPath)/RND_Routing.cc

###7. Running a simulation

After finishing all steps above and compiling Adyton, a simulation using the new protocol can be executed by typing the following command.

$ ./Adyton -rt RND