Sunteți pe pagina 1din 2

Node Module

Thelogicalstructureofasensornodedefinesinsrc/node/Node.nedfile.

The Node module includes other modules 1) The routing or radio module (in the src/node/communication folder) 2) The application modules (in the src/node/application folder). For application module, you must understand that the behavior of a sensor node depends on which application module you specify in the omnetpp.ini file with the SN.node[*].ApplicationName = "ValuePropagation" line. Actually, when you build the Castalia binary, all the object files are included, even those that defines the other Castalia application examples (valuePropagation, connectivityMap,...). However, with the definitions in the omnetpp.ini file the correct application module is applied at runtime for each sensor node. For instance, this is what can be found in the Simulations/valuePropagation/omnetpp.ini file) Note : The Application module is the one that the user will most commonly change, usually by creating a new module to implement a new algorithm.

Castalia offers support for building your own protocols, or applications by defining appropriate abstract classes The folder /Simulations/Value propogation/ contains the file omnetpp.ini.So if are implementaing a new algorithm then the name of that algorithm is given in this file Simulations/Value propogation/omnetpp.ini As :
SN.node[*].Communication.MACProtocolName = "NEWMAC"

choosing a specific behavior for the wireless channel, or the MAC layer, or the routing protocol is simply done by including the appropriate .ini file. In this example we have the following settings: the radio hardware is the Telos CC2420 that is found in most of the sensor hardware the MAC layer is the NewMAC which accepts many parameter changes there is no routing since it use the default "bypass" module the application behavior the the valuePropagation implementation Simulations/Parameters folder can also be seen to do more settings.

Adding your own MAC


Suppose that you want to implement a new MAC behavior called newMAC Here are the main steps:

1. go into src/node/communication/mac directory and create a new folder called newMac. You can use an existing MAC implementation to have a starting point for implementing you new Mac protocol since many things may be similar. For instance, you can copy all the file in the src/node/communication/mac/tunableMac folder into you new newMac folder. You can then use sed to change every occurence of "TunableMAC" by "NEWMAC" in both .cc and .h files Rename all the files as NEWMAC.CC, NEWMAC.h, NEWMAC.ned Note: This can be done by renaming the file names as NEWMAC (should be in Capital letters) go into the Castalia root directory > ./makemake > make 2. Don't forget to add or remove in the newMac.ned file any variables that you want to introduce/remove in your CLMac module 3. After implementing the behavior of you own MAC layer, you can set in the omnetpp.ini file (the one in Simulations/valuePropagation for instance) that the MAC layer of sensor nodes now uses your own implementation with the following lines: SN.node[*].Communication.MACProtocolName = "NEWMAC" You can test all these steps and try to compile Castalia again even if you are not changing the implementation of your newMac. If you based NEWMAC on TunableMAC, Castalia should compile and allows you to incrementally change newMac. Note that you could test if the introduction of newMac is successful by defining for the valuePropagation application the following omnetpp.ini file:
#indicates that node[0] runs our CLMac layer SN.node[0].networkInterface.macModuleName = "CLMAC" #all the other nodes will run TunableMacModule, but since we changed nothing, CLMac currently performs #exactly as TunableMac SN.node[*].Communication.MACProtocolName = "TunableMAC"

S-ar putea să vă placă și