Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 Jun 2010 15:27:08 +0000 (UTC)
From:      Robert Watson <rwatson@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r208873 - head/tools/tools/netrate/tcpp
Message-ID:  <201006061527.o56FR857080148@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rwatson
Date: Sun Jun  6 15:27:08 2010
New Revision: 208873
URL: http://svn.freebsd.org/changeset/base/208873

Log:
  Rework tcpp output so that it generates a comma-delimited list of values,
  optionally with a header if "-h" is passed.  Toast CPU time measurement
  in the server for now.  Remove -C and -T, since we now always report
  both connections/sec and Gb/sec.
  
  MFC after:	1 week
  Sponsored by:	Juniper Networks

Modified:
  head/tools/tools/netrate/tcpp/tcpp.c
  head/tools/tools/netrate/tcpp/tcpp.h
  head/tools/tools/netrate/tcpp/tcpp_client.c
  head/tools/tools/netrate/tcpp/tcpp_server.c

Modified: head/tools/tools/netrate/tcpp/tcpp.c
==============================================================================
--- head/tools/tools/netrate/tcpp/tcpp.c	Sun Jun  6 14:31:41 2010	(r208872)
+++ head/tools/tools/netrate/tcpp/tcpp.c	Sun Jun  6 15:27:08 2010	(r208873)
@@ -51,7 +51,7 @@
 
 struct sockaddr_in remoteip; 		/* Base target address. */
 struct sockaddr_in localipbase;		/* Base local address, if -l. */
-int cflag, lflag, mflag, pflag, sflag, tflag, Cflag, Mflag, Pflag, Tflag;
+int cflag, hflag, lflag, mflag, pflag, sflag, tflag, Mflag, Pflag;
 uint64_t bflag;
 u_short rflag;
 
