nexmon – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /*--------------------------------------------------------------- |
2 | * Copyright (c) 1999,2000,2001,2002,2003 |
||
3 | * The Board of Trustees of the University of Illinois |
||
4 | * All Rights Reserved. |
||
5 | *--------------------------------------------------------------- |
||
6 | * Permission is hereby granted, free of charge, to any person |
||
7 | * obtaining a copy of this software (Iperf) and associated |
||
8 | * documentation files (the "Software"), to deal in the Software |
||
9 | * without restriction, including without limitation the |
||
10 | * rights to use, copy, modify, merge, publish, distribute, |
||
11 | * sublicense, and/or sell copies of the Software, and to permit |
||
12 | * persons to whom the Software is furnished to do |
||
13 | * so, subject to the following conditions: |
||
14 | * |
||
15 | * |
||
16 | * Redistributions of source code must retain the above |
||
17 | * copyright notice, this list of conditions and |
||
18 | * the following disclaimers. |
||
19 | * |
||
20 | * |
||
21 | * Redistributions in binary form must reproduce the above |
||
22 | * copyright notice, this list of conditions and the following |
||
23 | * disclaimers in the documentation and/or other materials |
||
24 | * provided with the distribution. |
||
25 | * |
||
26 | * |
||
27 | * Neither the names of the University of Illinois, NCSA, |
||
28 | * nor the names of its contributors may be used to endorse |
||
29 | * or promote products derived from this Software without |
||
30 | * specific prior written permission. |
||
31 | * |
||
32 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||
33 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
||
34 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
||
35 | * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT |
||
36 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
||
37 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
||
38 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||
39 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||
40 | * ________________________________________________________________ |
||
41 | * National Laboratory for Applied Network Research |
||
42 | * National Center for Supercomputing Applications |
||
43 | * University of Illinois at Urbana-Champaign |
||
44 | * http://www.ncsa.uiuc.edu |
||
45 | * ________________________________________________________________ |
||
46 | * |
||
47 | * Reporter.h |
||
48 | * by Kevin Gibbs <kgibbs@nlanr.net> |
||
49 | * |
||
50 | * Since version 2.0 this handles all reporting. |
||
51 | * ________________________________________________________________ */ |
||
52 | |||
53 | #ifndef REPORTER_H |
||
54 | #define REPORTER_H |
||
55 | |||
56 | #include "headers.h" |
||
57 | #include "Mutex.h" |
||
58 | |||
59 | struct thread_Settings; |
||
60 | struct server_hdr; |
||
61 | |||
62 | #include "Settings.hpp" |
||
63 | |||
64 | #define NUM_REPORT_STRUCTS 10000 |
||
65 | #define NUM_MULTI_SLOTS 5 |
||
66 | // If the minimum latency exceeds the boundaries below |
||
67 | // assume the clocks are not synched and suppress the |
||
68 | // latency output. Units are seconds |
||
69 | #define UNREALISTIC_LATENCYMINMIN -1 |
||
70 | #define UNREALISTIC_LATENCYMINMAX 60 |
||
71 | |||
72 | #ifdef __cplusplus |
||
73 | extern "C" { |
||
74 | #endif |
||
75 | |||
76 | /* |
||
77 | * |
||
78 | * Used for end/end latency measurements |
||
79 | * |
||
80 | */ |
||
81 | typedef struct TransitStats { |
||
82 | double maxTransit; |
||
83 | double minTransit; |
||
84 | double sumTransit; |
||
85 | double lastTransit; |
||
86 | double meanTransit; |
||
87 | double m2Transit; |
||
88 | double vdTransit; |
||
89 | int cntTransit; |
||
90 | double totmaxTransit; |
||
91 | double totminTransit; |
||
92 | double totsumTransit; |
||
93 | int totcntTransit; |
||
94 | double totmeanTransit; |
||
95 | double totm2Transit; |
||
96 | double totvdTransit; |
||
97 | } TransitStats; |
||
98 | |||
99 | typedef struct ReadStats { |
||
100 | int cntRead; |
||
101 | int totcntRead; |
||
102 | int bins[8]; |
||
103 | int totbins[8]; |
||
104 | int binsize; |
||
105 | } ReadStats; |
||
106 | |||
107 | typedef struct WriteStats { |
||
108 | int WriteCnt; |
||
109 | int WriteErr; |
||
110 | int TCPretry; |
||
111 | int totWriteCnt; |
||
112 | int totWriteErr; |
||
113 | int totTCPretry; |
||
114 | int lastTCPretry; |
||
115 | int cwnd; |
||
116 | int rtt; |
||
117 | } WriteStats; |
||
118 | |||
119 | /* |
||
120 | * This struct contains all important information from the sending or |
||
121 | * recieving thread. |
||
122 | */ |
||
123 | typedef struct ReportStruct { |
||
124 | int packetID; |
||
125 | max_size_t packetLen; |
||
126 | struct timeval packetTime; |
||
127 | struct timeval sentTime; |
||
128 | int errwrite; |
||
129 | int emptyreport; |
||
130 | int socket; |
||
131 | } ReportStruct; |
||
132 | |||
133 | |||
134 | /* |
||
135 | * The type field of ReporterData is a bitmask |
||
136 | * with one or more of the following |
||
137 | */ |
||
138 | #define TRANSFER_REPORT 0x00000001 |
||
139 | #define SERVER_RELAY_REPORT 0x00000002 |
||
140 | #define SETTINGS_REPORT 0x00000004 |
||
141 | #define CONNECTION_REPORT 0x00000008 |
||
142 | #define MULTIPLE_REPORT 0x00000010 |
||
143 | |||
144 | typedef union { |
||
145 | ReadStats read; |
||
146 | WriteStats write; |
||
147 | } TCPStats; |
||
148 | |||
149 | typedef struct Transfer_Info { |
||
150 | void *reserved_delay; |
||
151 | int transferID; |
||
152 | int groupID; |
||
153 | int cntError; |
||
154 | int cntOutofOrder; |
||
155 | int cntDatagrams; |
||
156 | int IPGcnt; |
||
157 | int socket; |
||
158 | TransitStats transit; |
||
159 | TCPStats tcp; |
||
160 | // Hopefully int64_t's |
||
161 | max_size_t TotalLen; |
||
162 | double jitter; |
||
163 | double startTime; |
||
164 | double endTime; |
||
165 | double IPGsum; |
||
166 | // chars |
||
167 | char mFormat; // -f |
||
168 | char mEnhanced; // -e |
||
169 | u_char mTTL; // -T |
||
170 | char mUDP; |
||
171 | char mTCP; |
||
172 | char free; |
||
173 | } Transfer_Info; |
||
174 | |||
175 | typedef struct Connection_Info { |
||
176 | iperf_sockaddr peer; |
||
177 | Socklen_t size_peer; |
||
178 | iperf_sockaddr local; |
||
179 | Socklen_t size_local; |
||
180 | } Connection_Info; |
||
181 | |||
182 | typedef struct ReporterData { |
||
183 | char* mHost; // -c |
||
184 | char* mLocalhost; // -B |
||
185 | // int's |
||
186 | int type; |
||
187 | int cntError; |
||
188 | int lastError; |
||
189 | int cntOutofOrder; |
||
190 | int lastOutofOrder; |
||
191 | int cntDatagrams; |
||
192 | int lastDatagrams; |
||
193 | int PacketID; |
||
194 | int mBufLen; // -l |
||
195 | int mMSS; // -M |
||
196 | int mTCPWin; // -w |
||
197 | max_size_t mUDPRate; // -b or -u |
||
198 | RateUnits mUDPRateUnits; // -b is either bw or pps |
||
199 | /* flags is a BitMask of old bools |
||
200 | bool mBufLenSet; // -l |
||
201 | bool mCompat; // -C |
||
202 | bool mDaemon; // -D |
||
203 | bool mDomain; // -V |
||
204 | bool mFileInput; // -F or -I |
||
205 | bool mNodelay; // -N |
||
206 | bool mPrintMSS; // -m |
||
207 | bool mRemoveService; // -R |
||
208 | bool mStdin; // -I |
||
209 | bool mStdout; // -o |
||
210 | bool mSuggestWin; // -W |
||
211 | bool mUDP; |
||
212 | bool mMode_time;*/ |
||
213 | int flags; |
||
214 | // enums (which should be special int's) |
||
215 | ThreadMode mThreadMode; // -s or -c |
||
216 | ReportMode mode; |
||
217 | max_size_t TotalLen; |
||
218 | max_size_t lastTotal; |
||
219 | // doubles |
||
220 | // shorts |
||
221 | unsigned short mPort; // -p |
||
222 | // structs or miscellaneous |
||
223 | Transfer_Info info; |
||
224 | Connection_Info connection; |
||
225 | struct timeval startTime; |
||
226 | struct timeval packetTime; |
||
227 | struct timeval nextTime; |
||
228 | struct timeval intervalTime; |
||
229 | struct timeval IPGstart; |
||
230 | } ReporterData; |
||
231 | |||
232 | typedef struct MultiHeader { |
||
233 | int reporterindex; |
||
234 | int agentindex; |
||
235 | int groupID; |
||
236 | int threads; |
||
237 | ReporterData *report; |
||
238 | Transfer_Info *data; |
||
239 | Condition barrier; |
||
240 | struct timeval startTime; |
||
241 | } MultiHeader; |
||
242 | |||
243 | typedef struct ReportHeader { |
||
244 | int reporterindex; |
||
245 | int agentindex; |
||
246 | ReporterData report; |
||
247 | ReportStruct *data; |
||
248 | MultiHeader *multireport; |
||
249 | struct ReportHeader *next; |
||
250 | } ReportHeader; |
||
251 | |||
252 | typedef void* (* report_connection)( Connection_Info*, int ); |
||
253 | typedef void (* report_settings)( ReporterData* ); |
||
254 | typedef void (* report_statistics)( Transfer_Info* ); |
||
255 | typedef void (* report_serverstatistics)( Connection_Info*, Transfer_Info* ); |
||
256 | |||
257 | MultiHeader* InitMulti( struct thread_Settings *agent, int inID ); |
||
258 | ReportHeader* InitReport( struct thread_Settings *agent ); |
||
259 | void ReportPacket( ReportHeader *agent, ReportStruct *packet ); |
||
260 | void CloseReport( ReportHeader *agent, ReportStruct *packet ); |
||
261 | void EndReport( ReportHeader *agent ); |
||
262 | Transfer_Info* GetReport( ReportHeader *agent ); |
||
263 | void ReportServerUDP( struct thread_Settings *agent, struct server_hdr *server ); |
||
264 | void ReportSettings( struct thread_Settings *agent ); |
||
265 | void ReportConnections( struct thread_Settings *agent ); |
||
266 | |||
267 | extern report_connection connection_reports[]; |
||
268 | |||
269 | extern report_settings settings_reports[]; |
||
270 | |||
271 | extern report_statistics statistics_reports[]; |
||
272 | |||
273 | extern report_serverstatistics serverstatistics_reports[]; |
||
274 | |||
275 | extern report_statistics multiple_reports[]; |
||
276 | |||
277 | extern char buffer[64]; // Buffer for printing |
||
278 | |||
279 | #define rMillion 1000000 |
||
280 | |||
281 | #define TimeDifference( left, right ) (left.tv_sec - right.tv_sec) + \ |
||
282 | (left.tv_usec - right.tv_usec) / ((double) rMillion) |
||
283 | |||
284 | #define TimeAdd( left, right ) do { \ |
||
285 | left.tv_usec += right.tv_usec; \ |
||
286 | if ( left.tv_usec > rMillion ) { \ |
||
287 | left.tv_usec -= rMillion; \ |
||
288 | left.tv_sec++; \ |
||
289 | } \ |
||
290 | left.tv_sec += right.tv_sec; \ |
||
291 | } while ( 0 ) |
||
292 | #ifdef __cplusplus |
||
293 | } /* end extern "C" */ |
||
294 | #endif |
||
295 | |||
296 | #endif // REPORTER_H |