Skip to Content.
Sympa Menu

ndt-dev - [ndt-dev] [ndt] r828 committed - Update to use the new Web10G 2.0.6.2 userland....

Subject: NDT-DEV email list created

List archive

[ndt-dev] [ndt] r828 committed - Update to use the new Web10G 2.0.6.2 userland....


Chronological Thread 
  • From:
  • To:
  • Subject: [ndt-dev] [ndt] r828 committed - Update to use the new Web10G 2.0.6.2 userland....
  • Date: Thu, 20 Jun 2013 03:11:03 +0000
  • Authentication-results: sfpop-ironport07.merit.edu; dkim=neutral (message not signed) header.i=none

Revision: 828
Author:

Date: Wed Jun 19 20:10:20 2013
Log: Update to use the new Web10G 2.0.6.2 userland.
This no longer supports the old 2.0.4 userland, 2.0.6.2 is required. 2.0.6.2 will work with the 3.5 kernel patch(as well as the 3.6-3.8 one released with it), so it's just a matter downloading and installing the new library.

* Logging is now supported (NOTE: has some issues with the 3.5 kernel patch)
* genplot now has a Web10G counterpart genplot10g
* Lots of minor fixes
* Better support for 10Gig connections (still not 100%), (using 64-bit numbers for all variables)
* Changed naming of USE_TCPE to USE_WEB10G, since the library name changed back to estats its clearer to just use web10g.
http://code.google.com/p/ndt/source/detail?r=828

Added:
/branches/ndt-web10g/README_WEB10G
Deleted:
/branches/ndt-web10g/WEB10G_README
Modified:
/branches/ndt-web10g/Applet/NDTConstants.java
/branches/ndt-web10g/Applet/Tcpbw100.java
/branches/ndt-web10g/configure.ac
/branches/ndt-web10g/src/Makefile.am
/branches/ndt-web10g/src/genplot.c
/branches/ndt-web10g/src/heuristics.c
/branches/ndt-web10g/src/heuristics.h
/branches/ndt-web10g/src/network.c
/branches/ndt-web10g/src/network.h
/branches/ndt-web10g/src/test_c2s_srv.c
/branches/ndt-web10g/src/test_mid_srv.c
/branches/ndt-web10g/src/test_results_clt.c
/branches/ndt-web10g/src/test_s2c_srv.c
/branches/ndt-web10g/src/test_sfw_srv.c
/branches/ndt-web10g/src/testoptions.c
/branches/ndt-web10g/src/testoptions.h
/branches/ndt-web10g/src/utils.c
/branches/ndt-web10g/src/utils.h
/branches/ndt-web10g/src/web100-pcap.c
/branches/ndt-web10g/src/web100-util.c
/branches/ndt-web10g/src/web100clt.c
/branches/ndt-web10g/src/web100srv.c
/branches/ndt-web10g/src/web100srv.h
/branches/ndt-web10g/src/web10g-util.c

=======================================
--- /dev/null
+++ /branches/ndt-web10g/README_WEB10G Wed Jun 19 20:10:20 2013
@@ -0,0 +1,87 @@
+ ndt-web10g
+
+Required libraries:
+
+Web10G
+Download and install the latest userland and your kernel patch from
+http://web10g.org. You will need the use the Web10G userland-2.0.6.2
+(as at time of writing the newest release).
+
+This is known/expected to work with the following web10g kernel patches:
+Web10G-0.6.2-patches (Linux kernel 3.6, 3.7 & 3.8).
+Web10G-0.4-3.5-patch - You will have to make a small modification
+
+IMPORTANT - Web10G-0.4-3.5-patch modification
+Swap the single occurrence of ktime_to_ns(...) to ktime_to_us(...)
+before applying the patch.
+
+This will not work with the 3.2 kernel patch or earlier. Try running
+the sample applications included in the 2.0.6.2 userland, if these do
+not work the kernel patch your using doesn't support this userland
+and cannot be used.
+
+Although you only need the library installed to build, the patched
+web10g kernel is required to run the server, reading a log file on the
+other hand should be ok with the kernel patch. REMEMBER to modprobe
+tcp_estats_nl first and you'll most likely need sudo permissions to run
+the server.
+
+I2Util
+Grab the copy included in the ndt-3.6.5.1 release in the ndt google
+code project page. https://ndt.googlecode.com/files/ndt-3.6.5.1.tar.gz
+Or from svn here
+Build Instructions:
+
+Should be as simple as
+./bootstrap
+./configure
+make
+
+Web100 is still fully supported and if Web100 libs are found web100srv
+will also be built.
+
+Running:
+Unlike web100srv, web10gsrv doesn't require the variable name file and
+this will be ignored (-f option). Besides that the two work alike.
+
+The client web100clt can be used with both the Web10G and Web100
+servers. Only very minor changes have been made - such that the
+original ndt-web100 client should work correctly with both versions of
+the server.
+
+genplot is for web100 snaps where as genplot10g works with Web10G.
+
+I've tested with Linux 3.5.1 kernel patched with web10g
+Web10G-0.4-3.5-patch(modified)
+- There are some issues with logging Web10G Vars.
+
+Linux 3.8.8 kernel with web10g web10g-0.6.2-3.8.patch.
+- Works well.
+
+Known issues:
+Web10G related
+* Web10g kernel patch not quite right - 3.5 kernel patch need to swap
+ ktime_to_ns to ktime_to_us.
+* Logging using the 3.5 kernel patch doesn't work perfectly. Timestamps
+ and addresses are NOT recorded.
+* Server, Client(C and Java Applet) and genplot have been ported.
+ Other tools don't appear to rely upon the web100/10g library.
+
+Other
+* Running the server without a DNS server can cause tests to timeout and
+ fail. Add the NI_NUMERICHOST flag into the getnameinfo call within
+ _I2AddrSetNodePort() in the I2Util library to fix.
+* MSS incorrectly detecting modification when testing via IPv6??
+* A general ndt problem 10Gig connections may overflow integer values
+ and hence results may not be accurate - let us know if you notice
+ this happening.
+
+Reporting Issues:
+
+The best place to go for help is the

mailing
+list.
+
+Or to myself

(Richard Sanger).
+
+
+My work has been funded by Waikato University/The WAND group.
=======================================
--- /branches/ndt-web10g/WEB10G_README Sat Apr 13 19:56:13 2013
+++ /dev/null
@@ -1,21 +0,0 @@
-Quick Build Notes
-Although you don't need a web10g kernel to build, if you wish to run the server you will.
-
-I've tested with linux 3.5.1 kernel patched with web10g (web10.org - Web10G-0.4-3.5-patch). I had to modify the patch - Swap ktime_to_ns(...) with ktime_to_us(...).
-
-You need to make and install the Web10G-userland library I used Web10G-userland-2.0.4.
-
-NOTE: The older estats-userlands are not supported so the 3.2 kernel and earlier will not work.
-
-Configure and build ndt as normal. Web10G libs should be detected and hence the web10gsrv built. Web100 is still fully supported and if Web100 libs are found web100srv will be built.
-
-Known issues
-
-Web10G related
-* Logging functionality not yet implemented some related functions are missing.
-* Web10g kernel patch not quite right - need to modify ktime_to_ns to ktime_to_us.
-* Server and Client(C and Java Applet) have been ported, other tools have not. Depending on their function they may not work.
-
-Other
-* Running the server without a DNS server can cause tests to timeout and fail. Add the NI_NUMERICHOST flag into the getnameinfo call within _I2AddrSetNodePort() in the I2Util library to fix.
-* MSS incorrectly detecting modification when testing via IPv6??
=======================================
--- /branches/ndt-web10g/Applet/NDTConstants.java Thu Apr 11 07:52:06
2013
+++ /branches/ndt-web10g/Applet/NDTConstants.java Wed Jun 19 20:10:20
2013
@@ -18,7 +18,7 @@
public static final String META_BROWSER_OS = "client.browser.name";
public static final String META_CLIENT_KERNEL_VERSION = "client.kernel.version";
public static final String META_CLIENT_VERSION = "client.version";
- public static final String META_CLIENT_APPLICATION = "client.application";
+ public static final String META_CLIENT_APPLICATION = "client.application";

/*
* TODO for a later release: Version could be moved to some
"configurable"
=======================================
--- /branches/ndt-web10g/Applet/Tcpbw100.java Mon Jun 3 21:18:52 2013
+++ /branches/ndt-web10g/Applet/Tcpbw100.java Wed Jun 19 20:10:20 2013
@@ -1947,7 +1947,7 @@

// Get input stream to read bytes from socket
InputStream srvin = inSocket.getInputStream();
- int iBitCount = 0;
+ long iBitCount = 0;
int inlth;

// wait here for signal from server application
@@ -2750,7 +2750,7 @@
iSysval =
Integer.parseInt(sStrval);
// If it fails as an int it's probably to big since the values are often unsigned
} catch (Exception e) {
- System.out.println("Exception
occured reading a web100 var - " + e);
+ System.out.println("Exception occured reading a web100 var " + sSysvar + " - " + e);
iSysval = -1;
}
// save value into a key value
expected by us
@@ -2955,7 +2955,7 @@
case NDTConstants.DUPLEX_OK_INDICATOR:
if (bad_cable == 1) {

_resultsTxtPane.append(_resBundDisplayMsgs
- .getString("excessiveErrors ")
+ "\n");
+ .getString("excessiveErrors") +
"\n");
_sEmailText += _resBundDisplayMsgs
.getString("excessiveErrors") +
"\n%0A";
}
@@ -3379,7 +3379,7 @@
_txtStatistics.append("\n"
+
_resBundDisplayMsgs.getString("web100tcpOpts") + " \n");
_txtStatistics.append("RFC 2018 Selective Acknowledgment:
");
- if (_iSACKEnabled == NDTConstants.RFC_2018_ENABLED)
+ if (_iSACKEnabled != 0)

_txtStatistics.append(_resBundDisplayMsgs.getString("on")
+ "\n");
else
@@ -3387,7 +3387,7 @@
+ "\n");

_txtStatistics.append("RFC 896 Nagle Algorithm: ");
- if (_iNagleEnabled == NDTConstants.RFC_896_ENABLED)
+ if (_iNagleEnabled != 0)

_txtStatistics.append(_resBundDisplayMsgs.getString("on")
+ "\n");
else
@@ -3395,7 +3395,7 @@
+ "\n");

_txtStatistics.append("RFC 3168 Explicit Congestion
Notification: ");
- if (_iECNEnabled == NDTConstants.RFC_3168_ENABLED)
+ if (_iECNEnabled != 0)

_txtStatistics.append(_resBundDisplayMsgs.getString("on")
+ "\n");
else
@@ -3403,7 +3403,7 @@
+ "\n");

_txtStatistics.append("RFC 1323 Time Stamping: ");
- if (_iTimestampsEnabled ==
NDTConstants.RFC_1323_ENABLED)
+ if (_iTimestampsEnabled != 0)

_txtStatistics.append(_resBundDisplayMsgs.getString("on")
+ "\n");
else
=======================================
--- /branches/ndt-web10g/configure.ac Sat Apr 13 19:56:13 2013
+++ /branches/ndt-web10g/configure.ac Wed Jun 19 20:10:20 2013
@@ -146,17 +146,17 @@
AM_CONDITIONAL(HAVE_WEB100, false)
])

-AC_CHECK_LIB([tcpe], [tcpe_client_init],
+AC_CHECK_LIB([estats], [estats_record_open],
[
- LINKED_TCPELIB="-ltcpe"
- INCLUDED_TCPELIB="-I/usr/local/include/tcpe"
- AC_DEFINE(HAVE_LIBTCPE, 1, [Define to 1 if you have the 'Web10G' library (-ltcpe).])
- AM_CONDITIONAL(HAVE_TCPE, true)
+ LINKED_WEB10GLIB="-lestats"
+ INCLUDED_WEB10GLIB="-I/usr/local/include/estats"
+ AC_DEFINE(HAVE_LIBWEB10G, 1, [Define to 1 if you have the 'Web10G' library (-lestats >=2.0.6.2).])
+ AM_CONDITIONAL(HAVE_WEB10G, true)
],
[
- LINKED_TCPELIB=""
- INCLUDED_TCPELIB=""
- AM_CONDITIONAL(HAVE_TCPE, false)
+ LINKED_WEB10GLIB=""
+ INCLUDED_WEB10GLIB=""
+ AM_CONDITIONAL(HAVE_WEB10G, false)
])

AC_CHECK_LIB([pcap], [pcap_open_live],
@@ -210,16 +210,16 @@
])


-NDTINCDIR='$(INCLUDED_WEB100LIB) $(INCLUDED_PCAPLIB) $(INCLUDED_TCPELIB)'
+NDTINCDIR='$(INCLUDED_WEB100LIB) $(INCLUDED_PCAPLIB) $(INCLUDED_WEB10GLIB)'
NDTLIBDIR=/usr/local/lib
NDTLDFLAGS='-L$(NDTLIBDIR) -Wl,-rpath,$(NDTLIBDIR)'
-NDTLIBS='$(LINKED_WEB100LIB) $(LINKED_PCAPLIB) $(LINKED_ODBCLIB) $(LINKED_TCPELIB) -lm'
+NDTLIBS='$(LINKED_WEB100LIB) $(LINKED_PCAPLIB) $(LINKED_ODBCLIB) $(LINKED_WEB10GLIB) -lm'
NDTINCS='-I$(NDTINCDIR)'

AC_SUBST(LINKED_WEB100LIB)
AC_SUBST(INCLUDED_WEB100LIB)
-AC_SUBST(LINKED_TCPELIB)
-AC_SUBST(INCLUDED_TCPELIB)
+AC_SUBST(LINKED_WEB10GLIB)
+AC_SUBST(INCLUDED_WEB10GLIB)
AC_SUBST(LINKED_PCAPLIB)
AC_SUBST(INCLUDED_PCAPLIB)
AC_SUBST(LINKED_ODBCLIB)
@@ -290,14 +290,17 @@
echo ""
echo ""

-if test -z "$HAVE_TCPE_TRUE" && test -n "$HAVE_TCPE_FALSE"; then
+if test -z "$HAVE_WEB10G_TRUE" && test -n "$HAVE_WEB10G_FALSE"; then
if test -z "$HAVE_PCAP_H_TRUE" && test -n "$HAVE_PCAP_H_FALSE"; then
SUMMARY_WEB10GSRV="YES"
+ SUMMARY_GENPLOT10G="YES"
else
+ SUMMARY_GENPLOT10G="YES"
SUMMARY_WEB10GSRV="NO (missing pcap headers)"
fi
else
- SUMMARY_WEB10GSRV="NO (missing tcpe (web10g) library)"
+ SUMMARY_WEB10GSRV="NO (missing web10g userland library >=2.0.6.2)"
+ SUMMARY_GENPLOT10G="NO (missing web10g userland library >=2.0.6.2)"
fi

SUMMARY_WEB100CLT="YES"
@@ -359,6 +362,7 @@
echo "* viewtrace: ${SUMMARY_VIEWTRACE}"
echo "* tr-mkmap: ${SUMMARY_TRMKMAP}"
echo "* genplot: ${SUMMARY_GENPLOT}"
+echo "* genplot10g: ${SUMMARY_GENPLOT10G}"
echo "* JAnalyze.jar: ${SUMMARY_JANALYZEJAR}"
echo "* Admin.class: ${SUMMARY_ADMINCLASS}"
echo ""
=======================================
--- /branches/ndt-web10g/src/Makefile.am Thu Apr 11 07:52:06 2013
+++ /branches/ndt-web10g/src/Makefile.am Wed Jun 19 20:10:20 2013
@@ -33,40 +33,44 @@
bin_PROGRAMS = web100clt
endif

-if HAVE_TCPE
+if HAVE_WEB10G
if HAVE_PCAP_H
if HAVE_WEB100
-sbin_PROGRAMS += web10gsrv
+sbin_PROGRAMS += web10gsrv genplot10g
else
-sbin_PROGRAMS = fakewww web10gsrv
+sbin_PROGRAMS = fakewww web10gsrv genplot10g
endif
endif
endif

web100clt_SOURCES = web100clt.c network.c usage.c logging.c utils.c protocol.c runningtest.c ndtptestconstants.c \
test_sfw_clt.c test_mid_clt.c test_c2s_clt.c test_s2c_clt.c test_meta_clt.c strlutils.c \
- test_results_clt.c
+ test_results_clt.c
web100clt_LDADD = $(I2UTILLIBDEPS) -lpthread $(ZLIB)
web100clt_CPPFLAGS ='-DBASEDIR="$(ndtdir)"'
web100clt_DEPENDENCIES = $(I2UTILLIBDEPS)

genplot_SOURCES = genplot.c usage.c
genplot_LDADD = $(NDTLIBS) $(I2UTILLIBDEPS)
-genplot_CPPFLAGS ='-DBASEDIR="$(ndtdir)"'
+genplot_CPPFLAGS ='-DBASEDIR="$(ndtdir)"' -DFORCE_WEB100
+
+genplot10g_SOURCES = genplot.c usage.c web10g-util.c utils.c
+genplot10g_LDADD = $(NDTLIBS) $(I2UTILLIBDEPS)
+genplot10g_CPPFLAGS ='-DBASEDIR="$(ndtdir)"'

analyze_SOURCES = analyze.c usage.c logging.c runningtest.c ndtptestconstants.c strlutils.c
analyze_LDADD = $(NDTLIBS) $(I2UTILLIBDEPS) $(ZLIB)
analyze_CPPFLAGS ='-DBASEDIR="$(ndtdir)"' -DFORCE_WEB100

fakewww_SOURCES = fakewww.c troute.c troute6.c tr-tree.c tr-tree6.c network.c usage.c logging.c \
- runningtest.c ndtptestconstants.c strlutils.c
+ runningtest.c ndtptestconstants.c strlutils.c
fakewww_LDADD = $(I2UTILLIBDEPS) $(ZLIB)
fakewww_CPPFLAGS ='-DBASEDIR="$(ndtdir)"'

web100srv_SOURCES = web100srv.c web100-util.c web100-pcap.c web100-admin.c runningtest.c \
network.c usage.c utils.c mrange.c logging.c testoptions.c ndtptestconstants.c \
protocol.c test_sfw_srv.c test_meta_srv.c ndt_odbc.c strlutils.c heuristics.c \
- test_c2s_srv.c test_s2c_srv.c test_mid_srv.c
+ test_c2s_srv.c test_s2c_srv.c test_mid_srv.c
web100srv_LDFLAGS = $(NDTLDFLAGS) $(I2UTILLDFLAGS)
web100srv_LDADD = $(NDTLIBS) $(I2UTILLIBS) $(I2UTILLIBDEPS) -lpthread $(ZLIB)
web100srv_CPPFLAGS ='-DBASEDIR="$(ndtdir)"' -DFORCE_WEB100
@@ -107,5 +111,5 @@

EXTRA_DIST = clt_tests.h logging.h mrange.h network.h protocol.h testoptions.h test_sfw.h test_meta.h \
troute.h tr-tree.h usage.h utils.h varinfo.h web100-admin.h web100srv.h ndt_odbc.h runningtest.h ndtptestconstants.h \
- heuristics.h strlutils.h test_results_clt.h tests_srv.h
+ heuristics.h strlutils.h test_results_clt.h tests_srv.h

=======================================
--- /branches/ndt-web10g/src/genplot.c Thu Nov 15 13:34:19 2012
+++ /branches/ndt-web10g/src/genplot.c Wed Jun 19 20:10:20 2013
@@ -28,10 +28,7 @@
#include <getopt.h>
#include <sys/types.h>

-#ifdef HAVE_LIBWEB100
-#include <web100.h>
-#endif
-
+#include "web100srv.h"
#include "usage.h"

char *color[16] = { "green", "blue", "orange", "red", "yellow", "magenta",
@@ -42,6 +39,10 @@
0, 0, 'R' }, { "throughput", 0, 0, 'S' }, { "cwndtime", 0, 0, 'c' }, {
"help", 0, 0, 'h' }, { "version", 0, 0, 'v' }, { 0, 0, 0, 0 } };

+/**
+ * @param x
+ * @return x unless x == 2147483647 in which case -1 is returned.
+ */
int checkmz(int x) {
if (x == 2147483647) {
return -1;
@@ -49,16 +50,128 @@
return x;
}

-void get_title(web100_snapshot* snap, web100_log* log, web100_agent* agent,
- web100_group* group, char* title, char* remport) {
+
+#if USE_WEB100
+
+#define ELAPSED_TIME "Duration"
+#define TIME_SENDER "SndLimTimeSender"
+#define DATA_OCT_OUT "DataBytesOut"
+
+#elif USE_WEB10G
+
+#define Chk(x) \
+ do { \
+ err = (x); \
+ if (err != NULL) { \
+ goto Cleanup; \
+ } \
+ } while (0)
+
+/* ElapsedMicroSecs is the one of the only things not yet working in the
+ * kernel patch. Instead use snaplog timestamps to fake this */
+static uint64_t start_time = 0;
+#define ELAPSED_TIME "ElapsedMicroSecs"
+#define TIME_SENDER "SndLimTimeSnd"
+#define DATA_OCT_OUT "HCDataOctetsOut"
+
+/* web10g-util.c needs logging but we don't want real logging
+ * so let it link with this version and print to stderr */
+void log_println(int lvl, const char* format, ...) {
+ va_list ap;
+ va_start(ap, format);
+ vfprintf(stderr, format, ap);
+ fprintf(stderr, "\n");
+ va_end(ap);
+}
+
+#endif
+
+/**
+ * Given a snap (likely read from a log) read a value as a double.
+ * Upon failure will exit the program with error code EXIT_FAILURE.
+ *
+ *
+ * @param name The name of the variable to read in Web100/Web10G.
+ * @param snap A Web100/Web10G snap
+ * @param group A Web100 group - ignored by Web10G should be NULL
+ * @param agent A Web100 agent - ignored by Web10G should be NULL
+ *
+ * @return The value of 'name' covnerted to a double.
+ */
+double tcp_stat_read_double(const char * name, tcp_stat_snap* snap,
+ tcp_stat_group* group, tcp_stat_agent* agent) {
+#if USE_WEB100
web100_var* var;
- char buf[128];
+ char buf[256];
+#elif USE_WEB10G
+ estats_val val;
+#endif

- if ((web100_snap_from_log(snap, log)) != WEB100_ERR_SUCCESS) {
- web100_perror("web100_log_open_read");
- return;
+#if USE_WEB100
+ if ((web100_agent_find_var_and_group(agent, name, &group,
+ &var)) != WEB100_ERR_SUCCESS) {
+ web100_perror("web100_agent_find_var_and_group");
+ exit(EXIT_FAILURE);
}

+ if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
+ web100_perror("web100_snap_read");
+ exit(EXIT_FAILURE);
+ }
+ return atof(
+ web100_value_to_text(web100_get_var_type(var),
+ buf));
+#elif USE_WEB10G
+ int vartype = ESTATS_UNSIGNED32;
+ /* ELAPSED_TIME not working in kernel patch, so use time on the
+ * snap */
+ if (strcmp(name, ELAPSED_TIME) == 0) {
+ val.masked = 0;
+ val.uv32 = snap->tv.sec * 1000000 + snap->tv.usec - start_time;
+ } else {
+ vartype = web10g_find_val(snap, name, &val);
+ if (vartype == -1) {
+ printf("Bad vartype tcp_stat_read_double %s\n", name);
+ exit(EXIT_FAILURE);
+ }
+ }
+ switch (vartype) {
+ case ESTATS_UNSIGNED64:
+ return (double) val.uv64;
+ case ESTATS_UNSIGNED32:
+ return (double) val.uv32;
+ case ESTATS_SIGNED32:
+ return (double) val.sv32;
+ case ESTATS_UNSIGNED16:
+ return (double) val.uv16;
+ case ESTATS_UNSIGNED8:
+ return (double) val.uv8;
+ }
+ fprintf(stderr, "Bad vartype tcp_stat_read_double %s\n", name);
+ exit(EXIT_FAILURE);
+#endif
+}
+
+/**
+ * Get the title info from the snap. That is local address:port remote
+ * address:port.
+ *
+ * For Web10G this also logs the start_time because this is expected
+ * to be the first snap captured.
+ *
+ * @param snap A Web100/Web10G snap
+ * @param agent A Web100 agent - ignored by Web10G should be NULL
+ * @param group A Web100 group - ignored by Web10G should be NULL
+ * @param title Upon return contains the string
+ * "<localaddr>:<localport> --> <remoteaddr>"
+ * @param remport Upon return contains the remote port as a string
+ */
+void get_title(tcp_stat_snap* snap, tcp_stat_agent* agent,
+ tcp_stat_group* group, char* title, char* remport) {
+#if USE_WEB100
+ web100_var* var;
+ char buf[128];
+
if ((web100_agent_find_var_and_group(agent, "LocalAddress", &group, &var))
!= WEB100_ERR_SUCCESS) {
web100_perror("web100_agent_find_var_and_group");
@@ -102,14 +215,64 @@
}
strcpy(remport, web100_value_to_text(web100_get_var_type(var), buf));
/* printf("%s:%s\n", title, remport); */
+#elif USE_WEB10G
+ estats_error* err = NULL;
+ struct estats_connection_tuple_ascii tuple_ascii;
+
+ /* Quite a convenient little function we have */
+ if ((err = estats_connection_tuple_as_strings(&tuple_ascii,
+ &snap->tuple)) != NULL) {
+ /* If using the 3.5 kernel to make snaps it appears that the
+ * address isn't filled in, so continue with unknown */
+ fprintf(stderr, "WARNING estats_connection_tuple_as_string has"
+ " failed this could be due to using the 3.5 kernel patch which"
+ " doesn't log this information!!!!");
+ estats_error_print(stderr, err);
+ estats_error_free(&err);
+ sprintf(title, "unknown:unknown --> unknown");
+ sprintf(remport, "unknown");
+ // exit(EXIT_FAILURE);
+ }
+
+ sprintf(title, "%s:%s --> %s", tuple_ascii.local_addr,
+ tuple_ascii.local_port, tuple_ascii.rem_addr);
+ sprintf(remport, "%s", tuple_ascii.rem_port);
+ /* Notes the time fo this the first snap in the global start_time
+ * because ElapsedTimeMicroSec is unimplemented in the kernel patch */
+ start_time = snap->tv.sec * 1000000 + snap->tv.usec;
+
+#endif
}

-void plot_var(char *list, int cnt, char *name, web100_snapshot* snap,
- web100_log* log, web100_agent* agent, web100_group* group,
+/**
+ * Plot anything else.
+ *
+ * @param list A comma seperated list of Web100/Web10G names to
+ * plot.
+ * @param cnt The number of items in list to plot, starting from the
+ * start. Shouldn't be larger than the number of items in 'list'
+ * @param name The file name to output to (gets .<remport>.xpls
+ * appended to the end).
+ * @param snap Allocated storage for Web100 - NULL for Web10G
+ * @param log A open Web100/Web10G log file
+ * @param agent A Web100 agent - ignored by Web10G should be NULL
+ * @param group A Web100 group - ignored by Web10G should be NULL
+ * @param func (Can be NULL) A function that expects two integers for
+ * its arguments and returns a new integer. The first interger
+ * corrosponds to the item in 'list' 0 for the first etc.
+ * The second the value in the snap. The returned value is
+ * plotted.
+ * Called once for every list item for ever snap in the log.
+ */
+void plot_var(char *list, int cnt, char *name, tcp_stat_snap* snap,
+ tcp_stat_log* log, tcp_stat_agent* agent, tcp_stat_group* group,
int(*func)(const int arg, const int value)) {
+#if USE_WEB10G
+ estats_error* err = NULL;
+#endif
char *varg;
- char buf[256];
- web100_var* var;
+ /*char buf[256];
+ web100_var* var;*/
char varlist[256], lname[256], remport[8];
char title[256];
int i, first = 0;
@@ -124,11 +287,28 @@

memset(lname, 0, 256);

- get_title(snap, log, agent, group, title, remport);
+ /* Get the first snap from the log */
+#if USE_WEB100
+ if ((web100_snap_from_log(snap, log)) != WEB100_ERR_SUCCESS) {
+ web100_perror("web100_snap_from_log");
+ return;
+ }
+#elif USE_WEB10G
+ if ((err = estats_record_read_data(&snap, log)) != NULL) {
+ estats_record_close(&log);
+ estats_error_print(stderr, err);
+ estats_error_free(&err);
+ return;
+ }
+#endif
+
+ get_title(snap, agent, group, title, remport);

if (name == NULL) {
fn = stdout;
- strncpy(name, "Unknown", 7);
+ /* XXX writing into a NULL pointer?? */
+ // strncpy(name, "Unknown", 7);
+ name = "Unknown";
} else {
snprintf(lname, sizeof(lname), "%s.%s.xpl", name, remport);
fn = fopen(lname, "w");
@@ -149,9 +329,14 @@
first = 0;

for (;;) {
+ /* We've already read the first item to use with get_title */
if (first != 0) {
+#if USE_WEB100
if ((web100_snap_from_log(snap, log)) != WEB100_ERR_SUCCESS) {
- /* web100_perror("web100_log_open_read"); */
+#elif USE_WEB10G
+ if ((err = estats_record_read_data(&snap, log)) != NULL) {
+ estats_error_free(&err);
+#endif
fprintf(fn, "go\n");
return;
}
@@ -159,33 +344,16 @@
strncpy(varlist, list, strlen(list) + 1);
varg = strtok(varlist, ",");
for (i = 0; i < cnt; i++) {
- if ((web100_agent_find_var_and_group(agent, varg, &group, &var))
- != WEB100_ERR_SUCCESS) {
- web100_perror("web100_agent_find_var_and_group");
- exit(EXIT_FAILURE);
- }
-
- if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
- web100_perror("web100_snap_read");
- exit(EXIT_FAILURE);
- }
-
if (i == 0) {
if (first == 0) {
if (func) {
x1 = func(
i,
checkmz(
- atoi(
- web100_value_to_text(
- web100_get_var_type(
- var), buf))));
+ tcp_stat_read_double(varg, snap, group, agent)));
} else {
x1 = checkmz(
- atoi(
- web100_value_to_text(
- web100_get_var_type(var),
- buf)));
+ tcp_stat_read_double(varg, snap, group, agent));
}
} else {
x1 = x2;
@@ -196,16 +364,10 @@
y1[i - 1] = func(
i,
checkmz(
- atoi(
- web100_value_to_text(
- web100_get_var_type(
- var), buf))));
+ tcp_stat_read_double(varg, snap, group, agent)));
} else {
y1[i - 1] = checkmz(
- atoi(
- web100_value_to_text(
- web100_get_var_type(var),
- buf)));
+ tcp_stat_read_double(varg, snap, group, agent));
}
} else {
y1[i - 1] = y2[i - 1];
@@ -218,46 +380,25 @@
strncpy(varlist, list, strlen(list) + 1);
varg = strtok(varlist, ",");
for (i = 0; i < cnt; i++) {
- if ((web100_agent_find_var_and_group(agent, varg, &group, &var))
- != WEB100_ERR_SUCCESS) {
- web100_perror("web100_agent_find_var_and_group");
- exit(EXIT_FAILURE);
- }
-
- if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
- web100_perror("web100_snap_read");
- exit(EXIT_FAILURE);
- }
-
if (i == 0) {
if (func) {
x2 = func(
i,
checkmz(
- atoi(
- web100_value_to_text(
- web100_get_var_type(var),
- buf))));
+ tcp_stat_read_double(varg, snap, group, agent)));
} else {
x2 = checkmz(
- atoi(
- web100_value_to_text(
- web100_get_var_type(var), buf)));
+ tcp_stat_read_double(varg, snap, group, agent));
}
} else {
if (func) {
y2[i - 1] = func(
i,
checkmz(
- atoi(
- web100_value_to_text(
- web100_get_var_type(var),
- buf))));
+ tcp_stat_read_double(varg, snap, group, agent)));
} else {
y2[i - 1] = checkmz(
- atoi(
- web100_value_to_text(
- web100_get_var_type(var), buf)));
+ tcp_stat_read_double(varg, snap, group, agent));
}
fprintf(fn, "%s\nline %0.4f %0.4f %0.4f %0.4f\n", color[i - 1],
x1 / 1000000, y1[i - 1] / 1024, x2 / 1000000,
@@ -265,18 +406,33 @@
}
varg = strtok(NULL, ",");
}
+#if USE_WEB10G
+ estats_val_data_free(&snap);
+#endif
}
fprintf(fn, "go\n");
}

