ndt-dev - [ndt-dev] [ndt] r1001 committed - Cleanup CwndDecrease
Subject: NDT-DEV email list created
List archive
- From:
- To:
- Subject: [ndt-dev] [ndt] r1001 committed - Cleanup CwndDecrease
- Date: Mon, 10 Mar 2014 13:52:35 +0000
Revision: 1001
Author:
Date: Mon Mar 10 13:48:44 2014 UTC
Log: Cleanup CwndDecrease
http://code.google.com/p/ndt/source/detail?r=1001
Modified:
/branches/aaron-tcp_stats_cleanup/src/test_s2c_srv.c
/branches/aaron-tcp_stats_cleanup/src/testoptions.c
/branches/aaron-tcp_stats_cleanup/src/web100-util.c
/branches/aaron-tcp_stats_cleanup/src/web100srv.c
/branches/aaron-tcp_stats_cleanup/src/web100srv.h
=======================================
--- /branches/aaron-tcp_stats_cleanup/src/test_s2c_srv.c Mon Mar 10 13:48:11 2014 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/test_s2c_srv.c Mon Mar 10 13:48:44 2014 UTC
@@ -79,7 +79,6 @@
web100_snapshot* rsnap = NULL;
web100_group* tgroup;
web100_group* rgroup;
- web100_var* var;
#elif USE_WEB10G
estats_val_data* snap;
#endif
@@ -128,9 +127,7 @@
SnapArgs snapArgs;
snapArgs.snap = NULL;
-#if USE_WEB100
snapArgs.log = NULL;
-#endif
snapArgs.delay = options->snapDelay;
wait_sig = 0;
@@ -410,27 +407,15 @@
// get details of next sequence # to be sent and fetch value from
// snap file
-#if USE_WEB100
- web100_agent_find_var_and_group(agent, "SndNxt", &group,
- &var);
- web100_snap_read(var, snapArgs.snap, tmpstr);
- nextseqtosend = atoi(
- web100_value_to_text(web100_get_var_type(var),
- tmpstr));
+
+ // get next sequence # to be sent
+ tcp_stats_snap_read_var(agent, snapArgs.snap, "SndNxt", tmpstr, sizeof(tmpstr));
+ nextseqtosend = atoi(tmpstr);
+
// get oldest un-acked sequence number
- web100_agent_find_var_and_group(agent, "SndUna", &group,
- &var);
- web100_snap_read(var, snapArgs.snap, tmpstr);
- lastunackedseq = atoi(
- web100_value_to_text(web100_get_var_type(var),
- tmpstr));
-#elif USE_WEB10G
- struct estats_val value;
- web10g_find_val(snapArgs.snap, "SndNxt", &value);
- nextseqtosend = value.uv32;
- web10g_find_val(snapArgs.snap, "SndUna", &value);
- lastunackedseq = value.uv32;
-#endif
+ tcp_stats_snap_read_var(agent, snapArgs.snap, "SndUna", tmpstr, sizeof(tmpstr));
+ lastunackedseq = atoi(tmpstr);
+
pthread_mutex_unlock(&mainmutex);
// Temporarily stop sending data if you sense that the buffer is
=======================================
--- /branches/aaron-tcp_stats_cleanup/src/testoptions.c Mon Mar 10 13:47:12 2014 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/testoptions.c Mon Mar 10 13:48:44 2014 UTC
@@ -285,7 +285,7 @@
fplocal = fopen(get_logfile(), "a");
- snaparg->log = tcp_stats_open_log(metafilename, conn, group);
+ snaparg->log = tcp_stats_open_log(metafilename, conn, group, "w");
log_println( 0, "snaparg->log: %X", snaparg->log);
if (fplocal == NULL) {
=======================================
--- /branches/aaron-tcp_stats_cleanup/src/web100-util.c Mon Mar 10 13:48:28 2014 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/web100-util.c Mon Mar 10 13:48:44 2014 UTC
@@ -744,7 +744,6 @@
*
* @param sock integer socket file descriptor indicating data recipient
* @param agent pointer to a web100_agent
- * @param cn pointer to web100_connection
* @return On successful fetch of required web100_variables, integers:
* 0x01 if "Autotune send buffer" is not enabled
* 0x02 if "Autotune receive buffer" is not
enabled
@@ -806,7 +805,6 @@
}
/**
- * @param sock integer socket file descriptor indicating data recipient
* @param tcp_vars to local copies of tcp_stat variables
* @return integer 0
*/
@@ -888,83 +886,42 @@
* @return Integer, 0 on success, -1 on failure
*/
-int CwndDecrease(char* logname, u_int32_t *dec_cnt,
+int CwndDecrease(tcp_stat_agent *agent, char* logname, u_int32_t *dec_cnt,
u_int32_t *same_cnt, u_int32_t *inc_cnt) {
-#if USE_WEB100
- web100_var* var;
- char buff[256];
- web100_snapshot* snap;
- int s1, s2, cnt, rt;
- web100_log* log;
- web100_group* group;
- web100_agent* agnt;
-#elif USE_WEB10G
- estats_val var;
- char buff[256];
- estats_val_data* snap;
- int s1, s2, cnt, rt;
- estats_record* log;
-#endif
+ tcp_stat_log *log;
+ tcp_stat_snap *snap = NULL;
+ int s1, s2, cnt;
+ char buf[1024];
-#if USE_WEB100
- // open snaplog file to read values
- if ((log = web100_log_open_read(logname)) == NULL)
- return (0);
- if ((snap = web100_snapshot_alloc_from_log(log)) == NULL)
- return (-1);
- if ((agnt = web100_get_log_agent(log)) == NULL)
- return (-1);
- if ((group = web100_get_log_group(log)) == NULL)
- return (-1);
-
- // Find current values of the congestion window
- if (web100_agent_find_var_and_group(agnt, "CurCwnd", &group, &var)
- != WEB100_ERR_SUCCESS)
- return (-1);
-#elif USE_WEB10G
- estats_record_open(&log, logname, "r");
-#endif
+ log = tcp_stats_open_log(logname, NULL, NULL, "r");
s2 = 0;
cnt = 0;
// get values and update counts
-#if USE_WEB100
- while (web100_snap_from_log(snap, log) == 0) {
-#elif USE_WEB10G
- while (estats_record_read_data(&snap, log) == NULL) {
-#endif
- if (cnt++ == 0)
+ while (tcp_stats_read_snapshot(&snap, log) == 0) {
+ if (cnt++ == 0) {
+ tcp_stats_free_snapshot(snap);
continue;
+ }
+
s1 = s2;
// Parse snapshot, returning variable values
-#if USE_WEB100
- rt = web100_snap_read(var, snap, buff);
- s2 = atoi(web100_value_to_text(web100_get_var_type(var), buff));
-#elif USE_WEB10G
- rt = web10g_find_val(snap, "CurCwnd", &var);
- s2 = var.uv32;
-#endif
+
+ if (tcp_stats_snap_read_var(agent, snap, "CurCwnd", buf, sizeof(buf)) != 0) {
+ tcp_stats_free_snapshot(snap);
+ continue;
+ }
+
+ s2 = atoi(buf);
if (cnt < 20) {
-#if USE_WEB100
- log_println(7, "Reading snaplog %p (%d), var = %s", snap, cnt,
- (char*) var);
- log_println(
- 7,
- "Checking for Cwnd decreases. rt=%d, s1=%d, s2=%d (%s), dec-cnt=%d",
- rt, s1, s2,
- web100_value_to_text(web100_get_var_type(var), buff),
- *dec_cnt);
-#elif USE_WEB10G
- log_println(7, "Reading snaplog %p (%d), var = %"PRIu64, snap, cnt,
- var.uv64);
+ log_println(7, "Reading snaplog %p (%d), var = %s", snap, cnt, buf);
log_println(
7,
- "Checking for Cwnd decreases. rt=%d, s1=%d, s2=%d, dec-cnt=%d",
- rt, s1, s2,
+ "Checking for Cwnd decreases. s1=%d, s2=%d, dec-cnt=%d",
+ s1, s2,
*dec_cnt);
-#endif
}
if (s2 < s1)
(*dec_cnt)++;
@@ -973,21 +930,11 @@
if (s2 > s1)
(*inc_cnt)++;
-#if USE_WEB100
- if (rt != WEB100_ERR_SUCCESS)
- break;
-#elif USE_WEB10G
- estats_val_data_free(&snap);
- if (rt != -1)
- break;
-#endif
+ tcp_stats_free_snapshot(snap);
}
-#if USE_WEB100
- web100_snapshot_free(snap);
- web100_log_close_read(log);
-#elif USE_WEB10G
- estats_record_close(&log);
-#endif
+
+ tcp_stats_close_log(log);
+
log_println(
2,
"-=-=-=- CWND window report: increases = %d, decreases = %d, "
@@ -1140,13 +1087,21 @@
#endif
}
-tcp_stat_log *tcp_stats_open_log(char *filename, tcp_stat_connection conn, tcp_stat_group *group) {
+tcp_stat_log *tcp_stats_open_log(char *filename, tcp_stat_connection conn, tcp_stat_group *group, char *mode) {
tcp_stat_log *retval;
#if USE_WEB100
- retval = web100_log_open_write(filename, conn, group);
+ if (strcmp(mode, "w") == 0) {
+ retval = web100_log_open_write(filename, conn, group);
+ }
+ else if (strcmp(mode, "r") == 0) {
+ retval = web100_log_open_read(filename);
+ }
+ else {
+ retval = NULL;
+ }
#elif USE_WEB10G
- estats_record_open(&retval, filename, "w");
+ estats_record_open(&retval, filename, mode);
#endif
return retval;
@@ -1195,4 +1150,18 @@
return;
}
+int tcp_stats_read_snapshot(tcp_stat_snap **snap, tcp_stat_log *log) {
+ int retval;
+
+#if USE_WEB100
+ if (*snap == NULL)
+ if ((*snap = web100_snapshot_alloc_from_log(log)) == NULL)
+ return (-1);
+
+ retval = web100_snap_from_log(*snap, log);
+#elif USE_WEB10G
+ retval = estats_record_read_data(snap, log);
+#endif
+ return retval;
+}
=======================================
--- /branches/aaron-tcp_stats_cleanup/src/web100srv.c Mon Mar 10 13:48:28 2014 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/web100srv.c Mon Mar 10 13:48:44 2014 UTC
@@ -969,11 +969,6 @@
log_println(3, "run_test() routine, asking for test_suite = %s",
test_suite);
send_msg(ctlsockfd, MSG_LOGIN, test_suite, strlen(test_suite));
- /* if ((n = initialize_tests(ctlsockfd, &testopt, conn_options))) {
- log_println(0, "ERROR: Tests initialization failed (%d)", n);
- return;
- }
- */
log_println(1, "Starting test suite:");
if (testopt->midopt) {
@@ -1055,7 +1050,7 @@
// ...determine number of times congestion window has been changed
if (options.cwndDecrease) {
dec_cnt = inc_cnt = same_cnt = 0;
- CwndDecrease(options.s2c_logname, &dec_cnt, &same_cnt, &inc_cnt);
+ CwndDecrease(agent, options.s2c_logname, &dec_cnt, &same_cnt, &inc_cnt);
log_println(2, "####### decreases = %d, increases = %d, no change = %d",
dec_cnt, inc_cnt, same_cnt);
}
=======================================
--- /branches/aaron-tcp_stats_cleanup/src/web100srv.h Mon Mar 10 13:48:28 2014 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/web100srv.h Mon Mar 10 13:48:44 2014 UTC
@@ -312,10 +312,11 @@
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);
+int tcp_stats_read_snapshot(tcp_stat_snap **snap, tcp_stat_log *log);
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);
+tcp_stat_log *tcp_stats_open_log(char *filename, tcp_stat_connection conn, tcp_stat_group *group, char *mode);
void tcp_stats_close_log(tcp_stat_log *log);
int tcp_stats_autotune_enabled(tcp_stat_agent *agent, int sock);
@@ -330,7 +331,7 @@
int tcp_stat_get_data(tcp_stat_snap* snap, int testsock, int ctlsock,
tcp_stat_agent* agent);
-int CwndDecrease(char* logname,
+int CwndDecrease(tcp_stat_agent *agent, char* logname,
u_int32_t *dec_cnt, u_int32_t *same_cnt, u_int32_t *inc_cnt);
int tcp_stat_logvars(struct tcp_vars* vars);
- [ndt-dev] [ndt] r1001 committed - Cleanup CwndDecrease, ndt, 03/10/2014
Archive powered by MHonArc 2.6.16.