]> sjero.net Git - iperf/commitdiff
Support for UDP-Lite in iperf master
authorGerrit Renker <gerrit@erg.abdn.ac.uk>
Tue, 24 Feb 2009 19:52:37 +0000 (20:52 +0100)
committerGerrit Renker <gerrit@erg.abdn.ac.uk>
Tue, 24 Feb 2009 19:52:37 +0000 (20:52 +0100)
Applies on top of the DCCP patch and requires host support for UDP-Lite, which
means two minor changes to header include files.

See Documentation/networking/udplite.txt in the kernel sources (2.6.20 or higher)
on how to set this up.

include/Settings.hpp
include/headers.h
include/version.h
src/Locale.c
src/PerfSocket.cpp
src/Settings.cpp
src/main.cpp

index 0fe99212ca23eed93d34de405d9b2d3ed5802f00..d4c4244be91a669b9ceb6a5352d25e490481372e 100644 (file)
@@ -74,6 +74,7 @@ typedef enum Protocol {
         kProto_TCP     = IPPROTO_TCP,
         kProto_DCCP    = IPPROTO_DCCP,
         kProto_UDP     = IPPROTO_UDP,
+        kProto_UDPLITE = IPPROTO_UDPLITE,
 } Protocol;
 
 static inline const char *protoName(const unsigned proto)
@@ -82,6 +83,7 @@ static inline const char *protoName(const unsigned proto)
        case kProto_TCP:     return "TCP";
        case kProto_DCCP:    return "DCCP";
        case kProto_UDP:     return "UDP";
+       case kProto_UDPLITE: return "UDP-Lite";
        default:             return "(unknown)";
        }
 }
@@ -90,6 +92,7 @@ static inline unsigned sockType(const Protocol p)
 {
        switch (p) {
        case kProto_TCP:        return SOCK_STREAM;
+       case kProto_UDPLITE:    /* fall through */
        case kProto_UDP:        return SOCK_DGRAM;
        case kProto_DCCP:       return SOCK_DCCP;
        }
@@ -97,7 +100,7 @@ static inline unsigned sockType(const Protocol p)
 
 static inline bool is_connectionless(const Protocol p)
 {
-       return p == kProto_UDP;
+       return p == kProto_UDP || p == kProto_UDPLITE;
 }
 
 // server/client mode
@@ -198,6 +201,7 @@ typedef struct thread_Settings {
     // chars
     char   mFormat;                 // -f
     int    mTTL;                    // -T
+    int    cscov;                   // -u (partial csums)
     char  *congAlgo;                // -A
     char pad1[2];
     // structs or miscellaneous
index 0ef1c2e231e53d1faa1da290fc0f5df528baf65f..05d05c3c50ef553fd162a386414f90188d3dd009 100644 (file)
@@ -163,4 +163,15 @@ typedef uintmax_t max_size_t;
 #ifndef SOL_DCCP
 #define SOL_DCCP       269     /* include/linux/socket.h */
 #endif
+
+/* UDP-Lite specific definitions and includes */
+#ifdef IPPROTO_UDPLITE
+#include <netinet/udplite.h>
+#else
+#define IPPROTO_UDPLITE       136
+#define SOL_UDPLITE           136
+
+#define UDPLITE_SEND_CSCOV     10
+#define UDPLITE_RECV_CSCOV     11
+#endif
 #endif /* HEADERS_H */
index 1e659138bde8d49ef616f5ce8833be4c337bc9f2..ccfa57b024ac23a4a5e4c4a3cb7552a925a54566 100644 (file)
@@ -1,2 +1,2 @@
-#define IPERF_VERSION "2.0.2 with support for DCCP and TCP CC"
+#define IPERF_VERSION "2.0.2 with support for DCCP, UDP-Lite, and TCP CC"
 #define IPERF_VERSION_DATE "20th Jan 2009"
index cc025220629dd40a48e1a50ca7f352c9c784532a..cd05ba539762f7b6099c0fd7b034d698e70c0b29 100644 (file)
@@ -78,8 +78,9 @@ Client/Server:\n\
   -l, --len       #[KM]    length of buffer to read or write (default 8 KB)\n\
   -m, --print_mss          print TCP maximum segment size (MTU - TCP/IP header)\n\
   -p, --port      #        server port to listen on/connect to\n\
-  -u, --udp                use UDP as transport protocol\n\
-  -d, --dccp               use DCCP as transport protocol\n\
+  -u, --udp                use UDP      as transport; no argument may follow\n\
+  -u  --udplite   #        use UDP-Lite as transport; arg: cscov (0=full coverage)\n\
+  -d, --dccp               use DCCP     as transport\n\
   -w, --window    #[KM]    TCP window size (socket buffer size)\n\
   -A, --algorithm          set TCP congestion control algorithm\n\
   -B, --bind      <host>   bind to <host>, an interface or multicast address\n\
@@ -94,7 +95,7 @@ Server specific:\n\
   -D, --daemon             run the server as a daemon\n\
 \n\
 Client specific:\n\
-  -b, --bandwidth #[KM]    for UDP/DCCP, bandwidth to send at in bits/sec\n\
+  -b, --bandwidth #[KM]    for UDP(-Lite)/DCCP, bandwidth to send at in bits/sec\n\
                            (default 1 Mbit/sec, implies -u)\n\
   -c, --client    <host>   run in client mode, connecting to <host>\n\
   -2, --dualtest           Do a bidirectional test simultaneously\n\
index 63e97ff9480b4405fe98f770498a3a2c0e67dcce..1c3a779731f692aad66f50072cdf991579557939 100644 (file)
@@ -157,6 +157,18 @@ void SetSocketOptions( thread_Settings *inSettings )
                          &val, len );
         WARN_errno( rc == SOCKET_ERROR, "setsockopt DCCP_SOCKOPT_SERVICE" );
     }