-void plot_cwndtime(char *name, web100_snapshot* snap, web100_log* log,
- web100_agent* agent, web100_group* group) {
+
+/**
+ * Make a plot CwndTime(%) against total time.
+ *
+ * @param name The file name to output to (gets .<remport>.xpls
+ * appended to the end).
+ * @param snap Allocated storage for Web100 - NULL for Web10G
+ * @param log A open Web100/Web10G log file
+ * @param agent A Web100 agent - ignored by Web10G should be NULL
+ * @param group A Web100 group - ignored by Web10G should be NULL
+ */
+void plot_cwndtime(char *name, tcp_stat_snap* snap, tcp_stat_log* log,
+ tcp_stat_agent* agent, tcp_stat_group* group) {
+#if USE_WEB10G
+ estats_error* err = NULL;
+#endif
double SndLimTimeRwin = 0, SndLimTimeSender = 0;
- char buf[256];
- web100_var* var;
char lname[256], remport[8];
char title[256];
- char* variables[] = { "Duration", "SndLimTimeRwin", "SndLimTimeSender",
+ char* variables[] = { ELAPSED_TIME, "SndLimTimeRwin", TIME_SENDER,
"SndLimTimeCwnd" };
int i, first = 0;
double x1, x2, y1, y2;
@@ -284,11 +440,28 @@

memset(lname, 0, 256);

- get_title(snap, log, agent, group, title, remport);
+ /* Get the first snap from the log */
+#if USE_WEB100
+ if ((web100_snap_from_log(snap, log)) != WEB100_ERR_SUCCESS) {
+ web100_perror("web100_snap_from_log");
+ return;
+ }
+#elif USE_WEB10G
+ if ((err = estats_record_read_data(&snap, log)) != NULL) {
+ estats_record_close(&log);
+ estats_error_print(stderr, err);
+ estats_error_free(&err);
+ return;
+ }
+#endif
+
+ get_title(snap, agent, group, title, remport);

if (name == NULL) {
fn = stdout;
- strncpy(name, "Unknown", 7);
+ /* XXX writing into a NULL pointer?? */
+ // strncpy(name, "Unknown", 7);
+ name = "Unknown";
} else {
snprintf(lname, sizeof(lname), "%s.%s.xpl", name, remport);
fn = fopen(lname, "w");
@@ -302,104 +475,127 @@
first = 0;

for (;;) {
+ /* We've already read the first item to use with get_title */
if (first != 0) {
+#if USE_WEB100
if ((web100_snap_from_log(snap, log)) != WEB100_ERR_SUCCESS) {
+#elif USE_WEB10G
+ if ((err = estats_record_read_data(&snap, log)) != NULL) {
+ estats_error_free(&err);
+#endif
fprintf(fn, "go\n");
return;
}
}
for (i = 0; i < 4; i++) {
- if ((web100_agent_find_var_and_group(agent, variables[i], &group,
- &var)) != WEB100_ERR_SUCCESS) {
- web100_perror("web100_agent_find_var_and_group");
- exit(EXIT_FAILURE);
- }
-
- if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
- web100_perror("web100_snap_read");
- exit(EXIT_FAILURE);
- }
-
- if (i == 0) {
- if (first == 0) {
- x1 = atoi(
- web100_value_to_text(web100_get_var_type(var),
- buf));
- } else {
- x1 = x2;
- }
- } else if (i == 1) {
- if (first == 0) {
- SndLimTimeRwin = atoi(
- web100_value_to_text(web100_get_var_type(var),
- buf));
- }
- } else if (i == 2) {
- if (first == 0) {
- SndLimTimeSender = atoi(
- web100_value_to_text(web100_get_var_type(var),
- buf));
+ if (first == 0) {
+ /* Give everything starting values */
+ switch (i) {
+ case 0: /* ELAPSED_TIME */
+ x1 = tcp_stat_read_double(variables[i], snap, group, agent);
+ break;
+ case 1: /* "SndLimTimeRwin" */
+ SndLimTimeRwin = tcp_stat_read_double(variables[i],
+ snap, group, agent);
+ break;
+ case 2: /* "SndLimTimeSender" */
+ SndLimTimeSender = tcp_stat_read_double(variables[i],
+ snap, group, agent);
+ break;
+ case 3: /* "SndLimTimeCwnd" */
+ y1 = tcp_stat_read_double(variables[i], snap, group, agent);
+ y1 = y1 / (SndLimTimeRwin + SndLimTimeSender + y1);
+ break;
}
} else {
- if (first == 0) {
- y1 = atoi(
- web100_value_to_text(web100_get_var_type(var),
- buf));
- y1 = y1 / (SndLimTimeRwin + SndLimTimeSender + y1);
- } else {
- y1 = y2;
+ switch (i) {
+ case 0: /* ELAPSED_TIME */
+ x1 = x2;
+ break;
+ case 3: /* "SndLimTimeCwnd" */
+ y1 = y2;
+ break;
}
}
}

first++;
for (i = 0; i < 4; i++) {
- if ((web100_agent_find_var_and_group(agent, variables[i], &group,
- &var)) != WEB100_ERR_SUCCESS) {
- web100_perror("web100_agent_find_var_and_group");
- exit(EXIT_FAILURE);
- }
-
- if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
- web100_perror("web100_snap_read");
- exit(EXIT_FAILURE);
- }
-
- if (i == 0) {
- x2 = atoi(web100_value_to_text(web100_get_var_type(var), buf));
- } else if (i == 1) {
- SndLimTimeRwin = atoi(
- web100_value_to_text(web100_get_var_type(var), buf));
- } else if (i == 2) {
- SndLimTimeSender = atoi(
- web100_value_to_text(web100_get_var_type(var), buf));
- } else {
- y2 = atoi(web100_value_to_text(web100_get_var_type(var), buf));
+ if (i == 0) { /* ELAPSED_TIME */
+ x2 = tcp_stat_read_double(variables[i], snap, group, agent);
+ } else if (i == 1) { /* "SndLimTimeRwin" */
+ SndLimTimeRwin = tcp_stat_read_double(variables[i],
+ snap, group, agent);
+ } else if (i == 2) { /* "SndLimTimeSender" */
+ SndLimTimeSender = tcp_stat_read_double(variables[i],
+ snap, group, agent);
+ } else { /* "SndLimTimeCwnd" */
+ y2 = tcp_stat_read_double(variables[i], snap, group, agent);
y2 = y2 / (SndLimTimeRwin + SndLimTimeSender + y2);
fprintf(fn, "%s\nline %0.4f %0.4f %0.4f %0.4f\n", color[i - 1],
x1 / 1000000, y1, x2 / 1000000, y2);
}
}
+#if USE_WEB10G
+ estats_val_data_free(&snap);
+#endif
}
fprintf(fn, "go\n");
}

-void print_var(char *varlist, web100_snapshot* snap, web100_log* log,
- web100_agent* agent, web100_group* group,
+/**
+ *
+ * Loop through the supplied list of variables and prints them to
+ * stdout as a new row for every snap in the log file.
+ *
+ * A function 'func' can be provided to changed how these are printed.
+ *
+ * @param varlist A comma seperated list of Web100/Web10G names to
+ * print.
+ * @param snap Allocated storage for Web100 - NULL for Web10G
+ * @param log A open Web100/Web10G log file
+ * @param agent A Web100 agent - ignored by Web10G should be NULL
+ * @param group A Web100 group - ignored by Web10G should be NULL
+ * @param func (Can be NULL) A function that expects two integers for
+ * its arguments. The first corrosponds to the item in varlist
+ * 0 for the first etc. The second the value in the snap.
+ * Called once for every varlist item for ever snap in the log.
+ */
+void print_var(char *varlist, tcp_stat_snap* snap, tcp_stat_log* log,
+ tcp_stat_agent* agent, tcp_stat_group* group,
void(*func)(const int arg, const int value)) {
- char *varg, savelist[256], *text;
- char buf[256], title[256], remport[8];
+ char *varg, savelist[256];
+ char title[256], remport[8];
int i, j;
- web100_var* var;
+#if USE_WEB10G
+ estats_error* err = NULL;
+#endif
FILE* fn;

fn = stdout;
- get_title(snap, log, agent, group, title, remport);
+
+ /* Get the first snap from the log */
+#if USE_WEB100
+ if ((web100_snap_from_log(snap, log)) != WEB100_ERR_SUCCESS) {
+ web100_perror("web100_snap_from_log");
+ return;
+ }
+#elif USE_WEB10G
+ if ((err = estats_record_read_data(&snap, log)) != NULL) {
+ estats_record_close(&log);
+ estats_error_print(stderr, err);
+ estats_error_free(&err);
+ return;
+ }
+#endif
+
+ get_title(snap, agent, group, title, remport);
fprintf(fn, "Extracting Data from %s:%s connection\n\n", title, remport);

strncpy(savelist, varlist, strlen(varlist) + 1);
printf("Index\t");
varg = strtok(varlist, ",");
+ /* Loop through varlist and print them out as the column names */
for (j = 0;; j++) {
if (varg == NULL)
break;
@@ -411,45 +607,46 @@
varg = strtok(NULL, ",");
}
printf("\n");
+ /* Loop over the log file */
for (i = 0;; i++) {
- if ((web100_snap_from_log(snap, log)) != WEB100_ERR_SUCCESS) {
- /* web100_perror("web100_log_open_read"); */
- printf("-------------- End Of Data --------------\n\n");
- return;
+ /* We've already read the first item to use with get_title */
+ if (i != 0) {
+#if USE_WEB100
+ if ((web100_snap_from_log(snap, log)) != WEB100_ERR_SUCCESS) {
+#elif USE_WEB10G
+ if ((err = estats_record_read_data(&snap, log)) != NULL) {
+ estats_error_free(&err);
+#endif
+ printf("-------------- End Of Data --------------\n\n");
+ return;
+ }
}
printf("%5d\t", i);
-
strncpy(varlist, savelist, strlen(savelist) + 1);
varg = strtok(varlist, ",");
+ /* Loop over the vars we are printing out */
for (j = 0;; j++) {
- if (varg == NULL)
+ if (varg == NULL) {
break;
- if ((web100_agent_find_var_and_group(agent, varg, &group, &var))
- != WEB100_ERR_SUCCESS) {
- web100_perror("web100_agent_find_var_and_group");
- exit(EXIT_FAILURE);
- }
-
- if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
- web100_perror("web100_snap_read");
- exit(EXIT_FAILURE);
}
if (func) {
- func(
- j,
- atoi(
- web100_value_to_text(web100_get_var_type(var),
- buf)));
+ /* Let the provided function do the printing */
+ func(j, (int) tcp_stat_read_double(varg, snap, group, agent));
} else {
- text = web100_value_to_text(web100_get_var_type(var), buf);
- if (strcmp(text, "4294966376") == 0) {
+ /* Do it ourself */
+ double value = tcp_stat_read_double(varg, snap, group, agent);
+ // weird magic number ((2^32) - 1) - 919
+ if ((int) value == 4294966376) {
printf("%10s\t", "-1");
} else {
- printf("%10s\t", text);
+ printf("%10"PRId64"\t", (int64_t) value);
}
}
varg = strtok(NULL, ",");
}
+#if USE_WEB10G
+ estats_val_data_free(&snap);
+#endif
printf("\n");
}
}
@@ -460,9 +657,9 @@

if (arg == -1) {
if (value) {
- printf("%10s\t", "Throughput (kB/s)");
+ printf("%10s\t", "Throughput (mB/s)");
} else {
- printf("%10s\t", "Duration");
+ printf("%10s\t", ELAPSED_TIME);
}
return;
}
@@ -494,7 +691,7 @@

if (arg == -1) {
if (value == 0) {
- printf("%10s\t", "Duration");
+ printf("%10s\t", ELAPSED_TIME);
} else if (value == 3) {
printf("%10s\t", "CwndTime (%% of total time)");
}
@@ -519,11 +716,14 @@
/* --- */

int main(int argc, char** argv) {
- web100_agent* agent;
- web100_connection* conn;
- web100_group* group;
- web100_log* log;
- web100_snapshot* snap;
+ tcp_stat_agent* agent = NULL;
+ tcp_stat_connection conn = NULL;
+ tcp_stat_group* group = NULL;
+ tcp_stat_log* log = NULL;
+ tcp_stat_snap* snap = NULL;
+#if USE_WEB10G
+ estats_error* err = NULL;
+#endif
char fn[128];
char *varlist = NULL, list[1024];
char *varg;
@@ -577,6 +777,7 @@

for (j = optind; j < argc; j++) {
snprintf(fn, sizeof(fn), "%s", argv[j]);
+#if USE_WEB100
if ((log = web100_log_open_read(fn)) == NULL) {
web100_perror("web100_log_open_read");
exit(EXIT_FAILURE);
@@ -596,17 +797,25 @@
web100_perror("web100_get_log_connection");
exit(EXIT_FAILURE);
}
-
+#elif USE_WEB10G
+ if ((err = estats_record_open(&log, fn, "r")) != NULL) {
+ estats_error_print(stderr, err);
+ estats_error_free(&err);
+ exit(EXIT_FAILURE);
+ }
+#endif
fprintf(stderr, "Extracting data from Snaplog '%s'\n\n", fn);

+#if USE_WEB100
if ((snap = web100_snapshot_alloc_from_log(log)) == NULL) {
web100_perror("web100_snapshot_alloc_from_log");
exit(EXIT_FAILURE);
}
+#endif

if (plotuser == 1) {
memset(list, 0, 1024);
- strncpy(list, "Duration,", 9);
+ strncpy(list, ELAPSED_TIME",", 1024);
strncat(list, varlist, strlen(varlist));
varg = strtok(list, ",");
for (k = 1;; k++) {
@@ -614,7 +823,7 @@
break;
}
memset(list, 0, 1024);
- strncpy(list, "Duration,", 9);
+ strncpy(list, ELAPSED_TIME",", 1024);
strncat(list, varlist, strlen(varlist));
if (txt == 1)
print_var(list, snap, log, agent, group, NULL);
@@ -624,7 +833,7 @@
}
if (plotspd == 1) {
memset(list, 0, 1024);
- strncpy(list, "Duration,DataBytesOut", 21);
+ strncpy(list, ELAPSED_TIME","DATA_OCT_OUT, 1024);
if (txt == 1)
print_var(list, snap, log, agent, group, throughput);
else
@@ -634,8 +843,8 @@
if (plotcwndtime == 1) {
memset(list, 0, 1024);
strncpy(list,
- "Duration,SndLimTimeRwin,SndLimTimeSender,SndLimTimeCwnd",
- 55);
+ ELAPSED_TIME",SndLimTimeRwin,"TIME_SENDER",SndLimTimeCwnd",
+ 1024);
if (txt == 1)
print_var(list, snap, log, agent, group, cwndtime);
else
@@ -643,7 +852,7 @@
}
if (plotcwnd == 1) {
memset(list, 0, 1024);
- strncpy(list, "Duration,CurCwnd", 16);
+ strncpy(list, ELAPSED_TIME",CurCwnd", 1024);
if (txt == 1)
print_var(list, snap, log, agent, group, NULL);
else
@@ -651,7 +860,7 @@
}
if (plotrwin == 1) {
memset(list, 0, 1024);
- strncpy(list, "Duration,CurRwinRcvd", 20);
+ strncpy(list, ELAPSED_TIME",CurRwinRcvd", 1024);
if (txt == 1)
print_var(list, snap, log, agent, group, NULL);
else
@@ -659,13 +868,17 @@
}
if (plotboth == 1) {
memset(list, 0, 1024);
- strncpy(list, "Duration,CurCwnd,CurRwinRcvd", 28);
+ strncpy(list, ELAPSED_TIME",CurCwnd,CurRwinRcvd", 1024);
if (txt == 1)
print_var(list, snap, log, agent, group, NULL);
else
plot_var(list, 3, "Both", snap, log, agent, group, NULL);
}
- web100_log_close_read(log);
+#if USE_WEB100
+ web100_log_close_read(log);
+#elif USE_WEB10G
+ estats_record_close(&log);
+#endif
}

exit(0);
=======================================
--- /branches/ndt-web10g/src/heuristics.c Thu Nov 15 13:34:19 2012
+++ /branches/ndt-web10g/src/heuristics.c Wed Jun 19 20:10:20 2013
@@ -132,10 +132,12 @@
* @return average round trip time
* */

-double calc_avg_rtt(int sumRTT, int countRTT, double *avgRTT) {
+double calc_avg_rtt(tcp_stat_var sumRTT, tcp_stat_var countRTT,
+ double *avgRTT) {
*avgRTT = (double) sumRTT / countRTT;
log_println(log_lvl_heur,
- "-- Average round trip time= SumRTT (%d) over countRTT (%d)=%f",
+ "-- Average round trip time= SumRTT (%"VARtype") over "
+ "countRTT (%"VARtype")=%f",
sumRTT, countRTT, (*avgRTT) * .001);
return ((*avgRTT) * .001);
}
@@ -158,7 +160,8 @@
* @param c2sdatalinkspd Integer indicative of link speed, as collected in the C->S test
* @return packet loss value
* */
-double calc_packetloss(int congsnsignals, int pktsout, int c2sdatalinkspd) {
+double calc_packetloss(tcp_stat_var congsnsignals, tcp_stat_var pktsout,
+ int c2sdatalinkspd) {
double packetloss = (double) congsnsignals / pktsout;
if (packetloss == 0) {
if (c2sdatalinkspd > 5)
@@ -166,7 +169,8 @@
else
packetloss = .000001; // set to 10^-6 otherwise
}
- log_println(log_lvl_heur, "--packetloss=%d over %d=%f. Link spd=%d",
+ log_println(log_lvl_heur, "--packetloss=%"VARtype" over %"VARtype
+ "=%f. Link spd=%d",
congsnsignals, pktsout, packetloss, c2sdatalinkspd);
return packetloss;
}
@@ -179,7 +183,8 @@
* @param actualackcount number of non-duplicate ACKs received
* @return percentage of packets out of order
* */
-double calc_packets_outoforder(int dupackcount, int actualackcount) {
+double calc_packets_outoforder(tcp_stat_var dupackcount,
+ tcp_stat_var actualackcount) {
log_println(log_lvl_heur, "--packets out of order: %f",
(double) dupackcount / actualackcount);
return ((double) dupackcount / actualackcount);
@@ -197,12 +202,13 @@
* @param packetloss Packet loss
* @return maximum theoretical bandwidth
* */
-double calc_max_theoretical_throughput(int currentMSS, double rttsec,
- double packetloss) {
+double calc_max_theoretical_throughput(tcp_stat_var currentMSS,
+ double rttsec, double packetloss) {
double maxthruput;
maxthruput = (currentMSS / (rttsec * sqrt(packetloss))) * BITS_8 / KILO_BITS
/ KILO_BITS;
- log_println(log_lvl_heur, "--max_theoretical_thruput: %f. From %d,%f,%f",
+ log_println(log_lvl_heur, "--max_theoretical_thruput: %f. From %"
+ VARtype",%f,%f",
maxthruput, currentMSS, rttsec, packetloss);
return maxthruput;
}
@@ -218,9 +224,10 @@
* @param cwin congestion window value in bytes
*
* */
-void calc_window_sizes(int *SndWinScale, int *RcvWinScale, int SendBuf,
- int MaxRwinRcvd, int MaxCwnd, double *rwin, double *swin,
- double *cwin) {
+void calc_window_sizes(tcp_stat_var *SndWinScale,
+ tcp_stat_var *RcvWinScale, tcp_stat_var SendBuf,
+ tcp_stat_var MaxRwinRcvd, tcp_stat_var MaxCwnd,
+ double *rwin, double *swin, double *cwin) {
if ((*SndWinScale > WINDOW_SCALE_THRESH) || (SendBuf < MAX_TCP_PORT))
*SndWinScale = 0;
if ((*RcvWinScale > WINDOW_SCALE_THRESH) || (MaxRwinRcvd < MAX_TCP_PORT))
@@ -231,8 +238,9 @@
*cwin = (double) MaxCwnd * BITS_8 / KILO_BITS / KILO_BITS;
log_println(
log_lvl_heur,
- "--window sizes: SndWinScale= %d, RcvwinScale=%d, MaxRwinRcvd=%d, "
- "maxCwnd=%d,rwin=%f, swin=%f, cwin=%f",
+ "--window sizes: SndWinScale= %"VARtype", RcvwinScale=%"VARtype
+ ", MaxRwinRcvd=%"VARtype", "
+ "maxCwnd=%"VARtype",rwin=%f, swin=%f, cwin=%f",
*SndWinScale, *RcvWinScale, MaxRwinRcvd, MaxCwnd, *rwin, *swin, *cwin);
}

@@ -245,7 +253,8 @@
* @param totaltime total test time
* @return idle time fraction
* */
-double calc_RTOIdle(int timeouts, int currentRTO, double totaltime) {
+double calc_RTOIdle(tcp_stat_var timeouts, tcp_stat_var currentRTO,
+ double totaltime) {
double idlewaitingforpackets = (timeouts * ((double) currentRTO / 1000))
/ totaltime;
log_println(log_lvl_heur, "--RTOIdle:%f", idlewaitingforpackets);
@@ -263,10 +272,12 @@
* 'sender limited' state
* @return Total test time
* */
-int calc_totaltesttime(int SndLimTimeRwin, int SndLimTimeCwnd,
- int SndLimTimeSender) {
+int calc_totaltesttime(tcp_stat_var SndLimTimeRwin,
+ tcp_stat_var SndLimTimeCwnd,
+ tcp_stat_var SndLimTimeSender) {
int totaltime = SndLimTimeRwin + SndLimTimeCwnd + SndLimTimeSender;
- log_println(log_lvl_heur, "--Total test time: %d+%d+%d=%d ", SndLimTimeRwin,
+ log_println(log_lvl_heur, "--Total test time: %"VARtype"+%"VARtype"+%"
+ VARtype"=%d ", SndLimTimeRwin,
SndLimTimeCwnd, SndLimTimeSender, totaltime);
return (totaltime);
}
@@ -278,9 +289,10 @@
* @return sender limited time ratio
*
*/
-double calc_sendlimited_sndrfault(int SndLimTimeSender, int totaltime) {
+double calc_sendlimited_sndrfault(tcp_stat_var SndLimTimeSender,
+ int totaltime) {
double sendlimitedtime = ((double) SndLimTimeSender) / totaltime;
- log_println(log_lvl_heur, "--Send limited time: %d over %d=%f ",
+ log_println(log_lvl_heur, "--Send limited time: %"VARtype" over %d=%f ",
SndLimTimeSender, totaltime, sendlimitedtime);
return sendlimitedtime;
}
@@ -293,9 +305,10 @@
* @return sender limited time ratio
*
*/
-double calc_sendlimited_rcvrfault(int SndLimTimeRwin, int totaltime) {
+double calc_sendlimited_rcvrfault(tcp_stat_var SndLimTimeRwin,
+ int totaltime) {
double sendlimitedtime = ((double) SndLimTimeRwin) / totaltime;
- log_println(log_lvl_heur, "--Send limited time: %d over %d=%f ",
+ log_println(log_lvl_heur, "--Send limited time: %"VARtype" over %d=%f ",
SndLimTimeRwin, totaltime, sendlimitedtime);
return sendlimitedtime;
}
@@ -306,9 +319,10 @@
* @param totaltime Total test time
* @return sender limited time ratio
*/
-double calc_sendlimited_cong(int SndLimTimeCwnd, int totaltime) {
+double calc_sendlimited_cong(tcp_stat_var SndLimTimeCwnd,
+ int totaltime) {
double sendlimitedtime = ((double) SndLimTimeCwnd) / totaltime;
- log_println(log_lvl_heur, "--Send limited time: %d over %d=%f ",
+ log_println(log_lvl_heur, "--Send limited time: %"VARtype" over %d=%f ",
SndLimTimeCwnd, totaltime, sendlimitedtime);
return sendlimitedtime;
}
@@ -321,7 +335,8 @@
* @param totaltime Total test time in microseconds
* @return Actual throughput
*/
-double calc_real_throughput(int DataBytesOut, int totaltime) {
+double calc_real_throughput(tcp_stat_var DataBytesOut,
+ tcp_stat_var totaltime) {
double realthruput = ((double) DataBytesOut / (double) totaltime) * BITS_8;
log_println(log_lvl_heur, "--Actual observed throughput: %f ", realthruput);
return realthruput;
@@ -335,7 +350,8 @@
* expired when the RTO backoff multiplier is
equal to one
* @return Actual throughput
*/
-double cal_totalwaittime(int currentRTO, int timeoutcounters) {
+double cal_totalwaittime(tcp_stat_var currentRTO,
+ tcp_stat_var timeoutcounters) {
double waitarrivetime = (double) (currentRTO * timeoutcounters) / KILO;
log_println(log_lvl_heur, "--Total wait time: %f ", waitarrivetime);
return waitarrivetime;
@@ -404,8 +420,9 @@
* @param multiple is multiple test mode on?
* @return int 1 if duplex mismatch is found, 0 if not.
* */
-int detect_duplexmismatch(double cwndtime, double bwtheoretcl, int pktsretxed,
- double timesec, int maxsstartthresh, double idleRTO,
+int detect_duplexmismatch(double cwndtime, double bwtheoretcl,
+ tcp_stat_var pktsretxed, double timesec,
+ tcp_stat_var maxsstartthresh, double idleRTO,
int link, int s2cspd, int midboxspd, int multiple) {
int duplex_mismatch_yes = 0;
if ((cwndtime > .9) // more than 90% time spent being receiver window limited
@@ -468,7 +485,7 @@
* @return 1 is fault hardware suspected, 0 otherwise
* */
int detect_faultyhardwarelink(double packetloss, double cwndtime,
- double timesec, int maxslowstartthresh) {
+ double timesec, tcp_stat_var maxslowstartthresh) {
int faultyhw_found = 0;
if (((packetloss * 100) / timesec > 15) && (cwndtime / timesec > .6)
&& (packetloss < .01) && (maxslowstartthresh > 0)) {
@@ -532,7 +549,8 @@
* @return 1 if wireless link, 0 otherwise
* */
int detect_wirelesslink(double sendtime, double realthruput, double bw_theortcl,
- int sndlimtrans_rwin, int sndlimtrans_cwnd,
+ tcp_stat_var sndlimtrans_rwin,
+ tcp_stat_var sndlimtrans_cwnd,
double rwindowtime, int link) {
int is_wireless = 0;
if ((sendtime == 0) && (realthruput < 5) && (bw_theortcl > 50)
@@ -563,7 +581,8 @@
* @param link integer indicative of link type
* @return 1 if wireless link, 0 otherwise
* */
-int detect_DSLCablelink(int sndlim_timesender, int sndlim_transsender,
+int detect_DSLCablelink(tcp_stat_var sndlim_timesender,
+ tcp_stat_var sndlim_transsender,
double realthruput, double bw_theoretical, int link) {
int is_dslorcable = 0;
if ((sndlim_timesender < 600) && (sndlim_transsender == 0)
@@ -593,8 +612,8 @@
* @param totaltesttime total test time
* @return 1 if half_duplex link suspected, 0 otherwise
* */
-int detect_halfduplex(double rwintime, int sndlim_transrwin,
- int sndlim_transsender, double totaltesttime) {
+int detect_halfduplex(double rwintime, tcp_stat_var sndlim_transrwin,
+ tcp_stat_var sndlim_transsender, double totaltesttime) {
int is_halfduplex = 0;
if ((rwintime > .95) && (sndlim_transrwin / totaltesttime > 30)
&& (sndlim_transsender / totaltesttime > 30)) {
=======================================
--- /branches/ndt-web10g/src/heuristics.h Thu Nov 15 13:33:44 2012
+++ /branches/ndt-web10g/src/heuristics.h Wed Jun 19 20:10:20 2013
@@ -8,6 +8,8 @@
#ifndef SRC_HEURISTICS_H_
#define SRC_HEURISTICS_H_

+#include "web100srv.h"
+
// link speed algorithms
void calc_linkspeed(char spds[4][256], int spd_index, int *c2sdata, int *c2sack,
int* s2cdata, int *s2cack, float runave[4],
@@ -15,44 +17,55 @@
int *timeout, int *dupack, int isc2stest);

// calculate average round trip time
-double calc_avg_rtt(int sumRTT, int countRTT, double * avgRTT);
+double calc_avg_rtt(tcp_stat_var sumRTT, tcp_stat_var countRTT,
+ double *avgRTT);

// calculate packet loss percentage
-double calc_packetloss(int congsnsignals, int pktsout, int c2sdatalinkspd);
+double calc_packetloss(tcp_stat_var congsnsignals, tcp_stat_var pktsout,
+ int c2sdatalinkspd);

// Calculate the percentage of packets arriving out of order
-double calc_packets_outoforder(int dupackcount, int actualackcount);
+double calc_packets_outoforder(tcp_stat_var dupackcount,
+ tcp_stat_var actualackcount);

// calculate theoretical maximum goodput in bits
-double calc_max_theoretical_throughput(int currentMSS, double rttsec,
- double packetloss);
+double calc_max_theoretical_throughput(tcp_stat_var currentMSS,
+ double rttsec, double packetloss);

// finalize some window sizes
-void calc_window_sizes(int *SndWinScale, int *RcvWinScale, int SendBuf,
- int MaxRwinRcvd, int MaxCwnd, double *rwin, double *swin,
- double *cwin);
+void calc_window_sizes(tcp_stat_var *SndWinScale,
+ tcp_stat_var *RcvWinScale, tcp_stat_var SendBuf,
+ tcp_stat_var MaxRwinRcvd, tcp_stat_var MaxCwnd,
+ double *rwin, double *swin, double *cwin);

// calculate RTO Idle time
-double calc_RTOIdle(int timeouts, int CurrentRTO, double totaltime);
+double calc_RTOIdle(tcp_stat_var timeouts, tcp_stat_var currentRTO,
+ double totaltime);

// calculate total test time for S_C test
-int calc_totaltesttime(int SndLimTimeRwin, int SndLimTimeCwnd,
- int SndLimTimeSender);
+int calc_totaltesttime(tcp_stat_var SndLimTimeRwin,
+ tcp_stat_var SndLimTimeCwnd,
+ tcp_stat_var SndLimTimeSender);

// get time ratio of 'Sender Limited' time due to congestion
-double calc_sendlimited_cong(int SndLimTimeCwnd, int totaltime);
+double calc_sendlimited_cong(tcp_stat_var SndLimTimeCwnd,
+ int totaltime);

// get time ratio of 'Sender Limited' time due to receivers fault
-double calc_sendlimited_rcvrfault(int SndLimTimeRwin, int totaltime);
+double calc_sendlimited_rcvrfault(tcp_stat_var SndLimTimeRwin,
+ int totaltime);

// get time ratio of 'Sender Limited' time due to sender's fault
-double calc_sendlimited_sndrfault(int SndLimTimeSender, int totaltime);
+double calc_sendlimited_sndrfault(tcp_stat_var SndLimTimeSender,
+ int totaltime);

// Calculate actual throughput in Mbps
-double calc_real_throughput(int DataBytesOut, int totaltime);
+double calc_real_throughput(tcp_stat_var DataBytesOut,
+ tcp_stat_var totaltime);

// Calculate total time spent waiting for packets to arrive
-double cal_totalwaittime(int currentRTO, int timeoutcounters);
+double cal_totalwaittime(tcp_stat_var currentRTO,
+ tcp_stat_var timeoutcounters);

// Is throughput measured greater in value during the C->S than S->C test?
int is_c2s_throughputbetter(int c2stestresult, int s2ctestresult);
@@ -65,13 +78,14 @@
int isNotMultipleTestMode(int multiple);

// detect duplex mismatch mode
-int detect_duplexmismatch(double cwndtime, double bwtheoretcl, int pktsretxed,
- double timesec, int maxsstartthresh, double idleRTO,
+int detect_duplexmismatch(double cwndtime, double bwtheoretcl,
+ tcp_stat_var pktsretxed, double timesec,
+ tcp_stat_var maxsstartthresh, double idleRTO,
int link, int s2cspd, int midboxspd, int multiple);

// detect if faulty hardware may exist
int detect_faultyhardwarelink(double packetloss, double cwndtime,
- double timesec, int maxslowstartthresh);
+ double timesec, tcp_stat_var maxslowstartthresh);

// Is this an ethernet link?
int detect_ethernetlink(double realthruput, double s2cspd, double packetloss,
@@ -79,16 +93,18 @@

// Is wireless link?
int detect_wirelesslink(double sendtime, double realthruput, double bw_theortcl,
- int sndlimtrans_rwin, int sndlimtrans_cwnd,
+ tcp_stat_var sndlimtrans_rwin,
+ tcp_stat_var sndlimtrans_cwnd,
double rwindowtime, int link);

// Is DSL/Cable modem?
-int detect_DSLCablelink(int sndlim_timesender, int sndlim_transsender,
+int detect_DSLCablelink(tcp_stat_var sndlim_timesender,
+ tcp_stat_var sndlim_transsender,
double realthruput, double bw_theoretical, int link);

// Is a half_duplex link present?
-int detect_halfduplex(double rwintime, int sndlim_transrwin,
- int sndlim_transsender, double totaltesttime);
+int detect_halfduplex(double rwintime, tcp_stat_var sndlim_transrwin,
+ tcp_stat_var sndlim_transsender, double totaltesttime);

// Is congestion detected?
int detect_congestionwindow(double cwndtime, int mismatch, double cwin,
=======================================
--- /branches/ndt-web10g/src/network.c Mon Jun 3 21:18:52 2013
+++ /branches/ndt-web10g/src/network.c Wed Jun 19 20:10:20 2013
@@ -39,7 +39,7 @@
// Attempt to connect to one of the chosen addresses.
struct addrinfo* ai = NULL;
for (ai = fai; ai; ai = ai->ai_next) {
- if(ai->ai_family != family)
+ if (ai->ai_family != family)
continue;

// create socket with obtained address domain, socket type and protocol
@@ -281,7 +281,8 @@
*sockfd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (*sockfd < 0) {
// socket create failed. Abandon further activities using this socket
- log_println(1, "Failed to create %d %d %d", ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+ log_println(1, "Failed to create %d %d %d", ai->ai_family,
+ ai->ai_socktype, ai->ai_protocol);
continue;
}

@@ -356,7 +357,7 @@
return 1;
} else {
log_println(0, "Failed to connect: %s", strerror(errno));
- //goto error;
+ // goto error;
}
}

@@ -380,7 +381,7 @@
*
*/

-int send_msg(int ctlSocket, int type, void* msg, int len) {
+int send_msg(int ctlSocket, int type, const void* msg, int len) {
unsigned char buff[3];
int rc, i;

@@ -489,9 +490,9 @@
* @return The amount of bytes written to the file descriptor
*/

-int writen(int fd, void* buf, int amount) {
+int writen(int fd, const void* buf, int amount) {
int sent, n;
- char* ptr = buf;
+ const char* ptr = buf;
sent = 0;
assert(amount >= 0);
while (sent < amount) {
@@ -567,3 +568,4 @@
}
return received;
}
+
=======================================
--- /branches/ndt-web10g/src/network.h Mon Jun 3 21:18:52 2013
+++ /branches/ndt-web10g/src/network.h Wed Jun 19 20:10:20 2013
@@ -20,9 +20,9 @@
I2Addr CreateListenSocket(I2Addr addr, char* serv, int options, int buf_size);
int CreateConnectSocket(int* sockfd, I2Addr local_addr, I2Addr server_addr,
int option, int buf_sizes);
-int send_msg(int ctlSocket, int type, void* msg, int len);
+int send_msg(int ctlSocket, int type, const void* msg, int len);
int recv_msg(int ctlSocket, int* type, void* msg, int* len);
-int writen(int fd, void* buf, int amount);
+int writen(int fd, const void* buf, int amount);
int readn(int fd, void* buf, int amount);

/* web100-util.c routine used in network. */
=======================================
--- /branches/ndt-web10g/src/test_c2s_srv.c Thu Apr 11 07:52:06 2013
+++ /branches/ndt-web10g/src/test_c2s_srv.c Wed Jun 19 20:10:20 2013
@@ -21,10 +21,6 @@
#include "network.h"
#include "mrange.h"

-// used to store file descriptors of pipes created for ndttrace for C2S tests
-int mon_pipe1[2];
-
-
/**
* Perform the C2S Throughput test. This test intends to measure throughput
* from the client to the server by performing a 10 seconds memory-to-memory data transfer.
@@ -67,7 +63,8 @@
int count_vars, char spds[4][256], int* spd_index) {
tcp_stat_connection conn;
tcp_stat_group* group = NULL;
-
+ /* The pipe that will return packet pair results */
+ int mon_pipe[2];
int recvsfd; // receiver socket file descriptor
pid_t c2s_childpid = 0; // child process pids
int msgretvalue, tmpbytecount; // used during the "read"/"write" process
@@ -269,7 +266,7 @@
&pair, currenttestdesc, options->compress, meta.c2s_ndttrace);
*/

- pipe(mon_pipe1);
+ pipe(mon_pipe);
if ((c2s_childpid = fork()) == 0) {
/* close(ctlsockfd); */
close(testOptions->c2ssockfd);
@@ -277,19 +274,22 @@
log_println(
5,
"C2S test Child %d thinks pipe() returned fd0=%d, fd1=%d",
- testOptions->child0, mon_pipe1[0], mon_pipe1[1]);
+ testOptions->child0, mon_pipe[0], mon_pipe[1]);
log_println(2, "C2S test calling init_pkttrace() with pd=%p",
&cli_addr);
init_pkttrace(src_addr, (struct sockaddr *) &cli_addr, clilen,
- mon_pipe1, device, &pair, "c2s", options->compress);
+ mon_pipe, device, &pair, "c2s", options->compress);
log_println(1, "c2s is exiting gracefully");
+ /* Close the pipe */
+ close(mon_pipe[0]);
+ close(mon_pipe[1]);
exit(0); /* Packet trace finished, terminate gracefully */
}

// Get data collected from packet tracing into the C2S "ndttrace" file
memset(tmpstr, 0, 256);
for (i = 0; i < 5; i++) {
- msgretvalue = read(mon_pipe1[0], tmpstr, 128);
+ msgretvalue = read(mon_pipe[0], tmpstr, 128);
if ((msgretvalue == -1) && (errno == EINTR))
continue;
break;
@@ -301,7 +301,7 @@
}

log_println(5, "C2S test Parent thinks pipe() returned fd0=%d, fd1=%d",
- mon_pipe1[0], mon_pipe1[1]);
+ mon_pipe[0], mon_pipe[1]);

// experimental code, delete when finished
setCwndlimit(conn, group, agent, options);
@@ -378,10 +378,12 @@
if (record_reverse == 1)
tcp_stat_get_data_recv(recvsfd, agent, conn, count_vars);

+
+ close(recvsfd);
+ close(testOptions->c2ssockfd);
+
// Next, send speed-chk a flag to retrieve the data it collected.
// Skip this step if speed-chk isn't running.
- close(recvsfd);
- close(testOptions->c2ssockfd);

if (getuid() == 0) {
log_println(1, "Signal USR1(%d) sent to child [%d]", SIGUSR1,
@@ -389,13 +391,13 @@
testOptions->child1 = c2s_childpid;
kill(c2s_childpid, SIGUSR1);
FD_ZERO(&rfd);
- FD_SET(mon_pipe1[0], &rfd);
+ FD_SET(mon_pipe[0], &rfd);
sel_tv.tv_sec = 1;
sel_tv.tv_usec = 100000;
i = 0;

for (;;) {
- msgretvalue = select(mon_pipe1[0] + 1, &rfd, NULL, NULL,
+ msgretvalue = select(mon_pipe[0] + 1, &rfd, NULL, NULL,
&sel_tv);
if ((msgretvalue == -1) && (errno == EINTR))
continue;
@@ -416,7 +418,7 @@
* RAC 2/8/10
*/
if (msgretvalue > 0) {
- if ((msgretvalue = read(mon_pipe1[0], spds[*spd_index],
+ if ((msgretvalue = read(mon_pipe[0], spds[*spd_index],
sizeof(spds[*spd_index]))) < 0) {
snprintf(
spds[*spd_index],
@@ -440,7 +442,7 @@

// Close opened resources for packet capture
if (getuid() == 0) {
- stop_packet_trace(mon_pipe1);
+ stop_packet_trace(mon_pipe);
}

// log end of C->S test
=======================================
--- /branches/ndt-web10g/src/test_mid_srv.c Sat Apr 13 19:56:13 2013
+++ /branches/ndt-web10g/src/test_mid_srv.c Wed Jun 19 20:10:20 2013
@@ -238,22 +238,17 @@
// get tcp_stat connection data
#if USE_WEB100
if ((conn = tcp_stat_connection_from_socket(agent, midsfd)) == NULL) {
+#elif USE_WEB10G
+ if ((conn = tcp_stat_connection_from_socket(agent, midsfd)) == -1) {
+#endif
log_println(
0,
- "!!!!!!!!!!! test_mid() failed to get web100 connection data, rc=%d",
+ "!!!!!!!!!!! test_mid() failed to get "TCP_STAT_NAME
+ " connection data, rc=%d",
errno);
/* exit(-1); */
return -3;
}
-#elif USE_TCPE
- if ((conn = tcp_stat_connection_from_socket(agent, midsfd)) == -1) {
- log_println(
- 0,
- "test_mid() failed to get web10g connection data, rc=%d",
- errno);
- return -3;
- }
-#endif

// Perform S->C throughput test. Obtained results in "buff"
tcp_stat_middlebox(midsfd, agent, conn, buff, sizeof(buff));
=======================================
--- /branches/ndt-web10g/src/test_results_clt.c Thu Apr 11 07:52:06 2013
+++ /branches/ndt-web10g/src/test_results_clt.c Wed Jun 19 20:10:20 2013
@@ -302,7 +302,7 @@
*/
void print_SAck_RFC2018(int SACKEnabled) {
printf("RFC 2018 Selective Acknowledgment: ");
-#if USE_TCPE
+/* #if USE_WEB10G
if (SACKEnabled == 1)
printf("ON\n");
else if (SACKEnabled == 2)
@@ -311,12 +311,13 @@
printf("OFF (peer)\n");
else
printf("<undefined (%d)>\n", SACKEnabled);
-#elif USE_WEB100
+#elif USE_WEB100 */
+/* TODO Add this back end by from 'SACK's values, 'SACKEnabled' is
+ * converted to Web100 0=off else on */
if (SACKEnabled == 0)
printf("OFF\n");
else
printf("ON\n");
-#endif
}

/**
@@ -326,19 +327,20 @@

void print_Nagle_RFC896(int is_nagleenabled) {
printf("RFC 896 Nagle Algorithm: ");
-#if USE_TCPE
+/*#if USE_WEB10G
if (is_nagleenabled == 1)
printf("ON\n");
else if (is_nagleenabled == 2)
printf("OFF\n");
else
printf("<undefined (%d)>\n", is_nagleenabled);
-#elif USE_WEB100
+#elif USE_WEB100 */
+/* TODO Add this back end by from 'Nagle's values, 'NagleEnabled' is
+ * converted to Web100 0=off else on */
if (is_nagleenabled == 0)
printf("OFF\n");
else
printf("ON\n");
-#endif
}

/**
@@ -349,7 +351,7 @@
*/
void print_congestion_RFC3168(int is_ECNenabled) {
printf("RFC 3168 Explicit Congestion Notification: ");
-#if USE_TCPE
+/*#if USE_WEB10G
if (is_ECNenabled == 1)
printf("ON\n");
else if (is_ECNenabled == 2)
@@ -358,12 +360,13 @@
printf("OFF (peer)\n");
else
printf("<undefined (%d)>\n", is_ECNenabled);
-#elif USE_WEB100
+#elif USE_WEB100 */
+/* TODO Add this back end by from 'ECN's values, 'ECNEnabled' is
+ * converted to Web100 0=off else on */
if (is_ECNenabled == 0)
printf("OFF\n");
else
printf("ON\n");
-#endif
}

/**
@@ -374,7 +377,7 @@
*/
void print_timestamping_RFC1323(int is_timestampenabled) {
printf("RFC 1323 Time Stamping: ");
-#if USE_TCPE
+/*#if USE_WEB10G
if (is_timestampenabled == 1)
printf("ON\n");
else if (is_timestampenabled == 2)
@@ -383,12 +386,13 @@
printf("OFF (peer)\n");
else
printf("<undefined (%d)>\n", is_timestampenabled);
-#elif USE_WEB100
+#elif USE_WEB100 */
+/* TODO Add this back end by from 'TimeStamping's values,
+ * 'TimestampingEnabled' is converted to Web100 0=off else on */
if (is_timestampenabled == 0)
printf("OFF\n");
else
printf("ON\n");
-#endif
}

/**
=======================================
--- /branches/ndt-web10g/src/test_s2c_srv.c Thu Apr 11 07:52:06 2013
+++ /branches/ndt-web10g/src/test_s2c_srv.c Wed Jun 19 20:10:20 2013
@@ -25,8 +25,6 @@
extern pthread_mutex_t mainmutex;
extern pthread_cond_t maincond;

-// used to store file descriptors of pipes created for ndttrace for S2C tests
-int mon_pipe2[2];

/**
* Perform the S2C Throughput test. This throughput test tests the achievable
@@ -83,12 +81,14 @@
web100_group* tgroup;
web100_group* rgroup;
web100_var* var;
-#elif USE_TCPE
- tcpe_data* snap;
+#elif USE_WEB10G
+ estats_val_data* snap;
#endif
tcp_stat_connection conn;
/* Just a holder for web10g */
tcp_stat_group* group = NULL;
+ /* Pipe that handles returning packet pair timing */
+ int mon_pipe[2];
int ret; // ctrl protocol read/write return status
int j, k, n;
int xmitsfd; // transmit (i.e server) socket fd
@@ -298,7 +298,7 @@
clilen, device, &pair, "s2c", options->compress,
meta.s2c_ndttrace);
*/
- pipe(mon_pipe2);
+ pipe(mon_pipe);
if ((s2c_childpid = fork()) == 0) {
/* close(ctlsockfd); */
close(testOptions->s2csockfd);
@@ -306,19 +306,22 @@
log_println(
5,
"S2C test Child thinks pipe() returned fd0=%d, fd1=%d",
- mon_pipe2[0], mon_pipe2[1]);
+ mon_pipe[0], mon_pipe[1]);
// log_println(2, "S2C test calling init_pkttrace() with pd=0x%x",
// (int) &cli_addr);
init_pkttrace(src_addr, (struct sockaddr *) &cli_addr,
- clilen, mon_pipe2, device, &pair, "s2c",
+ clilen, mon_pipe, device, &pair, "s2c",
options->compress);
log_println(6,
"S2C test ended, why is timer still running?");
+ /* Close the pipe */
+ close(mon_pipe[0]);
+ close(mon_pipe[1]);
exit(0); /* Packet trace finished, terminate gracefully */
}
memset(tmpstr, 0, 256);
for (i = 0; i < 5; i++) { // read nettrace file name into "tmpstr"
- ret = read(mon_pipe2[0], tmpstr, 128);
+ ret = read(mon_pipe[0], tmpstr, 128);
// socket interrupted, try reading again
if ((ret == -1) && (errno == EINTR))
continue;
@@ -352,8 +355,8 @@
rsnap = web100_snapshot_alloc(rgroup, conn);
tgroup = web100_group_find(agent, "tune");
tsnap = web100_snapshot_alloc(tgroup, conn);
-#elif USE_TCPE
- tcpe_data_new(&snap);
+#elif USE_WEB10G
+ estats_val_data_new(&snap);
#endif

// fill send buffer with random printable data for throughput test
@@ -419,8 +422,8 @@
lastunackedseq = atoi(
web100_value_to_text(web100_get_var_type(var),
tmpstr));
-#elif USE_TCPE
- struct tcpe_val value;
+#elif USE_WEB10G
+ struct estats_val value;
web10g_find_val(snapArgs.snap, "SndNxt", &value);
nextseqtosend = value.uv32;
web10g_find_val(snapArgs.snap, "SndUna", &value);
@@ -485,8 +488,8 @@
#if USE_WEB100
web100_snap(rsnap);
web100_snap(tsnap);
-#elif USE_TCPE
- tcpe_read_vars(snap, conn, agent);
+#elif USE_WEB10G
+ estats_read_vars(snap, conn, agent);
#endif

log_println(1, "sent %d bytes to client in %0.2f seconds",
@@ -507,13 +510,13 @@
testOptions->child2 = s2c_childpid;
kill(s2c_childpid, SIGUSR2);
FD_ZERO(&rfd);
- FD_SET(mon_pipe2[0], &rfd);
+ FD_SET(mon_pipe[0], &rfd);
sel_tv.tv_sec = 1;
sel_tv.tv_usec = 100000;
i = 0;

for (;;) {
- ret = select(mon_pipe2[0] + 1, &rfd, NULL, NULL, &sel_tv);
+ ret = select(mon_pipe[0] + 1, &rfd, NULL, NULL, &sel_tv);
if ((ret == -1) && (errno == EINTR)) {
log_println(
6,
@@ -542,7 +545,7 @@
* RAC 2/8/10
*/
if (ret > 0) {
- if ((ret = read(mon_pipe2[0], spds[*spd_index], 128))
+ if ((ret = read(mon_pipe[0], spds[*spd_index], 128))
< 0)
snprintf(
spds[*spd_index],
@@ -577,9 +580,9 @@
// send tuning-related web100 data collected to client
ret = tcp_stat_get_data(rsnap, xmitsfd, ctlsockfd, agent, count_vars);
web100_snapshot_free(rsnap);
-#elif USE_TCPE
+#elif USE_WEB10G
ret = tcp_stat_get_data(snap, xmitsfd, ctlsockfd, agent, count_vars);
- tcpe_data_free(&snap);
+ estats_val_data_free(&snap);
#endif

// If sending web100 variables above failed, indicate to client
@@ -633,7 +636,7 @@
s2c_childpid);

if (getuid() == 0) {
- stop_packet_trace(mon_pipe2);
+ stop_packet_trace(mon_pipe);
}

// log end of test (generic and protocol logs)
=======================================
--- /branches/ndt-web10g/src/test_sfw_srv.c Thu Apr 11 07:52:06 2013
+++ /branches/ndt-web10g/src/test_sfw_srv.c Wed Jun 19 20:10:20 2013
@@ -135,8 +135,8 @@
web100_var* var;
web100_connection* cn;
web100_group* group;
-#elif USE_TCPE
- struct tcpe_val value;
+#elif USE_WEB10G
+ struct estats_val value;
int cn;
#endif
int maxRTT, maxRTO;
@@ -187,7 +187,7 @@
// 255);
strlcpy(hostname, web100_value_to_text(web100_get_var_type(var), buff),
sizeof(hostname));
-#elif USE_TCPE
+#elif USE_WEB10G
web10g_get_remote_addr(agent, cn, hostname, sizeof(hostname));
#endif

@@ -201,7 +201,7 @@
web100_agent_find_var_and_group(agent, "MaxRTO", &group, &var);
web100_raw_read(var, cn, buff);
maxRTO = atoi(web100_value_to_text(web100_get_var_type(var), buff));
-#elif USE_TCPE
+#elif USE_WEB10G
web10g_get_val(agent, cn, "MaxRTT", &value);
maxRTT = value.uv32;
web10g_get_val(agent, cn, "MaxRTO", &value);
=======================================
--- /branches/ndt-web10g/src/testoptions.c Thu Apr 11 07:52:06 2013
+++ /branches/ndt-web10g/src/testoptions.c Wed Jun 19 20:10:20 2013
@@ -51,15 +51,15 @@
web100_group* group;
web100_var* var;
char tmpstr[256];
-#elif USE_TCPE
- struct tcpe_val value;
+#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_TCPE
+#elif USE_WEB10G
web10g_find_val(snap, "CurCwnd", &value);
CurCwnd = value.uv32;
#endif
@@ -154,13 +154,13 @@
if (writeSnap) {
web100_log_write(snapArgs->log, snapArgs->snap);
}
-#elif USE_TCPE
- tcpe_read_vars(snapArgs->snap, snapArgs->conn, agent);
+#elif USE_WEB10G
+ estats_read_vars(snapArgs->snap, snapArgs->conn, agent);
if (peaks) {
findCwndPeaks(agent, peaks, snapArgs->snap);
}
if (writeSnap) {
- // TODO: logging
+ estats_record_write_data(snapArgs->log, snapArgs->snap);
}
#endif
pthread_mutex_unlock(&mainmutex);
@@ -294,9 +294,9 @@
#if USE_WEB100
group = web100_group_find(agentarg, "read");
snaparg->snap = web100_snapshot_alloc(group, conn);
-#elif USE_TCPE
+#elif USE_WEB10G
snaparg->conn = conn;
- tcpe_data_new(&snaparg->snap);
+ estats_val_data_new(&snaparg->snap);
#endif

if (snaplogenabled) {
@@ -308,6 +308,8 @@

#if USE_WEB100
snaparg->log = web100_log_open_write(metafilename, conn, group);
+#elif USE_WEB10G
+ estats_record_open(&snaparg->log, metafilename, "w");
#endif
if (fplocal == NULL) {
log_println(
@@ -335,9 +337,11 @@
if (snaplogenabled) {
web100_log_write(snaparg->log, snaparg->snap);
}
-#elif USE_TCPE
- tcpe_read_vars(snaparg->snap, conn, agentarg);
- // TODO: logging
+#elif USE_WEB10G
+ estats_read_vars(snaparg->snap, conn, agentarg);
+ if (snaplogenabled) {
+ estats_record_write_data(snaparg->log, snaparg->snap);
+ }
#endif
pthread_cond_wait(&maincond, &mainmutex);
pthread_mutex_unlock(&mainmutex);
@@ -362,10 +366,12 @@
if (snaplogenabled) {
web100_log_close_write(snapArgs_ptr->log);
}
-
web100_snapshot_free(snapArgs_ptr->snap);
-#elif USE_TCPE
- tcpe_data_free(&snapArgs_ptr->snap);
+#elif USE_WEB10G
+ if (snaplogenabled) {
+ estats_record_close(&snapArgs_ptr->log);
+ }
+ estats_val_data_free(&snapArgs_ptr->snap);
#endif
}

@@ -456,8 +462,8 @@
tcp_stat_agent* agentarg, Options* optionsarg) {
#if USE_WEB100
web100_var *LimRwin, *yar;
-#elif USE_TCPE
- struct tcpe_val yar;
+#elif USE_WEB10G
+ struct estats_val yar;
#endif

u_int32_t limrwin_val;
@@ -485,7 +491,7 @@
log_print(1, "now write %d to limit the Receive window",
limrwin_val);
web100_raw_write(LimRwin, connarg, &limrwin_val);
-#elif USE_TCPE
+#elif USE_WEB10G
if (connarg != -1) {
log_println(1,
"Got web10g connection for recvsfd socket\n");
@@ -494,7 +500,7 @@
yar.uv32, optionsarg->limit);
limrwin_val = optionsarg->limit * yar.uv32;
log_print(1, "now write %d to limit the Receive window", limrwin_val);
- tcpe_write_var("LimRwin", limrwin_val, connarg, agentarg);
+ estats_write_var("LimRwin", limrwin_val, connarg, agentarg);
#endif
log_println(1, " --- Done");
}
=======================================
--- /branches/ndt-web10g/src/testoptions.h Thu Apr 11 07:52:06 2013
+++ /branches/ndt-web10g/src/testoptions.h Wed Jun 19 20:10:20 2013
@@ -46,7 +46,7 @@

// Snap log characteristics
typedef struct snapArgs {
- tcp_stat_connection* conn;
+ tcp_stat_connection conn;
tcp_stat_snap* snap;
tcp_stat_log* log;
int delay; // periodicity, in ms, of collecting snap
=======================================
--- /branches/ndt-web10g/src/utils.c Wed Mar 20 08:05:33 2013
+++ /branches/ndt-web10g/src/utils.c Wed Jun 19 20:10:20 2013
@@ -197,3 +197,69 @@
// strlen(output_buf), output_buf);
return j - 1;
}
+
+/**
+ * Converts a IPv4-mapped IPv6 sockaddr_in6 to a sockaddr_in4
+ *
+ * @param ss a sockaddr_storage
+ *
+ * @return if the ss represents a IPv6 mapped IPv4 address it will be converted
+ * into a IPv4 sockaddr_in. Otherwise ss will remain unchanged.
+ */
+void ipv4mapped_to_ipv4(struct sockaddr_storage * ss) {
+#ifdef AF_INET6
+ if (ss->ss_family == AF_INET6) {
+ if (IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *) ss)->sin6_addr)) {
+ // Ports already in the right place so just move the actual address
+ ss->ss_family = AF_INET;
+ ((struct sockaddr_in *) ss)->sin_addr.s_addr =
+ ((uint32_t *) &((struct sockaddr_in6 *) ss)->sin6_addr)[3];
+ }
+ }
+#endif
+}
+
+/**
+ * Get a string representation of an ip address.
+ *
+ * NOTE: This will modify addr if its an IPv4 mapped address and return
+ * it as a IPv4 sockaddr.
+ *
+ * @param addr A sockaddr structure which contains the address
+ * @param buf A buffer to fill with the ip address as a string
+ * @param len The length of buf.
+ */
+void addr2a(struct sockaddr_storage * addr, char * buf, int len) {
+ ipv4mapped_to_ipv4(addr);
+
+ if (((struct sockaddr *)addr)->sa_family == AF_INET) {
+ /* IPv4 */
+ inet_ntop(AF_INET, &(((struct sockaddr_in *)addr)->sin_addr),
+ buf, len);
+ }
+#ifdef AF_INET6
+ else if (((struct sockaddr *)addr)->sa_family == AF_INET6) {
+ /* IPv6 */
+ inet_ntop(AF_INET6, &(((struct sockaddr_in6 *)addr)->sin6_addr),
+ buf, len);
+ }
+#endif
+}
+
+/**
+ * Get a string representation of an port number.
+ *
+ * @param addr A sockaddr structure which contains the port number
+ * @param buf A buffer to fill with the port number as a string
+ * @param len The length of buf.
+ */
+void port2a(struct sockaddr_storage* addr, char* buf, int len) {
+ if (((struct sockaddr*)addr)->sa_family == AF_INET) {
+ snprintf(buf, len, "%hu", ntohs(((struct sockaddr_in*)addr)->sin_port));
+ }
+#ifdef AF_INET6
+ else if (((struct sockaddr*)addr)->sa_family == AF_INET6) {
+ snprintf(buf, len, "%hu", ntohs(((struct sockaddr_in6*)addr)->sin6_port));
+ }
+#endif
+}
=======================================
--- /branches/ndt-web10g/src/utils.h Thu Nov 15 13:33:44 2012
+++ /branches/ndt-web10g/src/utils.h Wed Jun 19 20:10:20 2013
@@ -9,6 +9,8 @@
#ifndef SRC_UTILS_H_
#define SRC_UTILS_H_

+#include <arpa/inet.h>
+
int check_int(char* text, int* number);
int check_rint(char* text, int* number, int minVal, int maxVal);
int check_long(char* text, long* number);
@@ -18,6 +20,10 @@
void mysleep(double time);
int trim(char *line, int line_size,
char * output_buf, int output_buf_size);
+/* These are socket/sock_addr related functions */
+void ipv4mapped_to_ipv4(struct sockaddr_storage * ss);
+void addr2a(struct sockaddr_storage * addr, char * buf, int len);
+void port2a(struct sockaddr_storage* addr, char* buf, int len);

// Numbers 1 and 65535 are used in mrange.c for determining "valid" ranges
// While the methods could be used for any "range" comparison,
=======================================
--- /branches/ndt-web10g/src/web100-pcap.c Mon Jun 3 21:18:52 2013
+++ /branches/ndt-web10g/src/web100-pcap.c Wed Jun 19 20:10:20 2013
@@ -30,8 +30,7 @@
static int dumptrace;
static pcap_t *pd;
static pcap_dumper_t *pdump;
-static int mon_pipe1[2], mon_pipe2[2];
-/* int sig1, sig2; */
+static int* mon_pipe;
static int sigj = 0, sigk = 0;
static int ifspeed;

@@ -47,7 +46,7 @@
void init_iflist(void) {
/* pcap_addr_t *ifaceAddr; */
pcap_if_t *alldevs, *dp;
- struct ethtool_cmd ecmd;
+ struct ethtool_cmd ecmd = {0}; /* Keep valgrind happy */
int fd, cnt, i, err;
struct ifreq ifr;
char errbuf[256];
@@ -108,89 +107,49 @@
*
* This calls pcap_breakloop with the correct capture.
*/
-void force_breakloop(){
+void force_breakloop() {
if (pd != NULL) {
pcap_breakloop(pd);
}
}

-/** Check signal flags and process them accordingly.
- * If signal indicates request to terminate data collection for the speed bins,
- * make packet-pair based speed bins available to the parent process.
- *
- * @return 1 if data was successfully written
- * 0 if no relevant signals were actually received
+/**
+ * Send the packet-pair speed bins over pipe to parent.
*/
-static int check_signal_flags() {
- if ((sig1 == 1) || (sig2 == 1)) {
- log_println(
- 5,
- "Received SIGUSRx signal terminating data collection loop for pid=%d",
- getpid());
- if (sig1 == 1) {
- log_println(4,
- "Sending pkt-pair data back to parent on pipe %d, %d",
- mon_pipe1[0], mon_pipe1[1]);
- if (get_debuglvl() > 3) {
- if (fwd.family == 4) {
- fprintf(stderr, "fwd.saddr = %x:%d, rev.saddr = %x:%d\n",
- fwd.saddr[0], fwd.sport, rev.saddr[0], rev.sport);
- } else if (fwd.family == 6) {
- char str[136];
- memset(str, 0, 136);
- inet_ntop(AF_INET6, (void *) fwd.saddr, str, sizeof(str));
- fprintf(stderr, "fwd.saddr = %s:%d", str, fwd.sport);
- memset(str, 0, 136);
- inet_ntop(AF_INET6, (void *) rev.saddr, str, sizeof(str));
- fprintf(stderr, ", rev.saddr = %s:%d\n", str, rev.sport);
- } else {
- fprintf(stderr, "check_signal_flags: Unknown IP family (%d)\n",
- fwd.family);
- }
- }
- print_bins(&fwd, mon_pipe1);
- usleep(30000); /* wait here 30 msec, for parent to read this data */
- print_bins(&rev, mon_pipe1);
- usleep(30000); /* wait here 30 msec, for parent to read this data */
- if (dumptrace == 1)
- pcap_dump_close(pdump);
- sig1 = 2;
+static void send_bins() {
+ log_println(
+ 5,
+ "Received SIGUSRx signal terminating data collection loop for pid=%d",
+ getpid());
+ log_println(4,
+ "Sending pkt-pair data back to parent on pipe %d, %d",
+ mon_pipe[0], mon_pipe[1]);
+ if (get_debuglvl() > 3) {
+ if (fwd.family == 4) {
+ fprintf(stderr, "fwd.saddr = %x:%d, rev.saddr = %x:%d\n",
+ fwd.saddr[0], fwd.sport, rev.saddr[0], rev.sport);
+ } else if (fwd.family == 6) {
+ char str[136];
+ memset(str, 0, 136);
+ inet_ntop(AF_INET6, (void *) fwd.saddr, str, sizeof(str));
+ fprintf(stderr, "fwd.saddr = %s:%d", str, fwd.sport);
+ memset(str, 0, 136);
+ inet_ntop(AF_INET6, (void *) rev.saddr, str, sizeof(str));
+ fprintf(stderr, ", rev.saddr = %s:%d\n", str, rev.sport);
+ } else {
+ fprintf(stderr, "check_signal_flags: Unknown IP family (%d)\n",
+ fwd.family);
}
-
- if (sig2 == 1) {
- log_println(4,
- "Sending pkt-pair data back to parent on pipe %d, %d",
- mon_pipe2[0], mon_pipe2[1]);
- if (get_debuglvl() > 3) {
- if (fwd.family == 4) {
- fprintf(stderr, "fwd.saddr = %x:%d, rev.saddr = %x:%d\n",
- fwd.saddr[0], fwd.sport, rev.saddr[0], rev.sport);
- } else if (fwd.family == 6) {
- char str[136];
- memset(str, 0, 136);
- inet_ntop(AF_INET6, (void *) fwd.saddr, str, sizeof(str));
- fprintf(stderr, "fwd.saddr = %s:%d", str, fwd.sport);
- memset(str, 0, 136);
- inet_ntop(AF_INET6, (void *) rev.saddr, str, sizeof(str));
- fprintf(stderr, ", rev.saddr = %s:%d\n", str, rev.sport);
- } else {
- fprintf(stderr, "check_signal_flags: Unknown IP family (%d)\n",
- fwd.family);
- }
- }
- print_bins(&fwd, mon_pipe2);
- usleep(30000); /* wait here 30 msec, for parent to read this data */
- print_bins(&rev, mon_pipe2);
- usleep(30000); /* wait here 30 msec, for parent to read this data */
- if (dumptrace == 1)
- pcap_dump_close(pdump);
- sig2 = 2;
- }
- log_println(6, "Finished reading pkt-pair data from network, process %d "
- "should terminate now", getpid());
- return 1;
}
- return 0;
+ print_bins(&fwd, mon_pipe);
+ usleep(30000); /* wait here 30 msec, for parent to read this data */
+ print_bins(&rev, mon_pipe);
+ usleep(30000); /* wait here 30 msec, for parent to read this data */
+ if (dumptrace == 1)
+ pcap_dump_close(pdump);
+
+ log_println(6, "Finished reading pkt-pair data from network, process %d "
+ "should terminate now", getpid());
}

/**
@@ -264,8 +223,7 @@
log_print(3, "%u.%u.%u.%u:%d ", (cur->daddr[0] & 0xFF),
((cur->daddr[0] >> 8) & 0xff), ((cur->daddr[0] >> 16) & 0xff),
(cur->daddr[0] >> 24), cur->dport);
- }
- else {
+ } else {
char name[200];
socklen_t len;
memset(name, 0, 200);
@@ -743,14 +701,13 @@

void init_pkttrace(I2Addr srcAddr, struct sockaddr *sock_addr,
socklen_t saddrlen, int monitor_pipe[2], char *device,
- PortPair* pair, char *direction, int compress) {
+ PortPair* pair, const char *direction, int compress) {
char cmdbuf[256], dir[256];
pcap_handler printer;
u_char * pcap_userdata = (u_char*) pair;
struct bpf_program fcode;
char errbuf[PCAP_ERRBUF_SIZE];
int cnt, pflag = 0, i;
- char c;
char namebuf[200], isoTime[64];
size_t nameBufLen = 199;
I2Addr sockAddr = NULL;
@@ -762,9 +719,10 @@
char logdir[256];

cnt = -1; /* read forever, or until end of file */
- sig1 = 0;
- sig2 = 0;

+ /* Store the monitor pipe as a static global for this file
+ * so we can stop the trace later */
+ mon_pipe = monitor_pipe;
init_vars(&fwd);
init_vars(&rev);

@@ -778,11 +736,16 @@
sockAddr = I2AddrBySAddr(get_errhandle(), sock_addr, saddrlen, 0, 0);
sock_addr = I2AddrSAddr(sockAddr, 0);
src_addr = I2AddrSAddr(srcAddr, 0);
-
+#if 0
/* special check for localhost, set device accordingly */
if (I2SockAddrIsLoopback(sock_addr, saddrlen) > 0)
// hardcoding device address to 100, as initialised in main()
- strlcpy(device, "lo", 100);
+ // hardcoding to 100???? Not sure what this means don't copy into
+ // NULL possible pointer
+ device = "lo";
+ // strlcpy(device, "lo", 100);
+#endif
+ /* XXX Even if device is != NULL we still need to do address copying part */
if (device == NULL) {
if (pcap_findalldevs(&alldevs, errbuf) == 0) {
for (dp = alldevs; dp != NULL; dp = dp->next) {
@@ -930,7 +893,7 @@

log_println(2, "pcap_open_live() returned pointer %p", pd);

- switch(sock_addr->sa_family) {
+ switch (sock_addr->sa_family) {
case AF_INET:
inet_ntop(AF_INET, &(((struct sockaddr_in *)sock_addr)->sin_addr),
namebuf, nameBufLen);
@@ -1005,9 +968,7 @@
}

/* Send back results to our parent */
- if(check_signal_flags() == 0){
- log_println(5, "Whatever happened, we should have a sig flag set");
- }
+ send_bins();

pcap_close(pd);

@@ -1028,20 +989,6 @@
*/
free(sockAddr);

- if (sig1 == 2) {
- while ((read(mon_pipe1[0], &c, 1)) < 0) { }
- close(mon_pipe1[0]);
- close(mon_pipe1[1]);
- sig1 = 0;
- }
- if (sig2 == 2) {
- while ((read(mon_pipe2[0], &c, 1)) < 0) { }
- sleep(2);
- close(mon_pipe2[0]);
- close(mon_pipe2[1]);
- sig2 = 0;
- }
-
log_println(
8,
"Finally Finished reading data from network, process %d should "
=======================================
--- /branches/ndt-web10g/src/web100-util.c Thu Apr 11 07:52:06 2013
+++ /branches/ndt-web10g/src/web100-util.c Wed Jun 19 20:10:20 2013
@@ -23,7 +23,7 @@
};

/* Must match in-order with tcp_vars in web100srv.h struct */
-// TODO: more robust order matching with included file and preprocessor macros
+// TODO: is there better way to do this?? preprocessor macros or something
static struct tcp_name tcp_names[] = {
/* {"WEB100", "WEB10G" } / tcp_vars name / */
{"Timeouts", "Timeouts"}, /* Timeouts */
@@ -32,27 +32,51 @@
{"PktsRetrans", "SegsRetrans"}, /* PktsRetrans */
{"FastRetran", "FastRetran"}, /* FastRetran */
{"DataPktsOut", "DataSegsOut"}, /* DataPktsOut */
- {"AckPktsOut", NULL}, /* AckPktsOut - not included in web10g */
+ {"AckPktsOut", "AckSegsOut"}, /* AckSegsOut (like AckSegsIn) =
+ SegsOut - DataSegsOut */
{"CurMSS", "CurMSS"}, /* CurrentMSS */
{"DupAcksIn", "DupAcksIn"}, /* DupAcksIn */
/* NOTE: in the server to client throughput test all packets received from client are ack's
- * So SegsIn == AckPktsIn. I don't see a replacement in web10g maybe (SegsIn - DataSegsIn)
+ * So SegsIn == AckPktsIn. Replacement in web10g is AckPktsIn == (SegsIn - DataSegsIn)
+ *
+ * So web100 kernel code looked like this
+ *
+ vars->PktsIn++;
+ if (skb->len == th->doff*4) {
+ vars->AckPktsIn++;
+ if (TCP_SKB_CB(skb)->ack_seq == tp->snd_una)
+ vars->DupAcksIn++;
+ } else {
+ vars->DataPktsIn++;
+ vars->DataBytesIn += skb->len - th->doff*4;
+ }
+ * Web10G kernel code looks like this
+ *
+ vars->SegsIn++;
+ if (skb->len == th->doff * 4) {
+ if (TCP_SKB_CB(skb)->ack_seq == tp->snd_una)
+ vars->DupAcksIn++;
+ } else {
+ vars->DataSegsIn++;
+ vars->DataOctetsIn += skb->len - th->doff * 4;
+ }
*/
- {"AckPktsIn", "SegsIn"}, /* AckPktsIn - not included in web10g */
+ {"AckPktsIn", "AckSegsIn"}, /* AckPktsIn - not included in web10g */
{"MaxRwinRcvd", "MaxRwinRcvd"}, /* MaxRwinRcvd */
{"X_Sndbuf", NULL}, /* Sndbuf - Not in Web10g pull from socket */
{"CurCwnd", "CurCwnd"}, /* CurrentCwnd */
{"SndLimTimeRwin", "SndLimTimeRwin"}, /* SndLimTimeRwin */
{"SndLimTimeCwnd", "SndLimTimeCwnd"}, /* SndLimTimeCwnd */
{"SndLimTimeSender", "SndLimTimeSnd"}, /* SndLimTimeSender */
- {"DataBytesOut", "DataOctetsOut"}, /* DataBytesOut */
+ {"DataBytesOut", "HCDataOctetsOut"}, /* DataBytesOut HC for 10Gig */
{"SndLimTransRwin", "SndLimTransRwin"}, /* SndLimTransRwin */
{"SndLimTransCwnd", "SndLimTransCwnd"}, /* SndLimTransCwnd */
{"SndLimTransSender", "SndLimTransSnd"}, /* SndLimTransSender */
{"MaxSsthresh", "MaxSsthresh"}, /* MaxSsthresh */
{"CurRTO", "CurRTO"}, /* CurrentRTO */
{"CurRwinRcvd", "CurRwinRcvd"}, /* CurrentRwinRcvd */
- {"MaxCwnd", NULL}, /* MaxCwnd split into MaxSsCwnd and MaxCaCwnd web10g */
+ {"MaxCwnd", "MaxCwnd"}, /* MaxCwnd not in web10g but is
+ MAX(MaxSsCwnd, MaxCaCwnd) special case in web10g_find_val */
{"CongestionSignals", "CongSignals"}, /* CongestionSignals */
{"PktsOut", "SegsOut"}, /* PktsOut */
{"MinRTT", "MinRTT"}, /* MinRTT */
@@ -68,8 +92,6 @@
{"SlowStart", "SlowStart"}, /* SlowStart */
{"SubsequentTimeouts", "SubsequentTimeouts"}, /* SubsequentTimeouts */
{"ThruBytesAcked", "ThruOctetsAcked"}, /* ThruBytesAcked */
- { NULL, "MaxSsCwnd" }, /* MaxSsCwnd */
- { NULL, "MaxCaCwnd" } /* MaxCaCwnd */
};

/**
@@ -110,46 +132,10 @@
log_println(1, "web100_init() read %d variables from file", count_vars);

return (count_vars);
-#elif USE_TCPE
+#elif USE_WEB10G
return TOTAL_INDEX_MAX;
#endif
}
-
-/**
- * Get a string representation of an ip address.
- *
- * @param addr A sockaddr structure which contains the address
- * @param buf A buffer to fill with the ip address as a string
- * @param len The length of buf.
- */
-static void addr2a(struct sockaddr_storage* addr, char * buf, int len) {
- if (((struct sockaddr*)addr)->sa_family == AF_INET) {
- inet_ntop(AF_INET, &(((struct sockaddr_in*)addr)->sin_addr), buf, len);
- }
-#ifdef AF_INET6
- else if (((struct sockaddr*)addr)->sa_family == AF_INET6) {
- inet_ntop(AF_INET6, &(((struct sockaddr_in6*)addr)->sin6_addr), buf, len);
- }
-#endif
-}
-
-/**
- * Get a string representation of an port number.
- *
- * @param addr A sockaddr structure which contains the port number
- * @param buf A buffer to fill with the port number as a string
- * @param len The length of buf.
- */
-static void port2a(struct sockaddr_storage* addr, char* buf, int len) {
- if (((struct sockaddr*)addr)->sa_family == AF_INET) {
- snprintf(buf, len, "%hu", ntohs(((struct sockaddr_in*)addr)->sin_port));
- }
-#ifdef AF_INET6
- else if (((struct sockaddr*)addr)->sa_family == AF_INET6) {
- snprintf(buf, len, "%hu", ntohs(((struct sockaddr_in6*)addr)->sin6_port));
- }
-#endif
-}

/**
* Performs part of the middlebox test.
@@ -176,9 +162,9 @@
web100_group* group;
web100_snapshot* snap;
web100_var* LimCwnd;
-#elif USE_TCPE
- struct tcpe_val value;
- tcpe_data* data = NULL;
+#elif USE_WEB10G
+ struct estats_val value;
+ estats_val_data* data = NULL;
#endif

char buff[8192], line[256];
@@ -195,7 +181,7 @@
socklen_t saddr_size;

// middlebox test results
- static char vars[][255] = { "CurMSS", "WinScaleSent", "WinScaleRecv", };
+ static char vars[][255] = { "CurMSS", "WinScaleSent", "WinScaleRcvd", };

assert(results);

@@ -264,12 +250,18 @@
currentMSSval = atoi(
web100_value_to_text(web100_get_var_type(var), buff));
snprintf(line, sizeof(line), "%s;",
- web100_value_to_text(web100_get_var_type(var), buff));
-#elif USE_TCPE
- web10g_get_val(agent, cn, vars[i], &value);
- if (strcmp(vars[i], "CurMSS") == 0)
- currentMSSval = value.uv32;
- snprintf(line, sizeof(line), "%u;", value.uv32);
+ web100_value_to_text(web100_get_var_type(var), buff));
+#elif USE_WEB10G
+ int type;
+ type = web10g_get_val(agent, cn, vars[i], &value);
+ if (type == -1) {
+ log_println(0, "Middlebox: Failed to read the value of %s", vars[i]);
+ return;
+ } else {
+ if (strcmp(vars[i], "CurMSS") == 0)
+ currentMSSval = value.uv32;
+ snprintf(line, sizeof(line), "%u;", value.uv32);
+ }
#endif

if (strcmp(line, "4294967295;") == 0)
@@ -298,8 +290,8 @@

// set TCP CWND web100 variable to twice the current MSS Value
web100_raw_write(LimCwnd, cn, &limcwnd_val);
-#elif USE_TCPE
- tcpe_write_var("LimCwnd", (uint32_t)limcwnd_val, cn, agent);
+#elif USE_WEB10G
+ estats_write_var("LimCwnd", (uint32_t)limcwnd_val, cn, agent);
#endif

log_println(5, "Setting Cwnd Limit to %d octets", limcwnd_val);
@@ -329,8 +321,8 @@
// get web100 group with name "read"
group = web100_group_find(agent, "read");
snap = web100_snapshot_alloc(group, cn);
-#elif USE_TCPE
- tcpe_data_new(&data);
+#elif USE_WEB10G
+ estats_val_data_new(&data);
#endif

FD_ZERO(&wfd);
@@ -352,8 +344,8 @@
web100_agent_find_var_and_group(agent, "SndUna", &group, &var);
web100_snap_read(var, snap, line);
SndUna = atoi(web100_value_to_text(web100_get_var_type(var), line));
-#elif USE_TCPE
- tcpe_read_vars(data, cn, agent);
+#elif USE_WEB10G
+ estats_read_vars(data, cn, agent);
web10g_find_val(data, "SndNxt", &value);
SndMax = value.uv32;
web10g_find_val(data, "SndUna", &value);
@@ -379,8 +371,9 @@
log_println(5, "Finished with web100_middlebox() routine snap-0x%x, "
"sndbuff=%x0x", snap, sndbuff);
web100_snapshot_free(snap);
-#elif USE_TCPE
- tcpe_data_free(&data);
+#elif USE_WEB10G
+
+ estats_val_data_free(&data);
log_println(5, "Finished with web10g_middlebox() routine, "
"sndbuff=%x0x", sndbuff);
#endif
@@ -388,11 +381,11 @@
}

/**
- * Get receiver side Web100 stats and write them to the log file
+ * Get receiver side Web100/Web10G stats and writes them to the log file
*
* @param sock integer socket file descriptor
* @param agent pointer to a tcp_stat_agent
- * @param cn pointer to a tcp_stat_connection
+ * @param cn A tcp_stat_connection
* @param count_vars integer number of tcp_stat_vars to get value of
*
*/
@@ -401,8 +394,9 @@
#if USE_WEB100
web100_var* var = NULL;
web100_group* group = NULL;
-#elif USE_TCPE
- tcpe_data* data = NULL;
+#elif USE_WEB10G
+ estats_val_data* data = NULL;
+ estats_error* err = NULL;
#endif
int i;
char buf[32], line[256], *ctime();
@@ -423,7 +417,7 @@
web100_raw_read(var, cn, buf);
snprintf(line, sizeof(line), "%s;",
web100_value_to_text(web100_get_var_type(var), buf));
-#elif USE_TCPE
+#elif USE_WEB10G
web10g_get_remote_addr(agent, cn, buf, sizeof(buf));
snprintf(line, sizeof(line), "%s;", buf);
#endif
@@ -465,47 +459,27 @@
}
ok = 1;
}
-#elif USE_TCPE
- tcpe_data_new(&data);
- tcpe_read_vars(data, cn, agent);
+#elif USE_WEB10G
+ estats_val_data_new(&data);
+ estats_read_vars(data, cn, agent);

// Loop through all the web10g variables and write to file/log_print them
- for (i = 0; i < ARRAYSIZE(data->val); i++) {
- if (data->val[i].mask) continue;
+ for (i = 0; i < data->length; i++) {
+ if (data->val[i].masked) continue;
+ char * str = NULL;

- switch (tcpe_var_array[i].type) {
- case TCPE_UNSIGNED64:
- if (fp)
- fprintf(fp, "%" PRIu64 ";", data->val[i].uv64);
- log_println(9, "%s: %" PRIu64,
- tcpe_var_array[i].name, data->val[i].uv64);
- break;
- case TCPE_UNSIGNED32:
- if (fp)
- fprintf(fp, "%u;", data->val[i].uv32);
- log_println(9, "%s: %u", tcpe_var_array[i].name, data->val[i].uv32);
- break;
- case TCPE_SIGNED32:
- if (fp)
- fprintf(fp, "%d;", data->val[i].sv32);
- log_println(9, "%s: %d", tcpe_var_array[i].name, data->val[i].sv32);
- break;
- case TCPE_UNSIGNED16:
- if (fp)
- fprintf(fp, "%" PRIu16 ";", data->val[i].uv16);
- log_println(9, "%s: %" PRIu16,
- tcpe_var_array[i].name, data->val[i].uv16);
- break;
- case TCPE_UNSIGNED8:
- if (fp)
- fprintf(fp, "%" PRIu8 ";", data->val[i].uv8);
- log_println(9, "%s: %" PRIu8, tcpe_var_array[i].name, data->val[i].uv8);
- break;
- default:
- break;
+ if ((err = estats_val_as_string(&str, &data->val[i], estats_var_array[i].valtype)) != NULL) {
+ log_println(0, "Error: tcp_stat_get_data_recv - estats_val_as_string");
+ estats_error_print(stderr, err);
+ estats_error_free(&err);
+ continue;
}
+ if (fp)
+ fprintf(fp, "%s;", str);
+ log_println(9, "%s: %s", estats_var_array[i].name, estats_read_vars);
}
- tcpe_data_free(&data);
+
+ estats_val_data_free(&data);
#endif

// close file pointers after web100 variables have been fetched
@@ -515,13 +489,66 @@
}
}

-#if USE_TCPE
-// Persistent storage needed.
-static tcpe_data* dataDumpSave;
-static int X_SndBuf;
-static int X_RcvBuf;
+#if USE_WEB10G
+/* Persistent storage needed. These are filled by tcp_stat_get_data
+ * and later read by tcp_stat_logvars and free()'d */
+static estats_val_data* dataDumpSave = NULL;
+static int X_SndBuf = -1;
+static int X_RcvBuf = -1;
#endif

+
+
+#if USE_WEB10G
+
+/**
+ * Print a web10g variable to a line using the new name and then write
+ * this line to the test socket. Used by tcp_stat_get_data().
+ * i.e.
+ * <org_name>: <value>
+ *
+ * @param old_name The name within web10g, or an additional name
+ * supported by web10g_find_var
+ * @param new_name The name to print this as (i.e. the web100 name)
+ * @param snap A web10g snapshot
+ * @param line A char* to write the line to
+ * @param line_size Size of line in bytes
+ * @param ctlsock The socket to write to
+ *
+ * If this fails nothing is sent on the cltsocket and the error will
+ * be logged.
+ *
+ */
+static void print_10gvar_renamed(const char * old_name,
+ const char * new_name, const tcp_stat_snap* snap, char * line,
+ int line_size, int ctlsock) {
+ int type;
+ struct estats_val val;
+ estats_error* err;
+ char * str;
+
+ type = web10g_find_val(snap, old_name, &val);
+ if (type == -1) {
+ log_println(0, "In print_10gvar_renamed(), web10g_find_val()"
+ " failed to find %s", old_name);
+ } else {
+ if ((err = estats_val_as_string(&str, &val, type)) != NULL) {
+ log_println(0, "In print_10gvar_renamed(), estats_val_as_string()"
+ " failed for %s", old_name);
+ estats_error_print(stderr, err);
+ estats_error_free(&err);
+ } else {
+ snprintf(line, line_size, "%s: %s\n", new_name, str);
+ send_msg(ctlsock, TEST_MSG, line, strlen(line));
+ free(str);
+ str = NULL;
+ }
+ }
+}
+
+#endif
+
+
/**
* Collect Web100 stats from a snapshot and transmit to a receiver.
* The transmission is done using a TES_MSG type message and sent to
@@ -575,6 +602,7 @@
// receiver end
snprintf(web_vars[i].value, sizeof(web_vars[i].value), "%s",
web100_value_to_text(web100_get_var_type(var), buf));
+ /* Why do we atoi after getting as text anyway ?? */
snprintf(line, sizeof(line), "%s: %d\n", web_vars[i].name,
atoi(web_vars[i].value));
send_msg(ctlsock, TEST_MSG, line, strlen(line));
@@ -582,50 +610,48 @@
}
log_println(6, "S2C test - Send web100 data to client pid=%d", getpid());
return (0);
-#elif USE_TCPE
+#elif USE_WEB10G
int j;
- unsigned int m;
- struct tcpe_val val;
+ unsigned int xbuf_size;
+ struct estats_val val;
+ estats_error* err;

- m = sizeof(X_RcvBuf);
- getsockopt(testsock, SOL_SOCKET, SO_RCVBUF, (void *)&X_RcvBuf, &m);
- m = sizeof(X_SndBuf);
- getsockopt(testsock, SOL_SOCKET, SO_SNDBUF, (void *)&X_SndBuf, &m);
+ xbuf_size = sizeof(X_RcvBuf);
+ if (getsockopt(testsock,
+ SOL_SOCKET, SO_RCVBUF, (void *)&X_RcvBuf, &xbuf_size) != 0) {
+ log_println(0, "Error: failed to getsockopt() SO_RCVBUF");
+ }
+ xbuf_size = sizeof(X_SndBuf);
+ if (getsockopt(testsock,
+ SOL_SOCKET, SO_SNDBUF, (void *)&X_SndBuf, &xbuf_size) != 0) {
+ log_println(0, "Error: failed to getsockopt() SO_RCVBUF");
+ }

assert(snap);

- tcpe_data_new(&dataDumpSave);
+ /* Need to save this for later */
+ estats_val_data_new(&dataDumpSave);
+ memcpy(dataDumpSave, snap, sizeof(struct estats_val_data)
+ + (sizeof(struct estats_val) * snap->length));

- for (j = 0; j < ARRAYSIZE(snap->val); j++) {
- dataDumpSave->val[j].mask = snap->val[j].mask;
- dataDumpSave->val[j].uv64 = snap->val[j].uv64;
- if (snap->val[j].mask) continue;
+ for (j = 0; j < snap->length; j++) {
+ char *str;
+ if (snap->val[j].masked) continue;

- switch (tcpe_var_array[j].type) {
- case TCPE_UNSIGNED64:
- snprintf(line, sizeof(line), "%s: %" PRIu64 "\n",
- tcpe_var_array[j].name, snap->val[j].uv64);
- break;
- case TCPE_UNSIGNED32:
- snprintf(line, sizeof(line), "%s: %u\n",
- tcpe_var_array[j].name, snap->val[j].uv32);
- break;
- case TCPE_SIGNED32:
- snprintf(line, sizeof(line), "%s: %d\n",
- tcpe_var_array[j].name, snap->val[j].sv32);
- break;
- case TCPE_UNSIGNED16:
- snprintf(line, sizeof(line), "%s: %" PRIu16 "\n",
- tcpe_var_array[j].name, snap->val[j].uv16);
- case TCPE_UNSIGNED8:
- snprintf(line, sizeof(line), "%s: %" PRIu8 "\n",
- tcpe_var_array[j].name, snap->val[j].uv8);
- break;
- default:
- break;
+ if ((err = estats_val_as_string(&str, &snap->val[j],
+ estats_var_array[j].valtype)) != NULL) {
+ log_println(0, "In tcp_stat_get_data() estats_val_as_string()"
+ " failed for %s", estats_var_array[j].name);
+ estats_error_print(stderr, err);
+ estats_error_free(&err);
+ continue;
}
- send_msg(ctlsock, TEST_MSG, line, strlen(line));
+ snprintf(line, sizeof(line), "%s: %s\n",
+ estats_var_array[j].name, str);
+ send_msg(ctlsock, TEST_MSG, (const void *) line, strlen(line));
log_print(9, "%s", line);
+ free(str);
+ str = NULL;
}

/* This is the list of changed variable names that the client tries to read.
@@ -635,7 +661,8 @@
* SACKEnabled -> WillSendSACK & WillUseSACK
* TimestampsEnabled -> TimeStamps
* PktsRetrans -> SegsRetrans
- * X_Rcvbuf -> Not in web10g doesn't acutally use it so just leave it out
+ * X_Rcvbuf -> Not in web10g not used by client but send anyway
+ * X_Sndbuf -> Not in web10g but could be interesting for the client
* DataPktsOut -> DataSegsOut
* AckPktsOut -> Depreciated
* MaxCwnd -> MaxSsCwnd MaxCaCwnd
@@ -647,97 +674,106 @@
* CongestionSignals -> CongSignals
* RcvWinScale -> Same as WinScaleSent if WinScaleSent != -1
*/
- static const char* msg = "-~~~Web100_old_var_names~~~-: 1\n";
- send_msg(ctlsock, TEST_MSG, msg, strlen(msg));
- uint32_t temp;
+ static const char* frame_web100 = "-~~~Web100_old_var_names~~~-: 1\n";
+ int type;
+ char *str = NULL;
+ send_msg(ctlsock, TEST_MSG, (const void *)frame_web100,
+ strlen(frame_web100));

/* ECNEnabled -> ECN */
- val.uv64 = 0;
- web10g_find_val(snap, "ECN", &val);
- snprintf(line, sizeof(line), "ECNEnabled: %d\n", val.sv32);
- send_msg(ctlsock, TEST_MSG, line, strlen(line));
+ type = web10g_find_val(snap, "ECN", &val);
+ if (type != ESTATS_SIGNED32) {
+ log_println(0, "In tcp_stat_get_data(), web10g_find_val()"
+ " failed to find ECN bad type=%d", type);
+ } else {
+ snprintf(line, sizeof(line), "ECNEnabled: %"PRId32"\n", (val.sv32 == 1) ? 1 : 0);
+ send_msg(ctlsock, TEST_MSG, line, strlen(line));
+ }

/* NagleEnabled -> Nagle */
- val.uv64 = 0;
- web10g_find_val(snap, "Nagle", &val);
- snprintf(line, sizeof(line), "NagleEnabled: %d\n", val.sv32);
- send_msg(ctlsock, TEST_MSG, line, strlen(line));
+ type = web10g_find_val(snap, "Nagle", &val);
+ if (type != ESTATS_SIGNED32) {
+ log_println(0, "In tcp_stat_get_data(), web10g_find_val()"
+ " failed to find Nagle bad type=%d", type);
+ } else {
+ snprintf(line, sizeof(line), "NagleEnabled: %"PRId32"\n", (val.sv32 == 2) ? 1 : 0);
+ send_msg(ctlsock, TEST_MSG, line, strlen(line));
+ }

- /* SACKEnabled -> WillUseSACK & WillSendSACK
- * keep this in line with web100 for now i.e. 0 == off 1 == on */
- val.uv64 = 0;
- web10g_find_val(snap, "WillUseSACK", &val);
- snprintf(line, sizeof(line), "SACKEnabled: %d\n", (val.sv32 == 1) ? 1 : 0);
- send_msg(ctlsock, TEST_MSG, line, strlen(line));
+ /* SACKEnabled -> WillUseSACK & WillSendSACK */
+ type = web10g_find_val(snap, "WillUseSACK", &val);
+ if (type == -1) {
+ log_println(0, "In tcp_stat_get_data(), web10g_find_val()"
+ " failed to find WillUseSACK bad type=%d", type);
+ } else {
+ /* Yes this comes through as 3 from web100 */
+ snprintf(line, sizeof(line), "SACKEnabled: %d\n", (val.sv32 == 1) ? 3 : 0);
+ send_msg(ctlsock, TEST_MSG, line, strlen(line));
+ }

/* TimestampsEnabled -> TimeStamps */
- val.uv64 = 0;
- web10g_find_val(snap, "TimeStamps", &val);
- snprintf(line, sizeof(line), "TimestampsEnabled: %d\n", val.sv32);
- send_msg(ctlsock, TEST_MSG, line, strlen(line));
+ type = web10g_find_val(snap, "TimeStamps", &val);
+ if (type != ESTATS_SIGNED32) {
+ log_println(0, "In tcp_stat_get_data(), web10g_find_val()"
+ " failed to find TimeStamps bad type=%d", type);
+ } else {
+ snprintf(line, sizeof(line), "TimestampsEnabled: %"PRId32"\n", (val.sv32 == 1) ? 1 : 0);
+ send_msg(ctlsock, TEST_MSG, line, strlen(line));
+ }

/* PktsRetrans -> SegsRetrans */
- val.uv64 = 0;
- web10g_find_val(snap, "SegsRetrans", &val);
- snprintf(line, sizeof(line), "PktsRetrans: %u\n", val.uv32);
- send_msg(ctlsock, TEST_MSG, line, strlen(line));
+ print_10gvar_renamed("SegsRetrans", "PktsRetrans", snap, line,
+ sizeof(line), ctlsock);

/* DataPktsOut -> DataSegsOut */
- val.uv64 = 0;
- web10g_find_val(snap, "DataSegsOut", &val);
- snprintf(line, sizeof(line), "DataPktsOut: %u\n", val.uv32);
- send_msg(ctlsock, TEST_MSG, line, strlen(line));
+ print_10gvar_renamed("DataSegsOut", "DataPktsOut", snap, line,
+ sizeof(line), ctlsock);

- /* MaxCwnd -> MaxSsCwnd MaxCaCwnd */
- val.uv64 = 0;
- web10g_find_val(snap, "MaxSsCwnd", &val);
- temp = val.uv32;
- val.uv64 = 0;
- web10g_find_val(snap, "MaxCaCwnd", &val);
- temp = MAX(temp, val.uv32);
- snprintf(line, sizeof(line), "DataPktsOut: %u\n", temp);
- send_msg(ctlsock, TEST_MSG, line, strlen(line));
+ /* MaxCwnd -> MAX(MaxSsCwnd, MaxCaCwnd) */
+ print_10gvar_renamed("MaxCwnd", "MaxCwnd", snap, line,
+ sizeof(line), ctlsock);

/* SndLimTimeSender -> SndLimTimeSnd */
- val.uv64 = 0;
- web10g_find_val(snap, "SndLimTimeSnd", &val);
- snprintf(line, sizeof(line), "SndLimTimeSender: %u\n", val.uv32);
- send_msg(ctlsock, TEST_MSG, line, strlen(line));
+ print_10gvar_renamed("SndLimTimeSnd", "SndLimTimeSender", snap, line,
+ sizeof(line), ctlsock);

/* DataBytesOut -> DataOctetsOut */
- val.uv64 = 0;
- web10g_find_val(snap, "DataOctetsOut", &val);
- snprintf(line, sizeof(line), "DataBytesOut: %u\n", val.uv32);
- send_msg(ctlsock, TEST_MSG, line, strlen(line));
+ print_10gvar_renamed("HCDataOctetsOut", "DataBytesOut", snap, line,
+ sizeof(line), ctlsock);

/* SndLimTransSender -> SndLimTransSnd */
- val.uv64 = 0;
- web10g_find_val(snap, "SndLimTransSnd", &val);
- snprintf(line, sizeof(line), "SndLimTransSender: %u\n", val.uv32);
- send_msg(ctlsock, TEST_MSG, line, strlen(line));
+ print_10gvar_renamed("SndLimTransSnd", "SndLimTransSender", snap, line,
+ sizeof(line), ctlsock);

/* PktsOut -> SegsOut */
- val.uv64 = 0;
- web10g_find_val(snap, "SegsOut", &val);
- snprintf(line, sizeof(line), "PktsOut: %u\n", val.uv32);
- send_msg(ctlsock, TEST_MSG, line, strlen(line));
+ print_10gvar_renamed("SegsOut", "PktsOut", snap, line,
+ sizeof(line), ctlsock);

/* CongestionSignals -> CongSignals */
- val.uv64 = 0;
- web10g_find_val(snap, "CongSignals", &val);
- snprintf(line, sizeof(line), "CongestionSignals: %u\n", val.uv32);
- send_msg(ctlsock, TEST_MSG, line, strlen(line));
+ print_10gvar_renamed("CongSignals", "CongestionSignals", snap, line,
+ sizeof(line), ctlsock);

/* RcvWinScale -> Same as WinScaleSent if WinScaleSent != -1 */
- val.uv64 = 0;
- web10g_find_val(snap, "WinScaleSent", &val);
- if (val.sv32 == -1)
- snprintf(line, sizeof(line), "RcvWinScale: %u\n", 0);
- else
- snprintf(line, sizeof(line), "RcvWinScale: %d\n", val.sv32);
- send_msg(ctlsock, TEST_MSG, line, strlen(line));
+ type = web10g_find_val(snap, "WinScaleSent", &val);
+ if (type == -1) {
+ log_println(0, "In tcp_stat_get_data(), web10g_find_val()"
+ " failed to find WinScaleSent");
+ } else {
+ if (val.sv32 == -1)
+ snprintf(line, sizeof(line), "RcvWinScale: %u\n", 0);
+ else
+ snprintf(line, sizeof(line), "RcvWinScale: %d\n", val.sv32);
+ send_msg(ctlsock, TEST_MSG, (const void *) line, strlen(line));
+ }

- send_msg(ctlsock, TEST_MSG, msg, strlen(msg));
+ /* X_Rcvbuf & X_Sndbuf */
+ snprintf(line, sizeof(line), "X_Rcvbuf: %d\n", X_RcvBuf);
+ send_msg(ctlsock, TEST_MSG, (const void *) line, strlen(line));
+ snprintf(line, sizeof(line), "X_Sndbuf: %d\n", X_SndBuf);
+ send_msg(ctlsock, TEST_MSG, (const void *) line, strlen(line));
+
+ send_msg(ctlsock, TEST_MSG, (const void *)frame_web100,
+ strlen(frame_web100));

log_println(6, "S2C test - Send web100 data to client pid=%d", getpid());
return 0;
@@ -798,7 +834,7 @@
* @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_varibles, integers:
+ * @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
* 0x03 if both " Autotune send buffer" and "Autotune receive buffer" are not enabled.
@@ -850,7 +886,7 @@
if (i == 0)
j |= 0x02;
return (j);
-#elif USE_TCPE
+#elif USE_WEB10G
// Disabled in web10g.
return 0x03;
#endif
@@ -962,7 +998,7 @@

for (b = 0; b < count_vars; b++) {
if (strcmp(web_vars[b].name, web100_name) == 0) {
- tcp_stat_var* var = ((tcp_stat_var*) vars) + a;
+ tcp_stat_var* var = &((tcp_stat_var *)vars)[a];
*var = atoi(web_vars[b].value);
log_println(5, "Found %s : %i", web100_name, *var);
break;
@@ -972,40 +1008,51 @@
log_println(1, "WARNING: Failed to find Web100 var %s", web100_name);
}
}
-#elif USE_TCPE
- int a, b;
+#elif USE_WEB10G
+ int a;
+ estats_val val;
assert(dataDumpSave);
- for (a = 0; a < (sizeof(struct tcp_vars) / sizeof(tcp_stat_var)); ++a) {
+
+ for (a = 0; a < sizeof(struct tcp_vars) / sizeof(tcp_stat_var); ++a) {
const char* web10g_name = tcp_names[a].web10g_name;
+ int vartype;
if (web10g_name == NULL)
continue;

- for (b = 0; b < ARRAYSIZE(dataDumpSave->val); ++b) {
- if (dataDumpSave->val[b].mask)
- continue;
- if (strcmp(tcpe_var_array[b].name, web10g_name) == 0) {
- tcp_stat_var* var = ((tcp_stat_var*) vars) + a;
- *var = dataDumpSave->val[b].uv32;
- log_println(5, "Found %s : %i", web10g_name, *var);
- break;
+ /* Find each item in the list */
+ if ((vartype = web10g_find_val(dataDumpSave, web10g_name, &val)) == -1) {
+ log_println(1, "WARNING: Failed to find Web10g var %s", web10g_name);
+ } else {
+ tcp_stat_var* var = &((tcp_stat_var *)vars)[a];
+ switch (vartype) {
+ case ESTATS_UNSIGNED64:
+ *var = (tcp_stat_var) val.uv64;
+ break;
+ case ESTATS_UNSIGNED32:
+ *var = (tcp_stat_var) val.uv32;
+ break;
+ case ESTATS_SIGNED32:
+ *var = (tcp_stat_var) val.sv32;
+ break;
+ case ESTATS_UNSIGNED16:
+ *var = (tcp_stat_var) val.uv16;
+ break;
+ case ESTATS_UNSIGNED8:
+ *var = (tcp_stat_var) val.uv8;
+ break;
}
- }
- if (b == ARRAYSIZE(dataDumpSave->val)) {
- log_println(1, "WARNING: Failed to find Web10g var %s", web10g_name);
+ log_println(5, "Found %s : %i", web10g_name, *var);
}
}
-
- vars->AckPktsOut = 0;
+ /* Our special case */
vars->Sndbuf = X_SndBuf;
- vars->MaxCwnd = MAX(vars->MaxSsCwnd, vars->MaxCaCwnd);

- tcpe_data_free(&dataDumpSave);
- dataDumpSave = NULL;
+ estats_val_data_free(&dataDumpSave);
#endif
return 0;
}

-#if USE_WEB100
+
/**
* Routine to read snaplog file and determine the number of times the
* congestion window is reduced.
@@ -1019,8 +1066,9 @@
* @return Integer, 0 on success, -1 on failure
*/

-int CwndDecrease(web100_agent* agent, char* logname, u_int32_t *dec_cnt,
+int CwndDecrease(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;
@@ -1028,7 +1076,15 @@
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

+#if USE_WEB100
// open snaplog file to read values
if ((log = web100_log_open_read(logname)) == NULL)
return (0);
@@ -1043,18 +1099,33 @@
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
+
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)
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 (cnt < 20) {
+#if USE_WEB100
log_println(7, "Reading snaplog %p (%d), var = %s", snap, cnt,
(char*) var);
log_println(
@@ -1063,6 +1134,15 @@
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,
+ "Checking for Cwnd decreases. rt=%d, s1=%d, s2=%d, dec-cnt=%d",
+ rt, s1, s2,
+ *dec_cnt);
+#endif
}
if (s2 < s1)
(*dec_cnt)++;
@@ -1071,11 +1151,21 @@
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
}
+#if USE_WEB100
web100_snapshot_free(snap);
web100_log_close_read(log);
+#elif USE_WEB10G
+ estats_record_close(&log);
+#endif
log_println(
2,
"-=-=-=- CWND window report: increases = %d, decreases = %d, "
@@ -1083,7 +1173,6 @@
*inc_cnt, *dec_cnt, *same_cnt);
return (0);
}
-#endif // TODO: Implement in web10g when logging is doable.

#if USE_WEB100
/**
=======================================
--- /branches/ndt-web10g/src/web100clt.c Thu Apr 11 07:52:06 2013
+++ /branches/ndt-web10g/src/web100clt.c Wed Jun 19 20:10:20 2013
@@ -239,28 +239,6 @@
"and switch=Half mismatch condition\n");
}
}
-
-/**
- * Get a string representation of an ip address.
- *
- * @param addr A sockaddr structure which contains the address
- * @param buf A buffer to fill with the ip address as a string
- * @param len The length of buf.
- */
-static void addr2a(struct sockaddr_storage * addr, char * buf, int len) {
- if (((struct sockaddr *)addr)->sa_family == AF_INET) {
- /* IPv4 */
- inet_ntop(AF_INET, &(((struct sockaddr_in *)addr)->sin_addr),
- buf, len);
- }
-#ifdef AF_INET6
- else if (((struct sockaddr *)addr)->sa_family == AF_INET6) {
- /* IPv6 */
- inet_ntop(AF_INET6, &(((struct sockaddr_in6 *)addr)->sin6_addr),
- buf, len);
- }
-#endif
-}

/**
* This routine decodes the middlebox test results. The data is returned
=======================================
--- /branches/ndt-web10g/src/web100srv.c Mon Jun 3 21:18:52 2013
+++ /branches/ndt-web10g/src/web100srv.c Wed Jun 19 20:10:20 2013
@@ -464,7 +464,6 @@
log_println(6,
"DEBUG, caught SIGUSR1, setting sig1 flag and calling force_breakloop");
force_breakloop();
- sig1 = 1;
break;

case SIGUSR2:
@@ -472,7 +471,6 @@
log_println(6,
"DEBUG, caught SIGUSR2, setting sig2 flag and calling force_breakloop");
force_breakloop();
- sig2 = 1;
break;

case SIGALRM:
@@ -625,7 +623,7 @@
#if USE_WEB100
snprintf(wvfn, sizeof(wvfn), "%s", val);
VarFileName = wvfn;
-#elif USE_TCPE
+#elif USE_WEB10G
log_println(0, "Web10G does not require variable file. Ignoring");
#endif
continue;
@@ -895,7 +893,7 @@
char *test_suite) {
#if USE_WEB100
tcp_stat_connection conn = NULL;
-#elif USE_TCPE
+#elif USE_WEB10G
tcp_stat_connection conn = -1;
#endif
char date[32]; // date indicator
@@ -1071,16 +1069,15 @@
// Get web100 vars

// ...determine number of times congestion window has been changed
-#if USE_WEB100
if (options.cwndDecrease) {
dec_cnt = inc_cnt = same_cnt = 0;
- CwndDecrease(agent, options.s2c_logname, &dec_cnt, &same_cnt, &inc_cnt);
+ CwndDecrease(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);
}
-#endif

// ...other variables
+ memset(&vars, 0xFF, sizeof(vars));
tcp_stat_logvars(&vars, count_vars);

// end getting web100 variable values
@@ -1253,7 +1250,7 @@
send_msg(ctlsockfd, MSG_RESULTS, buff, strlen(buff));

snprintf(buff, sizeof(buff),
- "cwin: %0.4f\nrttsec: %0.6f\nSndbuf: %d\naspd: %0.5f\n"
+ "cwin: %0.4f\nrttsec: %0.6f\nSndbuf: %"VARtype"\naspd: %0.5f\n"
"CWND-Limited: %0.2f\n", cwin, rttsec, vars.Sndbuf, aspd, s2c2spd);
send_msg(ctlsockfd, MSG_RESULTS, buff, strlen(buff));

@@ -1276,14 +1273,18 @@
log_println(9, "2. meta.clientip =%s:%s:%d", meta.client_ip, rmt_host);

memset(tmpstr, 0, sizeof(tmpstr));
- snprintf(tmpstr, sizeof(tmpstr), "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,",
+ snprintf(tmpstr, sizeof(tmpstr), "%d,%d,%d,%"VARtype",%"VARtype",%"
+ VARtype",%"VARtype",%"VARtype",%"VARtype",%"VARtype",%"
+ VARtype",%"VARtype",%"VARtype",",
(int) s2c2spd, (int) s2cspd, (int) c2sspd, vars.Timeouts,
vars.SumRTT, vars.CountRTT, vars.PktsRetrans, vars.FastRetran,
vars.DataPktsOut, vars.AckPktsOut, vars.CurrentMSS, vars.DupAcksIn,
vars.AckPktsIn);
memcpy(meta.summary, tmpstr, strlen(tmpstr));
memset(tmpstr, 0, sizeof(tmpstr));
- snprintf(tmpstr, sizeof(tmpstr), "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,",
+ snprintf(tmpstr, sizeof(tmpstr), "%"VARtype",%"VARtype",%"VARtype",%"
+ VARtype",%"VARtype",%"VARtype",%"VARtype",%"VARtype
+ ",%"VARtype",%"VARtype",%"VARtype",%"VARtype",%"VARtype",",
vars.MaxRwinRcvd, vars.Sndbuf, vars.MaxCwnd, vars.SndLimTimeRwin,
vars.SndLimTimeCwnd, vars.SndLimTimeSender, vars.DataBytesOut,
vars.SndLimTransRwin, vars.SndLimTransCwnd, vars.SndLimTransSender,
@@ -1296,14 +1297,17 @@

strlcat(meta.summary, tmpstr, sizeof(meta.summary));
memset(tmpstr, 0, sizeof(tmpstr));
- snprintf(tmpstr, sizeof(tmpstr), ",%d,%d,%d,%d,%d,%d,%d,%d,%d",
+ snprintf(tmpstr, sizeof(tmpstr), ",%d,%d,%d,%d,%"VARtype",%"VARtype
+ ",%"VARtype",%"VARtype",%d",
c2s_linkspeed_data, c2s_linkspeed_ack, s2c_linkspeed_data,
s2c_linkspeed_ack, vars.CongestionSignals, vars.PktsOut, vars.MinRTT,
vars.RcvWinScale, autotune);

strlcat(meta.summary, tmpstr, sizeof(meta.summary));
memset(tmpstr, 0, sizeof(tmpstr));
- snprintf(tmpstr, sizeof(tmpstr), ",%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
+ snprintf(tmpstr, sizeof(tmpstr), ",%"VARtype",%"VARtype",%"VARtype",%"
+ VARtype",%"VARtype",%"VARtype",%"VARtype",%"VARtype",%"
+ VARtype",%"VARtype,
vars.CongAvoid, vars.CongestionOverCount, vars.MaxRTT,
vars.OtherReductions, vars.CurTimeoutCount, vars.AbruptTimeouts,
vars.SendStall, vars.SlowStart, vars.SubsequentTimeouts,
@@ -1326,23 +1330,30 @@
} else {
snprintf(date, sizeof(date), "%15.15s", ctime(&stime) + 4);
fprintf(fp, "%s,", date);
- fprintf(fp, "%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,", rmt_host,
+ fprintf(fp, "%s,%d,%d,%d,%"VARtype",%"VARtype",%"VARtype",%"
+ VARtype",%"VARtype",%"VARtype",%"VARtype",%"VARtype",%"
+ VARtype",%"VARtype",", rmt_host,
(int) s2c2spd, (int) s2cspd, (int) c2sspd, vars.Timeouts,
vars.SumRTT, vars.CountRTT, vars.PktsRetrans, vars.FastRetran,
vars.DataPktsOut, vars.AckPktsOut, vars.CurrentMSS, vars.DupAcksIn,
vars.AckPktsIn);
- fprintf(fp, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,", vars.MaxRwinRcvd,
+ fprintf(fp, "%"VARtype",%"VARtype",%"VARtype",%"VARtype",%"VARtype","
+ "%"VARtype",%"VARtype",%"VARtype",%"VARtype",%"VARtype",%"
+ VARtype",%"VARtype",%"VARtype",", vars.MaxRwinRcvd,
vars.Sndbuf, vars.MaxCwnd, vars.SndLimTimeRwin, vars.SndLimTimeCwnd,
vars.SndLimTimeSender, vars.DataBytesOut, vars.SndLimTransRwin,
vars.SndLimTransCwnd, vars.SndLimTransSender, vars.MaxSsthresh,
vars.CurrentRTO, vars.CurrentRwinRcvd);
fprintf(fp, "%d,%d,%d,%d,%d", link, mismatch, bad_cable, half_duplex,
congestion);
- fprintf(fp, ",%d,%d,%d,%d,%d,%d,%d,%d,%d", c2s_linkspeed_data,
+ fprintf(fp, ",%d,%d,%d,%d,%"VARtype",%"VARtype",%"VARtype",%"VARtype",%d",
+ c2s_linkspeed_data,
c2s_linkspeed_ack, s2c_linkspeed_data, s2c_linkspeed_ack,
vars.CongestionSignals, vars.PktsOut, vars.MinRTT, vars.RcvWinScale,
autotune);
- fprintf(fp, ",%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", vars.CongAvoid,
+ fprintf(fp, ",%"VARtype",%"VARtype",%"VARtype",%"VARtype",%"VARtype
+ ",%"VARtype",%"VARtype",%"VARtype",%"VARtype",%"VARtype,
+ vars.CongAvoid,
vars.CongestionOverCount, vars.MaxRTT, vars.OtherReductions,
vars.CurTimeoutCount, vars.AbruptTimeouts, vars.SendStall,
vars.SlowStart, vars.SubsequentTimeouts, vars.ThruBytesAcked);
@@ -1368,18 +1379,26 @@
if (usesyslog == 1) {
snprintf(
logstr1, sizeof(logstr1),
- "client_IP=%s,c2s_spd=%2.0f,s2c_spd=%2.0f,Timeouts=%d,SumRTT=%d,"
-
"CountRTT=%d,PktsRetrans=%d,FastRetran=%d,DataPktsOut=%d,AckPktsOut=%d,"
- "CurrentMSS=%d,DupAcksIn=%d,AckPktsIn=%d,",
+ "client_IP=%s,c2s_spd=%2.0f,s2c_spd=%2.0f,Timeouts=%"VARtype","
+ "SumRTT=%"VARtype","
+ "CountRTT=%"VARtype",PktsRetrans=%"VARtype","
+ "FastRetran=%"VARtype",DataPktsOut=%"VARtype","
+ "AckPktsOut=%"VARtype","
+ "CurrentMSS=%"VARtype",DupAcksIn=%"VARtype","
+ "AckPktsIn=%"VARtype",",
rmt_host, c2sspd, s2cspd, vars.Timeouts, vars.SumRTT, vars.CountRTT,
vars.PktsRetrans, vars.FastRetran, vars.DataPktsOut, vars.AckPktsOut,
vars.CurrentMSS, vars.DupAcksIn, vars.AckPktsIn);
snprintf(
logstr2, sizeof(logstr2),
- "MaxRwinRcvd=%d,Sndbuf=%d,MaxCwnd=%d,SndLimTimeRwin=%d,"
- "SndLimTimeCwnd=%d,SndLimTimeSender=%d,DataBytesOut=%d,"
- "SndLimTransRwin=%d,SndLimTransCwnd=%d,SndLimTransSender=%d,"
- "MaxSsthresh=%d,CurrentRTO=%d,CurrentRwinRcvd=%d,",
+ "MaxRwinRcvd=%"VARtype",Sndbuf=%"VARtype","
+ "MaxCwnd=%"VARtype",SndLimTimeRwin=%"VARtype","
+ "SndLimTimeCwnd=%"VARtype",SndLimTimeSender=%"VARtype","
+ "DataBytesOut=%"VARtype","
+ "SndLimTransRwin=%"VARtype",SndLimTransCwnd=%"VARtype","
+ "SndLimTransSender=%"VARtype","
+ "MaxSsthresh=%"VARtype",CurrentRTO=%"VARtype","
+ "CurrentRwinRcvd=%"VARtype",",
vars.MaxRwinRcvd, vars.Sndbuf, vars.MaxCwnd, vars.SndLimTimeRwin,
vars.SndLimTimeCwnd, vars.SndLimTimeSender, vars.DataBytesOut,
vars.SndLimTransRwin, vars.SndLimTransCwnd, vars.SndLimTransSender,
@@ -1389,7 +1408,8 @@
logstr2, sizeof(logstr2),
"link=%d,mismatch=%d,bad_cable=%d,half_duplex=%d,congestion=%d,"
"c2s_linkspeed_data=%d,c2sack=%d,s2cdata=%d,s2cack=%d,"
- "CongestionSignals=%d,PktsOut=%d,MinRTT=%d,RcvWinScale=%d\n",
+ "CongestionSignals=%"VARtype",PktsOut=%"VARtype",MinRTT=%"
+ VARtype",RcvWinScale=%"VARtype"\n",
link, mismatch, bad_cable, half_duplex, congestion, c2s_linkspeed_data,
c2s_linkspeed_ack, s2c_linkspeed_data, s2c_linkspeed_ack,
vars.CongestionSignals, vars.PktsOut, vars.MinRTT, vars.RcvWinScale);
@@ -1609,7 +1629,7 @@
case 'f':
#if USE_WEB100
VarFileName = optarg;
-#elif USE_TCPE
+#elif USE_WEB10G
log_println(2, "Web10g doesn't require varfile. Ignored.");
#endif
break;
@@ -1897,8 +1917,6 @@
head_ptr = NULL;
sig13 = 0;
sig17 = 0;
- sig1 = 0;
- sig2 = 0;
sem_init(&ndtq, 0, 1);

for (;;) {
@@ -2588,10 +2606,11 @@
web100_perror("web100_attach");
return 1;
}
-#elif USE_TCPE
- if (tcpe_client_init(&agent) != NULL) {
- log_println(
- 0, "Error: tcpe_client_init failed. Unable to use web10g.");
+#elif USE_WEB10G
+ if (estats_nl_client_init(&agent) != NULL) {
+ log_println(0,
+ "Error: estats_client_init failed."
+ "Unable to use web10g.");
return 1;
}
#endif
@@ -2720,10 +2739,12 @@
close(ctlsockfd);
#if USE_WEB100
web100_detach(agent);
-#elif USE_TCPE
- tcpe_client_destroy(&agent);
+#elif USE_WEB10G
+ estats_nl_client_destroy(&agent);
#endif
- log_free();
+ // log_free(); // Don't free the log we use it all the time
+ // log_println()
+ // Also makes valgrind angry

if (cputime && workerThreadId) {
cputimeworkerLoop = 0;
=======================================
--- /branches/ndt-web10g/src/web100srv.h Mon Jun 3 21:18:52 2013
+++ /branches/ndt-web10g/src/web100srv.h Wed Jun 19 20:10:20 2013
@@ -12,31 +12,31 @@

#include "../config.h"

-#if HAVE_LIBWEB100 && HAVE_LIBTCPE
+#if HAVE_LIBWEB100 && HAVE_LIBWEB10G

-// Prefer TCPE unless forced to use Web100
+// Prefer Web10G unless forced to use Web100
#if defined(FORCE_WEB100)
#define USE_WEB100 1
-#define USE_TCPE 0
+#define USE_WEB10G 0
#else
#define USE_WEB100 0
-#define USE_TCPE 1
+#define USE_WEB10G 1
#endif

-#elif HAVE_LIBTCPE
+#elif HAVE_LIBWEB10G

#define USE_WEB100 0
-#define USE_TCPE 1
+#define USE_WEB10G 1

#elif HAVE_LIBWEB100

#define USE_WEB100 1
-#define USE_TCPE 0
+#define USE_WEB10G 0

#else

#define USE_WEB100 0
-#define USE_TCPE 0
+#define USE_WEB10G 0

#endif

@@ -47,8 +47,8 @@
#if USE_WEB100
#include <web100.h>
#endif
-#if USE_TCPE
-#include <tcpe.h>
+#if USE_WEB10G
+#include <estats.h>
#endif
#ifdef HAVE_LIBPCAP
#include <pcap.h>
@@ -210,7 +210,12 @@
u_int32_t reserved[4];
};

-typedef int tcp_stat_var;
+/* Store everything as 64-bit ints, keep this signed. Not realistically
+ * expecting any of the unsigned 64bit variables to overflow a signed
+ * 64-bit*/
+typedef int64_t tcp_stat_var;
+/* Use when printing */
+#define VARtype PRId64

struct tcp_vars {
tcp_stat_var Timeouts;
@@ -252,9 +257,6 @@
tcp_stat_var SlowStart;
tcp_stat_var SubsequentTimeouts;
tcp_stat_var ThruBytesAcked;
- /* Additional for web10g */
- tcp_stat_var MaxSsCwnd;
- tcp_stat_var MaxCaCwnd;
};

/* web100-pcap */
@@ -265,7 +267,7 @@
int port3);
void init_pkttrace(I2Addr srcAddr, struct sockaddr *sock_addr,
socklen_t saddrlen, int monitor_pipe[2], char *device,
- PortPair* pair, char* direction, int compress);
+ PortPair* pair, const char* direction, int compress);
void force_breakloop();
#endif

@@ -273,25 +275,28 @@

void get_iflist(void);

-#if USE_TCPE
-typedef struct tcpe_client tcp_stat_agent;
+#if USE_WEB10G
+#define TCP_STAT_NAME "Web10G"
+typedef struct estats_nl_client tcp_stat_agent;
typedef int tcp_stat_connection;
-typedef struct tcpe_data tcp_stat_snap;
+typedef struct estats_val_data tcp_stat_snap;
/* Not relevent to web10g */
typedef void tcp_stat_group;
/* Log currently unimplemented in web10g */
-typedef void tcp_stat_log;
+typedef estats_record tcp_stat_log;
#define tcp_stat_connection_from_socket web10g_connection_from_socket

/* Extra Web10G functions web10g-util.c */
-int web10g_find_val(tcpe_data* data, char* name, struct tcpe_val* value);
-int web10g_get_val(struct tcpe_client* client, int conn, char* name,
- struct tcpe_val* value);
-int web10g_connection_from_socket(struct tcpe_client* client, int sockfd);
-int web10g_get_remote_addr(struct tcpe_client* client, int conn, char* out,
- int size);
+int web10g_find_val(const tcp_stat_snap* data, const char* name,
+ struct estats_val* value);
+int web10g_get_val(tcp_stat_agent* client, tcp_stat_connection conn,
+ const char* name, struct estats_val* value);
+int web10g_connection_from_socket(tcp_stat_agent* client, int sockfd);
+int web10g_get_remote_addr(tcp_stat_agent* client,
+ tcp_stat_connection conn, char* out, int size);

#elif USE_WEB100
+#define TCP_STAT_NAME "Web100"
typedef web100_agent tcp_stat_agent;
typedef web100_connection* tcp_stat_connection;
typedef web100_snapshot tcp_stat_snap;
@@ -313,19 +318,16 @@
int tcp_stat_get_data(tcp_stat_snap* snap, int testsock, int ctlsock,
tcp_stat_agent* agent, int count_vars);

-// TODO web10g version of CwndDecrease
-int CwndDecrease(tcp_stat_agent* agent, char* logname,
+int CwndDecrease(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, int count_vars);

int KillHung(void);
void writeMeta(int compress, int cputime, int snaplog, int tcpdump);
-void ipv4mapped_to_ipv6(struct sockaddr_storage * ss);
+
char *get_remotehost();

/* global variables for signal processing */
-sig_atomic_t sig1;
-sig_atomic_t sig2;
sig_atomic_t sig13;
sig_atomic_t sig17;
pid_t sig17_pid[256];
=======================================
--- /branches/ndt-web10g/src/web10g-util.c Sat Apr 13 19:56:13 2013
+++ /branches/ndt-web10g/src/web10g-util.c Wed Jun 19 20:10:20 2013
@@ -1,90 +1,23 @@
-/*
- * A handful of functions to handle some web10g specific stuff
+/**
+ * A handful of functions to handle some Web10G specific stuff.
+ * This provides some functions similar to those in the Web100 library
+ * for Web10G.
+ *
+ * Naming conventions
+ * web10g_* for functions added to ndt that extend the Web10G library,
+ * like everything in this file. The actual Web10G library uses
+ * estats_*.
+ *
+ * tcp_stat_* is used for types and functions intended to be used
+ * interchangably between web10g and web100.
*
* Author: Richard Sanger
- *
+ *

*/

#include "web100srv.h"
#include "logging.h"
-
-/*
- * These are used to pass information between web10g_connection_from_socket
- * and getremote_callback. It would be nice if these were not globals.
- */
-static struct sockaddr_storage local_name;
-static struct sockaddr_storage peer_name;
-static int connection_id;
-
-/**
- * Callback function used by web10g_connection_from_socket, will set
- * connection_id if the correct connection is found.
- *
- * @param ct A tuple containing connection information
- */
-static void fromsocket_callback(struct tcpe_connection_tuple* ct) {
- /* I'm assuming local_name and remote_name should both be on
- * the same addressing scheme i.e. either IPv4 or IPv6 not a mix of both */
- if (local_name.ss_family == AF_INET && peer_name.ss_family == AF_INET) {
- /* We are IPv4 check if this web10g connection also is */
- if ((ct->local_addr[16]) == TCPE_ADDRTYPE_IPV4 &&
- (ct->rem_addr[16]) == TCPE_ADDRTYPE_IPV4) {
- struct sockaddr_in * ipv4_local = (struct sockaddr_in *) &local_name;
- struct sockaddr_in * ipv4_peer = (struct sockaddr_in *) &peer_name;
-
- /* Compare local and remote ports and addresses */
- if (ct->local_port == ntohs(ipv4_local->sin_port) &&
- ct->rem_port == ntohs(ipv4_peer->sin_port) &&
- ((struct in_addr*) ct->rem_addr)->s_addr == ipv4_peer->sin_addr.s_addr &&
- ((struct in_addr*) ct->local_addr)->s_addr == ipv4_local->sin_addr.s_addr ) {
- /* Found it */
- connection_id = ct->cid;
- log_println(2, "Matched socket to web10g IPv4 connection #%d",
- connection_id);
- }
- }
- } else if (local_name.ss_family == AF_INET6 &&
- peer_name.ss_family == AF_INET6) {
- /* We are IPv6 check if this web10g connection also is */
- if ((ct->local_addr[16]) == TCPE_ADDRTYPE_IPV6 &&
- (ct->rem_addr[16]) == TCPE_ADDRTYPE_IPV6) {
- struct sockaddr_in6 * ipv6_local = (struct sockaddr_in6 *) &local_name;
- struct sockaddr_in6 * ipv6_peer = (struct sockaddr_in6 *) &peer_name;
-
- /* Compare local and remote ports and addresses */
- if (ct->local_port == ntohs(ipv6_local->sin6_port) &&
- ct->rem_port == ntohs(ipv6_peer->sin6_port) &&
- memcmp(ct->rem_addr, ipv6_peer->sin6_addr.s6_addr, sizeof(struct in6_addr)) == 0 &&
- memcmp(ct->local_addr, ipv6_local->sin6_addr.s6_addr, sizeof(struct in6_addr)) == 0) {
- /* Found it */
- connection_id = ct->cid;
- log_println(2, "Matched socket to web10g IPv6 connection #%d",
- connection_id);
- }
- }
- } else {
- log_println(1, "WARNING: Mismatch between local and peer family");
- }
-}
-
-/**
- * Converts a IPv4-mapped IPv6 sockaddr_in6 to a sockaddr_in4
- *
- * @param ss a sockaddr_storage
- *
- * @return if the ss represents a IPv6 mapped IPv4 address it will be converted
- * into a IPv4 sockaddr_in. Otherwise ss will remain unchanged.
- */
-void ipv4mapped_to_ipv6(struct sockaddr_storage * ss){
- if (ss->ss_family == AF_INET6){
- if (IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *) ss)->sin6_addr)){
- // Ports already in the right place so just move the actual address
- ss->ss_family = AF_INET;
- ((struct sockaddr_in *) ss)->sin_addr.s_addr =
- ((uint32_t *) &((struct sockaddr_in6 *) ss)->sin6_addr)[3];
- }
- }
-}
+#include "utils.h"

/**
* Find the web10g connection number related to a given socket.
@@ -96,13 +29,14 @@
* will be returned.
*
*/
-int web10g_connection_from_socket(struct tcpe_client* client, int sockfd) {
- socklen_t local_name_len;
- socklen_t peer_name_len;
-
- local_name_len = sizeof(local_name);
- peer_name_len = sizeof(peer_name);
- connection_id = -1;
+int web10g_connection_from_socket(tcp_stat_agent* client, int sockfd) {
+ struct sockaddr_storage local_name;
+ struct sockaddr_storage peer_name;
+ socklen_t local_name_len = sizeof(local_name);
+ socklen_t peer_name_len = sizeof(peer_name);
+ int connection_id = -1;
+ struct estats_connection_list* clist = NULL;
+ struct estats_list* list_pos;

/* Get the ip address of ourself on the localsocket */
if (getsockname(sockfd, (struct sockaddr*) &local_name,
@@ -110,7 +44,8 @@
log_println(1, "getsockname() failed: %s ", strerror(errno));
return -1;
}
- ipv4mapped_to_ipv6(&local_name);
+ /* IPv6 socket connected to IPv4? Convert to a real IPv4 address */
+ ipv4mapped_to_ipv4(&local_name);

/* Get the ip address of our peer */
if (getpeername(sockfd, (struct sockaddr*) &peer_name,
@@ -118,80 +53,71 @@
log_println(1, "getpeername() failed: %s ", strerror(errno));
return -1;
}
- ipv4mapped_to_ipv6(&peer_name);
+ ipv4mapped_to_ipv4(&peer_name);

- tcpe_list_conns(client, fromsocket_callback);
+ /* We have our sockaddrs so find the match in the Web10g table */
+ estats_connection_list_new(&clist);
+ estats_list_conns(clist, client);

- return connection_id;
-}

-/**
- * Find the specified web10g variable given a connection at the current
- * time.
- * Similar to web10g_find_val except this also retrieves data from web10g
- * rather than from a provided capture. If many varibles are being read
- * it's probably best to capture the data then use web10g_find_val.
- *
- * @param data A web10g data capture
- * @param name The web10g variable name
- * @param *value A pointer to a web10g value structure. If successful
- * this will contain the requested value upon return. If an error occurs
- * it's contents will remain untouched.
- *
- * @return int 0 if successful otherwise 1 in the event of an error
- * (including the case the specified value cannot be found).
- *
- */
-int web10g_get_val(struct tcpe_client* client, int conn, char* name,
- struct tcpe_val* value) {
- int i;
- tcpe_data* data = NULL;
+ ESTATS_LIST_FOREACH(list_pos, &(clist->connection_head)) {
+ struct estats_connection* cp =
+ ESTATS_LIST_ENTRY(list_pos, estats_connection, list);
+ struct estats_connection_tuple* ct =
+ (struct estats_connection_tuple*) cp;

- tcpe_data_new(&data);
- tcpe_read_vars(data, conn, client);
+ if (local_name.ss_family == AF_INET &&
+ peer_name.ss_family == AF_INET &&
+ ct->local_addr[16] == ESTATS_ADDRTYPE_IPV4 &&
+ ct->rem_addr[16] == ESTATS_ADDRTYPE_IPV4) {
+ /* All IPv4 - compare addresses */
+ struct sockaddr_in * ipv4_local =
+ (struct sockaddr_in *) &local_name;
+ struct sockaddr_in * ipv4_peer =
+ (struct sockaddr_in *) &peer_name;

- for (i = 0; i < ARRAYSIZE(data->val); i++) {
- if (data->val[i].mask) continue;
+ /* Compare local and remote ports and addresses */
+ if (ct->local_port == ntohs(ipv4_local->sin_port) &&
+ ct->rem_port == ntohs(ipv4_peer->sin_port) &&
+ ((struct in_addr*) ct->rem_addr)->s_addr ==
+ ipv4_peer->sin_addr.s_addr &&
+ ((struct in_addr*) ct->local_addr)->s_addr ==
+ ipv4_local->sin_addr.s_addr ) {
+ /* Found it */
+ connection_id = ct->cid;
+ log_println(2, "Matched socket to web10g IPv4 connection #%d",
+ connection_id);
+ goto Cleanup;
+ }
+ } else if (local_name.ss_family == AF_INET6 &&
+ peer_name.ss_family == AF_INET6 &&
+ ct->local_addr[16] == ESTATS_ADDRTYPE_IPV6 &&
+ ct->rem_addr[16] == ESTATS_ADDRTYPE_IPV6) {
+ /* We are IPv6 - compare addresses */
+ struct sockaddr_in6 * ipv6_local =
+ (struct sockaddr_in6 *) &local_name;
+ struct sockaddr_in6 * ipv6_peer =
+ (struct sockaddr_in6 *) &peer_name;

- if (strcmp(tcpe_var_array[i].name, name) == 0) {
- value->uv64 = data->val[i].uv64;
- value->mask = data->val[i].mask;
- i = -1;
- break;
+ /* Compare local and remote ports and addresses */
+ if (ct->local_port == ntohs(ipv6_local->sin6_port) &&
+ ct->rem_port == ntohs(ipv6_peer->sin6_port) &&
+ memcmp(ct->rem_addr, ipv6_peer->sin6_addr.s6_addr,
+ sizeof(struct in6_addr)) == 0 &&
+ memcmp(ct->local_addr, ipv6_local->sin6_addr.s6_addr,
+ sizeof(struct in6_addr)) == 0) {
+ /* Found it */
+ connection_id = ct->cid;
+ log_println(2, "Matched socket to web10g IPv6 connection #%d",
+ connection_id);
+ goto Cleanup;
+ }
}
}

- tcpe_data_free(&data);
- return i == -1 ? 1 : 0;
-}
-
-/*
- * These are used to pass information between web10g_get_remote_addr
- * and getremotecallback. It would be nice if these were not globals.
- */
-static int connid;
-static char * remote_name;
-static int remote_name_size;
-
-/**
- * Callback function used by web10g_get_remote_addr, will fill in
- * remote_name once if the correct connection is found and set remote_name
- * to NULL to indicate to web10g_get_remote_addr that the connection was
- * found.
- *
- * @param ct A tuple containing connection information
- *
- */
-static void getremote_callback(struct tcpe_connection_tuple* ct) {
- if (ct->cid != connid)
- return;
- if (ct->local_addr[16] == TCPE_ADDRTYPE_IPV4) {
- inet_ntop(AF_INET, &(ct->rem_addr[0]), remote_name, remote_name_size);
- remote_name = NULL;
- } else if (ct->local_addr[16] == TCPE_ADDRTYPE_IPV6) {
- inet_ntop(AF_INET6, &(ct->rem_addr[0]), remote_name, remote_name_size);
- remote_name = NULL;
- }
+ Cleanup:
+ estats_connection_list_free(&clist);
+ return connection_id;
}

/**
@@ -208,16 +134,37 @@
* (The connection could not be found).
*
*/
-int web10g_get_remote_addr(struct tcpe_client* client, int conn, char* out,
- int size) {
- /* Pass these to the callback routine using those globals */
- connid = conn;
- remote_name = out;
- remote_name_size = size;
- /* This will call the getremote_callback once for every tcp connection */
- tcpe_list_conns(client, getremote_callback);
+int web10g_get_remote_addr(tcp_stat_agent* client,
+ tcp_stat_connection conn, char* out, int size) {
+ struct estats_connection_list* clist = NULL;
+ struct estats_list* list_pos;
+
+ estats_connection_list_new(&clist);
+ estats_list_conns(clist, client);
+ out[0] = 0;
+
+ ESTATS_LIST_FOREACH(list_pos, &(clist->connection_head)) {
+ struct estats_connection* cp =
+ ESTATS_LIST_ENTRY(list_pos, estats_connection, list);
+ struct estats_connection_tuple* ct =
+ (struct estats_connection_tuple*) cp;
+
+ if (ct->cid == conn) {
+ if (ct->local_addr[16] == ESTATS_ADDRTYPE_IPV4) {
+ inet_ntop(AF_INET, &(ct->rem_addr[0]), out, size);
+ log_println(1, "Got remote address IPv4 %s", out);
+ goto Cleanup;
+ } else if (ct->local_addr[16] == ESTATS_ADDRTYPE_IPV6) {
+ inet_ntop(AF_INET6, &(ct->rem_addr[0]), out, size);
+ log_println(1, "Got remote address IPv6 %s", out);
+ goto Cleanup;
+ }
+ }
+ }

- return remote_name == NULL ? 0 : 1;
+ Cleanup:
+ estats_connection_list_free(&clist);
+ return out[0] == 0 ? 1 : 0;
}

/**
@@ -225,31 +172,130 @@
* Similar to web10g_get_val except this works on a previously retrieved
* set of data.
*
+ * This also handle some special cases to get web100 variables that
+ * no longer exist in web10g namely:
+ * MaxCwnd = MAX(MaxSsCwnd, MaxCaCwnd)
+ * AckSegsIn = SegsIn - DataSegsIn
+ * AckSegsOut = SegsOut - DataSegsOut
+ *
* @param data A web10g data capture
* @param name The web10g variable name
* @param *value A pointer to a web10g value structure. If successful
* this will contain the requested value upon return. If an error occurs
* its contents will remain untouched.
*
- * @return int 0 if successful otherwise 1 in the event of an error
+ * @return the type if successful otherwise -1 in the event of an error
* (including the case the specified value cannot be found).
*
*/
-int web10g_find_val(tcpe_data* data, char* name, struct tcpe_val* value) {
+int web10g_find_val(const tcp_stat_snap* data, const char* name,
+ struct estats_val* value) {
int i;

if (data == NULL || name == NULL || value == NULL)
- return 1;
+ return -1;
+
+ /* Special cases for old web100 variables that no longer have a direct
+ * mapping (i.e. must be calculated from others) */
+
+ if (strcmp(name, "MaxCwnd") == 0) {
+ /* = MAX(MaxSsCwnd, MaxCaCwnd) */
+ struct estats_val ss = {0};
+ struct estats_val ca = {0};
+ int type;
+ /* Types should be the same, failing that an error (-1) will take
+ * presidence when or'd (uv32's) */
+ type = web10g_find_val(data, "MaxSsCwnd", &ss);
+ type |= web10g_find_val(data, "MaxCaCwnd", &ca);
+ /* Get the max of the two */
+ if (ss.uv32 > ca.uv32) {
+ value->uv64 = ss.uv64;
+ value->masked = ss.masked;
+ } else {
+ value->uv64 = ca.uv64;
+ value->masked = ca.masked;
+ }
+ return type;
+ }
+
+ if (strcmp(name, "AckSegsIn") == 0) {
+ /* = SegsIn - DataSegsIn */
+ struct estats_val si = {0};
+ struct estats_val dsi = {0};
+ int type;
+ /* Both uv32's */
+ type = web10g_find_val(data, "SegsIn", &si);
+ type |= web10g_find_val(data, "DataSegsIn", &dsi);
+
+ value->masked = 0;
+ value->uv32 = si.uv32 - dsi.uv32;
+ return type;
+ };
+
+ if (strcmp(name, "AckSegsOut") == 0) {
+ /* = SegsOut - DataSegsOut */
+ struct estats_val so = {0};
+ struct estats_val dso = {0};
+ int type;
+ /* Both uv32's */
+ type = web10g_find_val(data, "SegsOut", &so);
+ type |= web10g_find_val(data, "DataSegsOut", &dso);
+
+ value->masked = 0;
+ value->uv32 = so.uv32 - dso.uv32;
+ return type;
+ };
+
+ for (i = 0; i < data->length; i++) {
+ if (data->val[i].masked) continue;

- for (i = 0; i < ARRAYSIZE(data->val); i++) {
- if (data->val[i].mask) continue;
- if (strcmp(tcpe_var_array[i].name, name) == 0) {
+ if (strcmp(estats_var_array[i].name, name) == 0) {
value->uv64 = data->val[i].uv64;
- value->mask = data->val[i].mask;
- return 0;
+ value->masked = data->val[i].masked; /* = 0*/
+ return estats_var_array[i].valtype;
}
}
+ log_println(0, "WARNING: Web10G failed to find name=%s", name);
+ return -1;
+}
+
+/**
+ * Find the specified web10g variable given a connection at the current
+ * time.
+ * Similar to web10g_find_val except this also retrieves data from web10g
+ * rather than from a provided capture. If many variables are being read
+ * it's probably best to capture the data then use web10g_find_val.
+ *
+ * @param data A web10g data capture
+ * @param name The web10g variable name
+ * @param *value A pointer to a web10g value structure. If successful
+ * this will contain the requested value upon return. If an error occurs
+ * it's contents will remain untouched.
+ *
+ * @return the type if successful otherwise -1 in the event of an error
+ * (including the case the specified value cannot be found).
+ *
+ */
+int web10g_get_val(tcp_stat_agent* client, tcp_stat_connection conn,
+ const char* name, struct estats_val* value) {
+ int ret;
+ estats_error* err;
+ estats_val_data* data = NULL;
+
+ if ((err = estats_val_data_new(&data)) != NULL) {
+ estats_error_print(stderr, err);
+ estats_error_free(&err);
+ return -1;
+ }
+
+ if ((err = estats_read_vars(data, conn, client)) != NULL) {
+ estats_error_print(stderr, err);
+ estats_error_free(&err);
+ estats_val_data_free(&data);
+ return -1;
+ }

- return 1;
+ ret = web10g_find_val(data, name, value);
+ estats_val_data_free(&data);
+ return ret;
}
-


  • [ndt-dev] [ndt] r828 committed - Update to use the new Web10G 2.0.6.2 userland...., ndt, 06/19/2013

Archive powered by MHonArc 2.6.16.

Top of Page