Debian Codegraph @

src/ITGSend/ITGSend.h

raw symbols SCIP
1 /*
2 * Component of the D-ITG 2.8.1 (r1023) platform (http://traffic.comics.unina.it/software/ITG)
3 *
4 * Copyright : (C) 2004-2013 by Alessio Botta, Walter de Donato, Alberto Dainotti,
5 * Stefano Avallone, Antonio Pescape' (PI)
6 * COMICS (COMputer for Interaction and CommunicationS) Group
7 * Department of Electrical Engineering and Information Technologies
8 * University of Napoli "Federico II".
9 * email : [email protected], [email protected], [email protected],
10 * [email protected], [email protected]
11 *
12 * This program is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 *
25 * For commercial use please refer to D-ITG Professional.
26 */
27
28
29
30 #include <vector>
31 #include <limits.h>
32 using namespace std;
33 #define DIM_NOME_FILE 200
34 #define DIM_MAX_IP_PACKET 65536
35
36 #define DefaultDSByte 0
37 #define rttmDelay 15
38 #define MAX_SCRIPT_LINE_SIZE 400
39
40
41 #define MSG_SM_NEWFLOW 1
42 #define MSG_SM_ENDFLOW 2
43 #define MSG_SM_ERRFLOW 3
44 #define MSG_SM_SNDACK 4
45
46
47 #define MSG_FP_END 1
48 #define MSG_FP_ERR1 2
49 #define MSG_FP_ERR2 3
50 #define MSG_FP_ERR3 4
51 #define MSG_FP_ERR4 5
52
53
54 #ifdef UNIX
55 extern const char DefaultLogFile[];
56 typedef int HANDLE;
57 #endif
58 #ifdef WIN32
59 extern char DefaultLogFile[];
60 #endif
61 extern const char DefaultDestIP[];
62
63
64
65
66 struct flowDescriptor {
67 int id;
68 struct addrinfo *SrcHost;
69 struct addrinfo *DestHost;
70 bool srcPortSpecify;
71 char *iface;
72 BYTE meter;
73 BYTE l4Proto;
74 BYTE l7Proto;
75 int icmptype;
76 unsigned int DSByte;
77 unsigned long Duration;
78 int TTL;
79 SumRandom * IntArriv;
80 SumRandom * PktSize;
81 TDistro IntArrivDistro;
82 TDistro PktSizeDistro;
83
84 #ifdef BURSTY
85 bool bursty;
86 SumRandom * OnPeriod;
87 SumRandom * OffPeriod;
88 TDistro OnPeriodDistro;
89 TDistro OffPeriodDistro;
90 #endif
91
92 int sigChanId;
93 BYTE status;
94 bool Nagle;
95 pthread_t handle;
96
97 HANDLE serial;
98 char serialReceiver[DIM_NAME_SERIAL_INTERFACE];
99
100 #ifdef UNIX
101 int parserPipe[2];
102 #endif
103 #ifdef WIN32
104 HANDLE parserPipe[3];
105 #endif
106 #ifdef SCTP
107 int sctpId;
108 #endif
109
110 int minPayloadSize;
111 int payloadLogType;
112
113 char payloadFile[DIM_PAYLOAD_FILE];
114 void * ptrPayloadBuffer;
115 long int dimPayloadBuffer;
116
117 int mean_adjustment;
118 bool srcAddrSpecify;
119 bool dstPortSpecify;
120
121 char pktSizeFile[DIM_NOME_FILE];
122 vector<uint32_t> vectSize;
123 char timeFile[DIM_NOME_FILE];
124 vector<Real> vectTime;
125 unsigned int numPacket;
126
127 unsigned long int KBToSend;
128
129
130 bool dstAddrSpecify;
131
132
133 struct addrinfo *SigDestHost;
134 struct addrinfo *SigSrcHost;
135 uint16_t SigSrcPort;
136 char *SigInterface;
137
138 bool pollingMode;
139
140 unsigned long int Delay;
141 struct timeval FlowStartTime;
142 };
143
144 extern flowDescriptor flows[MAX_NUM_THREAD];
145
146
147 struct flowParserParams {
148 int flowId;
149 char line[MAX_FLOW_LINE_SIZE];
150 };
151
152
153 struct icmppkt {
154 struct icmp icmp_buf;
155 char packet[MAX_PAYLOAD_SIZE];
156 };
157
158
159
160 struct icmppktv6 {
161 struct icmpv6 icmp_buf;
162 char packet[MAX_PAYLOAD_SIZE];
163 };
164
165
166 struct signalChannel {
167 int socket;
168 int flows;
169 #ifdef UNIX
170 int pipe[2];
171 #endif
172 #ifdef WIN32
173 HANDLE pipe[3];
174 #endif
175 pthread_t handle;
176 struct addrinfo *DestAddr;
177 bool errorLog;
178 };
179
180 extern signalChannel signalChannels[MAX_NUM_THREAD];
181
182 extern int sock;
183 extern char logFile[DIM_LOG_FILE];
184 extern ofstream out;
185 extern int logging;
186 extern int logSock;
187 extern int logremoto;
188 extern struct addrinfo *logHost;
189
190
191 extern BYTE protoTxLog;
192 extern BYTE protoTx_ServerLogReceiver;
193 extern int logSockSignaling;
194 extern int multiFlows;
195 extern int signalChanCount;
196 extern struct addrinfo *serverLogReceiver;
197 extern char LogFileServerLogReceiver[DIM_LOG_FILE];
198 extern int logServer;
199 extern int managerMode;
200 extern int managerSock;
201 #ifdef UNIX
202 extern pthread_mutex_t mutex;
203 extern pthread_mutex_t mutexLog;
204 #endif
205 #ifdef WIN32
206 extern HANDLE mutex;
207 extern HANDLE mutex_log;
208 #endif
209
210
211 int modeManager(int argc, char *argv[]);
212 int modeScript(int argc, char *argv[]);
213 int modeCommandLine(int argc, char *argv[]);
214 void parserMultiFlows(char *argv[], int argc);
215 void *flowParser(void *para);
216 void *signalManager(void *id);
217
218 int identifySignalManager(int flowId, int *chanId, struct addrinfo* &DestHost,bool &dstAddrSpecify);
219 void *flowSender(void *param);
220 void Terminate(int sig);
221 void printHelp();
222 void ReportErrorAndExit(const char *function, const char *msg, char *pname, int fid);
223 void sendType(int signalSock, BYTE typeMessag);
224 #ifdef UNIX
225 void createSignalChan(int signalSock);
226
227 void createTransportChan(int &signalSock, struct addrinfo* &DestHost,bool &dstAddrSpecify,struct addrinfo* &SrcHost,uint16_t SrcPort,const char * Interface);
228 void sendRelease(int signalSock);
229 #else
230 void createSignalChan(unsigned int signalSock);
231
232 void createTransportChan(unsigned int &signalSock, struct addrinfo* &DestHost,bool &dstAddrSpecify,struct addrinfo* &SrcHost,uint16_t SrcPort);
233 void sendRelease(unsigned int signalSock);
234 #endif
235 int sendLog(int signalSock, struct addrinfo *loghost, BYTE logProtocol, char *FileName);
236 void recvAck(int signalSock);
237 void closedFlowErr(int flowId, int signalSock);
238 int closedFlow(int flowId, int signalSock);
239 int sendAckFlow(int flowId, int signalSock);
240 int requestToSend(int flowId, int signalSock);
241 bool checkDestHostIP(int * chanId, struct addrinfo * DestHost);
242 void argvToString(char *argv[], int argc, char line[200]);
243 void flushBuffer(info *infos, int count);
244 void createRemoteLogFile(struct addrinfo *LogHost, BYTE Prototx_Log);
245 void memClean();
246 int isChannelClosable(int id);
247 void createSignalingLogChannel(BYTE protocolLog);
248 int sendNameLog(int signalSock, char *FileName,int sizeFileName);
249
250