OverSim
SimpleTCP.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2010 Institut fuer Telematik, Karlsruher Institut fuer Technologie (KIT)
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (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 General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //
18 
30 #ifndef __SIMPLETCP_H
31 #define __SIMPLETCP_H
32 
33 //#include <map>
34 //#include <set>
35 #include <omnetpp.h>
36 #include "IPvXAddress.h"
37 #include <TCPConnection.h>
38 #include <InitStages.h>
39 
40 class SimpleNodeEntry;
41 
42 
44 
45 public:
46 
47  // delay fault type string and corresponding map for switch..case
48  std::string delayFaultTypeString;
54  };
55  std::map<std::string, delayFaultTypeNum> delayFaultTypeMap;
56 
57  // statistics
58  int numSent;
62  simtime_t delay;
64  simtime_t constantDelay;
66  double jitter;
67  bool faultyDelay;
71 };
72 
73 class SimpleTCPConnection : public TCPConnection {
74 
75 public:
76  SimpleTCPConnection():TCPConnection(){};
77  SimpleTCPConnection(TCP* mod, int appGateIndex, int connId):TCPConnection(mod, appGateIndex, connId){};
78 
80  virtual void sendToIP(TCPSegment *tcpseg);
81 
83 
85  void sendRst(uint32 seq, IPvXAddress src, IPvXAddress dest, int srcPort, int destPort);
87  void sendRstAck(uint32 seq, uint32 ack, IPvXAddress src, IPvXAddress dest, int srcPort, int destPort);
88 
89 protected:
91  virtual void sendToIP(TCPSegment *tcpseg, IPvXAddress src, IPvXAddress dest);
92 
95 
96 };
97 
98 class SimpleTCP : public TCP {
99 
100 public:
102  virtual ~SimpleTCP() {};
103 
104  void setNodeEntry (SimpleNodeEntry* entry);
105 
107 
108 protected:
109  // utility methods
110  void segmentArrivalWhileClosed(TCPSegment *tcpseg, IPvXAddress srcAddr, IPvXAddress destAddr);
111  SimpleTCPConnection *createConnection(int appGateIndex, int connId);
112  virtual void initialize(int stage);
113  virtual void handleMessage(cMessage *msg);
114 
115  virtual int numInitStages() const
116  {
117  return MAX_STAGE_UNDERLAY + 1;
118  }
119 
120  void finish();
121 };
122 
123 #endif