#ifndef __TRANSACTION_H #define __TRANSACTION_H /* Note: all the functions here assume that there may be wraparound of TCP sequence and ack numbers */ #include #include #include #include "constants.h" #include "thresholds.h" #include "packet.h" #define MAX_TRANSACTIONS 200000 #define MAX_CONVERSATIONS 10000 #define OPEN 1 #define CLOSED 2 enum type {BASIC, SECOND, NOTYPE}; enum app {HTTP, DNS, Telnet, FTPData, FTPControl, VoIP, RAudio, Game, IRC, ICMP, MailSS, MailUS, News, FTPTelnet, NOAPP, FTP}; enum failReason {TCP_DELAY, FTP_DELAY, NO_DATA, HTTP_DELAY, DNS_DELAY, TELNET_DELAY, ICMP_DELAY, DURATION, MISSREPLY, OW_DELAY, JITTER, LOSS, MN_DELAY, NOREASON}; #define NUM_APPLICATIONS 16 #define ECHO_REQUEST 8 #define ECHO_REPLY 0 enum trans {TCP, UDP, ICMPT}; struct conversation{ int request; int reply; double requestTime; double replyTime; }; struct shortAppStats{ double pft; int successes; int failures; }; struct appstats{ enum app application; double avgThroughputTo; double avgThroughputFrom; double avgThroughput; int numtrans; int successes; int failures; int nt; double service; double QoS; double DoS; }; struct transaction{ /* Transaction type wrt performance measure */ enum type ttype; /* Application type */ enum app tapp; /* Transport protocol type */ enum trans ttrans; /* Transaction statistics */ int state; double startTime; double lastTime; double lastUsefulTime; double duration; int usefulBytesSent; int usefulBytesRcvd; int totalBytesSent; int totalBytesRcvd; double throughputTo; double throughputFrom; double avgThroughput; double goodputTo; double goodputFrom; double avgGoodput; /* Delay between a request and a response */ double anyMaxDelay; double wholeMaxDelay; /* One-way delay and jitter */ double oneWayDelay; double jitter; double maxjitter; double ds; /* Only useful if a transaction is TCP */ struct packet window[MAX_WIN]; int ws, we, win; double maxRTT; int lostpackets; int numpackets; int winloss; int winnum; double maxloss; double lastLU; unsigned int lastRcvdFromPeer; int finstate; /* Only useful if a transaction is FTP */ unsigned short dataport; unsigned short controlport; /* Request/reply data */ double requestStart; double requestEnd; double replyStart; double replyEnd; int requestBytes; int replyBytes; int ID; int missReply; struct conversation conversations[MAX_CONVERSATIONS]; int nc; /* Indication of a success or failure */ int success; int reason; double QoS; double timeOfDeath; /* Tracing information */ unsigned int sIP; unsigned int dIP; int sport; int dport; int tid; }; void createTransaction(struct transaction** pt, double time, enum type ttype, enum app tapp, enum trans ttrans, unsigned int sIP, int sport, unsigned int dIP, int dport, int tid); /* The sequence number here should be the sequence number that will be carried in the acknowledgment, i.e. the next one to be acked */ void addTCPPacket(struct transaction* t, double time, unsigned int seq, int len, int hlen, int index, int syn, int fin); void addTCPAck(struct transaction* t, double time, unsigned int peerseq, unsigned int ack, int len, int hlen, int index); /* We are sending some query, it could be DNS, ICMP, HTTP. Take the first query sent and expect a reply to this one. If there is already some query sent and we received a reply then it may be the time to close this transaction - return FALSE in this case. In case of query sent but no reply, still return FALSE. In case of no query sent yet return TRUE. */ int addQuery(struct transaction* t, double time, enum trans ttrans, int len, int identification); /* We are receiving some reply, it could be DNS, ICMP, HTTP. Take the last reply sent, this should be the end of the long reply for HTTP but we have no way of knowing if it is the end of the page or not. */ void addReply(struct transaction* t, double time, int len, int identification); int outstanding(struct transaction * t); void calculateSuccess(struct transaction *t, int* reason, double time); int closeTransaction(struct transaction ** pt, double time); void printTransaction(int n, struct transaction* t, FILE* output); void printTransactions(FILE* output); void loadTransactions(FILE* file, struct transaction* ta[MAX_TRANSACTIONS], int* nt); #endif