MoBANCoordinator.h

00001 /* -*- mode:c++ -*- ********************************************************
00002  * file:        MoBANCoordinator.h
00003  *
00004  * author:      Majid Nabi <m.nabi@tue.nl>
00005  *
00006  *              http://www.es.ele.tue.nl/nes
00007  *
00008  * copyright:   (C) 2010 Electronic Systems group(ES),
00009  *              Eindhoven University of Technology (TU/e), the Netherlands.
00010  *
00011  *
00012  *              This program is free software; you can redistribute it
00013  *              and/or modify it under the terms of the GNU General Public
00014  *              License as published by the Free Software Foundation; either
00015  *              version 2 of the License, or (at your option) any later
00016  *              version.
00017  *              For further information see file COPYING
00018  *              in the top level directory
00019  ***************************************************************************
00020  * part of:    MoBAN (Mobility Model for wireless Body Area Networks)
00021  * description:     Implementation of the coordinator module of the MoBAN mobility model
00022  ***************************************************************************
00023  * Citation of the following publication is appreciated if you use MoBAN for
00024  * a publication of your own.
00025  *
00026  * M. Nabi, M. Geilen, T. Basten. MoBAN: A Configurable Mobility Model for Wireless Body Area Networks.
00027  * In Proc. of the 4th Int'l Conf. on Simulation Tools and Techniques, SIMUTools 2011, Barcelona, Spain, 2011.
00028  *
00029  * BibTeX:
00030  *    @inproceedings{MoBAN,
00031  *    author = "M. Nabi and M. Geilen and T. Basten.",
00032  *    title = "{MoBAN}: A Configurable Mobility Model for Wireless Body Area Networks.",
00033  *      booktitle = "Proceedings of the 4th Int'l Conf. on Simulation Tools and Techniques.",
00034  *      series = {SIMUTools '11},
00035  *      isbn = {978-963-9799-41-7},
00036  *      year = {2011},
00037  *      location = {Barcelona, Spain},
00038  *      publisher = {ICST} }
00039  *
00040  **************************************************************************/
00041 
00042 #include <sstream>
00043 #include <omnetpp.h>
00044 #include <BaseWorldUtility.h>
00045 #include <ImNotifiable.h>
00046 #include <FindModule.h>
00047 #include <HostState.h>
00048 #include <BaseUtility.h>
00049 #include "MoBANBBItem.h"
00050 #include "Posture.h"
00051 #include "PostureTransition.h"
00052 
00053 
00054 #include <cxmlelement.h>
00055 #include <vector>
00056 #include <iostream>
00057 
00093 class MoBANCoordinator: public cSimpleModule
00094 {
00095   protected:
00096 
00098     bool debug;
00099 
00101    BaseUtility *utility;
00102 
00104    BaseWorldUtility *world;
00105 
00107     cModule* network;
00108 
00110   simtime_t updateInterval;
00111 
00113   cMessage* MoveMsg;
00114 
00115 
00117     unsigned int numNodes;
00118 
00120     double speed;
00121 
00123     int index;
00124 
00126     FILE* logfile;
00127 
00129     unsigned int numPostures;
00130 
00132     std::vector<Posture*> postureList;
00133 
00135     Posture* currentPosture;
00136 
00138     simtime_t duration;
00139 
00141     simtime_t minDuration;
00142 
00144     simtime_t maxDuration;
00145 
00147     int* nodeIndex;
00148 
00150     Coord logicalCenter;
00151 
00153     int step;
00154 
00156     int numSteps;
00157 
00159     Coord targetPos;
00160 
00162     Coord stepTarget;
00163 
00165     Coord stepSize;
00166 
00167 
00170     bool useMobilityPattern;
00171 
00173     typedef struct pattern{
00174       unsigned int postureID;
00175       Coord targetPos;
00176       double speed;
00177       simtime_t duration;
00178     }Pattern;
00179 
00180 
00182     Pattern* mobilityPattern;
00183 
00187     int patternLength;
00188 
00190     int currentPattern;
00191 
00195     double** markovMatrix;
00196 
00198     enum posture_sel_type {
00199       UNIFORM_RANDOM = 0,   // uniform random posture selection. No correlation is applied.
00200       MARKOV_BASE       // Either a Markov model matrix or a steady state vector is given for space-time domains
00201     };
00202 
00204     posture_sel_type postureSelStrategy;
00205 
00207     PostureTransition* transitions;
00208 
00209   public:
00210 
00212     virtual void initialize(int);
00213 
00214   protected:
00215 
00217     void handleMessage(cMessage *msg);
00218 
00220     virtual void finish();
00221 
00223     void selectPosture();
00224 
00226    Coord selectDestination();
00227 
00229    double selectSpeed();
00230 
00232    simtime_t  selectDuration();
00233 
00235    void mainProcess();
00236 
00238    void stepMove();
00239 
00241    bool isInsideWorld(Coord);
00242 
00244    bool readPostureSpecificationFile();
00245 
00247    bool readConfigurationFile();
00248 
00250    bool readMobilityPatternFile();
00251 
00253    void publishToNodes();
00254 
00255 };