ndt-dev - [ndt-dev] [ndt] r994 committed - Add some functions for dealing with logging and snapshots
Subject: NDT-DEV email list created
List archive
[ndt-dev] [ndt] r994 committed - Add some functions for dealing with logging and snapshots
Chronological Thread
- From:
- To:
- Subject: [ndt-dev] [ndt] r994 committed - Add some functions for dealing with logging and snapshots
- Date: Mon, 10 Mar 2014 13:45:35 +0000
Revision: 994
Author:
Date: Mon Mar 10 13:42:42 2014 UTC
Log: Add some functions for dealing with logging and snapshots
http://code.google.com/p/ndt/source/detail?r=994
Modified:
/branches/aaron-tcp_stats_cleanup/src/testoptions.c
/branches/aaron-tcp_stats_cleanup/src/web100-util.c
/branches/aaron-tcp_stats_cleanup/src/web100srv.h
=======================================
--- /branches/aaron-tcp_stats_cleanup/src/testoptions.c Mon Mar 10 13:41:09 2014 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/testoptions.c Mon Mar 10 13:42:42 2014 UTC
@@ -19,6 +19,7 @@
#include "I2util/util.h"
#include "runningtest.h"
#include "strlutils.h"
+#include "web100srv.h"
// Worker thread characteristics used to record snaplog and Cwnd peaks
@@ -132,23 +133,13 @@
pthread_mutex_unlock(&mainmutex);
break;
}
-#if USE_WEB100
- web100_snap(snapArgs->snap);
+ tcp_stats_take_snapshot(agent, snapArgs->conn, snapArgs->snap);
if (peaks) {
findCwndPeaks(agent, peaks, snapArgs->snap);
}
if (writeSnap) {
- web100_log_write(snapArgs->log, snapArgs->snap);
+ tcp_stats_write_snapshot(snapArgs->log, snapArgs->snap);
}
-#elif USE_WEB10G
- estats_read_vars(snapArgs->snap, snapArgs->conn, agent);
- if (peaks) {
- findCwndPeaks(agent, peaks, snapArgs->snap);
- }
- if (writeSnap) {
- estats_record_write_data(snapArgs->log, snapArgs->snap);
- }
-#endif
pthread_mutex_unlock(&mainmutex);
mysleep(delay);
}
@@ -280,13 +271,9 @@
workerArgs.peaks = peaks;
workerArgs.writeSnap = snaplogenabled;
-#if USE_WEB100
- group = web100_group_find(agentarg, "read");
- snaparg->snap = web100_snapshot_alloc(group, conn);
-#elif USE_WEB10G
- snaparg->conn = conn;
- estats_val_data_new(&snaparg->snap);
-#endif
+ group = tcp_stats_get_group(agentarg, "read");
+
+ snaparg->snap = tcp_stats_init_snapshot(agentarg, conn, group);
if (snaplogenabled) {
// memcpy(metafilevariablename, metafilename, strlen(metafilename));
@@ -295,11 +282,9 @@
fplocal = fopen(get_logfile(), "a");
-#if USE_WEB100
- snaparg->log = web100_log_open_write(metafilename, conn, group);
-#elif USE_WEB10G
- estats_record_open(&snaparg->log, metafilename, "w");
-#endif
+ snaparg->log = tcp_stats_open_log(metafilename, conn, group);
+ log_println( 0, "snaparg->log: %X", snaparg->log);
+
if (fplocal == NULL) {
log_println(
0,
@@ -321,17 +306,10 @@
pthread_mutex_lock(&mainmutex);
workerLoop= 1;
// obtain web100 snap into "snaparg.snap"
-#if USE_WEB100
- web100_snap(snaparg->snap);
- if (snaplogenabled) {
- web100_log_write(snaparg->log, snaparg->snap);
- }
-#elif USE_WEB10G
- estats_read_vars(snaparg->snap, conn, agentarg);
+ tcp_stats_take_snapshot(agentarg, conn, snaparg->snap);
if (snaplogenabled) {
- estats_record_write_data(snaparg->log, snaparg->snap);
+ tcp_stats_write_snapshot(snaparg->log, snaparg->snap);
}
-#endif
pthread_cond_wait(&maincond, &mainmutex);
pthread_mutex_unlock(&mainmutex);
}
@@ -351,17 +329,10 @@
pthread_join(*workerThreadId, NULL);
}
// close writing snaplog, if snaplog recording is enabled
-#if USE_WEB100
- if (snaplogenabled) {
- web100_log_close_write(snapArgs_ptr->log);
- }
- web100_snapshot_free(snapArgs_ptr->snap);
-#elif USE_WEB10G
if (snaplogenabled) {
- estats_record_close(&snapArgs_ptr->log);
+ tcp_stats_close_log(snapArgs_ptr->log);
}
- estats_val_data_free(&snapArgs_ptr->snap);
-#endif
+ tcp_stats_free_snapshot(snapArgs_ptr->snap);
}
/**
=======================================
--- /branches/aaron-tcp_stats_cleanup/src/web100-util.c Mon Mar 10 13:42:11 2014 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/web100-util.c Mon Mar 10 13:42:42 2014 UTC
@@ -17,6 +17,13 @@
#include "utils.h"
#include "web100srv.h"
+#if USE_WEB100
+#include <web100.h>
+#endif
+#if USE_WEB10G
+#include <estats.h>
+#endif
+
struct tcp_name {
char* web100_name;
char* web10g_name;
@@ -161,7 +168,6 @@
web100_var* var;
web100_group* group;
web100_snapshot* snap;
- web100_var* LimCwnd;
#elif USE_WEB10G
struct estats_val value;
estats_val_data* data = NULL;
@@ -392,7 +398,6 @@
#endif
socklen_t len;
struct sockaddr_storage addr;
- int port;
int i;
char buf[32], line[256], *ctime();
FILE * fp;
@@ -849,9 +854,6 @@
const char* web100_name = tcp_names[a].web100_name;
if (web100_name == NULL)
continue;
- int PktsIn = -1;
- int DataPktsIn = -1;
- int has_AckPktsIn = 0;
for (b = 0; b < count_vars; b++) {
if (strcmp(web_vars[b].name, web100_name) == 0) {
@@ -1104,3 +1106,74 @@
#endif
return;
}
+
+tcp_stat_group *tcp_stats_get_group(tcp_stat_agent *agent, char *group_name) {
+ tcp_stat_group *retval;
+
+#if USE_WEB100
+ retval = web100_group_find(agent, group_name);
+#elif USE_WEB10G
+ retval = NULL;
+#endif
+
+ return retval;
+}
+
+tcp_stat_snap *tcp_stats_init_snapshot(tcp_stat_agent *agent, tcp_stat_connection conn, tcp_stat_group *group) {
+ tcp_stat_snap *retval;
+
+#if USE_WEB100
+ retval = web100_snapshot_alloc(group, conn);
+#elif USE_WEB10G
+ estats_val_data_new(&retval);
+#endif
+
+ return retval;
+}
+
+void tcp_stats_take_snapshot(tcp_stat_agent *agent, tcp_stat_connection conn, tcp_stat_snap *snap) {
+#if USE_WEB100
+ web100_snap(snap);
+#elif USE_WEB10G
+ estats_read_vars(snap, conn, agent);
+#endif
+ return;
+}
+
+void tcp_stats_free_snapshot(tcp_stat_snap *snap) {
+#ifdef USE_WEB100
+ web100_snapshot_free(snap);
+#elif USE_WEB10G
+ estats_val_data_free(snap);
+#endif
+}
+
+tcp_stat_log *tcp_stats_open_log(char *filename, tcp_stat_connection conn, tcp_stat_group *group) {
+ tcp_stat_log *retval;
+
+#if USE_WEB100
+ retval = web100_log_open_write(filename, conn, group);
+#elif USE_WEB10G
+ estats_record_open(&retval, filename, "w");
+#endif
+
+ return retval;
+}
+
+void tcp_stats_close_log(tcp_stat_log *log) {
+#if USE_WEB100
+ web100_log_close_write(log);
+#else
+ estats_record_close(log);
+#endif
+ return;
+}
+
+void tcp_stats_write_snapshot(tcp_stat_log *log, tcp_stat_snap *snap) {
+#if USE_WEB100
+ web100_log_write(log, snap);
+#elif USE_WEB10G
+ estats_record_write_data(log, snap);
+#endif
+ return;
+}
=======================================
--- /branches/aaron-tcp_stats_cleanup/src/web100srv.h Mon Mar 10 13:42:11 2014 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/web100srv.h Mon Mar 10 13:42:42 2014 UTC
@@ -313,6 +313,16 @@
void tcp_stats_set_cwnd(tcp_stat_agent *agent, tcp_stat_connection cn, uint32_t cwnd);
tcp_stat_connection tcp_stats_connection_from_socket(tcp_stat_agent *agent, int sock);
+tcp_stat_group *tcp_stats_get_group(tcp_stat_agent *agent, char *group_name);
+
+tcp_stat_snap *tcp_stats_init_snapshot(tcp_stat_agent *agent, tcp_stat_connection conn, tcp_stat_group *group);
+void tcp_stats_take_snapshot(tcp_stat_agent *agent, tcp_stat_connection conn, tcp_stat_snap *snap);
+void tcp_stats_write_snapshot(tcp_stat_log *log, tcp_stat_snap *snap);
+void tcp_stats_free_snapshot(tcp_stat_snap *snap);
+
+tcp_stat_log *tcp_stats_open_log(char *filename, tcp_stat_connection conn, tcp_stat_group *group);
+void tcp_stats_close_log(tcp_stat_log *log);
+
int tcp_stat_autotune(int sock, tcp_stat_agent* agent, tcp_stat_connection cn);
void tcp_stat_middlebox(int sock, tcp_stat_agent* agent, tcp_stat_connection cn,
char *results, size_t results_strlen);
- [ndt-dev] [ndt] r994 committed - Add some functions for dealing with logging and snapshots, ndt, 03/10/2014
Archive powered by MHonArc 2.6.16.