[netperf-dev] netperf2 commit notice r294 - trunk/src
raj at netperf.org
raj at netperf.org
Fri Oct 24 16:46:09 PDT 2008
Author: raj
Date: 2008-10-24 16:46:08 -0700 (Fri, 24 Oct 2008)
New Revision: 294
Added:
trunk/src/net_uuid.c
Modified:
trunk/src/Makefile.am
trunk/src/Makefile.in
trunk/src/netperf.c
trunk/src/netsh.c
trunk/src/nettest_bsd.h
trunk/src/nettest_omni.c
Log:
enable tagging of test with an rfc4122 style UUID or up to 36 characters of the users own chosing
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2008-10-21 22:57:00 UTC (rev 293)
+++ trunk/src/Makefile.am 2008-10-24 23:46:08 UTC (rev 294)
@@ -15,7 +15,7 @@
EXTRA_DIST = netcpu_none.c netcpu_looper.c netcpu_pstat.c netcpu_pstatnew.c netcpu_perfstat.c netcpu_procstat.c netcpu_kstat.c netcpu_kstat10.c netcpu_sysctl.c netcpu_ntperf.c netcpu_osx.c dirs NetPerfDir/* NetServerDir/* netperf_version.h.in netrt_rtnetlink.c netrt_none.c netrt_rtmget.c netdrv_ethtool.c netdrv_none.c netslot_linux.c netslot_none.c netsys_none.c netsys_hpux11i.c netsys_linux.c netsys_solaris.c netdrv_solaris.c netslot_solaris.c netsec_linux.c netsec_none.c Makefile.uw
-COMMON_SRC = hist.h netlib.c netlib.h netcpu.h netsh.c netsh.h nettest_bsd.c nettest_bsd.h nettest_dlpi.c nettest_dlpi.h nettest_unix.c nettest_unix.h nettest_xti.c nettest_xti.h nettest_sctp.c nettest_sctp.h netperf_version.h nettest_sdp.c nettest_sdp.h nettest_omni.c
+COMMON_SRC = hist.h netlib.c netlib.h netcpu.h netsh.c netsh.h nettest_bsd.c nettest_bsd.h nettest_dlpi.c nettest_dlpi.h nettest_unix.c nettest_unix.h nettest_xti.c nettest_xti.h nettest_sctp.c nettest_sctp.h netperf_version.h nettest_sdp.c nettest_sdp.h nettest_omni.c net_uuid.c
netperf_SOURCES = netperf.c $(COMMON_SRC) $(USE_CPU_SOURCE) $(USE_RT_SOURCE) $(USE_DRV_SOURCE) $(USE_SLOT_SOURCE) $(USE_SYS_SOURCE) $(USE_SEC_SOURCE)
netserver_SOURCES = netserver.c $(COMMON_SRC) $(USE_CPU_SOURCE) $(USE_RT_SOURCE) $(USE_DRV_SOURCE) $(USE_SLOT_SOURCE) $(USE_SYS_SOURCE) $(USE_SEC_SOURCE)
Modified: trunk/src/Makefile.in
===================================================================
--- trunk/src/Makefile.in 2008-10-21 22:57:00 UTC (rev 293)
+++ trunk/src/Makefile.in 2008-10-24 23:46:08 UTC (rev 294)
@@ -149,7 +149,7 @@
EXTRA_DIST = netcpu_none.c netcpu_looper.c netcpu_pstat.c netcpu_pstatnew.c netcpu_perfstat.c netcpu_procstat.c netcpu_kstat.c netcpu_kstat10.c netcpu_sysctl.c netcpu_ntperf.c netcpu_osx.c dirs NetPerfDir/* NetServerDir/* netperf_version.h.in netrt_rtnetlink.c netrt_none.c netrt_rtmget.c netdrv_ethtool.c netdrv_none.c netslot_linux.c netslot_none.c netsys_none.c netsys_hpux11i.c netsys_linux.c netsys_solaris.c netdrv_solaris.c netslot_solaris.c netsec_linux.c netsec_none.c Makefile.uw
-COMMON_SRC = hist.h netlib.c netlib.h netcpu.h netsh.c netsh.h nettest_bsd.c nettest_bsd.h nettest_dlpi.c nettest_dlpi.h nettest_unix.c nettest_unix.h nettest_xti.c nettest_xti.h nettest_sctp.c nettest_sctp.h netperf_version.h nettest_sdp.c nettest_sdp.h nettest_omni.c
+COMMON_SRC = hist.h netlib.c netlib.h netcpu.h netsh.c netsh.h nettest_bsd.c nettest_bsd.h nettest_dlpi.c nettest_dlpi.h nettest_unix.c nettest_unix.h nettest_xti.c nettest_xti.h nettest_sctp.c nettest_sctp.h netperf_version.h nettest_sdp.c nettest_sdp.h nettest_omni.c net_uuid.c
netperf_SOURCES = netperf.c $(COMMON_SRC) $(USE_CPU_SOURCE) $(USE_RT_SOURCE) $(USE_DRV_SOURCE) $(USE_SLOT_SOURCE) $(USE_SYS_SOURCE) $(USE_SEC_SOURCE)
netserver_SOURCES = netserver.c $(COMMON_SRC) $(USE_CPU_SOURCE) $(USE_RT_SOURCE) $(USE_DRV_SOURCE) $(USE_SLOT_SOURCE) $(USE_SYS_SOURCE) $(USE_SEC_SOURCE)
@@ -168,7 +168,7 @@
am__objects_1 = netlib.$(OBJEXT) netsh.$(OBJEXT) nettest_bsd.$(OBJEXT) \
nettest_dlpi.$(OBJEXT) nettest_unix.$(OBJEXT) \
nettest_xti.$(OBJEXT) nettest_sctp.$(OBJEXT) \
- nettest_sdp.$(OBJEXT) nettest_omni.$(OBJEXT)
+ nettest_sdp.$(OBJEXT) nettest_omni.$(OBJEXT) net_uuid.$(OBJEXT)
am__objects_2 = netcpu_ at NETCPU_SOURCE@.$(OBJEXT)
am__objects_3 = netrt_ at NETRTLKUP_SOURCE@.$(OBJEXT)
am__objects_4 = netdrv_ at NETDRVLKUP_SOURCE@.$(OBJEXT)
@@ -193,7 +193,8 @@
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
- at AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/netcpu_ at NETCPU_SOURCE@.Po \
+ at AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/net_uuid.Po \
+ at AMDEP_TRUE@ ./$(DEPDIR)/netcpu_ at NETCPU_SOURCE@.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/netdrv_ at NETDRVLKUP_SOURCE@.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/netlib.Po ./$(DEPDIR)/netperf.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/netrt_ at NETRTLKUP_SOURCE@.Po \
@@ -271,6 +272,7 @@
distclean-compile:
-rm -f *.tab.c
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/net_uuid.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/netcpu_ at NETCPU_SOURCE@.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/netdrv_ at NETDRVLKUP_SOURCE@.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/netlib.Po at am__quote@
Added: trunk/src/net_uuid.c
===================================================================
--- trunk/src/net_uuid.c (rev 0)
+++ trunk/src/net_uuid.c 2008-10-24 23:46:08 UTC (rev 294)
@@ -0,0 +1,336 @@
+/* what follows is a somewhat stripped-down version of the sample
+ implementation of UUID generation from RFC 4122. */
+
+/*
+** Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc.
+** Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. &
+** Digital Equipment Corporation, Maynard, Mass.
+** Copyright (c) 1998 Microsoft.
+** To anyone who acknowledges that this file is provided "AS IS"
+** without any express or implied warranty: permission to use, copy,
+** modify, and distribute this file for any purpose is hereby
+** granted without fee, provided that the above copyright notices and
+** this notice appears in all source code copies, and that none of
+** the names of Open Software Foundation, Inc., Hewlett-Packard
+** Company, Microsoft, or Digital Equipment Corporation be used in
+** advertising or publicity pertaining to distribution of the software
+** without specific, written prior permission. Neither Open Software
+** Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital
+** Equipment Corporation makes any representations about the
+** suitability of this software for any purpose.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+
+/* set the following to the number of 100ns ticks of the actual
+ resolution of your system's clock */
+#define UUIDS_PER_TICK 1024
+
+#ifdef WIN32
+#include <windows.h>
+#else
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/sysinfo.h>
+#endif
+
+/* system dependent call to get the current system time. Returned as
+ 100ns ticks since UUID epoch, but resolution may be less than
+ 100ns. */
+
+#ifdef WIN32
+#define I64(C) C
+#else
+#define I64(C) C##LL
+#endif
+
+typedef uint64_t uuid_time_t;
+
+typedef struct {
+ char nodeID[6];
+} uuid_node_t;
+
+#undef uuid_t
+typedef struct {
+ uint32_t time_low;
+ uint16_t time_mid;
+ uint16_t time_hi_and_version;
+ uint8_t clock_seq_hi_and_reserved;
+ uint8_t clock_seq_low;
+ uint8_t node[6];
+} uuid_t;
+
+/* some forward declarations. kind of wimpy to do that but heck, we
+ are all friends here right? raj 20081024 */
+static uint16_t true_random(void);
+
+
+
+#ifdef WIN32
+
+static void get_system_time(uuid_time_t *uuid_time)
+{
+ ULARGE_INTEGER time;
+
+ /* NT keeps time in FILETIME format which is 100ns ticks since
+ Jan 1, 1601. UUIDs use time in 100ns ticks since Oct 15, 1582.
+ The difference is 17 Days in Oct + 30 (Nov) + 31 (Dec)
+ + 18 years and 5 leap days. */
+ GetSystemTimeAsFileTime((FILETIME *)&time);
+ time.QuadPart +=
+
+ (unsigned __int64) (1000*1000*10) // seconds
+ * (unsigned __int64) (60 * 60 * 24) // days
+ * (unsigned __int64) (17+30+31+365*18+5); // # of days
+ *uuid_time = time.QuadPart;
+}
+
+/* Sample code, not for use in production; see RFC 1750 */
+static void get_random_info(char seed[16])
+{
+ uint16_t myrand;
+ int i;
+
+ i = 0;
+ do {
+ myrand = true_random();
+ seed[i++] = myrand & 0xff;
+ seed[i++] = myrand >> 8;
+ } while (i < 14);
+
+}
+
+#else
+
+static void get_system_time(uuid_time_t *uuid_time)
+{
+ struct timeval tp;
+
+ gettimeofday(&tp, (struct timezone *)0);
+
+ /* Offset between UUID formatted times and Unix formatted times.
+ UUID UTC base time is October 15, 1582.
+ Unix base time is January 1, 1970.*/
+ *uuid_time = ((uint64_t)tp.tv_sec * 10000000)
+ + ((uint64_t)tp.tv_usec * 10)
+ + I64(0x01B21DD213814000);
+}
+
+/* Sample code, not for use in production; see RFC 1750 */
+static void get_random_info(char seed[16])
+{
+ FILE *fp;
+ uint16_t myrand;
+ int i;
+
+ /* we aren't all that picky, and we would rather not block so we
+ will use urandom */
+ fp = fopen("/dev/urandom","rb");
+
+ if (NULL != fp) {
+ fread(seed,sizeof(seed),1,fp);
+ return;
+ }
+
+ /* ok, now what? */
+
+ i = 0;
+ do {
+ myrand = true_random();
+ seed[i++] = myrand & 0xff;
+ seed[i++] = myrand >> 8;
+ } while (i < 14);
+
+}
+
+#endif
+
+
+/* true_random -- generate a crypto-quality random number.
+**This sample doesn't do that.** */
+static uint16_t true_random(void)
+{
+ static int inited = 0;
+ uuid_time_t time_now;
+
+ if (!inited) {
+ get_system_time(&time_now);
+ time_now = time_now / UUIDS_PER_TICK;
+ srand((unsigned int)
+ (((time_now >> 32) ^ time_now) & 0xffffffff));
+ inited = 1;
+ }
+
+ return rand();
+}
+
+/* puid -- print a UUID */
+void puid(uuid_t u)
+{
+ int i;
+
+ printf("%8.8x-%4.4x-%4.4x-%2.2x%2.2x-", u.time_low, u.time_mid,
+ u.time_hi_and_version, u.clock_seq_hi_and_reserved,
+ u.clock_seq_low);
+ for (i = 0; i < 6; i++)
+ printf("%2.2x", u.node[i]);
+ printf("\n");
+}
+
+/* snpuid -- print a UUID in the supplied buffer */
+void snpuid(char *str, size_t size, uuid_t u) {
+ int i;
+ char *tmp = str;
+
+ if (size < 38) {
+ snprintf(tmp,size,"%s","uuid string too small");
+ return;
+ }
+
+ /* perhaps this is a trifle optimistic but what the heck */
+ sprintf(tmp,
+ "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-",
+ u.time_low,
+ u.time_mid,
+ u.time_hi_and_version,
+ u.clock_seq_hi_and_reserved,
+ u.clock_seq_low);
+ tmp += 24;
+ for (i = 0; i < 6; i++) {
+ sprintf(tmp,"%2.2x", u.node[i]);
+ tmp += 2;
+ }
+ *tmp = 0;
+
+}
+
+/* get-current_time -- get time as 60-bit 100ns ticks since UUID epoch.
+ Compensate for the fact that real clock resolution is
+ less than 100ns. */
+static void get_current_time(uuid_time_t *timestamp)
+{
+ static int inited = 0;
+ static uuid_time_t time_last;
+ static uint16_t uuids_this_tick;
+ uuid_time_t time_now;
+
+ if (!inited) {
+ get_system_time(&time_now);
+ uuids_this_tick = UUIDS_PER_TICK;
+ inited = 1;
+ }
+
+ for ( ; ; ) {
+ get_system_time(&time_now);
+
+ /* if clock reading changed since last UUID generated, */
+ if (time_last != time_now) {
+ /* reset count of uuids gen'd with this clock reading */
+ uuids_this_tick = 0;
+ time_last = time_now;
+ break;
+ }
+ if (uuids_this_tick < UUIDS_PER_TICK) {
+ uuids_this_tick++;
+ break;
+ }
+ /* going too fast for our clock; spin */
+ }
+ /* add the count of uuids to low order bits of the clock reading */
+ *timestamp = time_now + uuids_this_tick;
+}
+
+
+/* system dependent call to get IEEE node ID.
+ This sample implementation generates a random node ID. */
+/* netperf mod - don't bother trying to read or write the nodeid */
+static void get_ieee_node_identifier(uuid_node_t *node)
+{
+ static int inited = 0;
+ static uuid_node_t saved_node;
+ char seed[16];
+
+ if (!inited) {
+ get_random_info(seed);
+ seed[0] |= 0x01;
+ memcpy(&saved_node, seed, sizeof saved_node);
+ }
+ inited = 1;
+
+ *node = saved_node;
+}
+
+
+/* format_uuid_v1 -- make a UUID from the timestamp, clockseq,
+ and node ID */
+static void format_uuid_v1(uuid_t* uuid, uint16_t clock_seq,
+ uuid_time_t timestamp, uuid_node_t node)
+{
+ /* Construct a version 1 uuid with the information we've gathered
+ plus a few constants. */
+ uuid->time_low = (unsigned long)(timestamp & 0xFFFFFFFF);
+ uuid->time_mid = (unsigned short)((timestamp >> 32) & 0xFFFF);
+ uuid->time_hi_and_version =
+ (unsigned short)((timestamp >> 48) & 0x0FFF);
+ uuid->time_hi_and_version |= (1 << 12);
+ uuid->clock_seq_low = clock_seq & 0xFF;
+ uuid->clock_seq_hi_and_reserved = (clock_seq & 0x3F00) >> 8;
+ uuid->clock_seq_hi_and_reserved |= 0x80;
+ memcpy(&uuid->node, &node, sizeof uuid->node);
+}
+
+/* uuid_create -- generator a UUID */
+int uuid_create(uuid_t *uuid)
+{
+ uuid_time_t timestamp;
+ uint16_t clockseq;
+ uuid_node_t node;
+
+ /* get time, node ID, saved state from non-volatile storage */
+ get_current_time(×tamp);
+ get_ieee_node_identifier(&node);
+
+ /* for us clockseq is always to be random as we have no state */
+ clockseq = true_random();
+
+ /* stuff fields into the UUID */
+ format_uuid_v1(uuid, clockseq, timestamp, node);
+ return 1;
+}
+
+void get_uuid_string(char *uuid_str, size_t size) {
+ uuid_t u;
+
+ uuid_create(&u);
+ snpuid(uuid_str,size,u);
+
+ return;
+}
+
+#ifdef NETPERF_STANDALONE_DEBUG
+
+int
+main(int argc, char *argv[])
+{
+ uuid_t u;
+ char uuid_str[38];
+#if 0
+ uuid_create(&u);
+ printf("uuid_create(): "); puid(u);
+ snpuid(uuid_str,sizeof(uuid_str),u);
+ printf("\nas a string %s\n",uuid_str);
+#endif
+ get_uuid_string(uuid_str,sizeof(uuid_str));
+ printf("uuid_str is %s\n",uuid_str);
+ return 0;
+}
+
+
+#endif
Modified: trunk/src/netperf.c
===================================================================
--- trunk/src/netperf.c 2008-10-21 22:57:00 UTC (rev 293)
+++ trunk/src/netperf.c 2008-10-24 23:46:08 UTC (rev 294)
@@ -269,6 +269,9 @@
else if (strcasecmp(test_name,"OMNI") == 0) {
send_omni(host_name);
}
+ else if (strcasecmp(test_name,"UUID") == 0) {
+ print_uuid(host_name);
+ }
#endif
else {
printf("The test you requested is unknown to this netperf.\n");
Modified: trunk/src/netsh.c
===================================================================
--- trunk/src/netsh.c 2008-10-21 22:57:00 UTC (rev 293)
+++ trunk/src/netsh.c 2008-10-24 23:46:08 UTC (rev 294)
@@ -1096,7 +1096,8 @@
#endif
#ifdef WANT_OMNI
- else if ((strcasecmp(test_name,"OMNI") == 0)) {
+ else if ((strcasecmp(test_name,"OMNI") == 0) ||
+ (strcasecmp(test_name,"UUID") == 0)) {
scan_omni_args(argc, argv);
}
#endif
Modified: trunk/src/nettest_bsd.h
===================================================================
--- trunk/src/nettest_bsd.h 2008-10-21 22:57:00 UTC (rev 293)
+++ trunk/src/nettest_bsd.h 2008-10-24 23:46:08 UTC (rev 294)
@@ -598,6 +598,10 @@
extern void send_udp_stream(char remote_host[]);
extern void send_udp_rr(char remote_host[]);
+extern void send_omni(char remote_host[]);
+extern void print_uuid(char remote_host[]);
+extern void recv_omni();
+
extern void recv_tcp_stream();
extern void recv_tcp_maerts();
extern void recv_tcp_rr();
Modified: trunk/src/nettest_omni.c
===================================================================
--- trunk/src/nettest_omni.c 2008-10-21 22:57:00 UTC (rev 293)
+++ trunk/src/nettest_omni.c 2008-10-24 23:46:08 UTC (rev 294)
@@ -317,11 +317,15 @@
#define NETPERF_CC(x) (!(x & NETPERF_XMIT) && !(x & NETPERF_RECV))
+extern void get_uuid_string(char *string, size_t size);
+
/* a boatload of globals while I settle things out */
char *csv_selection_file = NULL;
char *human_selection_file = NULL;
char *keyword_selection_file = NULL;
+char test_uuid[38];
+
double result_confid_pct = -1.0;
double loc_cpu_confid_pct = -1.0;
double rem_cpu_confid_pct = -1.0;
@@ -617,6 +621,7 @@
REMOTE_SECURITY_ENABLED,
REMOTE_SECURITY_SPECIFIC,
RESULT_BRAND,
+ UUID,
COMMAND_LINE,
OUTPUT_END,
NETPERF_OUTPUT_MAX
@@ -763,6 +768,8 @@
return "OUTPUT_NONE";
case COMMAND_LINE:
return "COMMAND_LINE";
+ case UUID:
+ return "UUID";
case RESULT_BRAND:
return "RESULT_BRAND";
case SOCKET_TYPE:
@@ -1409,6 +1416,16 @@
netperf_output_source[COMMAND_LINE].tot_line_len =
NETPERF_LINE_TOT(COMMAND_LINE);
+ netperf_output_source[UUID].output_name = UUID;
+ netperf_output_source[UUID].line[0] = "Test";
+ netperf_output_source[UUID].line[1] = "UUID";
+ netperf_output_source[UUID].format = "%s";
+ netperf_output_source[UUID].display_value = test_uuid;
+ netperf_output_source[UUID].max_line_len =
+ NETPERF_LINE_MAX(UUID);
+ netperf_output_source[UUID].tot_line_len =
+ NETPERF_LINE_TOT(UUID);
+
netperf_output_source[RESULT_BRAND].output_name = RESULT_BRAND;
netperf_output_source[RESULT_BRAND].line[0] = "Result";
netperf_output_source[RESULT_BRAND].line[1] = "Tag";
@@ -3851,6 +3868,17 @@
}
}
+/* brain dead simple way to get netperf to emit a uuid. sadly, by this
+ point we will have already established the control connection but
+ those are the breaks. we do _NOT_ include a trailing newline
+ because we want to be able to use this in a script */
+
+void
+print_uuid(char remote_host[])
+{
+ printf("%s",test_uuid);
+}
+
/* this code is intended to be "the two routines to run them all" for
BSDish sockets. it comes about as part of a desire to shrink the
code footprint of netperf and to avoid having so many blessed
@@ -5655,12 +5683,13 @@
{
-#define OMNI_ARGS "b:cCd:DnNhH:kL:m:M:oOp:P:r:s:S:t:T:Vw:W:46"
+#define OMNI_ARGS "b:cCd:DnNhH:kL:m:M:oOp:P:r:s:S:t:T:u:Vw:W:46"
extern char *optarg; /* pointer to option string */
int c;
-
+ int have_uuid = 0;
+
char
arg1[BUFSIZ], /* argument holders */
arg2[BUFSIZ];
@@ -5941,6 +5970,15 @@
/* set the protocol - aka "Transport" */
protocol = parse_protocol(optarg);
break;
+ case 'u':
+ /* use the supplied string as the UUID for this test. at some
+ point we may want to sanity check the string we are given but
+ for now we won't worry about it */
+ strncpy(test_uuid,optarg,sizeof(test_uuid));
+ /* strncpy may leave us with a string without a null at the end */
+ test_uuid[sizeof(test_uuid) - 1] = 0;
+ have_uuid = 1;
+ break;
case 'W':
/* set the "width" of the user space data */
/* buffer. This will be the number of */
@@ -5973,7 +6011,11 @@
};
}
- socket_type_str = hst_to_str(socket_type);
+ /* generate the UUID for this test if the user has not supplied it */
+ if (!have_uuid)
+ get_uuid_string(test_uuid,sizeof(test_uuid));
+
+
protocol_str = protocol_to_str(protocol);
/* ok, if we have gone through all that, and direction is still
zero, let us see if it needs to be set to something else. */
More information about the netperf-dev
mailing list