#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <tcl.h>
#include "proxytrace.h"
#include "my-endian.h"
Include dependency graph for proxytrace2any.cc:

Go to the source code of this file.
Enumerations | |
| enum | { ifNone = 0, ifDECV1_0, ifDECV1_2 } |
| enum | { ofNone = 0, ofDECText, ofSquid, ofSquidSwapped } |
Functions | |
| int | getInputFormat (char *argv[]) |
| int | getOutputFormat (char *argv[]) |
| double | lf_analyze (TEntry &lfe) |
| int | main (int argc, char *argv[]) |
| void | PrintEntry_Squid (FILE *out_file, TEntry *entry, int swap) |
| void | PrintEntry_Text (FILE *out_file, TEntry *entry, int noURL) |
| void | sort_rlog () |
| void | sort_url () |
Variables | |
| FILE * | cf |
| Tcl_HashTable | cidHash |
| double | duration |
| double | initTime |
| enum { ... } | InputFormat |
| unsigned int | num_rlog |
| enum { ... } | OutputFormat |
| ReqLog * | rlog |
| FILE * | sf |
| Tcl_HashTable | sidHash |
| double | startTime |
| unsigned int | sz_rlog |
| Tcl_HashTable | urlHash |
|
|
Definition at line 20 of file proxytrace2any.cc. 00020 { ifNone = 0, ifDECV1_0, ifDECV1_2 } InputFormat = ifNone;
|
|
|
Definition at line 21 of file proxytrace2any.cc. 00021 { ofNone = 0, ofDECText, ofSquid, ofSquidSwapped } OutputFormat = ofNone;
|
|
|
Definition at line 23 of file proxytrace2any.cc. References ifDECV1_0, ifDECV1_2, ifNone, and InputFormat. 00023 { 00024 00025 if (strncmp("-i", argv[0], 3) != 0) 00026 return ifNone; 00027 00028 if (strncmp("v1.0", argv[1], 5) == 0) 00029 InputFormat = ifDECV1_0; 00030 else 00031 if (strncmp("v1.2", argv[1], 5) == 0) 00032 InputFormat = ifDECV1_2; 00033 else 00034 InputFormat = ifNone; 00035 00036 return InputFormat; 00037 }
|
|
|
Definition at line 39 of file proxytrace2any.cc. References ofDECText, ofNone, ofSquid, ofSquidSwapped, and OutputFormat. 00039 { 00040 00041 if (strncmp("-o", argv[0], 3) != 0) 00042 return ofNone; 00043 00044 if (strncmp("txt", argv[1], 4) == 0) 00045 OutputFormat = ofDECText; 00046 else 00047 if (strncmp("squid", argv[1], 6) == 0) 00048 OutputFormat = ofSquid; 00049 else 00050 if (strncmp("squidsw", argv[1], 8) == 0) 00051 OutputFormat = ofSquidSwapped; 00052 else 00053 OutputFormat = ofNone; 00054 00055 return OutputFormat; 00056 }
|
|
|
Definition at line 103 of file dec/tr-stat.cc. Referenced by main(). 00104 { 00105 double time; 00106 int ne, cid, sid, uid; 00107 Tcl_HashEntry *he; 00108 00109 // Filter out entries with 'post', 'head' etc. only keep 'get' 00110 // Also filter out 00111 if (lfe.tail.method != METHOD_GET) 00112 return -1; 00113 if ((lfe.tail.flags & QUERY_FOUND_FLAG) || 00114 (lfe.tail.flags & CGI_BIN_FLAG)) 00115 return -1; 00116 if ((lfe.tail.status != 200) && (lfe.tail.status != 304)) 00117 return -1; 00118 00119 // We don't consider pages with size 0 00120 if (lfe.head.size == 0) 00121 return -1; 00122 // We don't consider file size larger than 10MB 00123 if (lfe.head.size > MAX_FILESIZE) 00124 return -1; 00125 00126 time = (double)lfe.head.time_sec + (double)lfe.head.time_usec/(double)1000000.0; 00127 00128 if (initTime < 0) { 00129 initTime = time; 00130 time = 0; 00131 } else 00132 time -= initTime; 00133 00134 // If a trace start time is required, don't do anything 00135 if ((startTime > 0) && (time < startTime)) 00136 return -1; 00137 00138 // check client id 00139 long clientKey = lfe.head.client; 00140 if (!(he = Tcl_FindHashEntry(&cidHash, (const char *)clientKey))) { 00141 // new client, allocate a client id 00142 he = Tcl_CreateHashEntry(&cidHash, (const char *)clientKey, &ne); 00143 client++; 00144 long clientValue = client; 00145 Tcl_SetHashValue(he, clientValue); 00146 cid = client; 00147 } else { 00148 // existing entry, find its client seqno 00149 cid = (long)Tcl_GetHashValue(he); 00150 } 00151 00152 // check server id 00153 long serverKey = lfe.head.server; 00154 if (!(he = Tcl_FindHashEntry(&sidHash, (const char *)serverKey))) { 00155 // new client, allocate a client id 00156 he = Tcl_CreateHashEntry(&sidHash, (const char *)serverKey, &ne); 00157 server++; 00158 long serverValue = server; 00159 Tcl_SetHashValue(he, serverValue); 00160 sid = server; 00161 } else { 00162 // existing entry, find its client seqno 00163 sid = (long)Tcl_GetHashValue(he); 00164 } 00165 00166 // check url id 00167 long urlKey = lfe.url; 00168 if (!(he = Tcl_FindHashEntry(&urlHash, (const char*)urlKey))) { 00169 // new client, allocate a client id 00170 he = Tcl_CreateHashEntry(&urlHash, (const char*)urlKey, &ne); 00171 URL* u = new URL(++url, sid, lfe.head.size); 00172 Tcl_SetHashValue(he, (const char*)u); 00173 uid = u->id; 00174 } else { 00175 // existing entry, find its client seqno 00176 URL* u = (URL*)Tcl_GetHashValue(he); 00177 u->access++; 00178 uid = u->id; 00179 } 00180 00181 rlog[num_rlog++] = ReqLog(time, cid, sid, uid); 00182 //fprintf(cf, "%f %d %d %d\n", time, cid, sid, uid); 00183 00184 if (startTime > 0) 00185 return time - startTime; 00186 else 00187 return time; 00188 }
|
|
||||||||||||
|
Definition at line 70 of file proxytrace2any.cc. References abort(), cf, cidHash, duration, IsLittleEndian(), lf_analyze(), ReadEntry(), ReadHeader(), rlog, sf, sidHash, sort_rlog(), sort_url(), startTime, sz_rlog, ToOtherEndian(), and urlHash. 00071 { 00072 int is_little_endian = 0; 00073 TEntry entry; 00074 double ctime; 00075 00076 // Init tcl 00077 Tcl_Interp *interp = Tcl_CreateInterp(); 00078 if (Tcl_Init(interp) == TCL_ERROR) { 00079 printf("%s\n", interp->result); 00080 abort(); 00081 } 00082 Tcl_InitHashTable(&cidHash, TCL_ONE_WORD_KEYS); 00083 Tcl_InitHashTable(&sidHash, TCL_ONE_WORD_KEYS); 00084 Tcl_InitHashTable(&urlHash, TCL_ONE_WORD_KEYS); 00085 00086 if ((cf = fopen("reqlog", "w")) == NULL) { 00087 printf("cannot open request log.\n"); 00088 exit(1); 00089 } 00090 if ((sf = fopen("pglog", "w")) == NULL) { 00091 printf("cannot open page log.\n"); 00092 exit(1); 00093 } 00094 00095 /* parse command line */ 00096 if ((argc < 2) || (argc > 4)) { 00097 printf("Usage: %s <trace size> [<time duration>] [<start_time>]\n", argv[0]); 00098 return 1; 00099 } 00100 if (argc >= 3) { 00101 duration = strtod(argv[2], NULL); 00102 if (argc == 4) { 00103 startTime = strtod(argv[3], NULL); 00104 printf("start time = %f\n", startTime); 00105 } 00106 } 00107 00108 sz_rlog = strtoul(argv[1], NULL, 10); 00109 rlog = new ReqLog[sz_rlog]; 00110 00111 /* determine endian-ness */ 00112 is_little_endian = IsLittleEndian(); 00113 00114 /* read trace header */ 00115 ReadHeader(stdin, 0); 00116 00117 /* read entries untill EOF */ 00118 while (ReadEntry(stdin, &entry)) { 00119 if ( !is_little_endian ) 00120 ToOtherEndian(&entry); 00121 // Analyse one log entry 00122 ctime = lf_analyze(entry); 00123 if ((duration > 0) && (ctime > duration)) 00124 break; 00125 } 00126 00127 Tcl_DeleteHashTable(&cidHash); 00128 Tcl_DeleteHashTable(&sidHash); 00129 00130 fprintf(stderr, "sort url\n"); 00131 sort_url(); 00132 fclose(sf); 00133 00134 fprintf(stderr, "sort requests\n"); 00135 sort_rlog(); 00136 fclose(cf); 00137 00138 return 0; 00139 }
Here is the call graph for this function: ![]() |
|
||||||||||||||||
|
Definition at line 24 of file formsquid.cc. References CGI_BIN_FLAG, duration, EXTENSION_SPECIFIED_FLAG, ExtensionStr(), head, make_port(), make_query(), MethodStr(), PORT_SPECIFIED_FLAG, ProtocolStr(), QUERY_FOUND_FLAG, and tail. 00024 { 00025 00026 u_4bytes duration = ((entry -> head.event_duration+500)/1000); /* milliseconds */ 00027 00028 fprintf(stdout, "%9d.%06u %d %d %s/%d %d %s %s://%d%s/%s%d%s%s %s %s/%d\n", 00029 entry -> head.time_sec, entry -> head.time_usec, 00030 (( swap) ? entry -> head.client : duration), 00031 ((!swap) ? entry -> head.client : duration), 00032 "NONE", /* Log Tag is missing */ 00033 entry -> tail.status, 00034 entry -> head.size, 00035 MethodStr(entry -> tail.method), 00036 ProtocolStr(entry -> tail.protocol), 00037 entry -> head.server, 00038 ((entry -> tail.flags & PORT_SPECIFIED_FLAG) ? make_port(entry -> head.port) : ""), 00039 ((entry -> tail.flags & CGI_BIN_FLAG) ? "cgi_bin/" : ""), 00040 entry -> head.path, 00041 ((entry -> tail.flags & EXTENSION_SPECIFIED_FLAG) ? ExtensionStr(entry -> tail.type) : ""), 00042 ((entry -> tail.flags & QUERY_FOUND_FLAG) ? make_query(entry -> head.query) : ""), 00043 "-", /* Ident is missing */ 00044 "DIRECT", /* assuming direct retrieval */ 00045 entry -> head.server); 00046 }
Here is the call graph for this function: ![]() |
|
||||||||||||||||
|
Definition at line 16 of file formtxt.cc. References ExtensionTypeStr(), head, MethodStr(), PrintHeader(), ProtocolStr(), tail, and url. 00016 { 00017 00018 static int entry_count = 0; 00019 00020 if (!entry_count++) 00021 PrintHeader(out_file, noURL); 00022 00023 fprintf(out_file, "%9d%06u %8d %8d %5d %7d %9d %6d %6s %6s %6d %6d %6s %6d %6d %6d", 00024 entry -> head.time_sec, entry -> head.time_usec, 00025 entry -> head.event_duration, entry -> head.server_duration, 00026 entry -> head.client, entry -> head.size, entry -> head.last_mod, 00027 entry -> tail.status, 00028 MethodStr(entry -> tail.method), 00029 ProtocolStr(entry -> tail.protocol), 00030 entry -> head.server, entry -> head.port, 00031 ExtensionTypeStr(entry -> tail.type), 00032 entry -> tail.flags, 00033 entry -> head.path, entry -> head.query); 00034 00035 if (noURL) 00036 fprintf(out_file, "\n"); 00037 else 00038 fprintf(out_file, " %6d\n", entry -> url); 00039 }
Here is the call graph for this function: ![]() |
|
|
Definition at line 51 of file dec/tr-stat.cc. References cf, compare(), num_rlog, rlog, umap, and url. Referenced by main(). 00052 { 00053 qsort((void *)rlog, num_rlog, sizeof(ReqLog), compare); 00054 double t = rlog[0].time; 00055 for (unsigned int i = 0; i < num_rlog; i++) { 00056 rlog[i].time -= t; 00057 fprintf(cf, "%f %d %d %d\n", rlog[i].time, 00058 rlog[i].cid, rlog[i].sid, umap[rlog[i].url]); 00059 } 00060 // Record trace duration and # of unique urls 00061 fprintf(cf, "i %f %u\n", rlog[num_rlog-1].time, url); 00062 00063 fprintf(stderr, 00064 "%d unique clients, %d unique servers, %d unique urls.\n", 00065 client, server, url); 00066 }
Here is the call graph for this function: ![]() |
|
|
Definition at line 75 of file dec/tr-stat.cc. References compare_url(), sf, umap, url, and urlHash. Referenced by main(). 00076 { 00077 // XXX use an interval member of Tcl_HashTable 00078 URL** tbl = new URL*[urlHash.numEntries]; 00079 Tcl_HashEntry *he; 00080 Tcl_HashSearch hs; 00081 int i = 0, sz = urlHash.numEntries; 00082 for (he = Tcl_FirstHashEntry(&urlHash, &hs); 00083 he != NULL; 00084 he = Tcl_NextHashEntry(&hs)) 00085 tbl[i++] = (URL*)Tcl_GetHashValue(he); 00086 Tcl_DeleteHashTable(&urlHash); 00087 00088 // sort using access frequencies 00089 qsort((void *)tbl, sz, sizeof(URL*), compare_url); 00090 umap = new int[url]; 00091 // write sorted url to page table 00092 for (i = 0; i < sz; i++) { 00093 umap[tbl[i]->id] = i; 00094 fprintf(sf, "%d %d %d %u\n", tbl[i]->sid, i, 00095 tbl[i]->size, tbl[i]->access); 00096 delete tbl[i]; 00097 } 00098 delete []tbl; 00099 }
Here is the call graph for this function: ![]() |
|
|
Definition at line 26 of file dec/tr-stat.cc. Referenced by SMAC::drop_CTS(), SMAC::drop_RTS(), SMAC::handleACK(), SMAC::handleCTS(), SMAC::handleRTS(), main(), SMAC::sendACK(), SMAC::sendCTS(), Mac802_11::sendCTS(), SMAC::sendRTS(), SMAC::sendSYNC(), SMAC::sentACK(), SMAC::sentCTS(), and sort_rlog(). |
|
|
Definition at line 31 of file dec/tr-stat.cc. Referenced by lf_analyze(), and main(). |
|
|
Definition at line 28 of file dec/tr-stat.cc. Referenced by main(), and PrintEntry_Squid(). |
|
|
Definition at line 27 of file dec/tr-stat.cc. Referenced by lf_analyze(). |
|
|
Referenced by getInputFormat(). |
|
|
Definition at line 42 of file dec/tr-stat.cc. Referenced by lf_analyze(), and sort_rlog(). |
|
|
Referenced by getOutputFormat(). |
|
|
Definition at line 41 of file dec/tr-stat.cc. Referenced by lf_analyze(), main(), and sort_rlog(). |
|
|
Definition at line 26 of file dec/tr-stat.cc. Referenced by XcpSink::ack(), SatTrace::format_hdlc(), HDLC::handleREJ(), HDLC::handleRR(), HDLC::handleSREJ(), SMAC::handleSYNC(), main(), HDLC::recvSframe(), HDLC::sendREJ(), HDLC::sendRR(), HDLC::sendSREJ(), and sort_url(). |
|
|
Definition at line 34 of file dec/tr-stat.cc. Referenced by lf_analyze(), and main(). |
|
|
Definition at line 29 of file dec/tr-stat.cc. Referenced by lf_analyze(), and main(). |
|
|
Definition at line 42 of file dec/tr-stat.cc. Referenced by main(). |
|
|
Definition at line 37 of file dec/tr-stat.cc. Referenced by lf_analyze(), main(), and sort_url(). |
1.4.6