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

raj at netperf.org raj at netperf.org
Tue Jan 15 16:56:29 PST 2008


Author: raj
Date: 2008-01-15 16:56:28 -0800 (Tue, 15 Jan 2008)
New Revision: 167

Modified:
   trunk/src/netlib.c
   trunk/src/netlib.h
   trunk/src/nettest_omni.c
Log:
omni rudimentary UDP stream and rr appears to work

Modified: trunk/src/netlib.c
===================================================================
--- trunk/src/netlib.c	2008-01-15 23:26:14 UTC (rev 166)
+++ trunk/src/netlib.c	2008-01-16 00:56:28 UTC (rev 167)
@@ -2502,6 +2502,34 @@
 
 
 void
+get_sock_buffer (SOCKET sd, enum sock_buffer which, int *effective_sizep)
+{
+#ifdef SO_SNDBUF
+  int optname = (which == SEND_BUFFER) ? SO_SNDBUF : SO_RCVBUF;
+  netperf_socklen_t sock_opt_len;
+
+  sock_opt_len = sizeof(*effective_sizep);
+  if (getsockopt(sd, SOL_SOCKET, optname, (char *)effective_sizep,
+		 &sock_opt_len) < 0) {
+    fprintf(where, "netperf: get_sock_buffer: getsockopt %s: errno %d\n",
+	    (which == SEND_BUFFER) ? "SO_SNDBUF" : "SO_RCVBUF", errno);
+    fflush(where);
+    *effective_sizep = -1;
+  }
+
+  if (debug) {
+    fprintf(where, "netperf: get_sock_buffer: "
+	    "%s socket size determined to be %d\n",
+	    (which == SEND_BUFFER) ? "send" : "receive", *effective_sizep);
+    fflush(where);
+  }
+
+#else
+  *effective_sizep = -1;
+#endif
+}
+
+void
 set_sock_buffer (SOCKET sd, enum sock_buffer which, int requested_size, int *effective_sizep)
 {
 #ifdef SO_SNDBUF
@@ -2531,25 +2559,13 @@
     }
   }
 
-  /* Now, we will find-out what the size actually became, and report */
-  /* that back to the user. If the call fails, we will just report a -1 */
-  /* back to the initiator for the recv buffer size. */
+  /* the getsockopt() call that used to be here has been hoisted into
+     its own routine to be used on those platforms where the socket
+     buffer sizes might change from the beginning to the end of the
+     run. raj 2008-01-15 */
 
-  sock_opt_len = sizeof(netperf_socklen_t);
-  if (getsockopt(sd, SOL_SOCKET, optname, (char *)effective_sizep,
-		 &sock_opt_len) < 0) {
-    fprintf(where, "netperf: set_sock_buffer: getsockopt %s: errno %d\n",
-	    (which == SEND_BUFFER) ? "SO_SNDBUF" : "SO_RCVBUF", errno);
-    fflush(where);
-    *effective_sizep = -1;
-  }
+  get_sock_buffer(sd, which, effective_sizep);
 
-  if (debug) {
-    fprintf(where, "netperf: set_sock_buffer: "
-	    "%s socket size determined to be %d\n",
-	    (which == SEND_BUFFER) ? "send" : "receive", *effective_sizep);
-    fflush(where);
-  }
 #else /* SO_SNDBUF */
   *effective_size = -1;
 #endif /* SO_SNDBUF */

Modified: trunk/src/netlib.h
===================================================================
--- trunk/src/netlib.h	2008-01-15 23:26:14 UTC (rev 166)
+++ trunk/src/netlib.h	2008-01-16 00:56:28 UTC (rev 167)
@@ -489,6 +489,9 @@
 			  float *local_service_demand,
 			  float *remote_service_demand);
 extern  void    display_confidence();
