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