]> sjero.net Git - iperf/blobdiff - src/ReportDefault.c
TCP Congestion Control Module via options
[iperf] / src / ReportDefault.c
index a3ecc979060091c31dc30242c9cbd946668ce274..150df1069d333e5c12557cae9636edf870262580 100644 (file)
@@ -140,6 +140,17 @@ void reporter_serverstats( Connection_Info *nused, Transfer_Info *stats ) {
     reporter_printstats( stats );
 }
 
+static char *McastIface(const unsigned if_index)
+{
+       static char ifnam[IF_NAMESIZE];
+
+       if (!if_index)
+               return "default interface";
+       if (if_indextoname(if_index, ifnam))
+               return ifnam;
+       return "unknown interface";
+}
+
 /*
  * Report the client or listener Settings in default style
  */
@@ -162,19 +173,18 @@ void reporter_reportsettings( ReporterData *data ) {
                 data->mPort );
     }
     if ( data->mLocalhost != NULL ) {
-        printf( bind_address, data->mLocalhost );
-        if ( SockAddr_isMulticast( &data->connection.local ) ) {
-            printf( join_multicast, data->mLocalhost );
-        }
+        if (SockAddr_isMulticast((struct sockaddr *)&data->connection.local))
+            printf(join_multicast, data->mLocalhost, McastIface(data->mMcastIface));
+       else
+           printf(bind_address, data->mLocalhost);
     }
 
     if ( isPacketOriented( data ) ) {
         printf( (data->mThreadMode == kMode_Listener ? 
                  server_datagram_size : client_datagram_size),
                 data->mBufLen );
-        if ( SockAddr_isMulticast( &data->connection.peer ) ) {
+        if (SockAddr_isMulticast((struct sockaddr *)&data->connection.peer))
             printf( multicast_ttl, data->info.mTTL);
-        }
     } else if (data->mProtocol == kProto_DCCP)
             printf("NOTE: running in bytestream-mode (maximum speed)\n");
 
@@ -194,62 +204,44 @@ void reporter_reportsettings( ReporterData *data ) {
         printf( warn_window_requested, buffer );
     }
     printf( "\n" );
+
+    if (data->mProtocol == kProto_TCP) {
+        char *cong_requested = data->info.congAlgo,
+              cong[64];
+        Socklen_t len = sizeof(cong);
+
+        if (getsockopt(data->info.transferID, IPPROTO_TCP, TCP_CONGESTION, cong, &len) < 0) {
+            fprintf(stderr, "WARNING: cannot determine TCP congestion control algorithm  (err: %d %s)\n",
+                           errno, strerror(errno));
+        } else {
+            printf("TCP congestion control algorithm: %s", cong[0] == '\0' ? "default" : cong);
+
+          if (data->info.congAlgo && strcmp(cong, data->info.congAlgo))
+            printf(" (NOT \"%s\"!)", data->info.congAlgo);
+          printf("\n");
+        }
+    }
+
     printf( seperator_line );
 }
 
 /*
  * Report a socket's peer IP address in default style
  */
-void *reporter_reportpeer( Connection_Info *stats, int ID ) {
-    if ( ID > 0 ) {
-        // copy the inet_ntop into temp buffers, to avoid overwriting
-        char local_addr[ REPORT_ADDRLEN ];
-        char remote_addr[ REPORT_ADDRLEN ];
-        struct sockaddr *local = ((struct sockaddr*)&stats->local);
-        struct sockaddr *peer = ((struct sockaddr*)&stats->peer);
-    
-        if ( local->sa_family == AF_INET ) {
-            inet_ntop( AF_INET, &((struct sockaddr_in*)local)->sin_addr, 
-                       local_addr, REPORT_ADDRLEN);
-        }
-#ifdef HAVE_IPV6
-          else {
-            inet_ntop( AF_INET6, &((struct sockaddr_in6*)local)->sin6_addr, 
-                       local_addr, REPORT_ADDRLEN);
-        }
-#endif
-    
-        if ( peer->sa_family == AF_INET ) {
-            inet_ntop( AF_INET, &((struct sockaddr_in*)peer)->sin_addr, 
-                       remote_addr, REPORT_ADDRLEN);
-        }
-#ifdef HAVE_IPV6
-          else {
-            inet_ntop( AF_INET6, &((struct sockaddr_in6*)peer)->sin6_addr, 
-                       remote_addr, REPORT_ADDRLEN);
-        }
-#endif
-    
-        printf( report_peer,
-                ID,
-                local_addr,  ( local->sa_family == AF_INET ?
-                              ntohs(((struct sockaddr_in*)local)->sin_port) :
-#ifdef HAVE_IPV6
-                              ntohs(((struct sockaddr_in6*)local)->sin6_port)),
-#else
-                              0),
-#endif
-                remote_addr, ( peer->sa_family == AF_INET ?
-                              ntohs(((struct sockaddr_in*)peer)->sin_port) :
-#ifdef HAVE_IPV6
-                              ntohs(((struct sockaddr_in6*)peer)->sin6_port)));
-#else
-                              0));
-#endif
+void *reporter_reportpeer(Connection_Info *stats, int ID)
+{
+    if (ID > 0) {
+        char    laddr[REPORT_ADDRLEN],
+                daddr[REPORT_ADDRLEN];
+       unsigned lport = SockAddr_port(&stats->local),
+                dport = SockAddr_port(&stats->peer);
+
+       SockAddr_name(&stats->local, laddr, sizeof(laddr));
+       SockAddr_name(&stats->peer,  daddr, sizeof(daddr));
+        printf(report_peer, ID, laddr, lport, daddr, dport);
     }
     return NULL;
 }
-// end ReportPeer
 
 /* -------------------------------------------------------------------
  * Report the MSS and MTU, given the MSS (or a guess thereof)