1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2009, 2010 Benjamin Poirier <benjamin.poirier@polymtl.ca>
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 2.1 of the License, or (at
7 * your option) any later version.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12 * License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef DATA_STRUCTURES_H
19 #define DATA_STRUCTURES_H
36 TYPE_COUNT
// This must be the last field
39 // Stage 1 to 2: These structures are passed from processing to matching modules
43 uint32_t saddr
, daddr
;
44 uint16_t source
, dest
;
49 ConnectionKey connectionKey
;
52 uint32_t seq
, ack_seq
;
54 uint8_t ack
, rst
, syn
, fin
;
59 enum Direction direction
;
60 SegmentKey
* segmentKey
;
66 uint32_t saddr
, daddr
;
67 uint16_t source
, dest
;
74 enum Direction direction
;
75 DatagramKey
* datagramKey
;
87 unsigned long traceNum
;
88 // wallTime is corrected according to factors in trace struct, cpuTime
93 // specific event structures and functions could be in separate files and
94 // type could be an int
96 // event could be a void*, this union is to avoid having to cast
102 void (*copy
)(const struct _Event
* const event
, struct _Event
** const newEvent
);
103 void (*destroy
)(struct _Event
* const event
);
106 // Stage 2 to 3: These structures are passed from matching to analysis modules
107 typedef struct _Message
111 void (*print
)(const struct _Message
* const message
);
127 // Stage 4: These structures contain correction factors
128 /* Correction factors for each trace, this is the final result of
132 double drift
, offset
;
135 // Correction factors between trace pairs, to be used for reduction
139 /* Used for identity factors (a0= 0, a1= 1) that map a trace to itself. In
140 * this case, min, max and accuracy are NULL.
144 /* The approximation is the middle of the min and max limits. All fields
149 /* min and max are not available. The approximation is a "best effort".
150 * min and max are NULL.
154 /* min or max is available but not both. approx and accuracy are not
159 /* The pair of trace did not have communications in both directions (maybe
160 * even no communication at all). approx and accuracy are NULL.
164 /* The algorithms are screwed. All fields may be NULL.
167 APPROX_NB
, // This must be the last member
170 extern const char* const approxNames
[APPROX_NB
];
174 Factors
* min
, * max
, * approx
;
181 unsigned int refCount
;
182 unsigned int traceNb
;
183 PairFactors
** pairFactors
;
187 // ConnectionKey-related functions
188 guint
ghfConnectionKeyHash(gconstpointer key
);
190 gboolean
gefConnectionKeyEqual(gconstpointer a
, gconstpointer b
);
191 bool connectionKeyEqual(const ConnectionKey
* const a
, const ConnectionKey
*
194 void gdnConnectionKeyDestroy(gpointer data
);
196 // SegmentKey-related functions
197 guint
ghfSegmentKeyHash(gconstpointer key
);
198 gboolean
gefSegmentKeyEqual(gconstpointer a
, gconstpointer b
);
200 // DatagramKey-related functions
201 guint
ghfDatagramKeyHash(gconstpointer key
);
202 gboolean
gefDatagramKeyEqual(gconstpointer a
, gconstpointer b
);
203 void gdnDestroyDatagramKey(gpointer data
);
205 // Event-related functions
206 void gdnDestroyEvent(gpointer data
);
207 void copyEvent(const Event
* const event
, Event
** const newEvent
);
208 void copyTCPEvent(const Event
* const event
, Event
** const newEvent
);
209 void copyUDPEvent(const Event
* const event
, Event
** const newEvent
);
210 void destroyEvent(Event
* const event
);
211 void destroyTCPEvent(Event
* const event
);
212 void destroyUDPEvent(Event
* const event
);
213 void gfDestroyEvent(gpointer data
, gpointer user_data
);
214 double wallTimeSub(const WallTime
const* tA
, const WallTime
const* tB
);
215 void gfAddEventToArray(gpointer data
, gpointer user_data
);
217 // Message-related functions
218 void printTCPSegment(const Message
* const segment
);
219 void convertIP(char* const str
, const uint32_t addr
);
221 gint
gcfTCPSegmentAckCompare(gconstpointer a
, gconstpointer b
);
222 bool isAcking(const Message
* const ackSegment
, const Message
* const ackedSegment
);
224 void gdnTCPSegmentListDestroy(gpointer data
);
225 void gfTCPSegmentDestroy(gpointer data
, gpointer user_data
);
226 void destroyTCPSegment(Message
* const segment
);
228 // Exchange-related functions
229 void destroyTCPExchange(Exchange
* const exchange
);
231 // Broadcast-related functions
232 void gdnDestroyBroadcast(gpointer data
);
233 void destroyBroadcast(Broadcast
* const broadcast
);
235 // Factor-related functions
236 void destroyPairFactors(PairFactors
* factorsCHull
);
238 AllFactors
* createAllFactors(const unsigned int traceNb
);
239 void freeAllFactors(AllFactors
* const allFactors
);