[netperf-dev] netperf4 commit notice r35 - in trunk: doc/examples
src
burger at netperf.org
burger at netperf.org
Wed Jan 18 12:56:18 PST 2006
Author: burger
Date: 2006-01-18 12:56:09 -0800 (Wed, 18 Jan 2006)
New Revision: 35
Added:
trunk/doc/examples/awk.gen_config
Modified:
trunk/src/netlib.c
trunk/src/netlib.h
trunk/src/netperf.c
trunk/src/netperf_docs.dtd
trunk/src/netserver.c
trunk/src/nettest_vst.c
trunk/src/nettest_vst.h
Log:
Fixed timing windows in nettest_vst.c
Modified netserver.c, netperf.c and netlib.c to detect and report stuck tests.
Modified definition of close, delete_test_set, and show_test_set commands
to correct errors while parsing netperf command files.
Added a new file awk.gen_config to doc/examples.
which generates a netperf4 configuration file for the large test I was running.
This can be used as an example by others
Had netperf4 running on one system.
Establishing 64 netservers on 33 other systems.
A total of 193 tests where run concurrently.
Stephen Burger
Added: trunk/doc/examples/awk.gen_config
===================================================================
--- trunk/doc/examples/awk.gen_config 2005-12-09 22:50:05 UTC (rev 34)
+++ trunk/doc/examples/awk.gen_config 2006-01-18 20:56:09 UTC (rev 35)
@@ -0,0 +1,116 @@
+BEGIN {
+ # generates configuration file for 32way sut with 32 links
+ # and 32 load generators for test.
+ # The sut gets 96 receiving tests running in 32 netservers.
+ # Each client get 3 sending tests running in 1 netserver.
+ # The sut also gets a sysstats test to collect system statistics.
+ # Total of 193 separate test threads are configured across 33 systems.
+ max_clnt = 16
+ min_clnt = 9
+ printf("<?xml version=\"1.0\" standalone=\"no\" ?>\n")
+ printf("<!DOCTYPE netperf SYSTEM \"./netperf_docs.dtd\" >\n")
+ printf("<netperf xmlns=\"http://www.netperf.org/ns/netperf\">\n")
+
+ # clients in cabinet 1
+ net[1, 9] = 29
+ net[1,10] = 30
+ net[1,11] = 31
+ net[1,12] = 32
+ net[1,13] = 33
+ net[1,14] = 34
+ net[1,15] = 35
+ net[1,16] = 36
+
+ # clients in cabinet 2
+ net[2, 9] = 37
+ net[2,10] = 38
+ net[2,11] = 39
+ net[2,12] = 40
+ net[2,13] = 41
+ net[2,14] = 42
+ net[2,15] = 43
+ net[2,16] = 44
+
+ # clients in cabinet 3
+ net[3, 9] = 1
+ net[3,10] = 20
+ net[3,11] = 21
+ net[3,12] = 22
+ net[3,13] = 7
+ net[3,14] = 23
+ net[3,15] = 24
+ net[3,16] = 25
+
+ # clients in cabinet 4
+ net[4, 9] = 10
+ net[4,10] = 26
+ net[4,11] = 27
+ net[4,12] = 28
+ net[4,13] = 14
+ net[4,14] = 15
+ net[4,15] = 16
+ net[4,16] = 17
+
+ file[1] = "wld_file1.xml"
+ file[2] = "wld_file2.xml"
+ file[3] = "wld_file3.xml"
+}
+END {
+ # declare tests for netserver running on k14ol101 32way olympia
+ ns = 0
+ tst = 0
+ printf("<netserver nid=\"n%d\"\n",ns)
+ printf(" remote_host = \"223.0.14.101\" >\n")
+ printf(" <test tid=\"t%d\"\n",tst)
+ printf(" test_name = \"sys_stats\"\n")
+ printf(" library = \"netsysstats.la\" >\n")
+ printf(" </test>\n")
+ for (clt=min_clnt;clt<=max_clnt;clt++) {
+ for (cab=1;cab<=4;cab++) {
+ if (ns > 0) {
+ printf("<netserver nid=\"n%d\"\n",ns)
+ printf(" remote_host = \"223.0.14.101\" >\n")
+ }
+ for (f=1; f<=3; f++) {
+ tst++
+ printf(" <test tid=\"t%d\"\n",tst)
+ printf(" test_name = \"recv_vst_rr\"\n")
+ printf(" library = \"nettest_vst.la\" >\n")
+ printf(" <socket_args\n")
+ printf(" local_host = \"192.101.%d.101\"\n",net[cab,clt])
+ printf(" req_size = \"32783\"\n")
+ printf(" rsp_size = \"16384\" />\n")
+ printf(" </test>\n")
+ }
+ ns++
+ printf("</netserver>\n")
+ }
+ }
+
+ # declare tests for netservers running on 32 clients
+ dep = 0
+ depns = 0
+ for (clt=min_clnt;clt<=max_clnt;clt++) {
+ for (cab=1;cab<=4;cab++) {
+ printf("<netserver nid=\"n%d\"\n",ns)
+ printf(" remote_host = \"223.0.%d.%d\" >\n",cab,clt)
+ for (f=1; f<=3; f++) {
+ dep++
+ tst++
+ printf(" <test tid=\"t%d\"\n",tst)
+ printf(" test_name = \"send_vst_rr\"\n")
+ printf(" library = \"nettest_vst.la\" >\n")
+ printf(" <dependson testid=\"t%d\"\n",dep)
+ printf(" netserverid=\"n%d\" />\n",depns)
+ printf(" <socket_args\n")
+ printf(" local_host = \"192.101.%d.%d\"\n",net[cab,clt],clt)
+ printf(" fill_file = \"/opt/netperf4/src/%s\" />\n",file[f])
+ printf(" </test>\n")
+ }
+ depns++
+ ns++
+ printf("</netserver>\n")
+ }
+ }
+ printf("</netperf>\n")
+}
Modified: trunk/src/netlib.c
===================================================================
--- trunk/src/netlib.c 2005-12-09 22:50:05 UTC (rev 34)
+++ trunk/src/netlib.c 2006-01-18 20:56:09 UTC (rev 35)
@@ -270,20 +270,83 @@
return(AF_UNSPEC);
}
+static void
+test_state_to_string(int value, char *string)
+{
+ char *state;
+
+ switch (value) {
+ case TEST_PREINIT:
+ state = "PRE ";
+ break;
+ case TEST_INIT:
+ state = "INIT";
+ break;
+ case TEST_IDLE:
+ state = "IDLE";
+ break;
+ case TEST_MEASURE:
+ state = "MEAS";
+ break;
+ case TEST_LOADED:
+ state = "LOAD";
+ break;
+ case TEST_ERROR:
+ state = "ERR ";
+ break;
+ case TEST_DEAD:
+ state = "DEAD";
+ break;
+ default:
+ state = "ILLG";
+ break;
+ }
+ strcpy(string,state);
+}
+
void
-report_test_status(server_t *server)
+report_test_status(test_t *test)
{
- int ret;
- test_hash_t *h;
bsd_data_t *my_data;
+ char current[8];
+ char requested[8];
+ char reported[8];
+ double a=-1.0,b=-1.0,c=-1.0,d=-1.0;
+
+ my_data = (bsd_data_t *)test->test_specific_data;
+ /* of course, there can be times when we don't yet have a my_data?
+ so, we best not be trying to dereference that pointer had we?!?
+ raj 2005-10-27 */
+ if (my_data) {
+ a = my_data->stats.counter[0];
+ b = my_data->stats.counter[1];
+ c = my_data->stats.counter[2];
+ d = my_data->stats.counter[3];
+ }
+
+ test_state_to_string(test->state, reported );
+ test_state_to_string(test->new_state, current );
+ test_state_to_string(test->state_req, requested);
+
+ fprintf(where,"%4s %4s %15s %4s %4s %4s %8g %8g %8g %8g %d\n",
+ test->server_id,test->id,test->test_name,
+ reported, current, requested, a, b, c, d, test->tid);
+ fflush(where);
+}
+
+void
+report_servers_test_status(server_t *server)
+{
+ int ret;
+ test_hash_t *h;
test_t *test;
char *state;
char *req_st;
double a=-1.0,b=-1.0,c=-1.0,d=-1.0;
int i;
- fprintf(where,"\n\n%3s %15s %7s %7s %8s %8s %8s %8s\n",
- "tst","test_name","state","req_st",
+ fprintf(where,"\n\n%4s %4s %15s %4s %4s %4s %8s %8s %8s %8s\n",
+ "srvr","tst","test_name","CURR","TEST","RQST",
"cnt1","cnt2","cnt3","cnt4");
for (i = 0; i < TEST_HASH_BUCKETS; i ++) {
h = &test_hash[i];
@@ -295,75 +358,8 @@
test = h->test;
while (test != NULL) {
-
- my_data = (bsd_data_t *)test->test_specific_data;
- /* of course, there can be times when we don't yet have a my_data?
- so, we best not be trying to dereference that pointer had we?!?
- raj 2005-10-27 */
- if (my_data) {
- a = my_data->stats.counter[0];
- b = my_data->stats.counter[1];
- c = my_data->stats.counter[2];
- d = my_data->stats.counter[3];
- }
-
-
if (!xmlStrcmp(test->server_id,server->id)) {
- switch (test->state) {
- case TEST_PREINIT:
- state = "PREINIT";
- break;
- case TEST_INIT:
- state = "INIT";
- break;
- case TEST_IDLE:
- state = "IDLE";
- break;
- case TEST_MEASURE:
- state = "MEASURE";
- break;
- case TEST_LOADED:
- state = "LOADED";
- break;
- case TEST_ERROR:
- state = "ERROR";
- break;
- case TEST_DEAD:
- state = "DEAD";
- break;
- default:
- state = "ILLEGAL";
- break;
- }
- switch (test->state_req) {
- case TEST_PREINIT:
- req_st = "PREINIT";
- break;
- case TEST_INIT:
- req_st = "INIT";
- break;
- case TEST_IDLE:
- req_st = "IDLE";
- break;
- case TEST_MEASURE:
- req_st = "MEASURE";
- break;
- case TEST_LOADED:
- req_st = "LOADED";
- break;
- case TEST_ERROR:
- req_st = "ERROR";
- break;
- case TEST_DEAD:
- req_st = "DEAD";
- break;
- default:
- req_st = "ILLEGAL";
- break;
- }
-
- fprintf(where,"%3s %15s %7s %7s %8g %8g %8g %8g\n",
- test->id,test->test_name,state,req_st,a,b,c,d);
+ report_test_status(test);
}
test = test->next;
}
@@ -373,8 +369,8 @@
fflush(where);
}
}
- fflush(where);
}
+
void
display_test_hash()
Modified: trunk/src/netlib.h
===================================================================
--- trunk/src/netlib.h 2005-12-09 22:50:05 UTC (rev 34)
+++ trunk/src/netlib.h 2006-01-18 20:56:09 UTC (rev 35)
@@ -39,7 +39,8 @@
extern void delete_test(const xmlChar *id);
extern test_t * find_test_in_hash(const xmlChar *id);
-extern void report_test_status(server_t *server);
+extern void report_test_status(test_t *test);
+extern void report_servers_test_status(server_t *server);
extern GenReport get_report_function(xmlNodePtr cmd);
extern const char * netperf_error_name(int rc);
Modified: trunk/src/netperf.c
===================================================================
--- trunk/src/netperf.c 2005-12-09 22:50:05 UTC (rev 34)
+++ trunk/src/netperf.c 2006-01-18 20:56:09 UTC (rev 35)
@@ -1024,7 +1024,7 @@
if (debug) {
fprintf(where,"netperf_worker: ho hum, nothing to do\n");
fflush(where);
- report_test_status(server);
+ report_servers_test_status(server);
}
}
pthread_mutex_lock(server->lock);
@@ -1164,6 +1164,7 @@
xmlChar *tid;
test_t *test;
tset_t *test_set;
+ int i;
if (debug) {
fprintf(where,"entering %s\n", __func__);
@@ -1176,25 +1177,42 @@
while (set_elt) {
test = set_elt->test;
if (test) {
+ i = 15;
while (test->state != test->state_req) {
if (test->state == TEST_ERROR) {
rc = NPE_TEST_FOUND_IN_ERROR_STATE;
break;
}
- sleep(1);
+ if (i) {
+ i--;
+ sleep(1);
+ }
+ else {
+ i = 15;
+ report_test_status(test);
+ }
}
}
set_elt = set_elt->next;
}
- } else {
+ }
+ else {
test = find_test_in_hash(tid);
if (test) {
+ i = 15;
while (test->state != test->state_req) {
if (test->state == TEST_ERROR) {
rc = NPE_TEST_FOUND_IN_ERROR_STATE;
break;
}
- sleep(1);
+ if (i) {
+ i--;
+ sleep(1);
+ }
+ else {
+ i = 15;
+ report_test_status(test);
+ }
}
}
}
@@ -1836,7 +1854,7 @@
static int
process_command(xmlNodePtr cmd)
{
- int loc_debug = 0;
+ int loc_debug = 1;
int rc = NPE_SUCCESS;
struct netperf_cmd *which_cmd;
Modified: trunk/src/netperf_docs.dtd
===================================================================
--- trunk/src/netperf_docs.dtd 2005-12-09 22:50:05 UTC (rev 34)
+++ trunk/src/netperf_docs.dtd 2006-01-18 20:56:09 UTC (rev 35)
@@ -127,12 +127,12 @@
<!ELEMENT delete_test_set EMPTY >
<!ATTLIST delete_test_set
- set_name ID #REQUIRED
+ set_name IDREF #REQUIRED
>
<!ELEMENT show_test_set EMPTY >
<!ATTLIST show_test_set
- set_name ID #REQUIRED
+ set_name IDREF #REQUIRED
>
@@ -219,6 +219,7 @@
<!ELEMENT close EMPTY >
<!ATTLIST close
+ xmlns CDATA #FIXED "http://www.netperf.org/ns/netperf"
sid CDATA #REQUIRED
flag (LOOP | EXIT) "LOOP"
>
Modified: trunk/src/netserver.c
===================================================================
--- trunk/src/netserver.c 2005-12-09 22:50:05 UTC (rev 34)
+++ trunk/src/netserver.c 2006-01-18 20:56:09 UTC (rev 35)
@@ -445,13 +445,44 @@
}
+static void
+report_stuck_test_status(server_t *netperf)
+{
+ int i;
+ uint32_t reported;
+ uint32_t requested;
+ uint32_t current;
+ test_hash_t *h;
+ test_t *test;
+ for (i = 0; i < TEST_HASH_BUCKETS; i ++) {
+ h = &test_hash[i];
+ /* mutex locking is not required because only one
+ netserver thread looks at these data structures sgb */
+ test = h->test;
+ while (test != NULL) {
+ reported = test->state;
+ current = test->new_state;
+ requested = test->state_req;
+ if (current != requested) {
+ if (current != TEST_ERROR) {
+ report_test_status(test);
+ }
+ }
+ if (current != reported) {
+ report_test_status(test);
+ }
+ test = test->next;
+ }
+ }
+}
+
static void
check_test_state()
{
int i;
- int orig;
- int new;
+ uint32_t orig;
+ uint32_t new;
int rc;
test_t *test;
test_hash_t *h;
@@ -621,7 +652,6 @@
static int
handle_netperf_requests(int sock)
{
- int loc_debug = 0;
int rc = NPE_SUCCESS;
struct pollfd fds;
xmlDocPtr message;
@@ -678,11 +708,12 @@
}
}
} else {
- if (debug || loc_debug) {
+ if (debug) {
fprintf(where,"ho hum, nothing to do\n");
fflush(where);
- report_test_status(netperf);
+ report_servers_test_status(netperf);
}
+ report_stuck_test_status(netperf);
}
/* mutex locking is not required because only one
netserver thread looks at these data structures sgb */
Modified: trunk/src/nettest_vst.c
===================================================================
--- trunk/src/nettest_vst.c 2005-12-09 22:50:05 UTC (rev 34)
+++ trunk/src/nettest_vst.c 2006-01-18 20:56:09 UTC (rev 35)
@@ -71,7 +71,9 @@
int err_code;
char *err_string;
{
- if (test->debug) {
+ int loc_debug = 1;
+
+ if (test->debug || loc_debug) {
fprintf(test->where,"%s: called report_test_failure:",function);
fprintf(test->where,"reporting %s errno = %d\n",err_string,GET_ERRNO);
fflush(test->where);
@@ -432,12 +434,13 @@
/* this routine will allocates a circular list of fixed buffers for */
- /* send and receive operations. each of these buffers will be aligned */
- /* and offset as per the users request. the circumference of this */
- /* ring will be controlled by the setting of send_width. the buffers */
- /* will be filled with data from the file specified in fill_file. if */
- /* fill_file is an empty string, the buffers will not be filled with */
- /* any particular data */
+ /* send and receive operations. each of these buffers will be offset */
+ /* as per the users request and then align will be adjusted to be a */
+ /* sizeof(int) or a multiple of size of int before buffer alignment. */
+ /* the circumference of this ring will be controlled by the setting */
+ /* of send_width. the buffers will be filled with data from the file */
+ /* specified in fill_file. if fill_file is an empty string, then */
+ /* buffers will not be filled with any particular data. */
static void
allocate_fixed_buffers(test_t *test)
@@ -472,8 +475,8 @@
recv_size = my_data->rsp_size;
recv_align = my_data->recv_align;
recv_offset = my_data->recv_offset;
- if (send_size < (sizeof(int)*3)) {
- send_size = sizeof(int) * 3 - 1;
+ if (send_size < (sizeof(int)*4)) {
+ send_size = sizeof(int) * 4;
}
}
else {
@@ -484,40 +487,65 @@
recv_size = my_data->req_size;
recv_align = my_data->recv_align;
recv_offset = my_data->recv_offset;
- if (recv_size < (sizeof(int)*3)) {
- recv_size = sizeof(int) * 3 - 1;
+ if (recv_size < (sizeof(int)*4)) {
+ recv_size = sizeof(int) * 4;
}
}
+ if (send_align < sizeof(int)) {
+ send_align = sizeof(int);
+ }
+ else {
+ send_align = (send_align + sizeof(int) - 1) & ~(sizeof(int) - 1);
+ }
+
+ if (recv_align < sizeof(int)) {
+ recv_align = sizeof(int);
+ }
+ else {
+ recv_align = (recv_align + sizeof(int) - 1) & ~(sizeof(int) - 1);
+ }
+
send_malloc_size = send_size + send_align + send_offset;
recv_malloc_size = recv_size + recv_align + recv_offset;
+ prev_link = NULL;
for (i = 0; i < width; i++) {
temp_link = (vst_ring_ptr)malloc(sizeof(vst_ring_elt_t));
temp_link->send_buff_base = (char *)malloc(send_malloc_size);
+ if (temp_link->send_buff_base == NULL) {
+ report_test_failure(test,
+ (char *)__func__,
+ VSTE_MALLOC_FAILED,
+ "error allocating vst send buffer");
+ }
+ temp_link->send_buff_ptr = temp_link->send_buff_base + send_offset;
temp_link->send_buff_ptr = (char *)(
- ( (long)(temp_link->send_buff_base)
- + (long)send_align -1)
- & ~((long)send_align -1));
- temp_link->send_buff_ptr += send_offset;
+ ( (long)(temp_link->send_buff_ptr)
+ + (long)send_align - 1)
+ & ~((long)send_align - 1));
temp_link->send_buff_size = send_malloc_size;
temp_link->send_size = send_size;
temp_link->recv_buff_base = (char *)malloc(recv_malloc_size);
+ if (temp_link->send_buff_base == NULL) {
+ report_test_failure(test,
+ (char *)__func__,
+ VSTE_MALLOC_FAILED,
+ "error allocating vst recv buffer");
+ }
+ temp_link->recv_buff_ptr = temp_link->recv_buff_base + recv_offset;
temp_link->recv_buff_ptr = (char *)(
- ( (long)(temp_link->recv_buff_base)
- + (long)recv_align -1)
- & ~((long)recv_align -1));
- temp_link->recv_buff_ptr += recv_offset;
+ ( (long)(temp_link->recv_buff_ptr)
+ + (long)recv_align - 1)
+ & ~((long)recv_align - 1));
temp_link->recv_buff_size = recv_malloc_size;
temp_link->recv_size = recv_size;
if (send) {
- send_buf = (int *)(
- ( (long)(temp_link->send_buff_ptr)
- + (long)sizeof(int) -1)
- & ~((long)sizeof(int) -1));
+ memset(temp_link->send_buff_base, -1, send_malloc_size);
+ send_buf = (int *)temp_link->send_buff_ptr;
send_buf[0] = send_size;
send_buf[1] = recv_size;
}
@@ -570,6 +598,20 @@
recv_align = my_data->recv_align;
recv_offset = my_data->recv_offset;
+ if (send_align < sizeof(int)) {
+ send_align = sizeof(int);
+ }
+ else {
+ send_align = (send_align + sizeof(int) - 1) & ~(sizeof(int) - 1);
+ }
+
+ if (recv_align < sizeof(int)) {
+ recv_align = sizeof(int);
+ }
+ else {
+ recv_align = (recv_align + sizeof(int) - 1) & ~(sizeof(int) - 1);
+ }
+
pattern = wld->xmlChildrenNode;
for (p=0;p < MAX_PATTERNS; p++) {
@@ -593,32 +635,51 @@
string = (char *)xmlGetProp(entry,(const xmlChar *)"rsp_size");
recv_size = atoi(string);
+ if (send_size < (sizeof(int)*4)) {
+ send_size = sizeof(int) * 4;
+ }
malloc_size = send_size + send_align + send_offset;
temp_link->send_buff_base = (char *)malloc(malloc_size);
+ if (temp_link->send_buff_base == NULL) {
+ report_test_failure(test,
+ (char *)__func__,
+ VSTE_MALLOC_FAILED,
+ "error allocating vst send buffer");
+ }
+ temp_link->send_buff_ptr = temp_link->send_buff_base + send_offset;
temp_link->send_buff_ptr = (char *)(
- ( (long)(temp_link->send_buff_base)
- + (long)send_align -1)
- & ~((long)send_align -1));
+ ( (long)(temp_link->send_buff_ptr)
+ + (long)send_align - 1)
+ & ~((long)send_align - 1));
temp_link->send_buff_size = malloc_size;
temp_link->send_size = send_size;
+ memset(temp_link->send_buff_base, -1, malloc_size);
+
malloc_size = recv_size + recv_align + recv_offset;
temp_link->recv_buff_base = (char *)malloc(malloc_size);
+ if (temp_link->send_buff_base == NULL) {
+ report_test_failure(test,
+ (char *)__func__,
+ VSTE_MALLOC_FAILED,
+ "error allocating vst recv buffer");
+ }
+ temp_link->recv_buff_ptr = temp_link->recv_buff_base + recv_offset;
temp_link->recv_buff_ptr = (char *)(
- ( (long)(temp_link->recv_buff_base)
- + (long)recv_align -1)
- & ~((long)recv_align -1));
+ ( (long)(temp_link->recv_buff_ptr)
+ + (long)recv_align - 1)
+ & ~((long)recv_align - 1));
temp_link->recv_buff_size = malloc_size;
temp_link->recv_size = recv_size;
- send_buf = (int *)(
- ( (long)(temp_link->send_buff_ptr)
- + (long)sizeof(int) -1)
- & ~((long)sizeof(int) -1));
+ send_buf = (int *)temp_link->send_buff_ptr;
+
send_buf[0] = send_size;
send_buf[1] = recv_size;
+ send_buf[2] = send_size;
+ send_buf[3] = recv_size;
temp_link->distribution = NULL;
@@ -1591,10 +1652,7 @@
/* code to timestamp enabled by WANT_HISTOGRAM */
HIST_TIMESTAMP(&time_one);
/* recv the request for the test */
- req_base = (int *)(
- ( (long)(my_data->vst_ring->recv_buff_ptr)
- + (long)sizeof(int) -1)
- & ~((long)sizeof(int) -1));
+ req_base = (int *)my_data->vst_ring->recv_buff_ptr;
req_ptr = my_data->vst_ring->recv_buff_ptr;
bytes_left = my_data->vst_ring->recv_size;
received = 0;
@@ -1615,8 +1673,30 @@
my_data->stats.named.recv_calls++;
received += len;
req_ptr += len;
- if (received >= (sizeof(int)*2)) {
- bytes_left = ntohl(req_base[0]) - received;
+ if (received >= (sizeof(int)*4)) {
+ bytes_left = ntohl(req_base[0]);
+ rsp_size = ntohl(req_base[1]);
+ if ((bytes_left > my_data->vst_ring->recv_size) ||
+ (rsp_size > my_data->vst_ring->send_size) ||
+ (bytes_left < (sizeof(int)*4)) ||
+ (rsp_size < (sizeof(int)*4)) ||
+ (bytes_left != ntohl(req_base[2])) ||
+ (rsp_size != ntohl(req_base[3])) ) {
+ fprintf(test->where,
+ "\n%s: Error in received packet for test_id = '%s'\n",
+ __func__, test->id);
+ fprintf(test->where,
+ "\treq_base[0] = %d\treq_base[1] = %d\n",
+ bytes_left, rsp_size);
+ fprintf(test->where,
+ "\treq_base[2] = %d\treq_base[3] = %d\n\n",
+ ntohl(req_base[2]), ntohl(req_base[3]));
+ fprintf(test->where,
+ "\treq_base = %p\torig_req_ptr = %p\treceived = %d\n",
+ req_base, my_data->vst_ring->recv_buff_ptr, received);
+ fflush(test->where);
+ }
+ bytes_left = bytes_left - received;
}
else {
bytes_left = my_data->vst_ring->recv_size - received;
@@ -1635,7 +1715,6 @@
"data connection closed during TEST_MEASURE state");
}
else {
- rsp_size = ntohl(req_base[1]);
my_data->stats.named.trans_received++;
if ((len=send(my_data->s_data,
my_data->vst_ring->send_buff_ptr,
@@ -1683,10 +1762,7 @@
while (NO_STATE_CHANGE(test)) {
/* recv the request for the test */
- req_base = (int *)(
- ( (long)(my_data->vst_ring->recv_buff_ptr)
- + (long)sizeof(int) -1)
- & ~((long)sizeof(int) -1));
+ req_base = (int *)my_data->vst_ring->recv_buff_ptr;
req_ptr = my_data->vst_ring->recv_buff_ptr;
bytes_left = my_data->vst_ring->recv_size;
received = 0;
@@ -1705,8 +1781,30 @@
}
received += len;
req_ptr += len;
- if (received >= (sizeof(int)*2)) {
- bytes_left = ntohl(req_base[0]) - received;
+ if (received >= (sizeof(int)*4)) {
+ bytes_left = ntohl(req_base[0]);
+ rsp_size = ntohl(req_base[1]);
+ if ((bytes_left > my_data->vst_ring->recv_size) ||
+ (rsp_size > my_data->vst_ring->send_size) ||
+ (bytes_left < (sizeof(int)*4)) ||
+ (rsp_size < (sizeof(int)*4)) ||
+ (bytes_left != ntohl(req_base[2])) ||
+ (rsp_size != ntohl(req_base[3])) ) {
+ fprintf(test->where,
+ "\n%s: Error in received packet for test_id = '%s'\n",
+ __func__, test->id);
+ fprintf(test->where,
+ "\treq_base[0] = %d\treq_base[1] = %d\n",
+ bytes_left, rsp_size);
+ fprintf(test->where,
+ "\treq_base[2] = %d\treq_base[3] = %d\n\n",
+ ntohl(req_base[2]), ntohl(req_base[3]));
+ fprintf(test->where,
+ "\treq_base = %p\torig_req_ptr = %p\treceived = %d\n",
+ req_base, my_data->vst_ring->recv_buff_ptr, received);
+ fflush(test->where);
+ }
+ bytes_left = bytes_left - received;
}
else {
bytes_left = my_data->vst_ring->recv_size - received;
@@ -1725,13 +1823,6 @@
a request to transition to the idle state */
break;
}
- rsp_size = ntohl(req_base[1]);
- if (rsp_size == 0) {
- fprintf(test->where,
- "%s: rsp_size = %d received = %d\n",
- __func__, rsp_size, received);
- fflush(test->where);
- }
if ((len=send(my_data->s_data,
my_data->vst_ring->send_buff_ptr,
rsp_size,
@@ -1877,6 +1968,7 @@
int bytes_left;
char *rsp_ptr;
vst_data_t *my_data;
+ int *send_buf;
my_data = GET_TEST_DATA(test);
@@ -1888,6 +1980,17 @@
HIST_TIMESTAMP(&time_one);
/* send data for the test */
send_len = my_data->vst_ring->send_size;
+ bytes_left = my_data->vst_ring->recv_size;
+ send_buf = (int *)my_data->vst_ring->send_buff_ptr;
+ if ((send_len != send_buf[0]) ||
+ (bytes_left != send_buf[1]) ||
+ (send_len != send_buf[2]) ||
+ (bytes_left != send_buf[3])) {
+ fprintf(test->where,
+ "\n%s: Found corrupted buffer is %d,%d should be %d,%d\n\n",
+ __func__, send_buf[0], send_buf[1], send_len, bytes_left);
+ fflush(test->where);
+ }
if((len=send(my_data->s_data,
my_data->vst_ring->send_buff_ptr,
send_len,
@@ -1904,7 +2007,6 @@
my_data->stats.named.send_calls++;
/* recv the request for the test */
rsp_ptr = my_data->vst_ring->recv_buff_ptr;
- bytes_left = my_data->vst_ring->recv_size;
while (bytes_left > 0) {
if ((len=recv(my_data->s_data,
rsp_ptr,
@@ -1960,6 +2062,7 @@
int bytes_left;
char *rsp_ptr;
vst_data_t *my_data;
+ int *send_buf;
my_data = GET_TEST_DATA(test);
@@ -1967,7 +2070,18 @@
/* code to make data dirty macro enabled by DIRTY */
MAKE_DIRTY(my_data,my_data->vst_ring);
/* send data for the test */
- send_len = my_data->vst_ring->send_size;
+ send_len = my_data->vst_ring->send_size;
+ bytes_left = my_data->vst_ring->recv_size;
+ send_buf = (int *)my_data->vst_ring->send_buff_ptr;
+ if ((send_len != send_buf[0]) ||
+ (bytes_left != send_buf[1]) ||
+ (send_len != send_buf[2]) ||
+ (bytes_left != send_buf[3])) {
+ fprintf(test->where,
+ "\n%s: Found corrupted buffer is %d,%d should be %d,%d\n\n",
+ __func__, send_buf[0], send_buf[1], send_len, bytes_left);
+ fflush(test->where);
+ }
if((len=send(my_data->s_data,
my_data->vst_ring->send_buff_ptr,
send_len,
@@ -1982,7 +2096,6 @@
}
/* recv the request for the test */
rsp_ptr = my_data->vst_ring->recv_buff_ptr;
- bytes_left = my_data->vst_ring->recv_size;
while (bytes_left > 0) {
if ((len=recv(my_data->s_data,
rsp_ptr,
Modified: trunk/src/nettest_vst.h
===================================================================
--- trunk/src/nettest_vst.h 2005-12-09 22:50:05 UTC (rev 34)
+++ trunk/src/nettest_vst.h 2006-01-18 20:56:09 UTC (rev 35)
@@ -159,5 +159,6 @@
VSTE_CONNECT_FAILED,
VSTE_DATA_SEND_ERROR,
VSTE_DATA_CONNECTION_CLOSED_ERROR,
+ VSTE_MALLOC_FAILED,
VSTE_SUCCESS = 0
};
More information about the netperf-dev
mailing list