From 10341d26543c63ff318a4cf5cb163bccdc58b19d Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Thu, 8 Oct 2009 16:03:07 -0400 Subject: [PATCH] Make the synchronization module interfaces more generic Instead of taking NetEvents and Packets, public interfaces take Events, Messages and Exchanges. These are specialized into other structures for TCP. This is to support the eventual integration of algorithms based on other event types, like UDP. Signed-off-by: Benjamin Poirier --- lttv/lttv/Makefile.am | 10 +- lttv/lttv/sync/Makefile.am | 2 +- ...ata_structures_tcp.c => data_structures.c} | 221 ++++++++++++------ lttv/lttv/sync/data_structures.h | 147 ++++++++++++ lttv/lttv/sync/data_structures_tcp.h | 106 --------- lttv/lttv/sync/event_analysis.h | 12 +- lttv/lttv/sync/event_analysis_chull.c | 32 +-- lttv/lttv/sync/event_analysis_chull.h | 2 +- lttv/lttv/sync/event_analysis_linreg.c | 46 ++-- lttv/lttv/sync/event_analysis_linreg.h | 2 +- lttv/lttv/sync/event_matching.h | 6 +- lttv/lttv/sync/event_matching_tcp.c | 159 +++++++------ lttv/lttv/sync/event_matching_tcp.h | 2 +- lttv/lttv/sync/event_processing.h | 2 +- ...mmon.c => event_processing_lttng_common.c} | 2 +- ...mmon.h => event_processing_lttng_common.h} | 0 ...v_null.c => event_processing_lttng_null.c} | 6 +- ...v_null.h => event_processing_lttng_null.h} | 0 ...rd.c => event_processing_lttng_standard.c} | 171 ++++++++------ ...rd.h => event_processing_lttng_standard.h} | 0 .../sync/{sync_chain.c => sync_chain_lttv.c} | 2 +- .../sync/{sync_chain.h => sync_chain_lttv.h} | 4 +- lttv/lttv/sync/unittest.c | 86 +++---- .../gui/lttvwindow/lttvwindow/callbacks.c | 2 +- lttv/modules/text/batchAnalysis.c | 2 +- 25 files changed, 586 insertions(+), 438 deletions(-) rename lttv/lttv/sync/{data_structures_tcp.c => data_structures.c} (52%) create mode 100644 lttv/lttv/sync/data_structures.h delete mode 100644 lttv/lttv/sync/data_structures_tcp.h rename lttv/lttv/sync/{event_processing_lttv_common.c => event_processing_lttng_common.c} (99%) rename lttv/lttv/sync/{event_processing_lttv_common.h => event_processing_lttng_common.h} (100%) rename lttv/lttv/sync/{event_processing_lttv_null.c => event_processing_lttng_null.c} (97%) rename lttv/lttv/sync/{event_processing_lttv_null.h => event_processing_lttng_null.h} (100%) rename lttv/lttv/sync/{event_processing_lttv_standard.c => event_processing_lttng_standard.c} (79%) rename lttv/lttv/sync/{event_processing_lttv_standard.h => event_processing_lttng_standard.h} (100%) rename lttv/lttv/sync/{sync_chain.c => sync_chain_lttv.c} (99%) rename lttv/lttv/sync/{sync_chain.h => sync_chain_lttv.h} (96%) diff --git a/lttv/lttv/Makefile.am b/lttv/lttv/Makefile.am index 58fd5958..3738b812 100644 --- a/lttv/lttv/Makefile.am +++ b/lttv/lttv/Makefile.am @@ -55,11 +55,11 @@ lttv_real_SOURCES = \ traceset.c\ filter.c\ print.c\ - sync/sync_chain.c\ - sync/data_structures_tcp.c\ - sync/event_processing_lttv_common.c\ - sync/event_processing_lttv_standard.c\ - sync/event_processing_lttv_null.c\ + sync/sync_chain_lttv.c\ + sync/data_structures.c\ + sync/event_processing_lttng_common.c\ + sync/event_processing_lttng_standard.c\ + sync/event_processing_lttng_null.c\ sync/event_matching_tcp.c\ sync/event_analysis_linreg.c\ sync/event_analysis_chull.c diff --git a/lttv/lttv/sync/Makefile.am b/lttv/lttv/sync/Makefile.am index 9a5c8b6c..dbe9ed59 100644 --- a/lttv/lttv/sync/Makefile.am +++ b/lttv/lttv/sync/Makefile.am @@ -5,7 +5,7 @@ check_PROGRAMS = unittest unittest_SOURCES = \ unittest.c\ - data_structures_tcp.c\ + data_structures.c\ event_matching_tcp.c\ event_analysis_linreg.c\ event_analysis_chull.c diff --git a/lttv/lttv/sync/data_structures_tcp.c b/lttv/lttv/sync/data_structures.c similarity index 52% rename from lttv/lttv/sync/data_structures_tcp.c rename to lttv/lttv/sync/data_structures.c index 4db03098..62069698 100644 --- a/lttv/lttv/sync/data_structures_tcp.c +++ b/lttv/lttv/sync/data_structures.c @@ -31,7 +31,7 @@ #include "lookup3.h" -#include "data_structures_tcp.h" +#include "data_structures.h" #ifndef g_info @@ -72,15 +72,19 @@ bool connectionKeyEqual(const ConnectionKey* const a, const * Check if a packet is an acknowledge of another packet. * * Args: - * ackPacket packet that is the confirmation - * ackedPacket packet that contains the original data, both packets have to - * come from the same direction of the same connection + * ackSegment packet that is the confirmation + * ackedSegment packet that contains the original data, both packets have to + * come from the same direction of the same connection. Both + * messages have to contain TCP events. */ -bool isAcking(const Packet* const ackPacket, const Packet* const - ackedPacket) +bool isAcking(const Message* const ackSegment, const Message* const + ackedSegment) { - if (SEQ_GT(ackPacket->inE->packetKey->ack_seq, - ackedPacket->inE->packetKey->seq)) + g_assert(ackSegment->inE->type == TCP); + g_assert(ackSegment->outE->type == TCP); + + if (SEQ_GT(ackSegment->inE->event.tcpEvent->segmentKey->ack_seq, + ackedSegment->inE->event.tcpEvent->segmentKey->seq)) { return true; } @@ -108,41 +112,48 @@ void convertIP(char* const str, const uint32_t addr) /* - * Print the content of a Packet structure + * Print the content of a TCP Message structure */ -void printPacket(const Packet* const packet) +void printTCPSegment(const Message* const segment) { char saddr[17], daddr[17]; - PacketKey* packetKey; + SegmentKey* segmentKey; + + g_assert(segment->inE->type == TCP); + g_assert(segment->inE->event.tcpEvent->segmentKey == + segment->outE->event.tcpEvent->segmentKey); - packetKey= packet->inE->packetKey; + segmentKey= segment->inE->event.tcpEvent->segmentKey; - convertIP(saddr, packetKey->connectionKey.saddr); - convertIP(daddr, packetKey->connectionKey.daddr); + convertIP(saddr, segmentKey->connectionKey.saddr); + convertIP(daddr, segmentKey->connectionKey.daddr); g_debug("%s:%u to %s:%u tot_len: %u ihl: %u seq: %u ack_seq: %u doff: %u " "ack: %u rst: %u syn: %u fin: %u", saddr, - packetKey->connectionKey.source, daddr, packetKey->connectionKey.dest, - packetKey->tot_len, packetKey->ihl, packetKey->seq, - packetKey->ack_seq, packetKey->doff, packetKey->ack, packetKey->rst, - packetKey->syn, packetKey->fin); + segmentKey->connectionKey.source, daddr, segmentKey->connectionKey.dest, + segmentKey->tot_len, segmentKey->ihl, segmentKey->seq, + segmentKey->ack_seq, segmentKey->doff, segmentKey->ack, segmentKey->rst, + segmentKey->syn, segmentKey->fin); } /* * A GHashFunc for g_hash_table_new() * - * This function is for indexing netEvents in unMatched lists. All fields of - * the corresponding packet must match for two keys to be equal. + * This function is for indexing TCPEvents in unMatched lists. All fields of + * the corresponding SegmentKey must match for two keys to be equal. * * Args: - * key PacketKey* + * key SegmentKey* + * + * Returns: + * A hash of all fields in the SegmentKey */ -guint ghfPacketKeyHash(gconstpointer key) +guint ghfSegmentKeyHash(gconstpointer key) { - const PacketKey* p; + const SegmentKey* p; uint32_t a, b, c; - p= (PacketKey*) key; + p= (SegmentKey*) key; a= p->connectionKey.source + (p->connectionKey.dest << 16); b= p->connectionKey.saddr; @@ -157,6 +168,8 @@ guint ghfPacketKeyHash(gconstpointer key) a+= p->ack + (p->rst << 8) + (p->syn << 16) + (p->fin << 24); final(a, b, c); + g_debug("segment key hash %p: %u", p, c); + return c; } @@ -164,37 +177,39 @@ guint ghfPacketKeyHash(gconstpointer key) /* * A GEqualFunc for g_hash_table_new() * - * This function is for indexing netEvents in unMatched lists. All fields of - * the corresponding packet must match for two keys to be equal. + * This function is for indexing TCPEvents in unMatched lists. All fields of + * the corresponding SegmentKey must match for two keys to be equal. * * Args: - * a, b PacketKey* + * a, b SegmentKey* * * Returns: * TRUE if both values are equal */ -gboolean gefPacketKeyEqual(gconstpointer a, gconstpointer b) +gboolean gefSegmentKeyEqual(gconstpointer a, gconstpointer b) { - const PacketKey* pA, * pB; - - pA= ((PacketKey*) a); - pB= ((PacketKey*) b); - - if (connectionKeyEqual(&pA->connectionKey, &pB->connectionKey) && - pA->ihl == pB->ihl && - pA->tot_len == pB->tot_len && - pA->seq == pB->seq && - pA->ack_seq == pB->ack_seq && - pA->doff == pB->doff && - pA->ack == pB->ack && - pA->rst == pB->rst && - pA->syn == pB->syn && - pA->fin == pB->fin) + const SegmentKey* sA, * sB; + + sA= (SegmentKey*) a; + sB= (SegmentKey*) b; + + if (connectionKeyEqual(&sA->connectionKey, &sB->connectionKey) && + sA->ihl == sB->ihl && + sA->tot_len == sB->tot_len && + sA->seq == sB->seq && + sA->ack_seq == sB->ack_seq && + sA->doff == sB->doff && + sA->ack == sB->ack && + sA->rst == sB->rst && + sA->syn == sB->syn && + sA->fin == sB->fin) { + g_debug("segment key equal %p %p: TRUE", sA, sB); return TRUE; } else { + g_debug("segment key equal %p %p: FALSE", sA, sB); return FALSE; } } @@ -204,11 +219,13 @@ gboolean gefPacketKeyEqual(gconstpointer a, gconstpointer b) * A GDestroyNotify function for g_hash_table_new_full() * * Args: - * data: NetEvent* + * data: Event* */ -void gdnDestroyNetEvent(gpointer data) +void gdnDestroyEvent(gpointer data) { - destroyNetEvent((NetEvent*) data); + Event* event= data; + + event->destroy(event); } @@ -218,15 +235,15 @@ void gdnDestroyNetEvent(gpointer data) * Args: * data: GQueue* list[Packet] */ -void gdnPacketListDestroy(gpointer data) +void gdnTCPSegmentListDestroy(gpointer data) { GQueue* list; list= (GQueue*) data; - g_debug("XXXX gdnPacketListDestroy\n"); + g_debug("XXXX gdnTCPSegmentListDestroy\n"); - g_queue_foreach(list, &gfPacketDestroy, NULL); + g_queue_foreach(list, &gfTCPSegmentDestroy, NULL); g_queue_free(list); } @@ -235,72 +252,124 @@ void gdnPacketListDestroy(gpointer data) * A GFunc for g_queue_foreach() * * Args: - * data Packet*, packet to destroy + * data Message*, TCP message to destroy * user_data NULL */ -void gfPacketDestroy(gpointer data, gpointer user_data) +void gfTCPSegmentDestroy(gpointer data, gpointer user_data) { - g_debug("XXXX gfPacketDestroy\n"); - destroyPacket((Packet*) data); + g_debug("XXXX gfTCPSegmentDestroy\n"); + destroyTCPSegment((Message*) data); } /* - * Free the memory used by a Packet and the memory of all its associated + * Free the memory used by a TCP Message and the memory of all its associated * resources + * + * Args: + * segment TCP Message to destroy */ -void destroyPacket(Packet* const packet) +void destroyTCPSegment(Message* const segment) { - g_debug("XXXX destroyPacket "); - printPacket(packet); - g_debug("\n"); + TCPEvent* inE, *outE; + + g_debug("XXXX destroyTCPSegment"); + segment->print(segment); - g_assert(packet->inE != NULL && packet->outE != NULL && - packet->inE->packetKey == packet->outE->packetKey); + g_assert(segment->inE != NULL && segment->outE != NULL); + g_assert(segment->inE->type == TCP && segment->outE->type == TCP); + inE= segment->inE->event.tcpEvent; + outE= segment->outE->event.tcpEvent; + g_assert(inE->segmentKey == outE->segmentKey); - packet->outE->packetKey= NULL; + outE->segmentKey= NULL; - destroyNetEvent(packet->inE); - destroyNetEvent(packet->outE); + destroyTCPEvent(segment->inE); + destroyTCPEvent(segment->outE); - if (packet->acks != NULL) + free(segment); +} + + +/* + * Free the memory used by a TCP Exchange and the memory of SOME of its + * associated resources. The message is not destroyed. Use destroyTCPSegment() + * to free it. + * + * Args: + * exchange TCP Exchange to destroy. The .message must be NULL + */ +void destroyTCPExchange(Exchange* const exchange) +{ + g_assert(exchange->message == NULL); + + if (exchange->acks != NULL) { - g_queue_foreach(packet->acks, &gfPacketDestroy, NULL); - g_queue_free(packet->acks); + g_queue_foreach(exchange->acks, &gfTCPSegmentDestroy, NULL); + g_queue_free(exchange->acks); } - free(packet); + free(exchange); } /* - * Free the memory used by a NetEvent + * Free the memory used by a TCP Event and its associated resources */ -void destroyNetEvent(NetEvent* const event) +void destroyTCPEvent(Event* const event) { - g_debug("XXXX destroyNetEvent\n"); + g_assert(event->type == TCP); - if (event->packetKey != NULL) + if (event->event.tcpEvent->segmentKey != NULL) { - free(event->packetKey); + free(event->event.tcpEvent->segmentKey); } + free(event->event.tcpEvent); + event->event.tcpEvent= NULL; + destroyEvent(event); +} + +/* + * Free the memory used by a base Event + */ +void destroyEvent(Event* const event) +{ + g_assert(event->event.tcpEvent == NULL); + free(event); } +/* + * Free the memory used by a UDP Event and its associated resources + */ +void destroyUDPEvent(Event* const event) +{ + g_assert(event->type == UDP); + + if (event->event.udpEvent->datagramKey != NULL) + { + free(event->event.udpEvent->datagramKey); + } + free(event->event.udpEvent); + event->event.udpEvent= NULL; + destroyEvent(event); +} + + /* * A GCompareFunc for g_queue_find_custom() * * Args: - * a Packet* acked packet - * b Packet* ack packet + * a Message* acked packet + * b Message* ack packet * * Returns: * 0 if b acks a */ -gint gcfPacketAckCompare(gconstpointer a, gconstpointer b) +gint gcfTCPSegmentAckCompare(gconstpointer a, gconstpointer b) { - if (isAcking((const Packet*) b, (const Packet*) a)) + if (isAcking((const Message*) b, (const Message*) a)) { return 0; } diff --git a/lttv/lttv/sync/data_structures.h b/lttv/lttv/sync/data_structures.h new file mode 100644 index 00000000..082bbdf6 --- /dev/null +++ b/lttv/lttv/sync/data_structures.h @@ -0,0 +1,147 @@ +/* This file is part of the Linux Trace Toolkit viewer + * Copyright (C) 2009 Benjamin Poirier + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License Version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + */ + +#ifndef DATA_STRUCTURES_H +#define DATA_STRUCTURES_H + +#include +#include +#include + +#include + +// Stage 1 to 2: These structures are passed from processing to matching modules +// TCP events +typedef struct +{ + uint32_t saddr, daddr; + uint16_t source, dest; +} ConnectionKey; + +typedef struct +{ + ConnectionKey connectionKey; + uint8_t ihl; + uint16_t tot_len; + uint32_t seq, ack_seq; + uint8_t doff; + uint8_t ack, rst, syn, fin; +} SegmentKey; + +enum Direction +{ + OUT, + IN, +}; + +typedef struct +{ + enum Direction direction; + SegmentKey* segmentKey; +} TCPEvent; + +// UDP events +typedef struct +{ + uint32_t saddr, daddr; + uint8_t dataKey[8]; +} DatagramKey; + +typedef struct +{ + enum Direction direction; + DatagramKey* datagramKey; + bool unicast; +} UDPEvent; + +typedef struct _Event +{ + unsigned long traceNum; + uint64_t time; + + // specific event structures and functions could be in separate files and + // type could be an int + enum {TCP, UDP} type; + // event could be a void*, this union is to avoid having to cast + union { + TCPEvent* tcpEvent; + UDPEvent* udpEvent; + } event; + + void (*destroy)(struct _Event* const event); +} Event; + +// Stage 2 to 3: These structures are passed from matching to analysis modules +typedef struct _Message +{ + Event* inE, * outE; + + void (*print)(const struct _Message* const message); +} Message; + +typedef struct +{ + Message* message; + GQueue* acks; +} Exchange; + +typedef struct +{ + GQueue* events; +} Broadcast; + +// One set of factors for each trace, this is the result of synchronization +typedef struct +{ + double drift, offset; +} Factors; + + +// ConnectionKey-related functions +guint ghfConnectionKeyHash(gconstpointer key); + +gboolean gefConnectionKeyEqual(gconstpointer a, gconstpointer b); +bool connectionKeyEqual(const ConnectionKey* const a, const ConnectionKey* + const b); + +void gdnConnectionKeyDestroy(gpointer data); + +// SegmentKey-related functions +guint ghfSegmentKeyHash(gconstpointer key); +gboolean gefSegmentKeyEqual(gconstpointer a, gconstpointer b); + +// Event-related functions +void gdnDestroyEvent(gpointer data); +void destroyEvent(Event* const event); +void destroyTCPEvent(Event* const event); +void destroyUDPEvent(Event* const event); + +// Message-related functions +void printTCPSegment(const Message* const segment); +void convertIP(char* const str, const uint32_t addr); + +gint gcfTCPSegmentAckCompare(gconstpointer a, gconstpointer b); +bool isAcking(const Message* const ackSegment, const Message* const ackedSegment); + +void gdnTCPSegmentListDestroy(gpointer data); +void gfTCPSegmentDestroy(gpointer data, gpointer user_data); +void destroyTCPSegment(Message* const segment); + +// Exchange-related functions +void destroyTCPExchange(Exchange* const exchange); +#endif diff --git a/lttv/lttv/sync/data_structures_tcp.h b/lttv/lttv/sync/data_structures_tcp.h deleted file mode 100644 index 0689353d..00000000 --- a/lttv/lttv/sync/data_structures_tcp.h +++ /dev/null @@ -1,106 +0,0 @@ -/* This file is part of the Linux Trace Toolkit viewer - * Copyright (C) 2009 Benjamin Poirier - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License Version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, - * MA 02111-1307, USA. - */ - -#ifndef DATA_STRUCTURES_TCP_H -#define DATA_STRUCTURES_TCP_H - -#include -#include -#include - -#include - -typedef struct -{ - uint32_t saddr, daddr; - uint16_t source, dest; -} ConnectionKey; - -typedef struct -{ - ConnectionKey connectionKey; - uint8_t ihl; - uint16_t tot_len; - uint32_t seq, ack_seq; - uint8_t doff; - uint8_t ack, rst, syn, fin; -} PacketKey; - -typedef struct -{ - // lttng metainformation - unsigned long traceNum; - LttCycleCount tsc; - - // kernel metainformation - void* skb; - - // packet header fields - PacketKey* packetKey; -} NetEvent; - -typedef struct -{ - NetEvent* inE, * outE; - GQueue* acks; -} Packet; - -typedef struct -{ - double drift, offset; -} Factors; - -typedef enum -{ - OUT, - IN -} EventType; - - -void convertIP(char* const str, const uint32_t addr); -void printPacket(const Packet* const packet); - -// ConnectionKey-related functions -bool connectionKeyEqual(const ConnectionKey* const a, const ConnectionKey* - const b); - -// NetEvent-related functions -void destroyNetEvent(NetEvent* const event); - -// Packet-related functions -bool isAcking(const Packet* const ackPacket, const Packet* const ackedPacket); -void destroyPacket(Packet* const packet); - -// ConnectionKey-related Glib functions -guint ghfConnectionKeyHash(gconstpointer key); -gboolean gefConnectionKeyEqual(gconstpointer a, gconstpointer b); -void gdnConnectionKeyDestroy(gpointer data); - -// PacketKey-related Glib functions -guint ghfPacketKeyHash(gconstpointer key); -gboolean gefPacketKeyEqual(gconstpointer a, gconstpointer b); - -// NetEvent-related Glib functions -void gdnDestroyNetEvent(gpointer data); - -// Packet-related Glib functions -void gdnPacketListDestroy(gpointer data); -void gfPacketDestroy(gpointer data, gpointer user_data); -gint gcfPacketAckCompare(gconstpointer a, gconstpointer b); - -#endif diff --git a/lttv/lttv/sync/event_analysis.h b/lttv/lttv/sync/event_analysis.h index 76658b4e..0838f28c 100644 --- a/lttv/lttv/sync/event_analysis.h +++ b/lttv/lttv/sync/event_analysis.h @@ -22,7 +22,7 @@ #include #include -#include "data_structures_tcp.h" +#include "data_structures.h" struct _SyncState; @@ -34,10 +34,12 @@ typedef struct void (*initAnalysis)(struct _SyncState* const syncState); void (*destroyAnalysis)(struct _SyncState* const syncState); - void (*analyzePacket)(struct _SyncState* const syncState, Packet* const - packet); - void (*analyzeExchange)(struct _SyncState* const syncState, Packet* const - packet); + void (*analyzeMessage)(struct _SyncState* const syncState, Message* const + message); + void (*analyzeExchange)(struct _SyncState* const syncState, Exchange* const + exchange); + void (*analyzeBroadcast)(struct _SyncState* const syncState, Broadcast* const + broadcast); GArray* (*finalizeAnalysis)(struct _SyncState* const syncState); void (*printAnalysisStats)(struct _SyncState* const syncState); void (*writeAnalysisGraphsPlots)(FILE* stream, struct _SyncState* const diff --git a/lttv/lttv/sync/event_analysis_chull.c b/lttv/lttv/sync/event_analysis_chull.c index 367b97cf..34630941 100644 --- a/lttv/lttv/sync/event_analysis_chull.c +++ b/lttv/lttv/sync/event_analysis_chull.c @@ -28,7 +28,7 @@ #include #include -#include "sync_chain.h" +#include "sync_chain_lttv.h" #include "event_analysis_chull.h" @@ -56,7 +56,8 @@ typedef enum static void initAnalysisCHull(SyncState* const syncState); static void destroyAnalysisCHull(SyncState* const syncState); -static void analyzePacketCHull(SyncState* const syncState, Packet* const packet); +static void analyzeMessageCHull(SyncState* const syncState, Message* const + message); static GArray* finalizeAnalysisCHull(SyncState* const syncState); static void printAnalysisStatsCHull(SyncState* const syncState); static void writeAnalysisGraphsPlotsCHull(FILE* stream, SyncState* const @@ -106,8 +107,9 @@ static AnalysisModule analysisModuleCHull= { .name= "chull", .initAnalysis= &initAnalysisCHull, .destroyAnalysis= &destroyAnalysisCHull, - .analyzePacket= &analyzePacketCHull, + .analyzeMessage= &analyzeMessageCHull, .analyzeExchange= NULL, + .analyzeBroadcast= NULL, .finalizeAnalysis= &finalizeAnalysisCHull, .printAnalysisStats= &printAnalysisStatsCHull, .writeAnalysisGraphsPlots= &writeAnalysisGraphsPlotsCHull, @@ -380,9 +382,9 @@ static void destroyAnalysisCHull(SyncState* const syncState) * * Args: * syncState container for synchronization data - * packet structure containing the events + * message structure containing the events */ -static void analyzePacketCHull(SyncState* const syncState, Packet* const packet) +static void analyzeMessageCHull(SyncState* const syncState, Message* const message) { AnalysisDataCHull* analysisData; Point* newPoint; @@ -392,29 +394,29 @@ static void analyzePacketCHull(SyncState* const syncState, Packet* const packet) analysisData= (AnalysisDataCHull*) syncState->analysisData; newPoint= malloc(sizeof(Point)); - if (packet->inE->traceNum < packet->outE->traceNum) + if (message->inE->traceNum < message->outE->traceNum) { // CA is inE->traceNum - newPoint->x= packet->inE->tsc; - newPoint->y= packet->outE->tsc; + newPoint->x= message->inE->time; + newPoint->y= message->outE->time; hullType= UPPER; - g_debug("Reception point hullArray[%lu][%lu] x= inE->tsc= %llu y= outE->tsc= %llu", - packet->inE->traceNum, packet->outE->traceNum, newPoint->x, + g_debug("Reception point hullArray[%lu][%lu] x= inE->time= %llu y= outE->time= %llu", + message->inE->traceNum, message->outE->traceNum, newPoint->x, newPoint->y); } else { // CA is outE->traceNum - newPoint->x= packet->outE->tsc; - newPoint->y= packet->inE->tsc; + newPoint->x= message->outE->time; + newPoint->y= message->inE->time; hullType= LOWER; - g_debug("Send point hullArray[%lu][%lu] x= inE->tsc= %llu y= outE->tsc= %llu", - packet->inE->traceNum, packet->outE->traceNum, newPoint->x, + g_debug("Send point hullArray[%lu][%lu] x= inE->time= %llu y= outE->time= %llu", + message->inE->traceNum, message->outE->traceNum, newPoint->x, newPoint->y); } hull= - analysisData->hullArray[packet->inE->traceNum][packet->outE->traceNum]; + analysisData->hullArray[message->inE->traceNum][message->outE->traceNum]; if (hull->length >= 1 && newPoint->x < ((Point*) g_queue_peek_tail(hull))->x) diff --git a/lttv/lttv/sync/event_analysis_chull.h b/lttv/lttv/sync/event_analysis_chull.h index ed4284d8..3059cf50 100644 --- a/lttv/lttv/sync/event_analysis_chull.h +++ b/lttv/lttv/sync/event_analysis_chull.h @@ -21,7 +21,7 @@ #include -#include "data_structures_tcp.h" +#include "data_structures.h" typedef struct diff --git a/lttv/lttv/sync/event_analysis_linreg.c b/lttv/lttv/sync/event_analysis_linreg.c index 41a32aeb..10dc8d78 100644 --- a/lttv/lttv/sync/event_analysis_linreg.c +++ b/lttv/lttv/sync/event_analysis_linreg.c @@ -27,7 +27,7 @@ #include #include -#include "sync_chain.h" +#include "sync_chain_lttv.h" #include "event_analysis_linreg.h" @@ -41,7 +41,7 @@ static void initAnalysisLinReg(SyncState* const syncState); static void destroyAnalysisLinReg(SyncState* const syncState); -static void analyzeExchangeLinReg(SyncState* const syncState, Packet* const packet); +static void analyzeExchangeLinReg(SyncState* const syncState, Exchange* const exchange); static GArray* finalizeAnalysisLinReg(SyncState* const syncState); static void printAnalysisStatsLinReg(SyncState* const syncState); static void writeAnalysisGraphsPlotsLinReg(FILE* stream, SyncState* const @@ -71,8 +71,9 @@ static AnalysisModule analysisModuleLinReg= { .name= "linreg", .initAnalysis= &initAnalysisLinReg, .destroyAnalysis= &destroyAnalysisLinReg, - .analyzePacket= NULL, + .analyzeMessage= NULL, .analyzeExchange= &analyzeExchangeLinReg, + .analyzeBroadcast= NULL, .finalizeAnalysis= &finalizeAnalysisLinReg, .printAnalysisStats= &printAnalysisStatsLinReg, .writeAnalysisGraphsPlots= &writeAnalysisGraphsPlotsLinReg, @@ -170,47 +171,38 @@ static void destroyAnalysisLinReg(SyncState* const syncState) /* * Perform analysis on a series of event pairs. * - * If one event pair is a packet, an exchange is composed of at least two - * packets, one in each direction. There should be a non-negative minimum - * "round trip time" (RTT) between the first and last event of the exchange. - * This RTT should be as small as possible so these packets should be closely - * related in time like a data packet and an acknowledgement packet. If the - * events analyzed are such that the minimum RTT can be zero, there's nothing - * gained in analyzing exchanges beyond what can already be figured out by - * analyzing packets. - * - * An exchange can also consist of more than two packets, in case one packet - * single handedly acknowledges many data packets. - * * Args: * syncState container for synchronization data - * packet structure containing the many events + * exchange structure containing the many events */ -static void analyzeExchangeLinReg(SyncState* const syncState, Packet* const packet) +static void analyzeExchangeLinReg(SyncState* const syncState, Exchange* const exchange) { unsigned int ni, nj; double dji, eji; double timoy; Fit* fit; - Packet* ackedPacket; + Message* ackedMessage; AnalysisDataLinReg* analysisData; g_debug("Synchronization calculation, "); g_debug("%d acked packets - using last one, ", - g_queue_get_length(packet->acks)); + g_queue_get_length(exchange->acks)); analysisData= (AnalysisDataLinReg*) syncState->analysisData; - ackedPacket= g_queue_peek_tail(packet->acks); + ackedMessage= g_queue_peek_tail(exchange->acks); // Calculate the intermediate values for the // least-squares analysis - dji= ((double) ackedPacket->inE->tsc - (double) ackedPacket->outE->tsc + - (double) packet->outE->tsc - (double) packet->inE->tsc) / 2; - eji= fabs((double) ackedPacket->inE->tsc - (double) ackedPacket->outE->tsc - - (double) packet->outE->tsc + (double) packet->inE->tsc) / 2; - timoy= ((double) ackedPacket->outE->tsc + (double) packet->inE->tsc) / 2; - ni= ackedPacket->outE->traceNum; - nj= ackedPacket->inE->traceNum; + dji= ((double) ackedMessage->inE->time - (double) ackedMessage->outE->time + + (double) exchange->message->outE->time - (double) + exchange->message->inE->time) / 2; + eji= fabs((double) ackedMessage->inE->time - (double) + ackedMessage->outE->time - (double) exchange->message->outE->time + + (double) exchange->message->inE->time) / 2; + timoy= ((double) ackedMessage->outE->time + (double) + exchange->message->inE->time) / 2; + ni= ackedMessage->outE->traceNum; + nj= ackedMessage->inE->traceNum; fit= &analysisData->fitArray[nj][ni]; fit->n++; diff --git a/lttv/lttv/sync/event_analysis_linreg.h b/lttv/lttv/sync/event_analysis_linreg.h index eb94eaa6..60002e3e 100644 --- a/lttv/lttv/sync/event_analysis_linreg.h +++ b/lttv/lttv/sync/event_analysis_linreg.h @@ -21,7 +21,7 @@ #include -#include "data_structures_tcp.h" +#include "data_structures.h" typedef struct diff --git a/lttv/lttv/sync/event_matching.h b/lttv/lttv/sync/event_matching.h index 0c3fe2d1..55c42243 100644 --- a/lttv/lttv/sync/event_matching.h +++ b/lttv/lttv/sync/event_matching.h @@ -21,7 +21,7 @@ #include -#include "data_structures_tcp.h" +#include "data_structures.h" struct _SyncState; @@ -33,8 +33,8 @@ typedef struct void (*initMatching)(struct _SyncState* const syncState); void (*destroyMatching)(struct _SyncState* const syncState); - void (*matchEvent)(struct _SyncState* const syncState, NetEvent* const event, - EventType eventType); + void (*matchEvent)(struct _SyncState* const syncState, Event* const + event); GArray* (*finalizeMatching)(struct _SyncState* const syncState); void (*printMatchingStats)(struct _SyncState* const syncState); void (*writeMatchingGraphsPlots)(FILE* stream, struct _SyncState* const diff --git a/lttv/lttv/sync/event_matching_tcp.c b/lttv/lttv/sync/event_matching_tcp.c index 5c0e3b69..25e39858 100644 --- a/lttv/lttv/sync/event_matching_tcp.c +++ b/lttv/lttv/sync/event_matching_tcp.c @@ -26,7 +26,7 @@ #include #include "event_analysis.h" -#include "sync_chain.h" +#include "sync_chain_lttv.h" #include "event_matching_tcp.h" @@ -40,8 +40,7 @@ static void initMatchingTCP(SyncState* const syncState); static void destroyMatchingTCP(SyncState* const syncState); -static void matchEventTCP(SyncState* const syncState, NetEvent* const event, - EventType eventType); +static void matchEventTCP(SyncState* const syncState, Event* const event); static GArray* finalizeMatchingTCP(SyncState* const syncState); static void printMatchingStatsTCP(SyncState* const syncState); static void writeMatchingGraphsPlotsTCP(FILE* stream, SyncState* const @@ -52,20 +51,20 @@ static void writeMatchingGraphsOptionsTCP(FILE* stream, SyncState* const // Functions specific to this module static void registerMatchingTCP() __attribute__((constructor (101))); -static void matchEvents(SyncState* const syncState, NetEvent* const event, +static void matchEvents(SyncState* const syncState, Event* const event, GHashTable* const unMatchedList, GHashTable* const unMatchedOppositeList, const size_t fieldOffset, const size_t oppositeFieldOffset); static void partialDestroyMatchingTCP(SyncState* const syncState); -static bool isAck(const Packet* const packet); -static bool needsAck(const Packet* const packet); +static bool isAck(const Message* const message); +static bool needsAck(const Message* const message); static void buildReversedConnectionKey(ConnectionKey* const reversedConnectionKey, const ConnectionKey* const connectionKey); static void openGraphDataFiles(SyncState* const syncState); static void closeGraphDataFiles(SyncState* const syncState); -static void writeMessagePoint(FILE* stream, const Packet* const packet); +static void writeMessagePoint(FILE* stream, const Message* const message); static MatchingModule matchingModuleTCP = { @@ -112,13 +111,13 @@ static void initMatchingTCP(SyncState* const syncState) matchingData= malloc(sizeof(MatchingDataTCP)); syncState->matchingData= matchingData; - matchingData->unMatchedInE= g_hash_table_new_full(&ghfPacketKeyHash, - &gefPacketKeyEqual, NULL, &gdnDestroyNetEvent); - matchingData->unMatchedOutE= g_hash_table_new_full(&ghfPacketKeyHash, - &gefPacketKeyEqual, NULL, &gdnDestroyNetEvent); + matchingData->unMatchedInE= g_hash_table_new_full(&ghfSegmentKeyHash, + &gefSegmentKeyEqual, NULL, &gdnDestroyEvent); + matchingData->unMatchedOutE= g_hash_table_new_full(&ghfSegmentKeyHash, + &gefSegmentKeyEqual, NULL, &gdnDestroyEvent); matchingData->unAcked= g_hash_table_new_full(&ghfConnectionKeyHash, &gefConnectionKeyEqual, &gdnConnectionKeyDestroy, - &gdnPacketListDestroy); + &gdnTCPSegmentListDestroy); if (syncState->stats) { @@ -234,23 +233,23 @@ static void partialDestroyMatchingTCP(SyncState* const syncState) * event new event to match * eventType type of event to match */ -static void matchEventTCP(SyncState* const syncState, NetEvent* const event, EventType eventType) +static void matchEventTCP(SyncState* const syncState, Event* const event) { MatchingDataTCP* matchingData; matchingData= (MatchingDataTCP*) syncState->matchingData; - if (eventType == IN) + if (event->event.tcpEvent->direction == IN) { matchEvents(syncState, event, matchingData->unMatchedInE, - matchingData->unMatchedOutE, offsetof(Packet, inE), - offsetof(Packet, outE)); + matchingData->unMatchedOutE, offsetof(Message, inE), + offsetof(Message, outE)); } else { matchEvents(syncState, event, matchingData->unMatchedOutE, - matchingData->unMatchedInE, offsetof(Packet, outE), - offsetof(Packet, inE)); + matchingData->unMatchedInE, offsetof(Message, outE), + offsetof(Message, inE)); } } @@ -328,41 +327,41 @@ static void printMatchingStatsTCP(SyncState* const syncState) * Implementation of a packet matching algorithm for TCP * * Args: - * netEvent: new event to match + * event: new event to match * unMatchedList: list of unmatched events of the same type (send or - * receive) as netEvent + * receive) as event * unMatchedOppositeList: list of unmatched events of the opposite type of - * netEvent - * fieldOffset: offset of the NetEvent field in the Packet struct for the - * field of the type of netEvent - * oppositeFieldOffset: offset of the NetEvent field in the Packet struct - * for the field of the opposite type of netEvent + * event + * fieldOffset: offset of the Event field in the Message struct for the + * field of the type of event + * oppositeFieldOffset: offset of the Event field in the Message struct + * for the field of the opposite type of event */ -static void matchEvents(SyncState* const syncState, NetEvent* const event, +static void matchEvents(SyncState* const syncState, Event* const event, GHashTable* const unMatchedList, GHashTable* const unMatchedOppositeList, const size_t fieldOffset, const size_t oppositeFieldOffset) { - NetEvent* companionEvent; - Packet* packet; + Event* companionEvent; + Message* packet; MatchingDataTCP* matchingData; GQueue* conUnAcked; matchingData= (MatchingDataTCP*) syncState->matchingData; - companionEvent= g_hash_table_lookup(unMatchedOppositeList, event->packetKey); + companionEvent= g_hash_table_lookup(unMatchedOppositeList, event->event.tcpEvent->segmentKey); if (companionEvent != NULL) { g_debug("Found matching companion event, "); - // If it's there, remove it and create a Packet - g_hash_table_steal(unMatchedOppositeList, event->packetKey); - packet= malloc(sizeof(Packet)); - *((NetEvent**) ((void*) packet + fieldOffset))= event; - *((NetEvent**) ((void*) packet + oppositeFieldOffset))= companionEvent; - // Both events can now share the same packetKey - free(packet->outE->packetKey); - packet->outE->packetKey= packet->inE->packetKey; - packet->acks= NULL; + // If it's there, remove it and create a Message + g_hash_table_steal(unMatchedOppositeList, event->event.tcpEvent->segmentKey); + packet= malloc(sizeof(Message)); + *((Event**) ((void*) packet + fieldOffset))= event; + *((Event**) ((void*) packet + oppositeFieldOffset))= companionEvent; + packet->print= &printTCPSegment; + // Both events can now share the same segmentKey + free(packet->outE->event.tcpEvent->segmentKey); + packet->outE->event.tcpEvent->segmentKey= packet->inE->event.tcpEvent->segmentKey; if (syncState->stats) { @@ -373,7 +372,7 @@ static void matchEvents(SyncState* const syncState, NetEvent* const event, // Discard loopback traffic if (packet->inE->traceNum == packet->outE->traceNum) { - destroyPacket(packet); + destroyTCPSegment(packet); return; } @@ -383,16 +382,16 @@ static void matchEvents(SyncState* const syncState, NetEvent* const event, packet); } - if (syncState->analysisModule->analyzePacket != NULL) + if (syncState->analysisModule->analyzeMessage != NULL) { - syncState->analysisModule->analyzePacket(syncState, packet); + syncState->analysisModule->analyzeMessage(syncState, packet); } // We can skip the rest of the algorithm if the analysis module is not // interested in exchanges if (syncState->analysisModule->analyzeExchange == NULL) { - destroyPacket(packet); + destroyTCPSegment(packet); return; } @@ -402,15 +401,18 @@ static void matchEvents(SyncState* const syncState, NetEvent* const event, ConnectionKey oppositeConnectionKey; buildReversedConnectionKey(&oppositeConnectionKey, - &event->packetKey->connectionKey); + &event->event.tcpEvent->segmentKey->connectionKey); conUnAcked= g_hash_table_lookup(matchingData->unAcked, &oppositeConnectionKey); if (conUnAcked != NULL) { - Packet* ackedPacket; + Message* ackedPacket; GList* result; + Exchange* exchange; - result= g_queue_find_custom(conUnAcked, packet, &gcfPacketAckCompare); + exchange= NULL; + + result= g_queue_find_custom(conUnAcked, packet, &gcfTCPSegmentAckCompare); while (result != NULL) { @@ -418,7 +420,7 @@ static void matchEvents(SyncState* const syncState, NetEvent* const event, // and keep it for later offset calculations g_debug("Found matching unAcked packet, "); - ackedPacket= (Packet*) result->data; + ackedPacket= (Message*) result->data; g_queue_delete_link(conUnAcked, result); if (syncState->stats) @@ -426,28 +428,30 @@ static void matchEvents(SyncState* const syncState, NetEvent* const event, matchingData->stats->totExchangeEffective++; } - if (packet->acks == NULL) + if (exchange == NULL) { - packet->acks= g_queue_new(); + exchange= malloc(sizeof(Exchange)); + exchange->message= packet; + exchange->acks= g_queue_new(); } - g_queue_push_tail(packet->acks, ackedPacket); + g_queue_push_tail(exchange->acks, ackedPacket); result= g_queue_find_custom(conUnAcked, packet, - &gcfPacketAckCompare); + &gcfTCPSegmentAckCompare); } // It might be possible to do an offset calculation - if (packet->acks != NULL) + if (exchange != NULL) { - ackedPacket= g_queue_peek_tail(packet->acks); + ackedPacket= g_queue_peek_tail(exchange->acks); if (ackedPacket->outE->traceNum != packet->inE->traceNum || ackedPacket->inE->traceNum != packet->outE->traceNum || packet->inE->traceNum == packet->outE->traceNum) { - printPacket(ackedPacket); - printPacket(packet); + ackedPacket->print(ackedPacket); + packet->print(packet); g_error("Disorganized exchange encountered during " "synchronization"); } @@ -459,8 +463,11 @@ static void matchEvents(SyncState* const syncState, NetEvent* const event, } syncState->analysisModule->analyzeExchange(syncState, - packet); + exchange); } + + exchange->message= NULL; + destroyTCPExchange(exchange); } } } @@ -475,13 +482,13 @@ static void matchEvents(SyncState* const syncState, NetEvent* const event, // If this packet will generate an ack, add it to the unAcked list g_debug("Adding to unAcked, "); conUnAcked= g_hash_table_lookup(matchingData->unAcked, - &event->packetKey->connectionKey); + &event->event.tcpEvent->segmentKey->connectionKey); if (conUnAcked == NULL) { ConnectionKey* connectionKey; connectionKey= malloc(sizeof(ConnectionKey)); - memcpy(connectionKey, &event->packetKey->connectionKey, + memcpy(connectionKey, &event->event.tcpEvent->segmentKey->connectionKey, sizeof(ConnectionKey)); g_hash_table_insert(matchingData->unAcked, connectionKey, conUnAcked= g_queue_new()); @@ -490,7 +497,7 @@ static void matchEvents(SyncState* const syncState, NetEvent* const event, } else { - destroyPacket(packet); + destroyTCPSegment(packet); } } else @@ -498,7 +505,7 @@ static void matchEvents(SyncState* const syncState, NetEvent* const event, // If there's no corresponding event, add the event to the unmatched // list for this type of event g_debug("Adding to unmatched event list, "); - g_hash_table_replace(unMatchedList, event->packetKey, event); + g_hash_table_replace(unMatchedList, event->event.tcpEvent->segmentKey, event); } } @@ -506,13 +513,16 @@ static void matchEvents(SyncState* const syncState, NetEvent* const event, /* * Check if a packet is an acknowledge * + * Args: + * packet TCP Message + * * Returns: * true if it is, * false otherwise */ -static bool isAck(const Packet* const packet) +static bool isAck(const Message* const packet) { - if (packet->inE->packetKey->ack == 1) + if (packet->inE->event.tcpEvent->segmentKey->ack == 1) { return true; } @@ -527,15 +537,18 @@ static bool isAck(const Packet* const packet) * Check if a packet will increment the sequence number, thus needing an * acknowledge * + * Args: + * packet TCP Message + * * Returns: * true if the packet will need an acknowledge * false otherwise */ -static bool needsAck(const Packet* const packet) +static bool needsAck(const Message* const packet) { - if (packet->inE->packetKey->syn || packet->inE->packetKey->fin || - packet->inE->packetKey->tot_len - packet->inE->packetKey->ihl * 4 - - packet->inE->packetKey->doff * 4 > 0) + if (packet->inE->event.tcpEvent->segmentKey->syn || packet->inE->event.tcpEvent->segmentKey->fin || + packet->inE->event.tcpEvent->segmentKey->tot_len - packet->inE->event.tcpEvent->segmentKey->ihl * 4 - + packet->inE->event.tcpEvent->segmentKey->doff * 4 > 0) { return true; } @@ -620,24 +633,24 @@ static void openGraphDataFiles(SyncState* const syncState) * Write a message point to a file used to generate graphs * * Args: - * stream: FILE*, file pointer where to write the point - * packet: message for which to write the point + * stream: FILE*, file pointer where to write the point + * message: message for which to write the point */ -static void writeMessagePoint(FILE* stream, const Packet* const packet) +static void writeMessagePoint(FILE* stream, const Message* const message) { LttCycleCount x, y; - if (packet->inE->traceNum < packet->outE->traceNum) + if (message->inE->traceNum < message->outE->traceNum) { // CA is inE->traceNum - x= packet->inE->tsc; - y= packet->outE->tsc; + x= message->inE->time; + y= message->outE->time; } else { // CA is outE->traceNum - x= packet->outE->tsc; - y= packet->inE->tsc; + x= message->outE->time; + y= message->inE->time; } fprintf(stream, "%20llu %20llu\n", x, y); diff --git a/lttv/lttv/sync/event_matching_tcp.h b/lttv/lttv/sync/event_matching_tcp.h index f0ce6225..2687aa21 100644 --- a/lttv/lttv/sync/event_matching_tcp.h +++ b/lttv/lttv/sync/event_matching_tcp.h @@ -21,7 +21,7 @@ #include -#include "data_structures_tcp.h" +#include "data_structures.h" typedef struct diff --git a/lttv/lttv/sync/event_processing.h b/lttv/lttv/sync/event_processing.h index 6e8c3799..44a2c4cf 100644 --- a/lttv/lttv/sync/event_processing.h +++ b/lttv/lttv/sync/event_processing.h @@ -24,7 +24,7 @@ #include -#include "data_structures_tcp.h" +#include "data_structures.h" struct _SyncState; diff --git a/lttv/lttv/sync/event_processing_lttv_common.c b/lttv/lttv/sync/event_processing_lttng_common.c similarity index 99% rename from lttv/lttv/sync/event_processing_lttv_common.c rename to lttv/lttv/sync/event_processing_lttng_common.c index b0d26c9e..95f80c3c 100644 --- a/lttv/lttv/sync/event_processing_lttv_common.c +++ b/lttv/lttv/sync/event_processing_lttng_common.c @@ -20,7 +20,7 @@ #include #endif -#include "event_processing_lttv_common.h" +#include "event_processing_lttng_common.h" #ifndef g_info diff --git a/lttv/lttv/sync/event_processing_lttv_common.h b/lttv/lttv/sync/event_processing_lttng_common.h similarity index 100% rename from lttv/lttv/sync/event_processing_lttv_common.h rename to lttv/lttv/sync/event_processing_lttng_common.h diff --git a/lttv/lttv/sync/event_processing_lttv_null.c b/lttv/lttv/sync/event_processing_lttng_null.c similarity index 97% rename from lttv/lttv/sync/event_processing_lttv_null.c rename to lttv/lttv/sync/event_processing_lttng_null.c index 678e3c34..170ebf12 100644 --- a/lttv/lttv/sync/event_processing_lttv_null.c +++ b/lttv/lttv/sync/event_processing_lttng_null.c @@ -22,10 +22,10 @@ #include -#include "sync_chain.h" -#include "event_processing_lttv_common.h" +#include "sync_chain_lttv.h" +#include "event_processing_lttng_common.h" -#include "event_processing_lttv_null.h" +#include "event_processing_lttng_null.h" #ifndef g_info diff --git a/lttv/lttv/sync/event_processing_lttv_null.h b/lttv/lttv/sync/event_processing_lttng_null.h similarity index 100% rename from lttv/lttv/sync/event_processing_lttv_null.h rename to lttv/lttv/sync/event_processing_lttng_null.h diff --git a/lttv/lttv/sync/event_processing_lttv_standard.c b/lttv/lttv/sync/event_processing_lttng_standard.c similarity index 79% rename from lttv/lttv/sync/event_processing_lttv_standard.c rename to lttv/lttv/sync/event_processing_lttng_standard.c index b981d3a8..de2d86a4 100644 --- a/lttv/lttv/sync/event_processing_lttv_standard.c +++ b/lttv/lttv/sync/event_processing_lttng_standard.c @@ -28,10 +28,10 @@ #include #include -#include "sync_chain.h" -#include "event_processing_lttv_common.h" +#include "sync_chain_lttv.h" +#include "event_processing_lttng_common.h" -#include "event_processing_lttv_standard.h" +#include "event_processing_lttng_standard.h" #ifndef g_info @@ -127,7 +127,7 @@ static void initProcessingLTTVStandard(SyncState* const syncState, LttvTracesetC for(i= 0; i < syncState->traceNb; i++) { processingData->pendingRecv[i]= g_hash_table_new_full(&g_direct_hash, - NULL, NULL, &gdnDestroyNetEvent); + NULL, NULL, &gdnDestroyEvent); } registerHooks(processingData->hookListList, traceSetContext, @@ -218,8 +218,6 @@ static void finalizeProcessingLTTVStandard(SyncState* const syncState) processingData->traceSetContext->time_span.start_time.tv_nsec, processingData->traceSetContext->time_span.end_time.tv_sec, processingData->traceSetContext->time_span.end_time.tv_nsec); - - return; } @@ -386,7 +384,7 @@ static gboolean processEventLTTVStandard(void* hookData, void* callData) if (info->name == LTT_EVENT_DEV_XMIT) { - NetEvent* outE; + Event* outE; if (!ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook, 1)) == ETH_P_IP || @@ -401,40 +399,48 @@ static gboolean processEventLTTVStandard(void* hookData, void* callData) processingData->stats->totOutE++; } - outE= malloc(sizeof(NetEvent)); - outE->packetKey= malloc(sizeof(PacketKey)); - + outE= malloc(sizeof(Event)); outE->traceNum= traceNum; - outE->tsc= tsc; - outE->skb= NULL; - outE->packetKey->connectionKey.saddr= ltt_event_get_unsigned(event, - lttv_trace_get_hook_field(traceHook, 3)); - outE->packetKey->connectionKey.daddr= ltt_event_get_unsigned(event, - lttv_trace_get_hook_field(traceHook, 4)); - outE->packetKey->tot_len= ltt_event_get_unsigned(event, - lttv_trace_get_hook_field(traceHook, 5)); - outE->packetKey->ihl= ltt_event_get_unsigned(event, + outE->time= tsc; + outE->type= TCP; + outE->destroy= &destroyTCPEvent; + outE->event.tcpEvent= malloc(sizeof(TCPEvent)); + outE->event.tcpEvent->direction= OUT; + outE->event.tcpEvent->segmentKey= malloc(sizeof(SegmentKey)); + outE->event.tcpEvent->segmentKey->connectionKey.saddr= + ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook, + 3)); + outE->event.tcpEvent->segmentKey->connectionKey.daddr= + ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook, + 4)); + outE->event.tcpEvent->segmentKey->tot_len= + ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook, + 5)); + outE->event.tcpEvent->segmentKey->ihl= ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook, 6)); - outE->packetKey->connectionKey.source= ltt_event_get_unsigned(event, - lttv_trace_get_hook_field(traceHook, 7)); - outE->packetKey->connectionKey.dest= ltt_event_get_unsigned(event, - lttv_trace_get_hook_field(traceHook, 8)); - outE->packetKey->seq= ltt_event_get_unsigned(event, + outE->event.tcpEvent->segmentKey->connectionKey.source= + ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook, + 7)); + outE->event.tcpEvent->segmentKey->connectionKey.dest= + ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook, + 8)); + outE->event.tcpEvent->segmentKey->seq= ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook, 9)); - outE->packetKey->ack_seq= ltt_event_get_unsigned(event, - lttv_trace_get_hook_field(traceHook, 10)); - outE->packetKey->doff= ltt_event_get_unsigned(event, + outE->event.tcpEvent->segmentKey->ack_seq= + ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook, + 10)); + outE->event.tcpEvent->segmentKey->doff= ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook, 11)); - outE->packetKey->ack= ltt_event_get_unsigned(event, + outE->event.tcpEvent->segmentKey->ack= ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook, 12)); - outE->packetKey->rst= ltt_event_get_unsigned(event, + outE->event.tcpEvent->segmentKey->rst= ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook, 13)); - outE->packetKey->syn= ltt_event_get_unsigned(event, + outE->event.tcpEvent->segmentKey->syn= ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook, 14)); - outE->packetKey->fin= ltt_event_get_unsigned(event, + outE->event.tcpEvent->segmentKey->fin= ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook, 15)); - syncState->matchingModule->matchEvent(syncState, outE, OUT); + syncState->matchingModule->matchEvent(syncState, outE); g_debug("Output event done\n"); } @@ -452,25 +458,26 @@ static gboolean processEventLTTVStandard(void* hookData, void* callData) if (protocol == ETH_P_IP) { - NetEvent* inE; + Event* inE; + void* skb; if (syncState->stats) { processingData->stats->totRecvIp++; } - inE= malloc(sizeof(NetEvent)); - + inE= malloc(sizeof(Event)); inE->traceNum= traceNum; - inE->tsc= tsc; - inE->skb= (void*) (long) ltt_event_get_long_unsigned(event, - lttv_trace_get_hook_field(traceHook, 0)); - inE->packetKey= NULL; + inE->time= tsc; + inE->event.tcpEvent= NULL; + inE->destroy= &destroyEvent; - g_hash_table_replace(processingData->pendingRecv[traceNum], - inE->skb, inE); + skb= (void*) (long) ltt_event_get_long_unsigned(event, + lttv_trace_get_hook_field(traceHook, 0)); + g_hash_table_replace(processingData->pendingRecv[traceNum], skb, + inE); - g_debug("Adding inE %p for skb %p to pendingRecv\n", inE, inE->skb); + g_debug("Adding inE %p for skb %p to pendingRecv\n", inE, skb); } else { @@ -479,14 +486,14 @@ static gboolean processEventLTTVStandard(void* hookData, void* callData) } else if (info->name == LTT_EVENT_TCPV4_RCV) { - NetEvent* inE; + Event* inE; void* skb; // Search pendingRecv for an event with the same skb skb= (void*) (long) ltt_event_get_long_unsigned(event, lttv_trace_get_hook_field(traceHook, 0)); - inE= (NetEvent*) + inE= (Event*) g_hash_table_lookup(processingData->pendingRecv[traceNum], skb); if (inE == NULL) { @@ -503,36 +510,52 @@ static gboolean processEventLTTVStandard(void* hookData, void* callData) // If it's there, remove it and proceed with a receive event g_hash_table_steal(processingData->pendingRecv[traceNum], skb); - inE->packetKey= malloc(sizeof(PacketKey)); - - inE->packetKey->connectionKey.saddr= ltt_event_get_unsigned(event, - lttv_trace_get_hook_field(traceHook, 1)); - inE->packetKey->connectionKey.daddr= ltt_event_get_unsigned(event, - lttv_trace_get_hook_field(traceHook, 2)); - inE->packetKey->tot_len= ltt_event_get_unsigned(event, - lttv_trace_get_hook_field(traceHook, 3)); - inE->packetKey->ihl= ltt_event_get_unsigned(event, - lttv_trace_get_hook_field(traceHook, 4)); - inE->packetKey->connectionKey.source= ltt_event_get_unsigned(event, - lttv_trace_get_hook_field(traceHook, 5)); - inE->packetKey->connectionKey.dest= ltt_event_get_unsigned(event, - lttv_trace_get_hook_field(traceHook, 6)); - inE->packetKey->seq= ltt_event_get_unsigned(event, - lttv_trace_get_hook_field(traceHook, 7)); - inE->packetKey->ack_seq= ltt_event_get_unsigned(event, - lttv_trace_get_hook_field(traceHook, 8)); - inE->packetKey->doff= ltt_event_get_unsigned(event, - lttv_trace_get_hook_field(traceHook, 9)); - inE->packetKey->ack= ltt_event_get_unsigned(event, - lttv_trace_get_hook_field(traceHook, 10)); - inE->packetKey->rst= ltt_event_get_unsigned(event, - lttv_trace_get_hook_field(traceHook, 11)); - inE->packetKey->syn= ltt_event_get_unsigned(event, - lttv_trace_get_hook_field(traceHook, 12)); - inE->packetKey->fin= ltt_event_get_unsigned(event, - lttv_trace_get_hook_field(traceHook, 13)); - - syncState->matchingModule->matchEvent(syncState, inE, IN); + inE->type= TCP; + inE->event.tcpEvent= malloc(sizeof(TCPEvent)); + inE->destroy= &destroyTCPEvent; + inE->event.tcpEvent->direction= IN; + inE->event.tcpEvent->segmentKey= malloc(sizeof(SegmentKey)); + inE->event.tcpEvent->segmentKey->connectionKey.saddr= + ltt_event_get_unsigned(event, + lttv_trace_get_hook_field(traceHook, 1)); + inE->event.tcpEvent->segmentKey->connectionKey.daddr= + ltt_event_get_unsigned(event, + lttv_trace_get_hook_field(traceHook, 2)); + inE->event.tcpEvent->segmentKey->tot_len= + ltt_event_get_unsigned(event, + lttv_trace_get_hook_field(traceHook, 3)); + inE->event.tcpEvent->segmentKey->ihl= + ltt_event_get_unsigned(event, + lttv_trace_get_hook_field(traceHook, 4)); + inE->event.tcpEvent->segmentKey->connectionKey.source= + ltt_event_get_unsigned(event, + lttv_trace_get_hook_field(traceHook, 5)); + inE->event.tcpEvent->segmentKey->connectionKey.dest= + ltt_event_get_unsigned(event, + lttv_trace_get_hook_field(traceHook, 6)); + inE->event.tcpEvent->segmentKey->seq= + ltt_event_get_unsigned(event, + lttv_trace_get_hook_field(traceHook, 7)); + inE->event.tcpEvent->segmentKey->ack_seq= + ltt_event_get_unsigned(event, + lttv_trace_get_hook_field(traceHook, 8)); + inE->event.tcpEvent->segmentKey->doff= + ltt_event_get_unsigned(event, + lttv_trace_get_hook_field(traceHook, 9)); + inE->event.tcpEvent->segmentKey->ack= + ltt_event_get_unsigned(event, + lttv_trace_get_hook_field(traceHook, 10)); + inE->event.tcpEvent->segmentKey->rst= + ltt_event_get_unsigned(event, + lttv_trace_get_hook_field(traceHook, 11)); + inE->event.tcpEvent->segmentKey->syn= + ltt_event_get_unsigned(event, + lttv_trace_get_hook_field(traceHook, 12)); + inE->event.tcpEvent->segmentKey->fin= + ltt_event_get_unsigned(event, + lttv_trace_get_hook_field(traceHook, 13)); + + syncState->matchingModule->matchEvent(syncState, inE); g_debug("Input event %p for skb %p done\n", inE, skb); } diff --git a/lttv/lttv/sync/event_processing_lttv_standard.h b/lttv/lttv/sync/event_processing_lttng_standard.h similarity index 100% rename from lttv/lttv/sync/event_processing_lttv_standard.h rename to lttv/lttv/sync/event_processing_lttng_standard.h diff --git a/lttv/lttv/sync/sync_chain.c b/lttv/lttv/sync/sync_chain_lttv.c similarity index 99% rename from lttv/lttv/sync/sync_chain.c rename to lttv/lttv/sync/sync_chain_lttv.c index 52e0bb9d..16190c48 100644 --- a/lttv/lttv/sync/sync_chain.c +++ b/lttv/lttv/sync/sync_chain_lttv.c @@ -34,7 +34,7 @@ #include #include -#include "sync_chain.h" +#include "sync_chain_lttv.h" #ifndef g_info diff --git a/lttv/lttv/sync/sync_chain.h b/lttv/lttv/sync/sync_chain_lttv.h similarity index 96% rename from lttv/lttv/sync/sync_chain.h rename to lttv/lttv/sync/sync_chain_lttv.h index 152d1321..a6a460b0 100644 --- a/lttv/lttv/sync/sync_chain.h +++ b/lttv/lttv/sync/sync_chain_lttv.h @@ -16,8 +16,8 @@ * MA 02111-1307, USA. */ -#ifndef SYNC_CHAIN_H -#define SYNC_CHAIN_H +#ifndef SYNC_CHAIN_LTTV_H +#define SYNC_CHAIN_LTTV_H #include diff --git a/lttv/lttv/sync/unittest.c b/lttv/lttv/sync/unittest.c index 4ca2b932..a452d08d 100644 --- a/lttv/lttv/sync/unittest.c +++ b/lttv/lttv/sync/unittest.c @@ -34,7 +34,7 @@ #include #include -#include "sync_chain.h" +#include "sync_chain_lttv.h" #ifndef g_info @@ -616,7 +616,7 @@ static void processEvents(SyncState* const syncState, FILE* testCase) unsigned int sender, receiver; double sendTime, recvTime; char tmp; - NetEvent* event; + Event* event; if (retval == -1 && !feof(testCase)) { @@ -650,48 +650,54 @@ static void processEvents(SyncState* const syncState, FILE* testCase) } // Output event - event= malloc(sizeof(NetEvent)); + event= malloc(sizeof(Event)); event->traceNum= sender; - event->tsc= round(sendTime * freq); - event->skb= NULL; - event->packetKey= malloc(sizeof(PacketKey)); - event->packetKey->ihl= 5; - event->packetKey->tot_len= 40; - event->packetKey->connectionKey.saddr= sender + addressOffset; - event->packetKey->connectionKey.daddr= receiver + addressOffset; - event->packetKey->connectionKey.source= 57645; - event->packetKey->connectionKey.dest= 80; - event->packetKey->seq= seq[sender]; - event->packetKey->ack_seq= 0; - event->packetKey->doff= 5; - event->packetKey->ack= 0; - event->packetKey->rst= 0; - event->packetKey->syn= 1; - event->packetKey->fin= 0; - - syncState->matchingModule->matchEvent(syncState, event, OUT); + event->time= round(sendTime * freq); + event->type= TCP; + event->destroy= &destroyTCPEvent; + event->event.tcpEvent= malloc(sizeof(TCPEvent)); + event->event.tcpEvent->direction= OUT; + event->event.tcpEvent->segmentKey= malloc(sizeof(SegmentKey)); + event->event.tcpEvent->segmentKey->ihl= 5; + event->event.tcpEvent->segmentKey->tot_len= 40; + event->event.tcpEvent->segmentKey->connectionKey.saddr= sender + addressOffset; + event->event.tcpEvent->segmentKey->connectionKey.daddr= receiver + addressOffset; + event->event.tcpEvent->segmentKey->connectionKey.source= 57645; + event->event.tcpEvent->segmentKey->connectionKey.dest= 80; + event->event.tcpEvent->segmentKey->seq= seq[sender]; + event->event.tcpEvent->segmentKey->ack_seq= 0; + event->event.tcpEvent->segmentKey->doff= 5; + event->event.tcpEvent->segmentKey->ack= 0; + event->event.tcpEvent->segmentKey->rst= 0; + event->event.tcpEvent->segmentKey->syn= 1; + event->event.tcpEvent->segmentKey->fin= 0; + + syncState->matchingModule->matchEvent(syncState, event); // Input event - event= malloc(sizeof(NetEvent)); + event= malloc(sizeof(Event)); event->traceNum= receiver; - event->tsc= round(recvTime * freq); - event->skb= NULL; - event->packetKey= malloc(sizeof(PacketKey)); - event->packetKey->ihl= 5; - event->packetKey->tot_len= 40; - event->packetKey->connectionKey.saddr= sender + addressOffset; - event->packetKey->connectionKey.daddr= receiver + addressOffset; - event->packetKey->connectionKey.source= 57645; - event->packetKey->connectionKey.dest= 80; - event->packetKey->seq= seq[sender]; - event->packetKey->ack_seq= 0; - event->packetKey->doff= 5; - event->packetKey->ack= 0; - event->packetKey->rst= 0; - event->packetKey->syn= 1; - event->packetKey->fin= 0; - - syncState->matchingModule->matchEvent(syncState, event, IN); + event->time= round(recvTime * freq); + event->type= TCP; + event->destroy= &destroyTCPEvent; + event->event.tcpEvent= malloc(sizeof(TCPEvent)); + event->event.tcpEvent->direction= IN; + event->event.tcpEvent->segmentKey= malloc(sizeof(SegmentKey)); + event->event.tcpEvent->segmentKey->ihl= 5; + event->event.tcpEvent->segmentKey->tot_len= 40; + event->event.tcpEvent->segmentKey->connectionKey.saddr= sender + addressOffset; + event->event.tcpEvent->segmentKey->connectionKey.daddr= receiver + addressOffset; + event->event.tcpEvent->segmentKey->connectionKey.source= 57645; + event->event.tcpEvent->segmentKey->connectionKey.dest= 80; + event->event.tcpEvent->segmentKey->seq= seq[sender]; + event->event.tcpEvent->segmentKey->ack_seq= 0; + event->event.tcpEvent->segmentKey->doff= 5; + event->event.tcpEvent->segmentKey->ack= 0; + event->event.tcpEvent->segmentKey->rst= 0; + event->event.tcpEvent->segmentKey->syn= 1; + event->event.tcpEvent->segmentKey->fin= 0; + + syncState->matchingModule->matchEvent(syncState, event); seq[sender]++; diff --git a/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c b/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c index 53681f48..6514ef0a 100644 --- a/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c +++ b/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/lttv/modules/text/batchAnalysis.c b/lttv/modules/text/batchAnalysis.c index 3ee4d021..4b02f332 100644 --- a/lttv/modules/text/batchAnalysis.c +++ b/lttv/modules/text/batchAnalysis.c @@ -34,7 +34,7 @@ #include #include #include -#include +#include static LttvTraceset *traceset; -- 2.34.1