[netperf-dev] netperf2 commit notice r404 - trunk/src

raj at netperf.org raj at netperf.org
Tue Jun 28 14:06:06 PDT 2011


Author: raj
Date: 2011-06-28 14:06:06 -0700 (Tue, 28 Jun 2011)
New Revision: 404

Modified:
   trunk/src/netlib.c
   trunk/src/netserver.c
   trunk/src/netsh.c
   trunk/src/nettest_omni.c
Log:
be nice and allow a migrated udp stream test to automagically cap the send size against the maximum udp datagram size of 65535 bytes less headers well at least when over ipv4 with no options

Modified: trunk/src/netlib.c
===================================================================
--- trunk/src/netlib.c	2011-06-28 18:36:06 UTC (rev 403)
+++ trunk/src/netlib.c	2011-06-28 21:06:06 UTC (rev 404)
@@ -3892,23 +3892,21 @@
    }
 }
 
-#define RB_printf printf
-
 void 
 output_row(FILE *fd, char *title, int *row){
   register int i;
   register int j;
   register int base =  HIST_NUM_OF_BUCKET / 10;
   register int sum;
-  RB_printf("%s", title);
+  fprintf(where,"%s", title);
   for(i = 0; i < 10; i++){
     sum = 0;
     for (j = i * base; j <  (i + 1) * base; j++) {
       sum += row[j];
     }
-    RB_printf(": %4d", sum);
+    fprintf(where,": %4d", sum);
   }
-  RB_printf("\n");
+  fprintf(where,"\n");
 }
 
 int
@@ -3935,8 +3933,8 @@
    output_row(stdout, "HUNDRED_MSEC  ", h->hundred_msec);
    output_row(stdout, "UNIT_SEC      ", h->unit_sec);
    output_row(stdout, "TEN_SEC       ", h->ten_sec);
-   RB_printf(">100_SECS: %d\n", h->ridiculous);
-   RB_printf("HIST_TOTAL:      %d\n", h->total);
+   fprintf(where,">100_SECS: %d\n", h->ridiculous);
+   fprintf(where,"HIST_TOTAL:      %d\n", h->total);
 }
 
 /* search buckets for each unit */

Modified: trunk/src/netserver.c
===================================================================
--- trunk/src/netserver.c	2011-06-28 18:36:06 UTC (rev 403)
+++ trunk/src/netserver.c	2011-06-28 21:06:06 UTC (rev 404)
@@ -880,16 +880,16 @@
 
 	/* Initialize the winsock lib ( version 2.2 ) */
 	if ( WSAStartup(MAKEWORD(2,2), &wsa_data) == SOCKET_ERROR ){
-		printf("WSAStartup() failed : %lu\n", GetLastError()) ;
-		return 1 ;
+	  printf("WSAStartup() failed : %lu\n", GetLastError()) ;
+	  return -1 ;
 	}
 #endif /* WIN32 */
 
 	/* Save away the program name */
 	program = (char *)malloc(strlen(argv[0]) + 1);
 	if (program == NULL) {
-		printf("malloc(%d) failed!\n", strlen(argv[0]) + 1);
-		return 1 ;
+	  printf("malloc for program name failed!\n");
+	  return -1 ;
 	}
 	strcpy(program, argv[0]);
 

Modified: trunk/src/netsh.c
===================================================================
--- trunk/src/netsh.c	2011-06-28 18:36:06 UTC (rev 403)
+++ trunk/src/netsh.c	2011-06-28 21:06:06 UTC (rev 404)
@@ -673,8 +673,8 @@
   
   program = (char *)malloc(strlen(argv[0]) + 1);
   if (program == NULL) {
-    printf("malloc(%d) failed!\n", strlen(argv[0]) + 1);
-    exit(1);
+    printf("malloc() to store program name failed!\n");
+    exit(-1);
   }
   strcpy(program, argv[0]);
 
