RINASim  October 2016
Documentation of framework for OMNeT++
RMTPort.h
Go to the documentation of this file.
1 // The MIT License (MIT)
2 //
3 // Copyright (c) 2014-2016 Brno University of Technology, PRISTINE project
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 // THE SOFTWARE.
22 
23 #ifndef __RINA_RMTPORT_H_
24 #define __RINA_RMTPORT_H_
25 
26 #include <omnetpp.h>
27 #include <algorithm>
28 
29 #include "Utils.h"
30 #include "RINASignals.h"
31 #include "Flow.h"
32 #include "RMTQueue.h"
33 #include "QueueIDGenBase.h"
34 #include "SDUData_m.h"
35 
36 class RMTPort : public cSimpleModule
37 {
38  /* tight coupling for management purposes */
39  friend class RA;
40  friend class RMT;
41  friend class RMTModuleAllocator;
42 
43  public:
44 
50  bool isOutputReady();
51 
57  bool isInputReady();
58 
62  void blockOutput();
63 
67  void unblockOutput();
68 
72  void blockInput();
73 
77  void unblockInput();
78 
82  bool hasBlockedInput() { return blockedInput; };
83 
84  /*
85  * Returns the input drain speed of this port.
86  */
87  long getInputRate();
88 
89  /*
90  * Sets the input drain speed of this port.
91  */
92  void setInputRate(long pdusPerSecond);
93 
99  const Flow* getFlow() const;
100 
108  RMTQueue* getFirstQueue(RMTQueueType type) const;
109 
117 
125  RMTQueue* getQueueById(RMTQueueType type, const char* queueId) const;
126 
133 
140 
147  unsigned long getWaiting(RMTQueueType direction);
148 
149  protected:
150  virtual void initialize();
151  virtual void handleMessage(cMessage* msg);
152 
158  void addWaiting(RMTQueueType direction);
159 
166  void substractWaiting(RMTQueueType direction);
167 
168  private:
173  unsigned long waitingOnInput;
174  unsigned long waitingOnOutput;
177  std::string dstAppAddr;
178  std::string dstAppQoS;
179 
182 
183  std::set<cGate*> northInputGates;
186  cGate* protectIn;
187  cGate* protectOut;
188  cGate* unprotectIn;
189  cGate* unprotectOut;
190  cChannel* outputChannel;
191 
194 
198  void setOutputReady();
199 
203  void setOutputBusy();
204 
208  void setInputReady();
209 
213  void setInputBusy();
214 
215  void postInitialize();
216  void setFlow(Flow* flow);
217  void registerInputQueue(RMTQueue* queue);
218  void registerOutputQueue(RMTQueue* queue);
219  void unregisterInputQueue(RMTQueue* queue);
220  void unregisterOutputQueue(RMTQueue* queue);
221  cGate* getSouthInputGate() const;
222  cGate* getSouthOutputGate() const;
223 
224  void scheduleNextRead();
225  void scheduleNextWrite();
226  void redrawGUI(bool redrawParent = false);
227 
230  simsignal_t sigStatRMTPortUp;
231  simsignal_t sigStatRMTPortDown;
232 };
233 
234 typedef std::vector<RMTPort*> RMTPorts;
235 
236 #endif
Class representing flow object with attributes from specs.
Definition: Flow.h:45
void unregisterOutputQueue(RMTQueue *queue)
Definition: RMTPort.cc:202
void unblockInput()
Definition: RMTPort.cc:423
void redrawGUI(bool redrawParent=false)
Definition: RMTPort.cc:341
simsignal_t sigRMTPortReadyForRead
Definition: RMTPort.h:228
cGate * southOutputGate
Definition: RMTPort.h:185
simsignal_t sigStatRMTPortDown
Definition: RMTPort.h:231
QueueIDGenBase * queueIdGen
Definition: RMTPort.h:181
void scheduleNextWrite()
Definition: RMTPort.cc:303
std::vector< RMTPort * > RMTPorts
Definition: RMTPort.h:234
unsigned long waitingOnInput
Definition: RMTPort.h:173
void postInitialize()
Definition: RMTPort.cc:65
cGate * protectIn
Definition: RMTPort.h:186
RMTQueue * getFirstQueue(RMTQueueType type) const
Definition: RMTPort.cc:219
void setInputRate(long pdusPerSecond)
Definition: RMTPort.cc:335
void unregisterInputQueue(RMTQueue *queue)
Definition: RMTPort.cc:196
void scheduleNextRead()
Definition: RMTPort.cc:308
RMTQueue * getLongestQueue(RMTQueueType type) const
Definition: RMTPort.cc:226
RMTQueues & getInputQueues()
Definition: RMTPort.cc:174
std::set< cGate * > northInputGates
Definition: RMTPort.h:183
void unblockOutput()
Definition: RMTPort.cc:408
void setOutputReady()
Definition: RMTPort.cc:266
unsigned long waitingOnOutput
Definition: RMTPort.h:174
Flow * flow
Definition: RMTPort.h:180
double postReadDelay
Definition: RMTPort.h:176
void blockOutput()
Definition: RMTPort.cc:397
cGate * unprotectOut
Definition: RMTPort.h:189
RMTQueues outputQueues
Definition: RMTPort.h:192
RMTQueues & getOutputQueues()
Definition: RMTPort.cc:179
bool outputReady
Definition: RMTPort.h:170
simsignal_t sigStatRMTPortUp
Definition: RMTPort.h:230
Definition: RA.h:61
cChannel * outputChannel
Definition: RMTPort.h:190
Definition: RMT.h:60
std::string dstAppAddr
Definition: RMTPort.h:177
void setInputReady()
Definition: RMTPort.cc:287
unsigned long getWaiting(RMTQueueType direction)
Definition: RMTPort.cc:315
bool blockedOutput
Definition: RMTPort.h:172
cGate * protectOut
Definition: RMTPort.h:187
cGate * getSouthInputGate() const
Definition: RMTPort.cc:209
bool isOutputReady()
Definition: RMTPort.cc:261
cGate * southInputGate
Definition: RMTPort.h:184
void substractWaiting(RMTQueueType direction)
Definition: RMTPort.cc:325
void addWaiting(RMTQueueType direction)
Definition: RMTPort.cc:320
void setInputBusy()
Definition: RMTPort.cc:297
void registerInputQueue(RMTQueue *queue)
Definition: RMTPort.cc:184
long inputReadRate
Definition: RMTPort.h:175
simsignal_t sigRMTPortReadyToWrite
Definition: RMTPort.h:229
RMTQueue * getQueueById(RMTQueueType type, const char *queueId) const
Definition: RMTPort.cc:244
bool blockedInput
Definition: RMTPort.h:171
RMTQueues inputQueues
Definition: RMTPort.h:193
void blockInput()
Definition: RMTPort.cc:416
bool isInputReady()
Definition: RMTPort.cc:282
std::string dstAppQoS
Definition: RMTPort.h:178
bool hasBlockedInput()
Definition: RMTPort.h:82
cGate * getSouthOutputGate() const
Definition: RMTPort.cc:214
long getInputRate()
Definition: RMTPort.cc:330
void setFlow(Flow *flow)
Definition: RMTPort.cc:374
void registerOutputQueue(RMTQueue *queue)
Definition: RMTPort.cc:190
void setOutputBusy()
Definition: RMTPort.cc:276
const Flow * getFlow() const
Definition: RMTPort.cc:369
std::vector< RMTQueue * > RMTQueues
Definition: RMTQueue.h:180
bool inputReady
Definition: RMTPort.h:169
virtual void handleMessage(cMessage *msg)
Definition: RMTPort.cc:76
virtual void initialize()
Definition: RMTPort.cc:30
cGate * unprotectIn
Definition: RMTPort.h:188