OMNeT++ Parallel Simulation Support 6.1
Discrete Event Simulation Library
cnullmessageprot.h
1 //=========================================================================
2 // CNULLMESSAGEPROT.H - part of
3 //
4 // OMNeT++/OMNEST
5 // Discrete System Simulation in C++
6 //
7 //=========================================================================
8 
9 /*--------------------------------------------------------------*
10  Copyright (C) 1992-2017 Andras Varga
11  Copyright (C) 2006-2017 OpenSim Ltd.
12 
13  This file is distributed WITHOUT ANY WARRANTY. See the file
14  `license' for details on this and other legal matters.
15 *--------------------------------------------------------------*/
16 
17 #ifndef __OMNETPP_CNULLMESSAGEPROT_H
18 #define __OMNETPP_CNULLMESSAGEPROT_H
19 
20 #include "omnetpp/cmessage.h" // MK_PARSIM_BEGIN
21 #include "cparsimprotocolbase.h"
22 
23 namespace omnetpp {
24 
25 class cCommBuffer;
26 class cNMPLookahead;
27 
28 
37 {
38  protected:
39  struct PartitionInfo
40  {
41  cMessage *eitEvent; // EIT received from partition
42  cMessage *eotEvent; // events which marks that a null message should be sent out
43  simtime_t lastEotSent; // last EOT value that was sent
44  };
45 
46  // partition information
47  int numSeg = 0; // number of partitions
48  PartitionInfo *segInfo = nullptr; // partition info array, size numSeg
49 
50  // controls null message resend frequency, 0<=laziness<=1
51  double laziness;
52 
53  // internally used message kinds
54  enum
55  {
56  MK_PARSIM_EIT = MK_PARSIM_BEGIN - 1,
57  MK_PARSIM_RESENDEOT = MK_PARSIM_BEGIN - 2
58  };
59 
60  bool debug;
61 
62  cNMPLookahead *lookaheadcalc;
63 
64  protected:
65  // process buffers coming from other partitions
66  virtual void processReceivedBuffer(cCommBuffer *buffer, int tag, int sourceProcId) override;
67 
68  // processes a received EIT: reschedule partition's EIT message
69  virtual void processReceivedEIT(int sourceProcId, simtime_t eit);
70 
71  // resend null message to this partition
72  virtual void sendNullMessage(int procId, simtime_t now);
73 
74  // reschedule event in FES, to the given time
75  virtual void rescheduleEvent(cMessage *msg, simtime_t t);
76 
77  public:
82 
86  virtual ~cNullMessageProtocol();
87 
92  virtual void setContext(cSimulation *sim, cParsimPartition *seg, cParsimCommunications *co) override;
93 
101  void setLaziness(double d) {laziness = d;}
102 
106  double getLaziness() {return laziness;}
107 
111  virtual void startRun() override;
112 
116  virtual void endRun() override;
117 
121  virtual cEvent *takeNextEvent() override;
122 
126  virtual void putBackEvent(cEvent *event) override;
127 
133  virtual void processOutgoingMessage(cMessage *msg, const SendOptions& options, int procId, int moduleId, int gateId, void *data) override;
134 };
135 
136 } // namespace omnetpp
137 
138 
139 #endif
omnetpp::cNullMessageProtocol::getLaziness
double getLaziness()
Definition: cnullmessageprot.h:106
omnetpp::cNullMessageProtocol::setLaziness
void setLaziness(double d)
Definition: cnullmessageprot.h:101
omnetpp::cNMPLookahead
Base class of lookahead calculations for cNullMessageProtocol which implements the "null message algo...
Definition: cnmplookahead.h:37
omnetpp::cParsimPartition
Represents one partition in a parallel simulation. Knows about partitions and the links between this ...
Definition: cparsimpartition.h:58
omnetpp::cParsimProtocolBase
Contains utility functions for implementing parallel simulation protocols.
Definition: cparsimprotocolbase.h:32
omnetpp::cNullMessageProtocol
Implements the "null message algorithm". Lookahead calculation is encapsulated into a separate object...
Definition: cnullmessageprot.h:36