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 screwed. 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 // ConnectionKey-related functions
189 guint
ghfConnectionKeyHash(gconstpointer key
);
191 gboolean
gefConnectionKeyEqual(gconstpointer a
, gconstpointer b
);
192 bool connectionKeyEqual(const ConnectionKey
* const a
, const ConnectionKey
*
195 void gdnConnectionKeyDestroy(gpointer data
);
197 // SegmentKey-related functions
198 guint
ghfSegmentKeyHash(gconstpointer key
);
199 gboolean
gefSegmentKeyEqual(gconstpointer a
, gconstpointer b
);
201 // DatagramKey-related functions
202 guint
ghfDatagramKeyHash(gconstpointer key
);
203 gboolean
gefDatagramKeyEqual(gconstpointer a
, gconstpointer b
);
204 void gdnDestroyDatagramKey(gpointer data
);
206 // Event-related functions
207 void gdnDestroyEvent(gpointer data
);
208 void copyEvent(const Event
* const event
, Event
** const newEvent
);
209 void copyTCPEvent(const Event
* const event
, Event
** const newEvent
);
210 void copyUDPEvent(const Event
* const event
, Event
** const newEvent
);
211 void destroyEvent(Event
* const event
);
212 void destroyTCPEvent(Event
* const event
);
213 void destroyUDPEvent(Event
* const event
);
214 void gfDestroyEvent(gpointer data
, gpointer user_data
);
215 double wallTimeSub(const WallTime
const* tA
, const WallTime
const* tB
);
216 void gfAddEventToArray(gpointer data
, gpointer user_data
);
218 // Message-related functions
219 void printTCPSegment(const Message
* const segment
);
220 void convertIP(char* const str
, const uint32_t addr
);
222 gint
gcfTCPSegmentAckCompare(gconstpointer a
, gconstpointer b
);
223 bool isAcking(const Message
* const ackSegment
, const Message
* const ackedSegment
);
225 void gdnTCPSegmentListDestroy(gpointer data
);
226 void gfTCPSegmentDestroy(gpointer data
, gpointer user_data
);
227 void destroyTCPSegment(Message
* const segment
);
229 // Exchange-related functions
230 void destroyTCPExchange(Exchange
* const exchange
);
232 // Broadcast-related functions
233 void gdnDestroyBroadcast(gpointer data
);
234 void destroyBroadcast(Broadcast
* const broadcast
);
236 // Factor-related functions
237 void destroyPairFactors(PairFactors
* factorsCHull
);
239 AllFactors
* createAllFactors(const unsigned int traceNb
);
240 void freeAllFactors(AllFactors
* const allFactors
, const unsigned int traceNb
);