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
25 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
38 TYPE_COUNT
// This must be the last field
41 // Stage 1 to 2: These structures are passed from processing to matching modules
45 uint32_t saddr
, daddr
;
46 uint16_t source
, dest
;
51 ConnectionKey connectionKey
;
54 uint32_t seq
, ack_seq
;
56 uint8_t ack
, rst
, syn
, fin
;
61 enum Direction direction
;
62 SegmentKey
* segmentKey
;
68 uint32_t saddr
, daddr
;
69 uint16_t source
, dest
;
76 enum Direction direction
;
77 DatagramKey
* datagramKey
;
89 unsigned long traceNum
;
90 // wallTime is corrected according to factors in trace struct, cpuTime
95 // specific event structures and functions could be in separate files and
96 // type could be an int
98 // event could be a void*, this union is to avoid having to cast
104 void (*copy
)(const struct _Event
* const event
, struct _Event
** const newEvent
);
105 void (*destroy
)(struct _Event
* const event
);
108 // Stage 2 to 3: These structures are passed from matching to analysis modules
109 typedef struct _Message
113 void (*print
)(const struct _Message
* const message
);
129 // Stage 4: These structures contain correction factors
130 /* Correction factors for each trace, this is the final result of
134 double drift
, offset
;
137 // Correction factors between trace pairs, to be used for reduction
141 /* Used for identity factors (a0= 0, a1= 1) that map a trace to itself. In
142 * this case, min, max and accuracy are NULL.
146 /* The approximation is the middle of the min and max limits. All fields
151 /* min and max are not available. The approximation is a "best effort".
152 * min and max are NULL.
156 /* min or max is available but not both. approx and accuracy are not
161 /* The pair of trace did not have communications in both directions (maybe
162 * even no communication at all). approx and accuracy are NULL.
166 /* The algorithms are defective. All fields may be NULL.
169 APPROX_NB
, // This must be the last member
172 extern const char* const approxNames
[APPROX_NB
];
176 Factors
* min
, * max
, * approx
;
183 unsigned int refCount
;
184 PairFactors
** pairFactors
;
188 // This structure is used to return a corrected time value with accuracy
192 uint64_t time
, min
, max
;
196 // ConnectionKey-related functions
197 guint
ghfConnectionKeyHash(gconstpointer key
);
199 gboolean
gefConnectionKeyEqual(gconstpointer a
, gconstpointer b
);
200 bool connectionKeyEqual(const ConnectionKey
* const a
, const ConnectionKey
*
203 void gdnConnectionKeyDestroy(gpointer data
);
205 // SegmentKey-related functions
206 guint
ghfSegmentKeyHash(gconstpointer key
);
207 gboolean
gefSegmentKeyEqual(gconstpointer a
, gconstpointer b
);
209 // DatagramKey-related functions
210 guint
ghfDatagramKeyHash(gconstpointer key
);
211 gboolean
gefDatagramKeyEqual(gconstpointer a
, gconstpointer b
);
212 void gdnDestroyDatagramKey(gpointer data
);
214 // Event-related functions
215 void gdnDestroyEvent(gpointer data
);
216 void copyEvent(const Event
* const event
, Event
** const newEvent
);
217 void copyTCPEvent(const Event
* const event
, Event
** const newEvent
);
218 void copyUDPEvent(const Event
* const event
, Event
** const newEvent
);
219 void destroyEvent(Event
* const event
);
220 void destroyTCPEvent(Event
* const event
);
221 void destroyUDPEvent(Event
* const event
);
222 void gfDestroyEvent(gpointer data
, gpointer user_data
);
223 double wallTimeSub(const WallTime
const* tA
, const WallTime
const* tB
);
224 void gfAddEventToArray(gpointer data
, gpointer user_data
);
226 // Message-related functions
227 void printTCPSegment(const Message
* const segment
);
228 void convertIP(char* const str
, const uint32_t addr
);
230 gint
gcfTCPSegmentAckCompare(gconstpointer a
, gconstpointer b
);
231 bool isAcking(const Message
* const ackSegment
, const Message
* const ackedSegment
);
233 void gdnTCPSegmentListDestroy(gpointer data
);
234 void gfTCPSegmentDestroy(gpointer data
, gpointer user_data
);
235 void destroyTCPSegment(Message
* const segment
);
237 // Exchange-related functions
238 void destroyTCPExchange(Exchange
* const exchange
);
240 // Broadcast-related functions
241 void gdnDestroyBroadcast(gpointer data
);
242 void destroyBroadcast(Broadcast
* const broadcast
);
244 // Factor-related functions
245 void destroyPairFactors(PairFactors
* factorsCHull
);
247 AllFactors
* createAllFactors(const unsigned int traceNb
);
248 void freeAllFactors(AllFactors
* const allFactors
, const unsigned int traceNb
);