[netperf-talk] [RFC][PATCH] Fix throughput calculation errors for mixed endian IEEE floating point machines

George G. Davis davis_g at comcast.net
Mon Feb 27 09:54:05 PST 2006


Greetings,

Although this "netperf reporting 0 bytes/s" issue was recently discussed
on this list and it sounds like the preferred solution is to migrate
netperf to use of 64-bit integers rather than double floats, I had been
looking into this issue before reading that thread and came up with the
following (interim : ) work around for this issue.

Some little endian ARM machines use mixed endian IEEE double floating
point format and report incorrect throughput when netserver/netperf is
used between same and non-ARM host machines.  This patch swaps the order
of double floating point words in htond() and ntohd() (when required)
such that the double floating point format is correct for the host/target
system and throughput is correctly reported.


Index: netperf-2.4.1/src/netlib.c
===================================================================
--- netperf-2.4.1.orig/src/netlib.c
+++ netperf-2.4.1/src/netlib.c
@@ -69,6 +69,7 @@ char    netlib_id[]="\
 #include <math.h>
 #include <string.h>
 #include <assert.h>
+#include <endian.h>
 
 
 #ifndef WIN32
@@ -547,6 +548,15 @@ ntohd(double net_double)
     conv_rec.bytes[7-i] = scratch;
   }
   
+#if __FLOAT_WORD_ORDER != __BYTE_ORDER
+  {
+    /* Fixup mixed endian floating point machines */
+    unsigned int scratch = conv_rec.words[0];
+    conv_rec.words[0] = conv_rec.words[1];
+    conv_rec.words[1] = scratch;
+  }
+#endif
+
   return(conv_rec.whole_thing);
   
 }
@@ -581,6 +591,15 @@ htond(double host_double)
     conv_rec.bytes[7-i] = scratch;
   }
   
+#if __FLOAT_WORD_ORDER != __BYTE_ORDER
+  {
+    /* Fixup mixed endian floating point machines */
+    unsigned int scratch = conv_rec.words[0];
+    conv_rec.words[0] = conv_rec.words[1];
+    conv_rec.words[1] = scratch;
+  }
+#endif
+
   /* we know that in the message passing routines htonl will */
   /* be called on the 32 bit quantities. we need to set things up so */
   /* that when this happens, the proper order will go out on the */



Here are the results of running `netperf -H <host> -t TCP_STREAM -- -m 1024`
without the above workaround between ARM and x86 machines:

[ARM]# /usr/local/bin/netperf -H 192.168.1.100 -t TCP_STREAM -- -m 1024
TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.1.100 (192.168.1.100) port 0 AF_INET
Recv   Send    Send
Socket Socket  Message  Elapsed
Size   Size    Size     Time     Throughput
bytes  bytes   bytes    secs.    10^6bits/sec

 87380  16384   1024    10.09       0.00

[x86]# /usr/local/bin/netperf -H 192.168.1.94 -t TCP_STREAM -- -m 1024
TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.1.94 (192.168.1.94) port 0 AF_INET
Recv   Send    Send
Socket Socket  Message  Elapsed
Size   Size    Size     Time     Throughput
bytes  bytes   bytes    secs.    10^6bits/sec

 87380  16384   1024    10.08       0.00


Here are the results of running `netperf -H <host> -t TCP_STREAM -- -m 1024`
with the above workaround between ARM and x86 machines:

[ARM]# /usr/local/bin/netperf -H 192.168.1.100 -t TCP_STREAM -- -m 1024
TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.1.100 (192.168.1.100) port 0 AF_INET
Recv   Send    Send
Socket Socket  Message  Elapsed
Size   Size    Size     Time     Throughput
bytes  bytes   bytes    secs.    10^6bits/sec

 87380  16384   1024    10.06       6.64

[x86]# /usr/local/bin/netperf -H 192.168.1.94 -t TCP_STREAM -- -m 1024
TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.1.94 (192.168.1.94) port 0 AF_INET
Recv   Send    Send
Socket Socket  Message  Elapsed
Size   Size    Size     Time     Throughput
bytes  bytes   bytes    secs.    10^6bits/sec

 87380  16384   1024    10.07       6.89


Please apply if this is an acceptable interim work around until such time
as netperf migrates to use of 64-bit integers.

Comments/feedback appreciated.

TIA!

--
Regards,
George


More information about the netperf-talk mailing list