Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5720 in orxonox.OLD for branches/network/src/lib


Ignore:
Timestamp:
Nov 23, 2005, 1:19:49 PM (19 years ago)
Author:
snellen
Message:

connection monitor updated

Location:
branches/network/src/lib/network
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/network/connection_monitor.cc

    r5618 r5720  
    3232  /*Data of the lifetime of the ConnectionMonitor Object*/
    3333  packetToAverage = 5;
     34  protocollType = "default";
    3435
    3536  startTime= SDL_GetTicks();
     
    7172  currentDelay = currentPacketTick - lastPacketTick;
    7273
    73   /*  Only for Udp
    74       if(currentPacketID - lastPacketID > 1)
    75       {
    76               totalLostPackets += currentPacketID - lastPacketID;
    77       }
    78 
    79      totalPacketloss = (totalLostPackets/totalReceivedPackets)*100 ;
    80   */
    81 
    8274  /*Do whats needed for Averaging*/
    8375
    8476  if(packetCounter = packetToAverage)
    8577    {
    86       computeAverageStatistic();
     78      computeCurrentDatarate();
    8779      displayStatistic();
    8880      packetCounter = 0;
     81      sizeOfLastFewPackets = 0;
    8982    }
    9083
     
    9285  lastFewPackets[packetCounter] = currentPacket;
    9386  sizeOfLastFewPackets += packetLength;
     87
     88  /*  Do protocol related stuff
     89
     90  Only for Udp:
     91  "currentPacketID = getID from package";
     92
     93  if(currentPacketID - lastPacketID > 1)
     94  {
     95  totalLostPackets += currentPacketID - lastPacketID;
     96}
     97
     98  totalPacketloss = (totalLostPackets/totalReceivedPackets)*100 ;
     99  */
    94100
    95101
     
    105111
    106112/* Compute the value of current Datarate*/
    107 void ConnectionMonitor::computeAverageStatistic()
     113void ConnectionMonitor::computeCurrentDatarate()
    108114{
    109115  int timeForLastFewPackets;
    110   for(int i=0;i <= packetToAverage-1;i++)
     116  for(int i=0;i < packetToAverage;i++)
    111117    timeForLastFewPackets += lastFewDelays[i];
    112118
    113   currentDatarate = packetToAverage/timeForLastFewPackets;
     119  currentDatarate = sizeOfLastFewPackets/timeForLastFewPackets;
     120}
     121
     122void doUDPRelatedStuff()
     123{
     124
    114125}
    115126
    116127
     128
     129/* Display connectoin statistic*/
    117130void ConnectionMonitor::displayStatistic()
    118131{
     
    125138
    126139  PRINT(0)("Current datarate :\n",currentDatarate);
    127   PRINT(0)("Delays of the last few packets :\n",currentDelay);
     140  PRINT(0)("Delays of the last few packets :\n");
    128141  for(int i=1 ;i <= packetToAverage-1;i++)
    129142    PRINT(0)("%i ",lastFewDelays[i]);
  • branches/network/src/lib/network/connection_monitor.h

    r5618 r5720  
    2323
    2424    void                displayStatistic();
    25     void                computeAverageStatistic();
     25    void                computeCurrentDatarate();
     26    void                doUDPRelatedStuff();
    2627
    2728    /*Data of the lifetime of the ConnectionMonitor Object*/
    2829    unsigned int        packetToAverage;
     30    char*               protocollType;
    2931
    3032    unsigned int        totalReceivedPackets;
Note: See TracChangeset for help on using the changeset viewer.