+    //  UDP-Lite specific options
+    if ( inSettings->mProtocol == kProto_UDPLITE ) {
+        /* we set the checksum coverage for both directions */
+        rc = setsockopt(inSettings->mSock, IPPROTO_UDPLITE, UDPLITE_SEND_CSCOV,
+                        &inSettings->cscov, len);
+        WARN_errno(rc == SOCKET_ERROR, "setsockopt UDPLITE_SEND_CSCOV");
+
+        rc = setsockopt(inSettings->mSock, IPPROTO_UDPLITE, UDPLITE_RECV_CSCOV,
+                        &inSettings->cscov, len);
+
+        WARN_errno(rc == SOCKET_ERROR, "setsockopt UDPLITE_RECV_CSCOV");
+    }
 
     // reuse the address, so we can run if a former server was killed off
     if (inSettings->mThreadMode == kMode_Listener) {
index 15b5ccd532b5a88605f40a8d96798f722f4500bf..3cb619faf3bd36ef257ec383b94f0cb8e153beb2 100644 (file)
@@ -101,6 +101,7 @@ const struct option long_options[] =
 {"server",           no_argument, NULL, 's'},
 {"time",       required_argument, NULL, 't'},
 {"udp",              no_argument, NULL, 'u'},
+{"udplite",    required_argument, NULL, 'u'},
 {"version",          no_argument, NULL, 'v'},
 {"window",     required_argument, NULL, 'w'},
 {"reportexclude", required_argument, NULL, 'x'},
@@ -174,7 +175,7 @@ const struct option env_options[] =
 #define SHORT_OPTIONS()
 
 const char short_options[] =
-      "12b::c:df:hi:j:l:mn:o:p:rst:uvw:x:y:A:B:CDF:IJ:L:M:NP:RS:T:UV:W";
+      "12b::c:df:hi:j:l:mn:o:p:rst:u::vw:x:y:A:B:CDF:IJ:L:M:NP:RS:T:UV:W";
 
 /* -------------------------------------------------------------------
  * defaults
@@ -472,8 +473,16 @@ void Settings_Interpret( char option, const char *optarg, thread_Settings *mExtS
             mExtSettings->mAmount = (int) (atof( optarg ) * 100.0);
             break;
 
-        case 'u': // UDP instead of TCP
-            mExtSettings->mProtocol = kProto_UDP;
+        case 'u': // UDP(-Lite) instead of TCP
+             if (optarg) {
+                mExtSettings->mProtocol = kProto_UDPLITE;
+                // Set partial checksum coverage:
+                // - 0 means entire datagram,
+                // - 1..7 is illegal and will be rounded up to 8;
+                // - 8 and greater mean genuine partial coverage.
+                mExtSettings->cscov = atoi(optarg);
+             } else
+                mExtSettings->mProtocol = kProto_UDP;
 
             setPacketOriented(mExtSettings);
             // if -b has already been processed, UDP rate will
index a69fd0ef91e1c3bdbffea4154f0f0940b687ddb0..d15e5a811c6d3aa20063b1aaa8efa0a7038fc681 100644 (file)
@@ -149,6 +149,7 @@ int main( int argc, char **argv ) {
 
     if (isPacketOriented(ext_gSettings) &&
         !(ext_gSettings->mProtocol == kProto_UDP ||
+          ext_gSettings->mProtocol == kProto_UDPLITE ||
           ext_gSettings->mProtocol == kProto_DCCP      ))
             die("Can't use packet-oriented mode with these settings.");