X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=src%2FReporter.c;h=c5eff5c35ba5a48e3610073272ea588db7a9a7dd;hb=a5a03e6ab0fdf9c4d7d4c085fcf01436f9ba3202;hp=e34763ec99915ffdd145f02f26afa7e4febe2d23;hpb=160c6a5bab3ab731f5b1ad8bc174e7d087ca7acb;p=iperf diff --git a/src/Reporter.c b/src/Reporter.c index e34763e..c5eff5c 100644 --- a/src/Reporter.c +++ b/src/Reporter.c @@ -156,23 +156,20 @@ MultiHeader* InitMulti( thread_Settings *agent, int inID ) { data->mLocalhost = agent->mLocalhost; data->mBufLen = agent->mBufLen; data->mMSS = agent->mMSS; - data->mTCPWin = agent->mTCPWin; + data->mWinSize = agent->mWinSize; data->flags = agent->flags; + data->mProtocol = agent->mProtocol; data->mThreadMode = agent->mThreadMode; data->mode = agent->mReportMode; data->info.mFormat = agent->mFormat; data->info.mTTL = agent->mTTL; - if ( isUDP( agent ) ) { + if ( isPacketOriented( agent ) ) { multihdr->report->info.mUDP = (char)agent->mThreadMode; } if ( isConnectionReport( agent ) ) { data->type |= CONNECTION_REPORT; data->connection.peer = agent->peer; - data->connection.size_peer = agent->size_peer; - SockAddr_setPortAny( &data->connection.peer ); data->connection.local = agent->local; - data->connection.size_local = agent->size_local; - SockAddr_setPortAny( &data->connection.local ); } } } else { @@ -237,13 +234,14 @@ ReportHeader* InitReport( thread_Settings *agent ) { data->mLocalhost = agent->mLocalhost; data->mBufLen = agent->mBufLen; data->mMSS = agent->mMSS; - data->mTCPWin = agent->mTCPWin; + data->mWinSize = agent->mWinSize; data->flags = agent->flags; + data->mProtocol = agent->mProtocol; data->mThreadMode = agent->mThreadMode; data->mode = agent->mReportMode; data->info.mFormat = agent->mFormat; data->info.mTTL = agent->mTTL; - if ( isUDP( agent ) ) { + if ( isPacketOriented( agent ) ) { reporthdr->report.info.mUDP = (char)agent->mThreadMode; } } else { @@ -269,9 +267,7 @@ ReportHeader* InitReport( thread_Settings *agent ) { if ( reporthdr != NULL ) { data->type |= CONNECTION_REPORT; data->connection.peer = agent->peer; - data->connection.size_peer = agent->size_peer; data->connection.local = agent->local; - data->connection.size_local = agent->size_local; } else { FAIL(1, "Out of Memory!!\n", agent); } @@ -371,7 +367,6 @@ void ReportPacket( ReportHeader* agent, ReportStruct *packet ) { */ void CloseReport( ReportHeader *agent, ReportStruct *packet ) { if ( agent != NULL) { - /* * Using PacketID of -1 ends reporting */ @@ -442,16 +437,16 @@ void ReportSettings( thread_Settings *agent ) { data->type = SETTINGS_REPORT; data->mBufLen = agent->mBufLen; data->mMSS = agent->mMSS; - data->mTCPWin = agent->mTCPWin; + data->mWinSize = agent->mWinSize; data->flags = agent->flags; + data->mProtocol = agent->mProtocol; data->mThreadMode = agent->mThreadMode; data->mPort = agent->mPort; + data->mMcastIface = agent->mMcastIface; data->info.mFormat = agent->mFormat; data->info.mTTL = agent->mTTL; data->connection.peer = agent->peer; - data->connection.size_peer = agent->size_peer; data->connection.local = agent->local; - data->connection.size_local = agent->size_local; #ifdef HAVE_THREAD /* @@ -511,9 +506,7 @@ void ReportServerUDP( thread_Settings *agent, server_hdr *server ) { stats->cntDatagrams = ntohl( server->datagrams ); stats->mUDP = (char)kMode_Server; reporthdr->report.connection.peer = agent->local; - reporthdr->report.connection.size_peer = agent->size_local; reporthdr->report.connection.local = agent->peer; - reporthdr->report.connection.size_local = agent->size_peer; #ifdef HAVE_THREAD /* @@ -672,24 +665,26 @@ int reporter_handle_packet( ReportHeader *reporthdr ) { Transfer_Info *stats = &reporthdr->report.info; int finished = 0; + // update received amount and time + data->TotalLen += packet->packetLen; + data->packetTime = packet->packetTime; data->cntDatagrams++; - // If this is the last packet set the endTime - if ( packet->packetID < 0 ) { - data->packetTime = packet->packetTime; + + if (packet->packetID < 0) { + // This is the last packet (FIN) finished = 1; - if ( reporthdr->report.mThreadMode != kMode_Client ) { - data->TotalLen += packet->packetLen; + if (isConnectionLess(&reporthdr->report)) { + // connectionless protocols don't count the last payload + if (reporthdr->report.mThreadMode == kMode_Client) + data->TotalLen -= packet->packetLen; + } else { + // connection-oriented protocols dont't count the FIN + data->cntDatagrams--; } - } else { - // update recieved amount and time - data->packetTime = packet->packetTime; - reporter_condprintstats( &reporthdr->report, reporthdr->multireport, finished ); - data->TotalLen += packet->packetLen; - if ( packet->packetID != 0 ) { - // UDP packet - double transit; - double deltaTransit; - + } else if ( packet->packetID != 0 ) { + // UDP or DCCP packet + double transit, deltaTransit; + // from RFC 1889, Real Time Protocol (RTP) // J = J + ( | D(i-1,i) | - J ) / 16 transit = TimeDifference( packet->packetTime, packet->sentTime ); @@ -701,7 +696,7 @@ int reporter_handle_packet( ReportHeader *reporthdr ) { stats->jitter += (deltaTransit - stats->jitter) / (16.0); } data->lastTransit = transit; - + // packet loss occured if the datagram numbers aren't sequential if ( packet->packetID != data->PacketID + 1 ) { if ( packet->packetID < data->PacketID + 1 ) { @@ -714,9 +709,7 @@ int reporter_handle_packet( ReportHeader *reporthdr ) { if ( packet->packetID > data->PacketID ) { data->PacketID = packet->packetID; } - } } - // Print a report if appropriate return reporter_condprintstats( &reporthdr->report, reporthdr->multireport, finished ); } @@ -791,11 +784,14 @@ int reporter_condprintstats( ReporterData *stats, MultiHeader *multireport, int if ( stats->info.cntError > stats->info.cntOutofOrder ) { stats->info.cntError -= stats->info.cntOutofOrder; } - stats->info.cntDatagrams = (isUDP(stats) ? stats->PacketID : stats->cntDatagrams); - stats->info.TotalLen = stats->TotalLen; + if (isConnectionLess(stats)) + stats->info.cntDatagrams = stats->PacketID; + else + stats->info.cntDatagrams = stats->cntDatagrams; + stats->info.TotalLen = stats->TotalLen; stats->info.startTime = 0; - stats->info.endTime = TimeDifference( stats->packetTime, stats->startTime ); - stats->info.free = 1; + stats->info.endTime = TimeDifference( stats->packetTime, stats->startTime ); + stats->info.free = 1; reporter_print( stats, TRANSFER_REPORT, force ); if ( isMultipleReport(stats) ) { reporter_handle_multiple_reports( multireport, &stats->info, force ); @@ -813,9 +809,13 @@ int reporter_condprintstats( ReporterData *stats, MultiHeader *multireport, int stats->info.cntError -= stats->info.cntOutofOrder; } stats->lastError = stats->cntError; - stats->info.cntDatagrams = (isUDP( stats ) ? stats->PacketID - stats->lastDatagrams : - stats->cntDatagrams - stats->lastDatagrams); - stats->lastDatagrams = (isUDP( stats ) ? stats->PacketID : stats->cntDatagrams); + if (isConnectionLess(stats)) { + stats->info.cntDatagrams = stats->PacketID - stats->lastDatagrams; + stats->lastDatagrams = stats->PacketID; + } else { + stats->info.cntDatagrams = stats->cntDatagrams - stats->lastDatagrams; + stats->lastDatagrams = stats->cntDatagrams; + } stats->info.TotalLen = stats->TotalLen - stats->lastTotal; stats->lastTotal = stats->TotalLen; stats->info.startTime = stats->info.endTime; @@ -838,7 +838,7 @@ int reporter_print( ReporterData *stats, int type, int end ) { switch ( type ) { case TRANSFER_REPORT: statistics_reports[stats->mode]( &stats->info ); - if ( end != 0 && isPrintMSS( stats ) && !isUDP( stats ) ) { + if ( end != 0 && isPrintMSS( stats ) && !isConnectionLess( stats ) ) { PrintMSS( stats ); } break; @@ -865,6 +865,8 @@ int reporter_print( ReporterData *stats, int type, int end ) { /* ------------------------------------------------------------------- * Report the MSS and MTU, given the MSS (or a guess thereof) + * This works for connection-oriented protocols only: it expects + * the protocol to be either TCP or DCCP and will give error otherwise * ------------------------------------------------------------------- */ // compare the MSS against the (MTU - 40) to (MTU - 80) bytes. @@ -872,8 +874,11 @@ int reporter_print( ReporterData *stats, int type, int end ) { #define checkMSS_MTU( inMSS, inMTU ) (inMTU-40) >= inMSS && inMSS >= (inMTU-80) -void PrintMSS( ReporterData *stats ) { - int inMSS = getsock_tcp_mss( stats->info.transferID ); +void PrintMSS( ReporterData *stats ) +{ + int inMSS = stats->mProtocol == kProto_TCP + ? getsock_tcp_mss( stats->info.transferID ) + : getsock_dccp_mps( stats->info.transferID ); if ( inMSS <= 0 ) { printf( report_mss_unsupported, stats->info.transferID );