@@ -61,7 +61,8 @@ usage(void)
 
 	fprintf(stderr, "client: tcpp"
 	    " -c remoteIP"
-	    " [-CPT]"
+	    " [-h]"
+	    " [-P]"
 	    " [-M localIPcount]"
 	    " [-l localIPbase]"
 	    "\n\t"
@@ -76,7 +77,7 @@ usage(void)
 
 	fprintf(stderr, "server: tcpp"
 	    " -s"
-	    " [-PT]"
+	    " [-P]"
 	    " [-l localIPbase]"
 	    " [-m maxtcpsatonce]"
 	    " [-p procs]"
@@ -112,7 +113,7 @@ main(int argc, char *argv[])
 	rflag = BASEPORT_DEFAULT;
 	tflag = TCPS_DEFAULT;
 	Mflag = 1;
-	while ((ch = getopt(argc, argv, "b:c:l:m:p:r:st:CM:PT")) != -1) {
+	while ((ch = getopt(argc, argv, "b:c:hl:m:p:r:st:CM:PT")) != -1) {
 		switch (ch) {
 		case 'b':
 			ll = strtoll(optarg, &dummy, 10);
@@ -127,6 +128,10 @@ main(int argc, char *argv[])
 				err(-1, "inet_aton: %s", optarg);
 			break;
 
+		case 'h':
+			hflag++;
+			break;
+
 		case 'l':
 			lflag++;
 			if (inet_aton(optarg, &localipbase.sin_addr) != 1)
@@ -165,10 +170,6 @@ main(int argc, char *argv[])
 			tflag = ll;
 			break;
 
-		case 'C':
-			Cflag++;
-			break;
-
 		case 'M':
 			ll = strtoll(optarg, &dummy, 10);
 			if (*dummy != '\0' || ll <= 1)
@@ -184,10 +185,6 @@ main(int argc, char *argv[])
 			errx(EX_USAGE, "-P current unsupported");
 #endif
 
-		case 'T':
-			Tflag++;
-			break;
-
 		default:
 			usage();
 		}
@@ -204,7 +201,7 @@ main(int argc, char *argv[])
 		usage();
 
 	/* Several flags are valid only on the client, disallow if server. */
-	if (sflag && (Cflag || Mflag > 1))
+	if (sflag && (hflag || Mflag > 1))
 		usage();
 
 	if (cflag)

Modified: head/tools/tools/netrate/tcpp/tcpp.h
==============================================================================
--- head/tools/tools/netrate/tcpp/tcpp.h	Sun Jun  6 14:31:41 2010	(r208872)
+++ head/tools/tools/netrate/tcpp/tcpp.h	Sun Jun  6 15:27:08 2010	(r208873)
@@ -30,8 +30,8 @@
 #define	TCPP_H
 
 extern struct sockaddr_in localipbase, remoteip;
-extern int cflag, lflag, mflag, pflag, sflag, tflag;
-extern int Cflag, Iflag, Mflag, Pflag, Tflag;
+extern int cflag, hflag, lflag, mflag, pflag, sflag, tflag;
+extern int Iflag, Mflag, Pflag;
 extern uint64_t bflag;
 extern u_short rflag;
 

Modified: head/tools/tools/netrate/tcpp/tcpp_client.c
==============================================================================
--- head/tools/tools/netrate/tcpp/tcpp_client.c	Sun Jun  6 14:31:41 2010	(r208872)
+++ head/tools/tools/netrate/tcpp/tcpp_client.c	Sun Jun  6 15:27:08 2010	(r208873)
@@ -1,7 +1,11 @@
 /*-
  * Copyright (c) 2008-2009 Robert N. M. Watson
+ * Copyright (c) 2010 Juniper Networks, Inc.
  * All rights reserved.
  *
+ * This software was developed by Robert N. M. Watson under contract
+ * to Juniper Networks, Inc.
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -337,33 +341,37 @@ tcpp_client(void)
 	if (failed)
 		errx(-1, "Too many errors");
 
-	printf("%jd bytes transferred in %jd.%09jd seconds\n", 
-	    (bflag * tflag * pflag), (intmax_t)ts_finish.tv_sec,
+	if (hflag)
+		printf("bytes,seconds,conn/s,Gb/s,user%%,nice%%,sys%%,"
+		    "intr%%,idle%%\n");
+
+	/*
+	 * Configuration parameters.
+	 */
+	printf("%jd,", bflag * tflag * pflag);
+	printf("%jd.%09jd,", (intmax_t)ts_finish.tv_sec,
 	    (intmax_t)(ts_finish.tv_nsec));
 
-	if (Tflag)
-		printf("%d procs ", pflag);
-	if (Cflag) {
-		printf("%f cps%s", (double)(pflag * tflag)/
-		    (ts_finish.tv_sec + ts_finish.tv_nsec * 1e-9),
-		    Tflag ? " " : "\n");
-	} else {
-		printf("%f Gbps%s", (double)(bflag * tflag * pflag * 8) /
-		    (ts_finish.tv_sec + ts_finish.tv_nsec * 1e-9) * 1e-9,
-		    Tflag ? " " : "\n");
-	}
-	if (Tflag) {
-		ticks = 0;
-		for (i = 0; i < CPUSTATES; i++) {
-			cp_time_finish[i] -= cp_time_start[i];
-			ticks += cp_time_finish[i];
-		}
-		printf("user%% %lu nice%% %lu sys%% %lu intr%% %lu "
-		    "idle%% %lu\n",
-		    (100 * cp_time_finish[CP_USER]) / ticks,
-		    (100 * cp_time_finish[CP_NICE]) / ticks,
-		    (100 * cp_time_finish[CP_SYS]) / ticks,
-		    (100 * cp_time_finish[CP_INTR]) / ticks,
-		    (100 * cp_time_finish[CP_IDLE]) / ticks);
+	/*
+	 * Effective transmit rates.
+	 */
+	printf("%f,", (double)(pflag * tflag)/
+	    (ts_finish.tv_sec + ts_finish.tv_nsec * 1e-9));
+	printf("%f,", (double)(bflag * tflag * pflag * 8) /
+	    (ts_finish.tv_sec + ts_finish.tv_nsec * 1e-9) * 1e-9);
+
+	/*
+	 * CPU time (est).
+	 */
+	ticks = 0;
+	for (i = 0; i < CPUSTATES; i++) {
+		cp_time_finish[i] -= cp_time_start[i];
+		ticks += cp_time_finish[i];
 	}
+	printf("%0.02f,", (float)(100 * cp_time_finish[CP_USER]) / ticks);
+	printf("%0.02f,", (float)(100 * cp_time_finish[CP_NICE]) / ticks);
+	printf("%0.02f,", (float)(100 * cp_time_finish[CP_SYS]) / ticks);
+	printf("%0.02f,", (float)(100 * cp_time_finish[CP_INTR]) / ticks);
+	printf("%0.02f", (float)(100 * cp_time_finish[CP_IDLE]) / ticks);
+	printf("\n");
 }

Modified: head/tools/tools/netrate/tcpp/tcpp_server.c
==============================================================================
--- head/tools/tools/netrate/tcpp/tcpp_server.c	Sun Jun  6 14:31:41 2010	(r208872)
+++ head/tools/tools/netrate/tcpp/tcpp_server.c	Sun Jun  6 15:27:08 2010	(r208873)
@@ -277,8 +277,10 @@ tcpp_server_worker(int workernum)
 void
 tcpp_server(void)
 {
+#if 0
 	long cp_time_last[CPUSTATES], cp_time_now[CPUSTATES], ticks;
 	size_t size;
+#endif
 	pid_t pid;
 	int i;
 
@@ -307,7 +309,7 @@ tcpp_server(void)
 		pid_list[i] = pid;
 	}
 
-	if (Tflag) {
+#if 0
 		size = sizeof(cp_time_last);
 		if (sysctlbyname(SYSCTLNAME_CPTIME, &cp_time_last, &size,
 		    NULL, 0) < 0)
@@ -334,7 +336,7 @@ tcpp_server(void)
 			    (100 * cp_time_last[CP_IDLE]) / ticks);
 			bcopy(cp_time_now, cp_time_last, sizeof(cp_time_last));
 		}
-	}
+#endif
 
 	/*
 	 * GC workers.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201006061527.o56FR857080148>