+extern  void    get_sock_buffer(SOCKET sd,
+				enum sock_buffer which,
+				int *effective_sizep);
 extern  void    set_sock_buffer(SOCKET sd,
 				enum sock_buffer which,
 				int requested_size,

Modified: trunk/src/nettest_omni.c
===================================================================
--- trunk/src/nettest_omni.c	2008-01-15 23:26:14 UTC (rev 166)
+++ trunk/src/nettest_omni.c	2008-01-16 00:56:28 UTC (rev 167)
@@ -1048,6 +1048,19 @@
     /* if this is a connection test, we want to do some stuff about
        connection close here in the test loop. raj 2008-01-08 */
     if (connection_test) {
+
+#ifdef __linux
+      /* so, "Linux" with autotuning likes to alter the socket buffer
+	 sizes over the life of the connection, but only does so when
+	 one takes the defaults at time of socket creation.  if we
+	 took those defaults, we should inquire as to what the values
+	 ultimately became. raj 2008-01-15 */
+      if (lsr_size_req < 0)
+	get_sock_buffer(data_socket, RECV_BUFFER, &lsr_size_end);
+      if (lss_size_req < 0)
+	get_sock_buffer(data_socket, SEND_BUFFER, &lss_size_end);
+#endif
+
       ret = disconnect_data_socket(data_socket,
 				   (no_control) ? 1 : 0,
 				   1);
@@ -1104,11 +1117,18 @@
   fflush(where);
 
   if (connected) {
-    /* before we do close the connection, we may want to retrieve some
-       of the socket parameters - Linux, thanks to its autotuning, can
-       have the final socket buffer sizes different from the initial
-       socket buffer sizes.  isn't that nice.  raj 2008-01-08 */
-    /* FILL THIS IN; */
+
+#ifdef __linux
+    /* so, "Linux" with autotuning likes to alter the socket buffer
+       sizes over the life of the connection, but only does so when
+       one takes the defaults at time of socket creation.  if we took
+       those defaults, we should inquire as to what the values
+       ultimately became. raj 2008-01-15 */
+    if (lsr_size_req < 0)
+      get_sock_buffer(data_socket, RECV_BUFFER, &lsr_size_end);
+    if (lss_size_req < 0)
+      get_sock_buffer(data_socket, SEND_BUFFER, &lss_size_end);
+#endif
     /* CHECK PARMRS HERE; */
     ret = disconnect_data_socket(data_socket,
 				 1,
@@ -1167,6 +1187,24 @@
 	 omni_result->trans_received,
 	 elapsed_time);
 
+  printf("lss_size_req %d lsr_size_req %d rss_size_req %d rsr_size_req %d\n",
+	 lss_size_req,
+	 lsr_size_req,
+	 rss_size_req,
+	 rsr_size_req);
+
+  printf("lss_size %d lsr_size %d rss_size %d rsr_size %d\n",
+	 lss_size,
+	 lsr_size,
+	 rss_size,
+	 rsr_size);
+
+  printf("lss_size_end %d lsr_size_end %d rss_size_end %d rsr_size_end %d\n",
+	 lss_size_end,
+	 lsr_size_end,
+	 rss_size_end,
+	 rsr_size_end);
+
   if (local_cpu_usage || remote_cpu_usage) {
     /* We must now do a little math for service demand and cpu */
     /* utilization for the system(s) */
@@ -1579,6 +1617,10 @@
 #endif /* KLUDGE_SOCKET_OPTIONS */
   
     }
+    else {
+      /* I wonder if duping would be better here? */
+      data_socket = s_listen;
+    }
 
     fprintf(where,"one  direction %x\n",omni_request->direction);
     fflush(where);
@@ -1710,6 +1752,17 @@
     }
 
     if (connection_test) {
+#ifdef __linux
+      /* so, "Linux" with autotuning likes to alter the socket buffer
+	 sizes over the life of the connection, but only does so when
+	 one takes the defaults at time of socket creation.  if we
+	 took those defaults, we should inquire as to what the values
+	 ultimately became. raj 2008-01-15 */
+      if (lsr_size_req < 0)
+	get_sock_buffer(data_socket, RECV_BUFFER, &lsr_size_end);
+      if (lss_size_req < 0)
+	get_sock_buffer(data_socket, SEND_BUFFER, &lss_size_end);
+#endif
       ret = close_data_socket(data_socket);
       if (ret < 0) {
 	perror("netperf: send_omni: disconnect_data_socket failed");
@@ -1750,15 +1803,29 @@
   }
 
   if (connected) {
+#ifdef __linux
+    /* so, "Linux" with autotuning likes to alter the socket buffer
+       sizes over the life of the connection, but only does so when
+       one takes the defaults at time of socket creation.  if we took
+       those defaults, we should inquire as to what the values
+       ultimately became. raj 2008-01-15 */
+    if (lsr_size_req < 0)
+      get_sock_buffer(data_socket, RECV_BUFFER, &lsr_size_end);
+    if (lss_size_req < 0)
+      get_sock_buffer(data_socket, SEND_BUFFER, &lss_size_end);
+#endif
     close_data_socket(data_socket);
   }
 
   /* send the results to the sender  */
   
   omni_results->bytes_received	= bytes_received;
+  omni_results->recv_buf_size   = lsr_size_end;
   omni_results->bytes_sent      = bytes_sent;
+  omni_results->send_buf_size   = lss_size_end;
   omni_results->trans_received	= trans_completed;
   omni_results->elapsed_time	= elapsed_time;
+
   if (omni_request->measure_cpu) {
     omni_results->cpu_util	= calc_cpu_util(elapsed_time);
   }



More information about the netperf-dev mailing list