Changeset 399 in flair-src for trunk/tools/FlairGCS/src/UdtSocket.cpp


Ignore:
Timestamp:
Mar 16, 2021, 5:50:25 PM (4 years ago)
Author:
Sanahuja Guillaume
Message:

change color of status bar in gcs if high bandwidth usage is detected

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/FlairGCS/src/UdtSocket.cpp

    r307 r399  
    1515#include <assert.h>
    1616#include <QThread>
     17
    1718#define COMPRESS_CHUNK 1024*100
    1819
     
    3738  total_received=0;
    3839  pktSndLossTotal=0;
    39  
     40  lastpktRecvTotal=0;
     41 
    4042  bool blocking = false;
    4143  if (UDT::setsockopt(socket, 0, UDT_RCVSYN, &blocking, sizeof(bool)) != 0)
     
    9496    fprintf(stderr,"total number of received NAK packets: %i\n",perf.pktRecvNAKTotal);
    9597    fprintf(stderr,"round trip time: %fms\n",perf.msRTT);
    96      
    9798  }*/
    9899  bool loosingPackets=false;
    99100  if(perf.pktSndLossTotal>pktSndLossTotal) loosingPackets=true;
    100101  pktSndLossTotal=perf.pktSndLossTotal;
    101   stats=QString("rx rate %1kB/s, round trip %2ms, lost packets %3").arg(rxRate,0,'f',3).arg(perf.msRTT,0,'f',3).arg(perf.pktSndLossTotal);
    102   UDTStats(stats,loosingPackets);
     102  unsigned int pktPerSec=(perf.pktRecvTotal-lastpktRecvTotal)*1000/COMPUTE_UDT_STATS_TIMER;
     103  QString stylesheet="color: black";
     104  if(pktPerSec>=100) {
     105    stylesheet="color: red";
     106  }
     107  else if(pktPerSec>=50) {
     108    stylesheet="color: orange";
     109  }
     110  stats=QString("rx rate %1kB/s, %2 rx packets/s, round trip %3ms, lost packets %4").arg(rxRate,0,'f',3).arg(pktPerSec).arg(perf.msRTT,0,'f',3).arg(perf.pktSndLossTotal);
     111  lastpktRecvTotal=perf.pktRecvTotal;
     112  UDTStats(stats,stylesheet,loosingPackets);
    103113}
    104114
Note: See TracChangeset for help on using the changeset viewer.