cnullmessageprot.h

00001 //=========================================================================
00002 //  CNULLMESSAGEPROT.H - part of
00003 //
00004 //                  OMNeT++/OMNEST
00005 //           Discrete System Simulation in C++
00006 //
00007 //  Author: Andras Varga, 2003
00008 //          Dept. of Electrical and Computer Systems Engineering,
00009 //          Monash University, Melbourne, Australia
00010 //
00011 //=========================================================================
00012 
00013 /*--------------------------------------------------------------*
00014   Copyright (C) 2003-2008 Andras Varga
00015   Copyright (C) 2006-2008 OpenSim Ltd.
00016 
00017   This file is distributed WITHOUT ANY WARRANTY. See the file
00018   `license' for details on this and other legal matters.
00019 *--------------------------------------------------------------*/
00020 
00021 #ifndef __CNULLMESSAGEPROT_H__
00022 #define __CNULLMESSAGEPROT_H__
00023 
00024 #include "cparsimprotocolbase.h"
00025 #include "cmessage.h"  // MK_PARSIM_BEGIN
00026 
00027 NAMESPACE_BEGIN
00028 
00029 // forward declarations
00030 class cCommBuffer;
00031 class cNMPLookahead;
00032 
00033 
00041 class SIM_API cNullMessageProtocol : public cParsimProtocolBase
00042 {
00043   protected:
00044     struct PartitionInfo
00045     {
00046         cMessage *eitEvent;  // EIT received from partition
00047         cMessage *eotEvent;  // events which marks that a null message should be sent out
00048         simtime_t lastEotSent; // last EOT value that was sent
00049     };
00050 
00051     // partition information
00052     int numSeg;              // number of partitions
00053     PartitionInfo *segInfo;  // partition info array, size numSeg
00054 
00055     // controls null message resend frequency, 0<=laziness<=1
00056     double laziness;
00057 
00058     // internally used message kinds
00059     enum
00060     {
00061         MK_PARSIM_EIT =       MK_PARSIM_BEGIN - 1,
00062         MK_PARSIM_RESENDEOT = MK_PARSIM_BEGIN - 2
00063     };
00064 
00065     bool debug;
00066 
00067     cNMPLookahead *lookaheadcalc;
00068 
00069   protected:
00070     // process buffers coming from other partitions
00071     virtual void processReceivedBuffer(cCommBuffer *buffer, int tag, int sourceProcId);
00072 
00073     // processes a received EIT: reschedule partition's EIT message
00074     virtual void processReceivedEIT(int sourceProcId, simtime_t eit);
00075 
00076     // resend null message to this partition
00077     virtual void sendNullMessage(int procId, simtime_t now);
00078 
00079     // reschedule event in FES, to the given time
00080     virtual void rescheduleEvent(cMessage *msg, simtime_t t);
00081 
00082   public:
00086     cNullMessageProtocol();
00087 
00091     virtual ~cNullMessageProtocol();
00092 
00097     virtual void setContext(cSimulation *sim, cParsimPartition *seg, cParsimCommunications *co);
00098 
00106     void setLaziness(double d)  {laziness = d;}
00107 
00111     double getLaziness()  {return laziness;}
00112 
00116     virtual void startRun();
00117 
00121     virtual void endRun();
00122 
00126     virtual cMessage *getNextEvent();
00127 
00133     virtual void processOutgoingMessage(cMessage *msg, int procId, int moduleId, int gateId, void *data);
00134 };
00135 
00136 NAMESPACE_END
00137 
00138 
00139 #endif
Generated on Tue Dec 2 11:16:32 2014 for OMNeT++ Parallel Simulation Support by  doxygen 1.6.3