@@ -813,7 +813,7 @@
       }
       if((confidence_level != 95) && (confidence_level != 99)){
 	printf("Only 95%% and 99%% confidence level is supported\n");
-	exit(1);
+	exit(-1);
       }
       if (arg2[0] ) {
 	/* it doesn't make much sense to use convert() here so just

Modified: trunk/src/nettest_omni.c
===================================================================
--- trunk/src/nettest_omni.c	2011-06-28 18:36:06 UTC (rev 403)
+++ trunk/src/nettest_omni.c	2011-06-28 21:06:06 UTC (rev 404)
@@ -4491,6 +4491,30 @@
 
 }
 
+/* choosing the default send size is a trifle more complicated than it
+   used to be as we have to account for different protocol limits */
+
+#define UDP_LENGTH_MAX (0xFFFF - 28)
+
+static int
+choose_send_size(int lss, int protocol) {
+
+  int send_size;
+
+  if (lss > 0) {
+    send_size = lss_size;
+
+#ifdef IPPROTO_UDP
+    if ((protocol == IPPROTO_UDP) && (send_size > UDP_LENGTH_MAX))
+      send_size = UDP_LENGTH_MAX;
+#endif
+  }
+  else {
+    send_size = 4096;
+  }
+  return send_size;
+}
+
 /* 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
@@ -4696,12 +4720,7 @@
 	else {
 	  /* stream test */
 	  if (send_size == 0) {
-	    if (lss_size > 0) {
-	      send_size = lss_size;
-	    }
-	    else {
-	      send_size = 4096;
-	    }
+	    send_size = choose_send_size(lss_size,protocol);
 	  }
 	  if (send_width == 0) 
 	    send_width = (lss_size/send_size) + 1;
@@ -5742,8 +5761,8 @@
       }
     }
     fprintf(where," times\n");
+    HIST_report(time_hist);
     fflush(where);
-    HIST_report(time_hist);
 #endif /* WANT_HISTOGRAM */
 
   }
@@ -5927,8 +5946,7 @@
     }
     else {
       if (omni_request->send_size == -1) {
-	if (lss_size > 0) bytes_to_send = lss_size;
-	else bytes_to_send = 4096;
+	bytes_to_send = choose_send_size(lss_size,omni_request->protocol);
       }
       else bytes_to_send = omni_request->send_size;
       /* set the send_width */
@@ -6828,12 +6846,12 @@
       fprintf(where,
 	      ksink_fmt2,
 	      transport_mss);
-      fflush(where);
+
 #ifdef WANT_HISTOGRAM
       fprintf(where,"\n\nHistogram of time spent in recv() call.\n");
-      fflush(where);
       HIST_report(time_hist);
 #endif /* WANT_HISTOGRAM */
+      fflush(where);
     }
   }
 }
@@ -7067,10 +7085,9 @@
 
 #ifdef WANT_HISTOGRAM
       fprintf(where,"\nHistogram of request/response times\n");
-      fflush(where);
       HIST_report(time_hist);
 #endif /* WANT_HISTOGRAM */
-
+      fflush(where);
     }
   }  
 }
@@ -7163,7 +7180,7 @@
 	}
 
 	fprintf(where,
-		cpu_fmt_1_line_1,		/* the format string */
+		cpu_fmt_1_line_1,	/* the format string */
 		lss_size,		/* local sendbuf size */
 		lsr_size,
 		req_size,		/* how large were the requests */
@@ -7230,18 +7247,16 @@
       fprintf(where,
 	      ksink_fmt,
 	      local_send_align,
-	      remote_recv_offset,
+	      remote_recv_align,
 	      local_send_offset,
 	      remote_recv_offset);
 
 #ifdef WANT_HISTOGRAM
       fprintf(where,"\nHistogram of request/response times\n");
-      fflush(where);
       HIST_report(time_hist);
 #endif /* WANT_HISTOGRAM */
-
+      fflush(where);
     }
-  
   }
 }
 
@@ -7375,14 +7390,13 @@
       }
     }
 
-    fflush(where);
 #ifdef WANT_HISTOGRAM
     if (verbosity > 1) {
       fprintf(where,"\nHistogram of time spent in send() call\n");
-      fflush(where);
       HIST_report(time_hist);
     }
 #endif /* WANT_HISTOGRAM */
+    fflush(where);
   }
 }
 
@@ -7549,7 +7563,6 @@
 	break;
       }
     }
-    fflush(where);
 
     /* it would be a good thing to include information about some of the */
     /* other parameters that may have been set for this test, but at the */
@@ -7568,10 +7581,10 @@
     
 #ifdef WANT_HISTOGRAM
       fprintf(where,"\nHistogram of request/reponse times.\n");
-      fflush(where);
       HIST_report(time_hist);
 #endif /* WANT_HISTOGRAM */
     }
+    fflush(where);
   }
 }
 



More information about the netperf-dev mailing list