RINASim  October 2016
Documentation of framework for OMNeT++
PortsLoadMonitor.h
Go to the documentation of this file.
1 //
2 // Copyright © 2014 - 2015 PRISTINE Consortium (http://ict-pristine.eu)
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Lesser General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public License
15 // along with this program. If not, see http://www.gnu.org/licenses/.
16 //
17 
18 #ifndef __PORTSLOADMONITOR_H
19 #define __PORTSLOADMONITOR_H
20 
21 // Comment to remove the enhanced debugging.
22 //#define PORTSLOADMONITOR_ENHANCED_DEBUG
23 
24 #include "RMTQMonitorBase.h"
25 #include "RMTModuleAllocator.h"
26 
27 // Will map (link --> input + output bytes).
28 typedef std::map<RMTPort *, int64_t> PortsMap;
29 // Single entry of the map.
30 typedef std::pair<RMTPort *, int64_t> PMElem;
31 // Simply iterator over the map.
32 typedef PortsMap::iterator PMIter;
33 
34 // This policy will be in charge of monitoring the receiving/transmission rates
35 // for the IPC process.
36 //
38 {
39 private:
40 
41  // Pointer to the RMT module allocator to resolve queue --> port matching.
43 
44  // Accumulation map.
46  // Rates map.
48 
49 #ifdef PORTSLOADMONITOR_ENHANCED_DEBUG
50  void enhancedDebug();
51 #endif
52 
53 protected:
54 
55  // Timed operation are handled here.
56  virtual void handleMessage(cMessage* msg);
57 
58  // Initialization operations.
59  virtual void onPolicyInit();
60 
61 public:
62 
63  // Get the load of the port.
64  // 0 if no traffic has been detected or if the port does not exists.
65  int64_t getByteRate(RMTPort * port);
66 
67  // A PDU arrived.
68  virtual void postPDUInsertion(RMTQueue* queue);
69 
70  // A PDU departed; when this procedure is invoked then the PDU has already
71  // left the queue.
72  virtual void prePDURelease(RMTQueue* queue);
73 };
74 
75 #endif // __PORTSLOADMONITOR_H
std::pair< RMTPort *, int64_t > PMElem
virtual void onPolicyInit()
PortsMap::iterator PMIter
std::map< RMTPort *, int64_t > PortsMap
virtual void postPDUInsertion(RMTQueue *queue)
RMTModuleAllocator * rmtA
virtual void prePDURelease(RMTQueue *queue)
int64_t getByteRate(RMTPort *port)
virtual void handleMessage(cMessage *msg)