[netperf-dev] netperf4 commit notice r21 - in trunk: doc/examples
src
raj at netperf.org
raj at netperf.org
Fri Nov 18 17:07:56 PST 2005
Author: raj
Date: 2005-11-18 17:07:54 -0800 (Fri, 18 Nov 2005)
New Revision: 21
Added:
trunk/doc/examples/dns_request_list
trunk/src/dns_commands.xml
trunk/src/dns_config.xml
Modified:
trunk/src/netmsg.c
trunk/src/netperf.c
trunk/src/netperf_docs.dtd
trunk/src/netsysstats_hpux.c
trunk/src/nettest_dns.c
trunk/src/nettest_dns.h
Log:
It would seem that the DNS tests may actually work!-) Likely creaky as all
getout, but some simple stuff has run under HP-UX against a name server.
Examples of the config and command files for a dns test are added in the
form of dns_config.xml and dns_commands.xml (and a slight tweak to the
dtd file) and an example of the format of the "fill_file" that lists the
RR's to query is in doc/examples/dns_request_list
Added: trunk/doc/examples/dns_request_list
===================================================================
--- trunk/doc/examples/dns_request_list 2005-11-18 19:45:00 UTC (rev 20)
+++ trunk/doc/examples/dns_request_list 2005-11-19 01:07:54 UTC (rev 21)
@@ -0,0 +1 @@
+your.domain.com C_IN T_A 1
Added: trunk/src/dns_commands.xml
===================================================================
--- trunk/src/dns_commands.xml 2005-11-18 19:45:00 UTC (rev 20)
+++ trunk/src/dns_commands.xml 2005-11-19 01:07:54 UTC (rev 21)
@@ -0,0 +1,28 @@
+<?xml version="1.0" standalone="no" ?>
+<!DOCTYPE commands SYSTEM "./netperf_docs.dtd" >
+<commands xmlns="http://www.netperf.org/ns/netperf">
+
+<!-- 20 second DNS_RR test, details of the config in the config file
+ eg dns_config.xml or whatever you may want to use -->
+
+ <!-- cause a set of tests to be instantiated -->
+ <create_test_set set_name="s0" tests_in_set="t0,t1" />
+ <wait tid="s0" />
+ <!-- now ask that all the tests in the set go to the load state -->
+ <load tid="s0" />
+ <wait tid="s0" />
+ <!-- now ask that all the tests in the set go to the MEAS state -->
+ <measure tid="s0" />
+ <wait tid="s0" seconds="20" />
+ <load tid="s0" />
+ <wait tid="s0" />
+ <get_stats tid="t0" />
+ <get_stats tid="t1" />
+ <clear_stats tid="t0" />
+ <clear_stats tid="t1" />
+ <idle tid="s0" />
+ <wait tid="s0" />
+ <report_stats test_set="s0"
+ library="nettest_dns.la"
+ function="report_dns_test_results" />
+</commands>
Added: trunk/src/dns_config.xml
===================================================================
--- trunk/src/dns_config.xml 2005-11-18 19:45:00 UTC (rev 20)
+++ trunk/src/dns_config.xml 2005-11-19 01:07:54 UTC (rev 21)
@@ -0,0 +1,23 @@
+<?xml version="1.0" standalone="no" ?>
+<!DOCTYPE netperf SYSTEM "./netperf_docs.dtd" >
+<netperf xmlns="http://www.netperf.org/ns/netperf">
+<!-- the "netserver" entity gives info on how to contact the netserver -->
+<netserver nid="n1" >
+ <!-- within the netserver there can be several "test" entities -->
+ <test tid="t0"
+ test_name = "sys_stats"
+ library = "netsysstats.la" >
+ </test>
+ <test tid="t1"
+ test_name = "send_dns_rr"
+ library = "nettest_dns.la" >
+ <!-- The dependency data section gives the info for the DNS server -->
+ <dependency_data use_tcp = "false" remote_port = "53" remote_host="15.243.160.51" />
+ <!-- We get local addressing info from the socket_args entity -->
+ <socket_args
+ fill_file = "/tmp/dns_requests"
+ send_buffer_size = "128"
+ recv_buffer_size = "128" />
+ </test>
+</netserver>
+</netperf>
Modified: trunk/src/netmsg.c
===================================================================
--- trunk/src/netmsg.c 2005-11-18 19:45:00 UTC (rev 20)
+++ trunk/src/netmsg.c 2005-11-19 01:07:54 UTC (rev 21)
@@ -900,7 +900,7 @@
test = find_test_in_hash(testid);
if (test != NULL) {
if (debug) {
- fprintf(where,"test_stats_message: test_state = %d ",test->state);
+ fprintf(where,"test_stats_message: test_state = %d\n",test->state);
fflush(where);
}
if (test->received_stats == NULL) {
Modified: trunk/src/netperf.c
===================================================================
--- trunk/src/netperf.c 2005-11-18 19:45:00 UTC (rev 20)
+++ trunk/src/netperf.c 2005-11-19 01:07:54 UTC (rev 21)
@@ -233,6 +233,15 @@
xmlNodePtr root = NULL;
xmlNsPtr ns;
+ if (debug) {
+ if (fname) {
+ fprintf(where,"parse_xml_file called with fname %s\n",fname);
+ }
+ else {
+ fprintf(where,"parse_xml_file called with null fname\n");
+ fflush(where);
+ }
+ }
if (fname == NULL) {
if (!xmlStrcmp(doctype,(const xmlChar *)"netperf")) {
fname = "default_config.xml";
@@ -241,6 +250,11 @@
fname = "default_commands.xml";
}
}
+
+ if (debug) {
+ fprintf(where,"%s parsing file %s\n",__func__,fname);
+ fflush(where);
+ }
if ((doc = xmlParseFile(fname)) != NULL) {
/* find the root element of the document */
@@ -1850,7 +1864,7 @@
}
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int rc = NPE_SUCCESS;
int tmp;
Modified: trunk/src/netperf_docs.dtd
===================================================================
--- trunk/src/netperf_docs.dtd 2005-11-18 19:45:00 UTC (rev 20)
+++ trunk/src/netperf_docs.dtd 2005-11-19 01:07:54 UTC (rev 21)
@@ -223,6 +223,7 @@
family (AF_INET|AF_INET6|AF_UNSPEC) "AF_INET"
remote_port CDATA #REQUIRED
remote_host CDATA #REQUIRED
+ use_tcp (yes | no | true | false) #IMPLIED
>
Modified: trunk/src/netsysstats_hpux.c
===================================================================
--- trunk/src/netsysstats_hpux.c 2005-11-18 19:45:00 UTC (rev 20)
+++ trunk/src/netsysstats_hpux.c 2005-11-19 01:07:54 UTC (rev 21)
@@ -92,7 +92,7 @@
void
get_cpu_time_counters(cpu_time_counters_t *res,
- struct timeval *time,
+ struct timeval *timestamp,
test_t *test)
{
@@ -111,8 +111,8 @@
bits and then just sum-in the psc_lo value. raj 2005/09/06 */
if (pstat_getprocessor(psp, sizeof(*psp), num_cpus, 0) != -1) {
- gettimeofday(time, NULL);
- elapsed = (double)time->tv_sec + ((double)time->tv_usec / (double)1000000);
+ gettimeofday(timestamp, NULL);
+ elapsed = (double)timestamp->tv_sec + ((double)timestamp->tv_usec / (double)1000000);
ticks = sysconf(_SC_CLK_TCK);
for (i = 0; i < num_cpus; i++) {
/* we use lib_iticksperclktick in our sanity checking. raj 2005/09/06 */
@@ -148,7 +148,7 @@
}
if (test->debug) {
fprintf(test->where, "\tseconds=%d\tusec=%d\telapsed=%f\n",
- time->tv_sec,time->tv_usec,elapsed);
+ timestamp->tv_sec,timestamp->tv_usec,elapsed);
fflush(test->where);
}
}
Modified: trunk/src/nettest_dns.c
===================================================================
--- trunk/src/nettest_dns.c 2005-11-18 19:45:00 UTC (rev 20)
+++ trunk/src/nettest_dns.c 2005-11-19 01:07:54 UTC (rev 21)
@@ -94,6 +94,14 @@
#include <poll.h>
#endif
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+
#include "netperf.h"
#ifdef HISTOGRAM
@@ -255,10 +263,39 @@
remotefam = strtofam(string);
memset(&hints, 0, sizeof(hints));
hints.ai_family = remotefam;
- hints.ai_socktype = type;
- hints.ai_protocol = protocol;
- hints.ai_flags = 0;
+ if ((-1 == type) &&
+ (-1 == protocol)) {
+ /* that means we retrieve type and protocol based on dependency
+ data if there is a use_tcp attribute _and_ it says yes or true,
+ then we will use TCP. otherwise we will use UDP. raj 2005-11-18
+ */
+ string = xmlGetProp(test->dependency_data,(const xmlChar *)"use_tcp");
+ if (NULL == string) {
+ hints.ai_socktype = SOCK_DGRAM;
+ hints.ai_protocol = IPPROTO_UDP;
+ my_data->use_tcp = 0;
+ }
+ else {
+ if (!strcasecmp(string,"true") ||
+ !strcasecmp(string,"yes")) {
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_protocol = IPPROTO_TCP;
+ my_data->use_tcp = 1;
+ }
+ else {
+ hints.ai_socktype = SOCK_DGRAM;
+ hints.ai_protocol = IPPROTO_UDP;
+ my_data->use_tcp = 0;
+ }
+ }
+ }
+ else {
+ }
+ hints.ai_flags = AI_ADDRCONFIG;
+
+ /* we depend on the parser making sure these were actually
+ present... */
remoteport = xmlGetProp(test->dependency_data,(const xmlChar *)"remote_port");
remotehost = xmlGetProp(test->dependency_data,(const xmlChar *)"remote_host");
count = 0;
@@ -598,7 +635,7 @@
static int
strtotype(char type_string[]){
- if (!stracasecmp(type_string,"T_A")) return(T_A);
+ if (!strcasecmp(type_string,"T_A")) return(T_A);
else if (!strcasecmp(type_string,"T_NS")) return(T_NS);
else if (!strcasecmp(type_string,"T_MD")) return(T_MD);
else if (!strcasecmp(type_string,"T_MF")) return(T_MF);
@@ -725,6 +762,9 @@
/* zero the dns test specific data structure */
test_specific_data_init(new_data);
+ /* while we are not using it as a means to fill buffers with data,
+ we do use "fill_file" as the way to tell where the list of
+ dns_requests happen to be */
string = xmlGetProp(args,(const xmlChar *)"fill_file");
/* fopen the fill file it will be used when allocating buffer rings */
if (string) {
@@ -742,8 +782,9 @@
units = xmlGetProp(args,(const xmlChar *)"recv_buffer_units");
new_data->recv_buf_size = convert(string,units);
- /* we need to add code here to get stuff such as whether we should
- use TCP, set TCP_NODELAY, keep the TCP connection open... */
+ /* we need to add code somewhere here to get stuff such as whether
+ we should use TCP, set TCP_NODELAY, keep the TCP connection
+ open... */
/* we also neeed to add code to get stuff such as the name of the
remote DNS server, the port number and what address family to
@@ -954,10 +995,13 @@
{
dns_data_t *my_data;
+ NETPERF_DEBUG_ENTRY(test->debug,test->where);
+
my_data = test->test_specific_data;
- /* I don't think we will be using get_dependency_data */
- /* get_dependency_data(test, SOCK_STREAM, IPPROTO_TCP); */
+ /* let get_dependency_data know to pick type and protocol based on
+ the dependency info */
+ get_dependency_data(test, -1, -1);
my_data->query_socket = create_data_socket(test);
}
@@ -966,6 +1010,8 @@
{
dns_data_t *my_data;
+ NETPERF_DEBUG_ENTRY(test->debug,test->where);
+
my_data = test->test_specific_data;
if (test->debug) {
@@ -995,6 +1041,8 @@
uint32_t new_state;
dns_data_t *my_data;
+ NETPERF_DEBUG_ENTRY(test->debug,test->where);
+
my_data = test->test_specific_data;
len = last_len;
@@ -1039,6 +1087,7 @@
uint32_t new_state;
int len;
int ret;
+ int i;
int response_len;
int bytes_left;
int req_size;
@@ -1056,6 +1105,9 @@
HISTOGRAM_VARS;
+
+ NETPERF_DEBUG_ENTRY(test->debug,test->where);
+
my_data = test->test_specific_data;
@@ -1076,6 +1128,7 @@
status_entry = &(my_data->outstanding_requests[message_id]);
if (status_entry->active) {
/* this could be bad? or is it just an expired entry? */
+ printf("Hey dummy, this entry is already active!\n");
}
else {
status_entry->active = 1;
@@ -1103,8 +1156,8 @@
"data send error");
}
}
- my_data->stats.named.queries_sent++;
- my_data->stats.named.query_bytes_sent += len;
+ /* my_data->stats.named.queries_sent++; */
+ /* my_data->stats.named.query_bytes_sent += len; */
/* recv the request for the test, but first we really need some sort
of timeout on a poll call or whatnot... */
@@ -1152,7 +1205,7 @@
break;
}
/* do we have more to read this time around? */
- if (!my_data->use_tcp) {
+ if (my_data->use_tcp == 0) {
/* we are UDP */
response_len = len;
bytes_left = 0;
@@ -1161,8 +1214,6 @@
/* not quite sure what to do here - probably have to parse the
packet a bit more, update response_len etc... */
}
- rsp_ptr += len;
- bytes_left -= len;
}
else {
/* len is 0 the connection was closed exit the while loop */
@@ -1177,13 +1228,18 @@
HIST_TIMESTAMP(&time_two);
HIST_ADD(my_data->time_hist,
delta_macro(&(status_entry->sent_time),&time_two));
- my_data->stats.named.responses_received++;
- my_data->stats.named.response_bytes_received += response_len;
+ /* my_data->stats.named.responses_received++; */
+ /* so we can continue to "leverage" the nettest_bsd reporter for
+ now. raj 2005-11-18 */
+ my_data->stats.named.trans_sent++;
+ my_data->stats.named.trans_received++;
+ /* my_data->stats.named.response_bytes_received += response_len; */
}
else {
/* is this bad? well, if we were in a transition from LOAD to
MEAS state it could happen I suppose so for now we will simply
ignore the message */
+ printf("Yo! no match on request_id, entry inactive\n");
}
if (len == 0) {
@@ -1193,6 +1249,7 @@
DNSE_DATA_CONNECTION_CLOSED_ERROR,
"data connection closed during TEST_MEASURE state");
}
+ break;
}
new_state = CHECK_REQ_STATE;
if (new_state == TEST_LOADED) {
@@ -1208,11 +1265,13 @@
send_dns_rr_load(test_t *test)
{
uint32_t new_state;
+ int ret;
int len;
int bytes_left;
int req_size;
char *rsp_ptr;
dns_data_t *my_data;
+ struct pollfd fds;
char request_buffer[NS_PACKETSZ]; /* that aught to be
enough to hold it
- modulo stuff
@@ -1220,6 +1279,8 @@
requests on TCP
connections... */
+ NETPERF_DEBUG_ENTRY(test->debug,test->where);
+
my_data = test->test_specific_data;
/* go through and build the next request to send */
@@ -1241,46 +1302,72 @@
"data send error");
}
}
- /* recv the request for the test */
- rsp_ptr = request_buffer;
- bytes_left = NS_PACKETSZ;
- while (bytes_left > 0) {
- if ((len=recv(my_data->query_socket,
- rsp_ptr,
- bytes_left,
- 0)) != 0) {
- /* this macro hides windows differences */
- if (CHECK_FOR_RECV_ERROR(len)) {
- report_test_failure(test,
- __func__,
- DNSE_DATA_RECV_ERROR,
- "data_recv_error");
- break;
+
+ fds.fd = my_data->query_socket;
+ fds.events = POLLIN;
+ fds.revents = 0;
+
+ ret = poll(&fds,1,5000); /* magic constant alert - that is something
+ that should come from the config
+ file... */
+
+ switch (ret) {
+ case -1:
+ /* something bad happened */
+ report_test_failure(test,
+ __func__,
+ DNSE_DATA_RECV_ERROR,
+ "poll_error");
+
+ break;
+ case 0:
+ /* we had a timeout. since we are not actually measuring anything,
+ there is no status_entry to update. raj 2005-11-18 */
+ break;
+ case 1:
+ /* recv the request for the test */
+ rsp_ptr = request_buffer;
+ bytes_left = NS_PACKETSZ;
+ while (bytes_left > 0) {
+ if ((len=recv(my_data->query_socket,
+ rsp_ptr,
+ bytes_left,
+ 0)) != 0) {
+ /* this macro hides windows differences */
+ if (CHECK_FOR_RECV_ERROR(len)) {
+ report_test_failure(test,
+ __func__,
+ DNSE_DATA_RECV_ERROR,
+ "data_recv_error");
+ break;
+ }
+ /* do we have more to read this time around? */
+ if (!my_data->use_tcp) {
+ /* we are UDP */
+ bytes_left = 0;
+ }
+ else {
+ /* not quite sure what to do here - probably have to parse the
+ packet a bit more */
+ }
+ rsp_ptr += len;
+ bytes_left -= len;
}
- /* do we have more to read this time around? */
- if (!my_data->use_tcp) {
- /* we are UDP */
- bytes_left = 0;
- }
else {
- /* not quite sure what to do here - probably have to parse the
- packet a bit more */
+ /* len is 0 the connection was closed exit the while loop */
+ break;
}
- rsp_ptr += len;
- bytes_left -= len;
}
- else {
- /* len is 0 the connection was closed exit the while loop */
- break;
- }
+ break;
+
}
-
new_state = CHECK_REQ_STATE;
if ((len == 0) ||
(new_state == TEST_IDLE)) {
send_dns_rr_idle_link(test,len);
new_state = TEST_IDLE;
- } else {
+ }
+ else {
if (new_state == TEST_MEASURE) {
/* transitioning to measure state from loaded state
set previous timestamp */
@@ -1341,7 +1428,14 @@
send_dns_rr(test_t *test)
{
uint32_t state, new_state;
- dns_test_init(test, SOCK_STREAM, IPPROTO_TCP);
+
+ /* this may be interesting as we may have to move things around a
+ bit - we may not necessarily know if we are using UDP or TCP at
+ this point in the parsing... raj 2005-11-18 */
+ dns_test_init(test, SOCK_DGRAM, IPPROTO_UDP);
+
+ NETPERF_DEBUG_ENTRY(test->debug,test->where);
+
state = GET_TEST_STATE;
while ((state != TEST_ERROR) &&
(state != TEST_DEAD )) {
Modified: trunk/src/nettest_dns.h
===================================================================
--- trunk/src/nettest_dns.h 2005-11-18 19:45:00 UTC (rev 20)
+++ trunk/src/nettest_dns.h 2005-11-19 01:07:54 UTC (rev 21)
@@ -101,7 +101,10 @@
uint64_t responses_received; /* the number of responses
received */
uint64_t response_bytes_received; /* their byte count */
+ uint64_t trans_sent;
+ uint64_t trans_received;
uint64_t connect_calls;
+ uint64_t accepts;
} named;
} stats;
struct timeval elapsed_time;
More information about the netperf-dev
mailing list