ndt-dev - [ndt-dev] [ndt] r738 committed - Protocol logging to indicate test starts and incomong connections for ...
Subject: NDT-DEV email list created
List archive
[ndt-dev] [ndt] r738 committed - Protocol logging to indicate test starts and incomong connections for ...
Chronological Thread
- From:
- To:
- Subject: [ndt-dev] [ndt] r738 committed - Protocol logging to indicate test starts and incomong connections for ...
- Date: Fri, 28 Oct 2011 14:59:37 +0000
Revision: 738
Author:
Date: Fri Oct 28 07:58:55 2011
Log: Protocol logging to indicate test starts and incomong connections for CLT
http://code.google.com/p/ndt/source/detail?r=738
Modified:
/branches/kkumar_code_organize/src/logging.c
/branches/kkumar_code_organize/src/test_c2s_clt.c
/branches/kkumar_code_organize/src/test_mid_clt.c
/branches/kkumar_code_organize/src/test_s2c_clt.c
/branches/kkumar_code_organize/src/test_sfw_clt.c
/branches/kkumar_code_organize/src/web100clt.c
=======================================
--- /branches/kkumar_code_organize/src/logging.c Wed Oct 19 19:26:33
2011
+++ /branches/kkumar_code_organize/src/logging.c Fri Oct 28 07:58:55
2011
@@ -227,10 +227,12 @@
}
/**
+ * This method is no longer needed since the protocol log file name
+ * includes client+server name, and is constructed on the fly.
* Sets the protocol log filename.
* @param filename The new protocol log filename
- *
- */
+ * */
+/*
void set_protologfile(char* client_ip, char* protologlocalarr) {
FILE * fp;
@@ -239,20 +241,50 @@
}
sprintf(protologlocalarr, "%s/%s%s%s%s", ProtocolLogDirName, PROTOLOGPREFIX,
client_ip, PROTOLOGSUFFIX, "\0");
+ //strlcpy(ProtocolLogFileName, protologlocalarr, sizeof(ProtocolLogFileName));
+ strlcpy(protologlocalarr,ProtocolLogDirName,sizeof(protologlocalarr));
+ strlcat(protologlocalarr,"/",sizeof(protologlocalarr));
+ strlcat(protologlocalarr,PROTOLOGPREFIX,sizeof(protologlocalarr));
+ strlcat(protologlocalarr,client_ip,sizeof(protologlocalarr));
+ strlcat(protologlocalarr,PROTOLOGSUFFIX,sizeof(protologlocalarr));
strlcpy(ProtocolLogFileName, protologlocalarr, sizeof(ProtocolLogFileName));
- log_println(5, "Protocol filename: %s: %s\n", ProtocolLogFileName,
+
+ log_println(0, "Protocol filename: %s: %s\n", ProtocolLogFileName,
ProtocolLogDirName);
-}
+
+}
+*/
/**
* Return the protocol validation log filename.
+ * The protocol log filename contains the local and remote address
+ * of the test, and is uniform across server and client.
* @return The protocol log filename
*/
char*
-get_protologfile() {
- return ProtocolLogFileName;
+get_protologfile(int socketNum) {
+ char localAddr[64], remoteAddr[64], tmpstr[FILENAME_SIZE + 128];
+ size_t tmpstrlen = sizeof(localAddr);
+ memset(localAddr, 0, tmpstrlen);
+ memset(remoteAddr, 0, tmpstrlen);
+ memset(tmpstr, 0, 384);
+ // get remote address
+ I2Addr tmp_addr =
+ I2AddrBySockFD(get_errhandle(), socketNum, False);
+ I2AddrNodeName(tmp_addr, remoteAddr, &tmpstrlen); //client name
+
+ // get local address
+ tmp_addr = I2AddrByLocalSockFD(get_errhandle(), socketNum, False);
+
+ I2AddrNodeName(tmp_addr, localAddr, &tmpstrlen);
+
+ // copy address into tmpstr String
+ sprintf(tmpstr, "%s/%s%s%s%s%s%s", ProtocolLogDirName, PROTOLOGPREFIX,
+ localAddr, "_",remoteAddr, PROTOLOGSUFFIX,
"\0");
+ //log_print(0, "Log file name ---%s---", tmpstr);
+ return tmpstr;
}
/**
@@ -379,7 +411,7 @@
* @param key string key
* @param value string value associated with this key
*/
-void protolog_printgeneric(const char* key, const char* value) {
+void protolog_printgeneric(const char* key, const char* value, int socketnum) {
FILE * fp;
char isotime[64];
@@ -394,12 +426,12 @@
// make delimiters in message payload explicit
quote_delimiters(value, strlen(value), logmessage,
sizeof(logmessage));
- fp = fopen(get_protologfile(), "a");
+ fp = fopen(get_protologfile(socketnum), "a");
if (fp == NULL) {
printf(
"--Unable to open proto file while trying to record key-vale: %s:%s \n",
key, value);
- log_println(0,
+ log_println(5,
"--Unable to open proto file while trying to
record msg: %s \n",
key, value);
} else {
@@ -420,9 +452,9 @@
*
*/
void protolog_status(int pid, enum TEST_ID testid,
- enum TEST_STATUS_INT teststatus) {
+ enum TEST_STATUS_INT teststatus, int socketnum) {
FILE * fp;
- va_list ap;
+ //va_list ap;
char protomessage[256];
char currenttestarr[TEST_NAME_DESC_SIZE];
char currentstatusarr[TEST_STATUS_DESC_SIZE];
@@ -439,13 +471,13 @@
return;
}
- fp = fopen(get_protologfile(), "a");
+ fp = fopen(get_protologfile(socketnum), "a");
if (fp == NULL) {
printf(
"--Unable to open protocol log file while trying to record test status message: %s for the %s test \n",
teststatusdesc, currenttestname);
log_println(
- 0,
+ 5,
"--Unable to open protocol log file while trying to record test status message: %s for the %s test \n",
teststatusdesc, currenttestname);
} else {
@@ -471,7 +503,7 @@
*
*/
void protolog_procstatus(int pid, enum TEST_ID testidarg,
- enum PROCESS_TYPE_INT procidarg, enum PROCESS_STATUS_INT
teststatusarg) {
+ enum PROCESS_TYPE_INT procidarg, enum PROCESS_STATUS_INT teststatusarg, int socketnum) {
FILE * fp;
char protomessage[256];
char isotime[64];
@@ -493,16 +525,18 @@
return;
}
- fp = fopen(get_protologfile(), "a");
+ fp = fopen(get_protologfile(socketnum), "a");
+
if (fp == NULL) {
printf(
"--Unable to open protocol log file while trying to record process status message: %s for the %s test \n",
procstatusdesc, currentprocname);
log_println(
- 0,
+ 3,
"--Unable to open protocol log file while trying to record process status message: %s for the %s test \n",
procstatusdesc, currentprocname);
} else {
+ log_println(0, " a0\n %s, %s, %s,%d", procstatusdesc,currentprocname,currenttestname,pid);
sprintf(
protomessage,
" event=\"%s\", name=\"%s\", test=\"%s\", pid=\"%d\",
time=\"%s\"\n",
@@ -549,12 +583,12 @@
// make delimiters in message payload explicit
quote_delimiters(msg, len, logmessage, sizeof(logmessage));
- fp = fopen(get_protologfile(), "a");
+ fp = fopen(get_protologfile(ctlSocket), "a");
if (fp == NULL) {
log_println(
5,
"Unable to open protocol log file '%s', continuing
on without logging",
- get_protologfile());
+ get_protologfile(ctlSocket));
} else {
fprintf(
@@ -784,15 +818,17 @@
void writeMeta(int compress, int cputime, int snaplog, int tcpdump) {
FILE * fp;
- char tmpstr[256], dir[128];
+ char tmpstr[256];
+ //char dir[128];
char dirpathstr[256]="";
char *tempptr;
int ptrdiff=0;
- char isoTime[64], filename[256];
+ //char isoTime[64];
+ char filename[256];
size_t tmpstrlen = sizeof(tmpstr);
socklen_t len;
- DIR *dp;
+ //DIR *dp;
char metafilesuffix[256] = "meta";
/* Get the clients domain name and same in metadata file
@@ -895,7 +931,7 @@
} else
log_println(
5,
- "Zlib compression disabled, log files will
not be compressed");
+ "Zlib compression disabled, log files will not be compressed in %s", tmpstr);
}
/* #endif */
@@ -951,8 +987,8 @@
void create_named_logdir(char *dirnamedestarg, int destnamearrsize,
char *finalsuffix) {
- char namebuf[256];
- size_t namebuflen = 255;
+ //char namebuf[256];
+ //size_t namebuflen = 255;
char dir[128];
DIR *dp;
=======================================
--- /branches/kkumar_code_organize/src/test_c2s_clt.c Tue Oct 25 13:58:59 2011
+++ /branches/kkumar_code_organize/src/test_c2s_clt.c Fri Oct 28 07:58:55 2011
@@ -57,10 +57,19 @@
int i, k; // temporary iterator
int outSocket; // socket descriptor for the outgoing
connection
double t, stop_time;// test-time indicators
+ // variables used for protocol validation logs
+ enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
+ enum TEST_ID testids = C2S;
+
if (tests & TEST_C2S) { // C2S test has to be performed
struct sigaction new, old;
log_println(1, " <-- C2S throughput test -->");
+ setCurrentTest(TEST_C2S);
+ //protocol logs
+ teststatuses = TEST_STARTED;
+ protolog_status(getpid(), testids, teststatuses, ctlSocket);
+
msgLen = sizeof(buff);
// Initially, the server sends a TEST_PREPARE message. Any
other message
@@ -192,6 +201,10 @@
return 2;
}
log_println(1, " <------------------------->");
+ //log protocol validation logs
+ teststatuses = TEST_ENDED;
+ protolog_status(getpid(), testids, teststatuses,ctlSocket);
+ setCurrentTest(TEST_NONE);
}
return 0;
}
=======================================
--- /branches/kkumar_code_organize/src/test_mid_clt.c Tue Oct 25 13:58:59 2011
+++ /branches/kkumar_code_organize/src/test_mid_clt.c Fri Oct 28 07:58:55 2011
@@ -57,8 +57,16 @@
struct timeval sel_tv;
fd_set rfd;
+ enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
+ enum TEST_ID testids = MIDDLEBOX;
+
if (tests & TEST_MID) { // middlebox test has to be performed
log_println(1, " <-- Middlebox test -->");
+ setCurrentTest(TEST_MID);
+ //protocol logs
+ teststatuses = TEST_STARTED;
+ protolog_status(getpid(), testids, teststatuses, ctlSocket);
+
// Initially, expecting a TEST_PREPARE message. Any other
message
// ..type is unexpected at this stage.
@@ -177,6 +185,10 @@
return 2;
}
log_println(1, " <-------------------->");
+ // log protocol test ending
+ teststatuses = TEST_ENDED;
+ protolog_status(getpid(), testids, teststatuses,ctlSocket);
+ setCurrentTest(TEST_NONE);
}
return 0;
}
=======================================
--- /branches/kkumar_code_organize/src/test_s2c_clt.c Tue Oct 25 13:58:59 2011
+++ /branches/kkumar_code_organize/src/test_s2c_clt.c Fri Oct 28 07:58:55 2011
@@ -53,7 +53,18 @@
fd_set rfd;
char* ptr;
+ // variables used for protocol validation logs
+ enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
+ enum TEST_ID testids = S2C;
+ enum PROCESS_STATUS_INT procstatusenum = UNKNOWN;
+ enum PROCESS_TYPE_INT proctypeenum = CONNECT_TYPE;
+
if (tests & TEST_S2C) {
+ setCurrentTest(TEST_S2C);
+ //protocol logs
+ teststatuses = TEST_STARTED;
+ protolog_status(getpid(), testids, teststatuses, ctlSocket);
+
// First message expected from the server is a TEST_PREPARE. Any other message
// ...type is unexpected at this point.
log_println(1, " <-- S2C throughput test -->");
@@ -232,6 +243,11 @@
}
log_println(6, "result_srv = '%s', of len %d", result_srv,
msgLen);
log_println(1, " <------------------------->");
+
+ //log protocol validation logs
+ teststatuses = TEST_ENDED;
+ protolog_status(getpid(), testids, teststatuses,ctlSocket);
+ setCurrentTest(TEST_NONE);
}
return 0;
=======================================
--- /branches/kkumar_code_organize/src/test_sfw_clt.c Tue Oct 25 13:58:59 2011
+++ /branches/kkumar_code_organize/src/test_sfw_clt.c Fri Oct 28 07:58:55 2011
@@ -59,6 +59,11 @@
struct sockaddr_storage srv_addr;
socklen_t srvlen;
+ // protocol logging
+ enum PROCESS_TYPE_INT proctypeenum = PROCESS_TYPE;
+ enum PROCESS_STATUS_INT procstatusenum = UNKNOWN;
+ enum TEST_ID testids = SFW;
+
// listen for a message from server for a preset time, testTime
FD_ZERO(&fds);
FD_SET(sfwsockfd, &fds);
@@ -70,7 +75,7 @@
I2AddrFree(sfwcli_addr);
return NULL;
case 0: // timeout, indicates that firewall is a possibility
- log_println(1, "Simple firewall test: no connection for %d seconds", testTime);
+ log_println(1, "Simple firewall test: CLT: no connection for %d seconds", testTime);
s2c_result = SFW_POSSIBLE;
I2AddrFree(sfwcli_addr);
return NULL;
@@ -80,6 +85,15 @@
// .. cannot be determined
srvlen = sizeof(srv_addr);
sockfd = accept(sfwsockfd, (struct sockaddr *) &srv_addr, &srvlen);
+
+ // log protocol for connection accept
+ if (sockfd > 0) {
+ procstatusenum = PROCESS_STARTED;
+ proctypeenum = CONNECT_TYPE;
+ protolog_procstatus(getpid(), testids , proctypeenum,
+ procstatusenum, sockfd );
+ }
+
msgLen = sizeof(buff);
if (recv_msg(sockfd, &msgType, buff, &msgLen)) {
log_println(0, "Simple firewall test: unrecognized message");
@@ -159,8 +173,18 @@
char* ptr;
pthread_t threadId;
+ // variables used for protocol validation logs
+ enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
+ enum TEST_ID testids = SFW;
+
if (tests & TEST_SFW) { // SFW test is to be performed
log_println(1, " <-- Simple firewall test -->");
+ setCurrentTest(TEST_SFW);
+ //protocol logs
+ teststatuses = TEST_STARTED;
+ protolog_status(getpid(), testids, teststatuses, ctlsockfd);
+
+
printf("checking for firewalls . . . . . . . . . . . . . . . . . .
. ");
fflush(stdout);
msgLen = sizeof(buff);
@@ -291,6 +315,10 @@
return 2;
}
log_println(1, " <-------------------------->");
+ // log protocol validation test ending
+ teststatuses = TEST_ENDED;
+ protolog_status(getpid(), testids, teststatuses,ctlsockfd);
+ setCurrentTest(TEST_NONE);
}
return 0;
}
=======================================
--- /branches/kkumar_code_organize/src/web100clt.c Tue Oct 25 13:58:59
2011
+++ /branches/kkumar_code_organize/src/web100clt.c Fri Oct 28 07:58:55
2011
@@ -50,6 +50,8 @@
'l' }, { "web100variables", 0, 0, 301 }, {
"buffer", 1, 0, 'b' }, {
"disablemid", 0, 0, 302 }, { "disablec2s", 0, 0, 303 }, { "disables2c",
0, 0, 304 }, {
"disablesfw", 0, 0, 305 },
+ {
"protocol_log", 1, 0, 'u' },
+ {
"enableprotolog", 0, 0, 'e' },
#ifdef AF_INET6
{
"ipv4", 0, 0, '4'},
{
"ipv6", 0, 0, '6'},
@@ -488,9 +490,10 @@
#define GETOPT_LONG_INET6(x) x
#endif
// Read and record various optional values used for the tests/process
- while ((useroption = getopt_long(argc, argv, GETOPT_LONG_INET6("n:p:dhlvb:"),
+ while ((useroption = getopt_long(argc, argv, GETOPT_LONG_INET6("n:u:e:p:dhlvb:"),
long_options, 0)) != -1) {
switch (useroption) {
+ printf("USER OPTION %c",useroption);
case '4':
conn_options |= OPT_IPV4_ONLY;
break;
@@ -519,6 +522,14 @@
case 'n':
host = optarg;
break;
+ case 'u':
+ printf("Calling set protolog from case-u");
+ set_protologdir(optarg);
+ break;
+ case 'e':
+ printf("Enabling protocol logging");
+ enableprotocollogging();
+ break;
case 301:
printWeb100VarInfo();
exit(0);
@@ -538,6 +549,7 @@
case '?':
short_usage(argv[0], "");
break;
+
}
}
@@ -582,6 +594,11 @@
} else {
printf("Using IPv6 address\n");
}
+
+ // set options for test direction
+ enum Tx_DIRECTION currentDirn = C_S;
+ setCurrentDirn(currentDirn);
+ // end protocol logging
/* set the TEST_STATUS flag so the server knows this client will respond to status requests.
* this will let the server kill off zombie clients from the queue
- [ndt-dev] [ndt] r738 committed - Protocol logging to indicate test starts and incomong connections for ..., ndt, 10/28/2011
Archive powered by MHonArc 2.6.16.