Skip to Content.
Sympa Menu

ndt-dev - [ndt-dev] [ndt] r734 committed - Start re-architecting web100clt.c and test_c2s_clt.c

Subject: NDT-DEV email list created

List archive

[ndt-dev] [ndt] r734 committed - Start re-architecting web100clt.c and test_c2s_clt.c


Chronological Thread 
  • From:
  • To:
  • Subject: [ndt-dev] [ndt] r734 committed - Start re-architecting web100clt.c and test_c2s_clt.c
  • Date: Sat, 22 Oct 2011 17:53:54 +0000

Revision: 734
Author:

Date: Sat Oct 22 10:53:27 2011
Log: Start re-architecting web100clt.c and test_c2s_clt.c
http://code.google.com/p/ndt/source/detail?r=734

Modified:
/branches/kkumar_code_organize/src/test_c2s_clt.c
/branches/kkumar_code_organize/src/utils.h
/branches/kkumar_code_organize/src/web100clt.c

=======================================
--- /branches/kkumar_code_organize/src/test_c2s_clt.c Mon Oct 17 06:43:25 2011
+++ /branches/kkumar_code_organize/src/test_c2s_clt.c Sat Oct 22 10:53:27 2011
@@ -1,4 +1,4 @@
-/*
+/**
* This file contains the functions needed to handle C2S throughput
* test (client part).
*
@@ -22,20 +22,47 @@
int sndqueue;
double spdout, c2sspd;

+/**
+ * Client to server throughput test. This test performs 10 seconds
+ * memory-to-memory data transfer to test achievable network bandwidth.
+ *
+ * @param ctlSocket Socket on which messages are received from the server
+ * @param tests Character indicator for test to be run
+ * @param host Server name string
+ * @param conn_options Options to use while connecting to server(for ex, IPV4)
+ * @param buf_size TCP send/receive buffer size
+ * @return integer > 0 if successful, < 0 in case of error
+ * Return codes:
+ * 1: Error receiving protocol message
+ * 2: Unexpected protocol message (type) received
+ * 3: Improper message payload
+ * 4: Incorrect message data received
+ * -3: Unable to resolve server address
+ * -11: Cannot connect to server
+ *
+ */
int test_c2s_clt(int ctlSocket, char tests, char* host, int conn_options,
int buf_size) {
/* char buff[BUFFSIZE+1]; */
- char buff[64 * 1024];int msgLen, msgType;
- int c2sport = 3002;
- I2Addr sec_addr = NULL;
- int ret, one=1, i, k;
- int outSocket;
- double t, stop_time;
-
- if (tests & TEST_C2S) {
+ char buff[64 * KILO_BITS]; // message payload. Todo size variations between server and CLT?
+
+ int msgLen, msgType; // message related data
+ int c2sport = 3002; // default C2S port
+ I2Addr sec_addr = NULL; // server address
+ int retcode; // return code
+ int one=1; // socket option store
+ int i, k; // temporary iterator
+ int outSocket; // socket descriptor for the outgoing
connection
+ double t, stop_time;// test-time indicators
+
+ if (tests & TEST_C2S) { // C2S test has to be performed
struct sigaction new, old;
log_println(1, " <-- C2S throughput test -->");
msgLen = sizeof(buff);
+
+ // Initially, the server sends a TEST_PREPARE message. Any
other message
+ // type, or a message with payload length <0 is unexpected and
+ // indicative of an error
if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
log_println(0, "Protocol error - missed prepare
message!");
return 1;
@@ -47,6 +74,9 @@
log_println(0, "Improper message");
return 3;
}
+
+ // Server sends port number to bind to in the TEST_PREPARE.
Check if this
+ // message body (string) is a valid integral port number.
buff[msgLen] = 0;
if (check_int(buff, &c2sport)) {
log_println(0, "Invalid port number");
@@ -54,19 +84,23 @@
}
log_println(1, " -- port: %d", c2sport);

+ // make struct of "address details" of the server using the
host name
if ((sec_addr = I2AddrByNode(get_errhandle(), host)) == NULL)
{
log_println(0, "Unable to resolve server address:
%s", strerror(errno));
return -3;
}
- I2AddrSetPort(sec_addr, c2sport);
-
- if ((ret = CreateConnectSocket(&outSocket, NULL, sec_addr, conn_options, buf_size))) {
+ I2AddrSetPort(sec_addr, c2sport); //set port value
+
+ // connect to server and set socket options
+ if ((retcode = CreateConnectSocket(&outSocket, NULL, sec_addr, conn_options, buf_size))) {
log_println(0, "Connect() for client to server failed", strerror(errno));
return -11;
}

setsockopt(outSocket, SOL_SOCKET, SO_REUSEADDR, &one,
sizeof(one));

+ // Expect a TEST_START message from server now. Any other
message
+ // type is an error
msgLen = sizeof(buff);
if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
log_println(0, "Protocol error - missed start
message!");
@@ -76,53 +110,75 @@
return 2;
}

+ // Prepare for running a C->S throughput test
printf("running 10s outbound test (client to server) . . . . .
");
fflush(stdout);

+ // ....Fill buffer upto NDTConstants.PREDEFNED_BUFFER_SIZE
packets
pkts = 0;
k = 0;
- for (i=0; i<(64*1024); i++) {
+ for (i=0; i<(64*KILO_BITS); i++) { //again todo- verify buffer sizes . seemed like 8192 a
+ //
though, this may not be a problem since the actual
+ //
byte tx is timed
while (!isprint(k&0x7f))
- k++;
+ k++;
buff[i] = (k++ % 0x7f);
}
+
+ // set the test time to 10 seconds
t = secs();
stop_time = t + 10;
/* ignore the pipe signal */
memset(&new, 0, sizeof(new));
new.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &new, &old);
+
+ // While the 10 s timer ticks, stream data to server. Record the byte count
do {
write(outSocket, buff, lth);
pkts++;
}while (secs() < stop_time);
sigaction(SIGPIPE, &old, NULL);
- sndqueue = sndq_len(outSocket);
+ sndqueue = sndq_len(outSocket); //get send-queue length
+
+ // get actual duration for which data was sent to the server
t = secs() - t;
I2AddrFree(sec_addr);
- spdout = ((8.0 * pkts * lth) / 1000) / t;
-
- /* receive the c2sspd from the server */
+
+ // Calculate C2S throughput in kbps
+ spdout = ((BITS_8 * pkts * lth) / KILO) / t;
+
+
+ // The client has stopped streaming data, and the server is
now
+ // expected to send a TEST_MSG message with the throughout it
calculated.
+ // So, its time now to receive this throughput (c2sspd).
+
msgLen = sizeof(buff);
if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
log_println(0, "Protocol error - missed text
message!");
return 1;
}
if (check_msg_type("C2S throughput test", TEST_MSG, msgType, buff, msgLen)) {
+ // other message types at this junctue indicate error
return 2;
}
- if (msgLen <= 0) {
+ if (msgLen <= 0) { // message payload size cannot be
negative! Error.
log_println(0, "Improper message");
return 3;
}
buff[msgLen] = 0;
+
+ // get C->S test speed as calculated by server
c2sspd = atoi(buff);

- if (c2sspd < 1000)
- printf(" %0.2f kb/s\n", c2sspd);
+ // Print results in the most convenient units (kbps or Mbps)
+ if (c2sspd < KILO)
+ printf(" %0.2f kb/s\n", c2sspd);
else
- printf(" %0.2f Mb/s\n", c2sspd/1000);
-
+ printf(" %0.2f Mb/s\n", c2sspd/KILO);
+
+ // Server should close test session with an empty
TEST_FINALIZE message.
+ // Any other type of message is an error
msgLen = sizeof(buff);
if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
log_println(0, "Protocol error - missed finalize
message!");
=======================================
--- /branches/kkumar_code_organize/src/utils.h Tue Oct 18 09:01:08 2011
+++ /branches/kkumar_code_organize/src/utils.h Sat Oct 22 10:53:27 2011
@@ -33,9 +33,13 @@
#define KILO 1000

// duplex indicators
-#define DUPLEX_OK_INDICATOR 0;
-#define DUPLEX_OLD_ALGO_INDICATOR 1;
-#define DUPLEX_SWITCH_FULL_HOST_HALF 2;
+#define DUPLEX_OK_INDICATOR 0
+#define DUPLEX_OLD_ALGO_INDICATOR 1
+#define DUPLEX_SWITCH_FULL_HOST_HALF 2
+#define DUPLEX_SWITCH_HALF_HOST_FULL 3
+#define DUPLEX_SWITCH_FULL_HOST_HALF_POSS 4
+#define DUPLEX_SWITCH_HALF_HOST_FULL_POSS 5
+#define DUPLEX_SWITCH_HALF_HOST_FULL_WARN 7

// link indicators
#define CANNOT_DETERMINE_LINK 100
=======================================
--- /branches/kkumar_code_organize/src/web100clt.c Mon Oct 17 06:43:25
2011
+++ /branches/kkumar_code_organize/src/web100clt.c Sat Oct 22 10:53:27
2011
@@ -18,6 +18,7 @@
#include "test_meta.h"
#include "clt_tests.h"
#include "strlutils.h"
+#include "test_results_clt.h"

#ifndef VIEW_DIFF
#define VIEW_DIFF 0.1
@@ -50,18 +51,24 @@

static struct option long_options[] = { { "name", 1, 0, 'n' }, { "port", 1, 0,
'p' }, { "debug", 0, 0, 'd' }, { "help", 0, 0, 'h' }, {
"msglvl", 0, 0,
- 'l' }, { "web100variables", 0, 0, 301 }, { "buffer", 1, 0,
'b' }, {
- "disablemid", 0, 0, 302 }, { "disablec2s", 0, 0, 303 }, {
"disables2c",
- 0, 0, 304 }, { "disablesfw", 0, 0, 305 },
+ 'l' }, { "web100variables", 0, 0, 301 }, {
"buffer", 1, 0, 'b' }, {
+ "disablemid", 0, 0, 302 }, { "disablec2s", 0, 0, 303 }, { "disables2c",
+ 0, 0, 304 }, {
"disablesfw", 0, 0, 305 },
#ifdef AF_INET6
- { "ipv4", 0, 0, '4'},
- { "ipv6", 0, 0, '6'},
+ {
"ipv4", 0, 0, '4'},
+ {
"ipv6", 0, 0, '6'},
#endif
- { 0, 0, 0, 0 } };
+ { 0, 0, 0, 0
} };

void save_int_values(char *sysvar, int sysval);
void save_dbl_values(char *sysvar, float *sysval);

+/**
+ * Print variables from a string containing
+ * key-value pairs, where the key is separated from the value by
+ * a whitespace and each key-value pair is delimited by a newline.
+ * @param tmpstr Char array containing key-value pairs
+ * todo: can this go to some clt-utils file? */
void printVariables(char *tmpstr) {
int i, j, k;
char sysvar[128], sysval[128];
@@ -82,6 +89,11 @@
return;
}
}
+
+/** Print information about web 100 variables
+ * from a pre-defined array.
+ * todo :see if this can go to a file called "web100 utils"
+ */

void printWeb100VarInfo() {
int i = 0;
@@ -137,105 +149,110 @@
}
}

- if (CountRTT > 0) {
-
+ if (CountRTT > 0) { //todo . Whats ic ountRTT > 0??
+
+ // Get the link speed as determined during the C2S test. if it was performed
if (tests & TEST_C2S) {
- if (c2sData < 3) {
- if (c2sData < 0) {
- printf(
- "Server unable to
determine bottleneck link type.\n");
- } else {
- printf("Your host is connected to a
");
- if (c2sData == 1) {
- printf("Dial-up Modem\n");
- mylink = .064;
- } else {
- printf("Cable/DSL modem\n");
- mylink = 2;
- }
- }
- } else {
- printf("The slowest link in the end-to-end path is
a ");
- if (c2sData == 3) {
- printf("10 Mbps Ethernet or WiFi 11b
subnet\n");
- mylink = 10;
- } else if (c2sData == 4) {
- printf("45 Mbps T3/DS3 or WiFi 11 a/g
subnet\n");
- mylink = 45;
- } else if (c2sData == 5) {
- printf("100 Mbps ");
- mylink = 100;
- if (half_duplex == 0) {
- printf("Full duplex Fast Ethernet
subnet\n");
- } else {
- printf("Half duplex Fast Ethernet
subnet\n");
- }
- } else if (c2sData == 6) {
- printf("a 622 Mbps OC-12 subnet\n");
- mylink = 622;
- } else if (c2sData == 7) {
- printf("1.0 Gbps Gigabit Ethernet
subnet\n");
- mylink = 1000;
- } else if (c2sData == 8) {
- printf("2.4 Gbps OC-48 subnet\n");
- mylink = 2400;
- } else if (c2sData == 9) {
- printf("10 Gbps 10 Gigabit Ethernet/OC-192
subnet\n");
- mylink = 10000;
- }
- }
+ mylink = get_linkspeed(c2sData, half_duplex);
+ /*
+ //if (c2sData < 3) {
+ if (c2sData < DATA_RATE_ETHERNET) {
+ //if (c2sData < 0) {
+ if (c2sData < DATA_RATE_RTT) {
+ printf("Server unable to determine bottleneck link
type.\n");
+ } else {
+ printf("Your host is connected to a ");
+ //if (c2sData == 1) {
+ if (c2sData == DATA_RATE_DIAL_UP) {
+ printf("Dial-up Modem\n");
+ mylink = .064;
+ } else {
+ printf("Cable/DSL modem\n");
+ mylink = 2;
+ }
+ }
+ } else {
+ printf("The slowest link in the end-to-end path is a
");
+ //if (c2sData == 3) {
+ if (c2sData == DATA_RATE_ETHERNET) {
+ printf("10 Mbps Ethernet or WiFi 11b subnet\n");
+ mylink = 10;
+ //} else if (c2sData == 4) {
+ } else if (c2sData == DATA_RATE_T3) {
+ printf("45 Mbps T3/DS3 or WiFi 11 a/g subnet\n");
+ mylink = 45;
+ //} else if (c2sData == 5) {
+ } else if (c2sData == DATA_RATE_FAST_ETHERNET) {
+ printf("100 Mbps ");
+ mylink = 100;
+ if (half_duplex == 0) {
+ printf("Full duplex Fast Ethernet subnet\n");
+ } else {
+ printf("Half duplex Fast Ethernet subnet\n");
+ }
+ //} else if (c2sData == 6) {
+ } else if (c2sData == DATA_RATE_OC_12) {
+ printf("a 622 Mbps OC-12 subnet\n");
+ mylink = 622;
+ //} else if (c2sData == 7) {
+ } else if (c2sData == DATA_RATE_GIGABIT_ETHERNET) {
+ printf("1.0 Gbps Gigabit Ethernet subnet\n");
+ mylink = 1000;
+ //} else if (c2sData == 8) {
+ } else if (c2sData == DATA_RATE_OC_48) {
+ printf("2.4 Gbps OC-48 subnet\n");
+ mylink = 2400;
+ //} else if (c2sData == 9) {
+ } else if (c2sData == DATA_RATE_10G_ETHERNET) {
+ printf("10 Gbps 10 Gigabit Ethernet/OC-192
subnet\n");
+ mylink = 10000;
+ }
+ }*/
}

- switch (mismatch) {
- case 1:
- printf("Warning: Old Duplex-Mismatch condition
detected.\n");
- break;
-
- case 2:
- printf(
- "Alarm: Duplex Mismatch condition detected. Switch=Full and Host=Half\n");
- break;
- case 4:
- printf(
- "Alarm: Possible Duplex Mismatch condition detected. Switch=Full and Host=Half\n");
- break;
-
- case 3:
- printf(
- "Alarm: Duplex Mismatch condition detected. Switch=Half and Host=Full\n");
- break;
- case 5:
- printf(
- "Alarm: Possible Duplex Mismatch condition detected. Switch=Half and Host=Full\n");
- break;
- case 7:
- printf(
- "Warning: Possible Duplex Mismatch condition detected. Switch=Half and Host=Full\n");
- break;
- }
+ /*
+ switch(mismatch) {
+ case 1 : printf("Warning: Old Duplex-Mismatch condition
detected.\n");
+ break;
+
+ case 2 : printf("Alarm: Duplex Mismatch condition detected. Switch=Full and Host=Half\n");
+ break;
+ case 4 : printf("Alarm: Possible Duplex Mismatch condition detected. Switch=Full and Host=Half\n");
+ break;
+
+ case 3 : printf("Alarm: Duplex Mismatch condition detected. Switch=Half and Host=Full\n");
+ break;
+ case 5 : printf("Alarm: Possible Duplex Mismatch condition detected. Switch=Half and Host=Full\n");
+ break;
+ case 7 : printf("Warning: Possible Duplex Mismatch condition detected. Switch=Half and Host=Full\n");
+ break;
+ }
+ */
+ print_results_mismatchcheck(mismatch);

if (mismatch == 0) {
- if (bad_cable == 1) {
- printf("Alarm: Excessive errors, check network
cable(s).\n");
- }
- if (congestion == 1) {
- printf(
- "Information: Other network
traffic is congesting the link\n");
- }
- log_print(
- 3,
- "Is larger buffer recommended? rwin*2/rttsec (%0.4f) < mylink (%0.4f) ",
- ((rwin * 2) / rttsec), mylink);
- log_println(3, "AND j (%0.4f) > MaxRwinRcvd (%d)",
- (float) ((mylink * avgrtt) * 1000) /
8, MaxRwinRcvd);
- if (((rwin * 2) / rttsec) < mylink) {
- j = (float) ((mylink * avgrtt) * 1000) / 8;
- if ((int) j > MaxRwinRcvd) {
- printf("Information: The receive buffer
should be %0.0f ",
- j / 1024);
- printf("kbytes to maximize
throughput\n");
- }
- }
+ /*
+ if (bad_cable == 1) {
+ printf("Alarm: Excessive errors, check network
cable(s).\n");
+ }
+ if (congestion == 1) {
+ printf("Information: Other network traffic is congesting
the link\n");
+ }
+
+ log_print(3, "Is larger buffer recommended? rwin*2/rttsec (%0.4f) < mylink (%0.4f) ", ((rwin*2)/rttsec), mylink);
+ log_println(3, "AND j (%0.4f) > MaxRwinRcvd (%d)", (float)((mylink * avgrtt)*1000)/8, MaxRwinRcvd);
+ if (((rwin*2)/rttsec) < mylink) {
+ j = (float)((mylink * avgrtt)*1000) / 8;
+ if ((int)j > MaxRwinRcvd) {
+ printf("Information: The receive buffer should be %0.0f
", j/1024);
+ printf("kbytes to maximize throughput\n");
+ }
+ }
+ */
+ check_congestion(congestion);
+ check_badcable(bad_cable);
+ print_recommend_buffersize(rwin, rttsec, avgrtt,
mylink,
+ MaxRwinRcvd);
}

if (tests & TEST_C2S) {
@@ -465,7 +482,7 @@

void save_int_values(char *sysvar, int sysval) {
/* Values saved for interpretation:
- * SumRTT
+ * SumRTT
* CountRTT
* CurrentMSS
* Timeouts
@@ -822,7 +839,7 @@
continue;
}

- /* Each test should take less than 30 seconds, so tell them 45 sec * number of
+ /* Each test should take less than 30 seconds, so tell them 45 sec * number of
* tests in the queue.
*/
xwait = (xwait * 45);


  • [ndt-dev] [ndt] r734 committed - Start re-architecting web100clt.c and test_c2s_clt.c, ndt, 10/22/2011

Archive powered by MHonArc 2.6.16.

Top of Page