Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5800 in orxonox.OLD


Ignore:
Timestamp:
Nov 27, 2005, 7:05:34 PM (18 years ago)
Author:
patrick
Message:

network: included more comments to make it easier to debug

Location:
branches/network/src
Files:
5 edited

Legend:

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

    r5798 r5800  
    8888  /*Update the lifetime Variables*/
    8989  totalReceivedPackets ++;
    90   averageDatarate = totalReceivedPackets/(currentPacketTick - startTime);
     90  float timeDiff = this->currentPacketTick - this->startTime;
     91  if( timeDiff != 0.0f )
     92    averageDatarate = totalReceivedPackets/timeDiff;
    9193
    9294  /*Preparefor the next Packet*/
     
    134136//   PRINT(0)("Total lost packets:",totalLostPackets);
    135137//   PRINT(0)("Packetloss [%] :\n",totalPacketloss);
    136 // 
     138//
    137139//   PRINT(0)("Current datarate :\n",currentDatarate);
    138140//   PRINT(0)("Delays of the last few packets :\n");
    139141//   for(int i=1 ;i <= packetToAverage-1;i++)
    140142//     PRINT(0)("%i ",lastFewDelays[i]);
    141 // 
     143//
    142144//   PRINT(0)("============================================\n");
    143145
  • branches/network/src/lib/network/network_stream.cc

    r5798 r5800  
    1111### File Specific:
    1212   main-programmer: claudio
    13    co-programmer: 
     13   co-programmer:
    1414*/
    1515
     
    3939
    4040
    41 NetworkStream::NetworkStream() 
     41NetworkStream::NetworkStream()
    4242  : DataStream()
    4343{
     
    5151
    5252
    53 NetworkStream::NetworkStream(IPaddress& address, Synchronizeable& sync, NodeType type) 
     53NetworkStream::NetworkStream(IPaddress& address, Synchronizeable& sync, NodeType type)
    5454  : DataStream()
    5555{
     
    6363
    6464
    65 NetworkStream::NetworkStream(Synchronizeable& sync, int port, NodeType type) 
     65NetworkStream::NetworkStream(Synchronizeable& sync, int port, NodeType type)
    6666  : DataStream()
    6767{
     
    9595{
    9696
    97  
     97
    9898  int ret = 0;
    9999
    100100  /* DOWNSTREAM */
    101101
     102  PRINT(0)("\n\n");
     103  PRINT(0)("============= DOWNSTREAM:===============\n");
    102104  /* first of all read the synchronizeable's data: */
    103105  ret = this->synchronizeables->readBytes((byte*)downBuffer);
    104  
     106
    105107  /* send the received data to connectionMonitor */
    106108  this->connectionMonitor->processPacket((byte*)downBuffer, ret + sizeof(Header));
     
    108110  this->networkProtocol->createHeader((byte*)downBuffer, ret, DATA_STREAM_BUFFER_SIZE,
    109111                                       *(this->synchronizeables), 12);
    110        
     112
    111113  /* pass the data to the network socket */
    112114  ret = this->networkSocket->writeBytes((byte*)downBuffer, PACKAGE_SIZE + sizeof(Header));
    113115  /* check if there was an error */
    114116  if( ret == -1) { PRINTF(0)("Error in writing data to the NetworkSocket\n");}
    115  
     117
    116118
    117119
    118120  /* UPSTREAM */
    119  
    120   ret = 0;
    121121
     122  ret = 0;
     123  PRINT(0)("============== UPSTREAM:================\n");
    122124  /* first of all read  data from networkSocket*/
    123125  ret = this->networkSocket->readBlock((byte*)upBuffer, PACKAGE_SIZE + sizeof(Header));
     
    130132  /* extract Header */
    131133  this->networkProtocol->extractHeader((byte*) upBuffer , PACKAGE_SIZE + sizeof(Header));
    132    
     134
    133135  /* now pass the data to the sync object */
    134   this->synchronizeables->writeBytes((byte*)upBuffer, PACKAGE_SIZE);
     136  this->synchronizeables->writeBytes((byte*)upBuffer, ret);
    135137
    136138}
  • branches/network/src/subprojects/network/network_unit_test.cc

    r5798 r5800  
    144144
    145145  /* synchronize the data 1 time (increment for longer tests) */
    146   for( int i = 0; i < 3; i++) {
     146  for( int i = 0; i < 2; i++) {
    147147    nm->synchronize();
    148148  }
    149149
    150150  printf("Test finished\n");
    151  
    152  
     151
     152
    153153  /* delete the network manager again */
    154154  delete nm;
  • branches/network/src/subprojects/network/simple_sync.cc

    r5798 r5800  
    11/*
    22  orxonox - the future of 3D-vertical-scrollers
    3  
     3
    44  Copyright (C) 2004 orx
    5  
     5
    66  This program is free software; you can redistribute it and/or modify
    77  it under the terms of the GNU General Public License as published by
    88      the Free Software Foundation; either version 2, or (at your option)
    99      any later version.
    10  
     10
    1111### File Specific:
    1212    main-programmer: Patrick Boenzli
    13     co-programmer: 
     13    co-programmer:
    1414*/
    1515
     
    2424#include "debug.h"
    2525
     26
    2627/**
    2728 *  default constructor
     
    3132{
    3233  this->outLength = 10;
     34  this->recLength = 0;
    3335  this->inLength = 40;
    3436  this->outData = new byte[this->outLength];
    3537  this->inData = new byte[this->inLength];
    36  
     38
    3739  for( int i = 0; i < this->outLength; i++)
    3840  {
    3941    this->outData[i] = i;
    4042  }
     43  for( int i = 0; i < this->inLength; i++)
     44  {
     45    this->inData[i] = 0;
     46  }
     47
    4148}
     49
    4250
    4351/**
     
    4856}
    4957
     58
    5059/**
    5160 *  write data to Synchronizeable
     
    5362void SimpleSync::writeBytes(byte* data, int length)
    5463{
     64  PRINTF(0)("SimpleSync: got %i bytes of data\n", length);
     65  this->recLength = length;
    5566  if(this->inLength < length)
    5667    PRINTF(0)("ERROR: local buffer is smaller than the data to receive.\n");
    5768  /* copy the data localy */
    58   for( int i = 0; i < this->inLength; i++)
     69  for( int i = 0; i < length; i++)
    5970  {
    6071    this->inData[i] = data[i];
     
    7081int SimpleSync::readBytes(byte* data)
    7182{
     83  PRINTF(0)("SimpleSync: sent %i bytes of data\n", this->outLength);
    7284  /* write the test message */
    7385  data = this->outData;
     
    7890}
    7991
     92
    8093void SimpleSync::writeDebug()
    8194{
    8295  PRINTF(0)("Write in: |");
    83   for(int i = 0; i < this->inLength; i++)
     96  for(int i = 0; i < this->recLength; i++)
    8497  {
    8598    PRINT(0)(" %i ",this->inData[i]);
     
    88101}
    89102
     103
    90104void SimpleSync::readDebug()
    91105{
     
    93107  for(int i = 0; i < this->outLength; i++)
    94108  {
    95     PRINT(0)(" %i ",this->outData[i]);
     109    PRINT(0)(" %c ",this->outData[i]);
    96110  }
    97111  PRINT(0)("|\n");
  • branches/network/src/subprojects/network/simple_sync.h

    r5650 r5800  
    1515    SimpleSync();
    1616    ~SimpleSync();
    17  
     17
    1818    virtual void writeBytes(byte* data, int length);
    1919    virtual int readBytes(byte* data);
    20    
     20
    2121  private:
    2222    virtual void writeDebug();
    2323    virtual void readDebug();
    2424
    25    
     25
    2626  private:
    2727    byte* inData;
    2828    int   inLength;
     29    int   recLength;
    2930    byte* outData;
    3031    int   outLength;
Note: See TracChangeset for help on using the changeset viewer.