OverSim
SimpleNodeEntry.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2000 Institut fuer Telematik, Universitaet Karlsruhe
3 // Copyright (C) 2004 Andras Varga
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 //
19 
26 #ifndef __SIMPLENODEENTRY_H
27 #define __SIMPLENODEENTRY_H
28 
29 
30 #include <omnetpp.h>
31 #include <IPvXAddress.h>
32 
33 #include "UDPPacket_m.h"
34 #include "TCPSegment.h"
35 
36 #include "BaseLocation.h"
37 
38 
39 class NodeRecord: public BaseLocation
40 {
41  public:
42  //NodeRecord(uint32_t dim);
43  NodeRecord();
44  ~NodeRecord();
45  NodeRecord(const NodeRecord& nodeRecord);
46  NodeRecord& operator=(const NodeRecord& nodeRecord);
47  bool operator==(const BaseLocation& rhs);
48  void debugOutput(int dim);
49 
50  double* coords;
51  //IPvXAddress ip;
52  static uint8_t dim;
53  static void setDim(uint8_t dimension) { dim = dimension; };
54  uint8_t getDim() const { return dim; };
55 };
56 
62 class SimpleNodeEntry : public cPolymorphic
63 {
64 public:
65 
67  {
68  if (index == -1) delete nodeRecord;
69  }
70 
80  SimpleNodeEntry(cModule* node, cChannelType* typeRx, cChannelType* typeTx,
81  uint32_t sendQueueLength, uint32_t fieldSize);
82 
93  SimpleNodeEntry(cModule* node, cChannelType* typeRx, cChannelType* typeTx,
94  uint32_t sendQueueLength, NodeRecord* nodeRecord,
95  int index);
96 
102  inline cGate* getUdpIPv4Gate() const
103  {
104  return UdpIPv4ingate;
105  };
106 
112  inline cGate* getUdpIPv6Gate() const
113  {
114  return UdpIPv6ingate;
115  };
116 
122  inline cGate* getTcpIPv4Gate() const
123  {
124  return TcpIPv4ingate;
125  };
126 
132  inline cGate* getTcpIPv6Gate() const
133  {
134  return TcpIPv6ingate;
135  };
136 
137  typedef std::pair<simtime_t, bool> SimpleDelay;
138 
147  SimpleDelay calcDelay(cPacket* msg,
148  const SimpleNodeEntry& dest,
149  bool faultyDelay = false);
150 
157  SimpleDelay calcAccessRouterDelay(cPacket* msg);
158 
164  std::string info() const;
165 
173  friend std::ostream& operator<<(std::ostream& out, const SimpleNodeEntry& entry);
174 
175  simtime_t getAccessDelay() const { return tx.accessDelay; };
176 
177  simtime_t getTxAccessDelay() const { return tx.accessDelay; };
178  simtime_t getRxAccessDelay() const { return rx.accessDelay; };
179 
180  // typo fixed, thanks to huebby
181  float getBandwidth() const { return tx.bandwidth; };
182 
183  float getTxBandwidth() const { return tx.bandwidth; };
184  float getRxBandwidth() const { return rx.bandwidth; };
185 
186  float getErrorRate() const { return tx.errorRate; };
187 
188  inline void setX(float x) { nodeRecord->coords[0] = x; };
189  inline void setY(float y) { nodeRecord->coords[1] = y; };
190  inline float getX() const { return nodeRecord->coords[0]; };
191  inline float getY() const { return nodeRecord->coords[1]; };
192  inline float getCoords(int dim) const { return nodeRecord->coords[dim]; };
193  inline uint8_t getDim() const { return nodeRecord->getDim(); };
194 
195  int getRecordIndex() const { return index; };
196  NodeRecord* getNodeRecord() const { return nodeRecord; };
197 
203  static simtime_t getFaultyDelay(simtime_t oldDelay);
204 
205 
206 protected:
207 
214  float operator-(const SimpleNodeEntry& entry) const;
215 
216  cGate* UdpIPv4ingate;
217  cGate* UdpIPv6ingate;
218  cGate* TcpIPv4ingate;
219  cGate* TcpIPv6ingate;
220 
221  struct Channel {
222  simtime_t finished;
223  simtime_t maxQueueTime;
224  simtime_t accessDelay;
225  double bandwidth;
226  double errorRate;
227  } rx, tx;
228 
230  int index;
231 };
232 
233 
234 #endif // __SIMPLENODEENTRY_H