ndt-dev - [ndt-dev] [ndt] r991 committed - Add tcp_stats_snap_read_var and tcp_stats_set_cwnd functions to cleanu...
Subject: NDT-DEV email list created
List archive
[ndt-dev] [ndt] r991 committed - Add tcp_stats_snap_read_var and tcp_stats_set_cwnd functions to cleanu...
Chronological Thread
- From:
- To:
- Subject: [ndt-dev] [ndt] r991 committed - Add tcp_stats_snap_read_var and tcp_stats_set_cwnd functions to cleanu...
- Date: Mon, 10 Mar 2014 13:42:35 +0000
Revision: 991
Author:
Date: Mon Mar 10 13:41:09 2014 UTC
Log: Add tcp_stats_snap_read_var and tcp_stats_set_cwnd functions to cleanup some of the logic in web100-utils functions
http://code.google.com/p/ndt/source/detail?r=991
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.c
/branches/aaron-tcp_stats_cleanup/src/web100srv.h
=======================================
--- /branches/aaron-tcp_stats_cleanup/src/testoptions.c Fri Feb 21 16:32:03 2014 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/testoptions.c Mon Mar 10 13:41:09 2014 UTC
@@ -47,22 +47,8 @@
void findCwndPeaks(tcp_stat_agent* agent, CwndPeaks* peaks,
tcp_stat_snap* snap) {
int CurCwnd;
-#if USE_WEB100
- web100_group* group;
- web100_var* var;
- char tmpstr[256];
-#elif USE_WEB10G
- struct estats_val value;
-#endif
-#if USE_WEB100
- web100_agent_find_var_and_group(agent, "CurCwnd", &group, &var);
- web100_snap_read(var, snap, tmpstr);
- CurCwnd = atoi(web100_value_to_text(web100_get_var_type(var), tmpstr));
-#elif USE_WEB10G
- web10g_find_val(snap, "CurCwnd", &value);
- CurCwnd = value.uv32;
-#endif
+ CurCwnd = tcp_stats_snap_read_var(agent, snap, "CurCwnd");
if (slowStart) {
if (CurCwnd < prevCWNDval) {
=======================================
--- /branches/aaron-tcp_stats_cleanup/src/web100-util.c Mon Mar 10 13:40:31 2014 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/web100-util.c Mon Mar 10 13:41:09 2014 UTC
@@ -101,7 +101,7 @@
* @return integer indicating number of web100 variables read
* or indicating failure of initialization
*/
-int tcp_stat_init(char *VarFileName) {
+int tcp_stats_init(char *VarFileName) {
#if USE_WEB100
FILE * fp;
char line[256], trimmedline[256];
@@ -284,15 +284,7 @@
limcwnd_val = 2 * currentMSSval;
-#if USE_WEB100
- // get web100_var and web100_group
- web100_agent_find_var_and_group(agent, "LimCwnd", &group, &LimCwnd);
-
- // set TCP CWND web100 variable to twice the current MSS Value
- web100_raw_write(LimCwnd, cn, &limcwnd_val);
-#elif USE_WEB10G
- estats_write_var("LimCwnd", (uint32_t)limcwnd_val, cn, agent);
-#endif
+ tcp_stats_set_cwnd(agent, cn, limcwnd_val);
log_println(5, "Setting Cwnd Limit to %d octets", limcwnd_val);
@@ -1038,3 +1030,36 @@
*inc_cnt, *dec_cnt, *same_cnt);
return (0);
}
+
+int tcp_stats_snap_read_var(tcp_stat_agent *agent, tcp_stat_snap *snap, const char *var_name) {
+#if USE_WEB100
+ web100_group* group;
+ web100_var* var;
+ char tmpstr[256];
+
+ web100_agent_find_var_and_group(agent, var_name, &group, &var);
+ web100_snap_read(var, snap, tmpstr);
+ return atoi(web100_value_to_text(web100_get_var_type(var), tmpstr));
+#elif USE_WEB10G
+ struct estats_val value;
+
+ web10g_find_val(snap, var_name, &value);
+ return value.uv32;
+#endif
+}
+
+void tcp_stats_set_cwnd(tcp_stat_agent *agent, tcp_stat_connection cn, uint32_t cwnd) {
+#if USE_WEB100
+ web100_var* LimCwnd;
+ web100_group* group;
+
+ // get web100_var and web100_group
+ web100_agent_find_var_and_group(agent, "LimCwnd", &group, &LimCwnd);
+
+ // set TCP CWND web100 variable to twice the current MSS Value
+ web100_raw_write(LimCwnd, cn, &cwnd);
+#elif USE_WEB10G
+ estats_write_var("LimCwnd", (uint32_t)cwnd, cn, agent);
+#endif
+}
+
=======================================
--- /branches/aaron-tcp_stats_cleanup/src/web100srv.c Mon Mar 10 13:40:31 2014 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/web100srv.c Mon Mar 10 13:41:09 2014 UTC
@@ -535,7 +535,7 @@
case SIGHUP:
/* Initialize Web100 structures */
- count_vars = tcp_stat_init(VarFileName);
+ count_vars = tcp_stats_init(VarFileName);
/* The administrator view automatically generates a usage page for the
* NDT server. This page is then accessable to the general public.
@@ -1836,7 +1836,7 @@
log_println(1, "server ready on port %s (family %d)", port, meta.family);
// Initialize tcp_stat structures
- count_vars = tcp_stat_init(VarFileName);
+ count_vars = tcp_stats_init(VarFileName);
if (count_vars == -1) {
log_println(0, "No Web100 variables file found, terminating program");
exit(-5);
=======================================
--- /branches/aaron-tcp_stats_cleanup/src/web100srv.h Mon Mar 10 13:40:31 2014 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/web100srv.h Mon Mar 10 13:41:09 2014 UTC
@@ -307,8 +307,12 @@
#endif
+// Generic functions that, at compile-time, reads either from web10g or web100
+int tcp_stats_init(char *VarFileName);
+int tcp_stats_snap_read_var(tcp_stat_agent *agent, tcp_stat_snap *snap, const char *var_name);
+void tcp_stats_set_cwnd(tcp_stat_agent *agent, tcp_stat_connection cn, uint32_t cwnd);
+
int tcp_stat_autotune(int sock, tcp_stat_agent* agent, tcp_stat_connection cn);
-int tcp_stat_init(char *VarFileName);
void tcp_stat_middlebox(int sock, tcp_stat_agent* agent, tcp_stat_connection cn,
char *results, size_t results_strlen);
void tcp_stat_get_data_recv(int sock, tcp_stat_agent* agent,
- [ndt-dev] [ndt] r991 committed - Add tcp_stats_snap_read_var and tcp_stats_set_cwnd functions to cleanu..., ndt, 03/10/2014
Archive powered by MHonArc 2.6.16.