- Timestamp:
- Nov 27, 2005, 7:05:34 PM (19 years ago)
- Location:
- branches/network/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/connection_monitor.cc
r5798 r5800 88 88 /*Update the lifetime Variables*/ 89 89 totalReceivedPackets ++; 90 averageDatarate = totalReceivedPackets/(currentPacketTick - startTime); 90 float timeDiff = this->currentPacketTick - this->startTime; 91 if( timeDiff != 0.0f ) 92 averageDatarate = totalReceivedPackets/timeDiff; 91 93 92 94 /*Preparefor the next Packet*/ … … 134 136 // PRINT(0)("Total lost packets:",totalLostPackets); 135 137 // PRINT(0)("Packetloss [%] :\n",totalPacketloss); 136 // 138 // 137 139 // PRINT(0)("Current datarate :\n",currentDatarate); 138 140 // PRINT(0)("Delays of the last few packets :\n"); 139 141 // for(int i=1 ;i <= packetToAverage-1;i++) 140 142 // PRINT(0)("%i ",lastFewDelays[i]); 141 // 143 // 142 144 // PRINT(0)("============================================\n"); 143 145 -
branches/network/src/lib/network/network_stream.cc
r5798 r5800 11 11 ### File Specific: 12 12 main-programmer: claudio 13 co-programmer: 13 co-programmer: 14 14 */ 15 15 … … 39 39 40 40 41 NetworkStream::NetworkStream() 41 NetworkStream::NetworkStream() 42 42 : DataStream() 43 43 { … … 51 51 52 52 53 NetworkStream::NetworkStream(IPaddress& address, Synchronizeable& sync, NodeType type) 53 NetworkStream::NetworkStream(IPaddress& address, Synchronizeable& sync, NodeType type) 54 54 : DataStream() 55 55 { … … 63 63 64 64 65 NetworkStream::NetworkStream(Synchronizeable& sync, int port, NodeType type) 65 NetworkStream::NetworkStream(Synchronizeable& sync, int port, NodeType type) 66 66 : DataStream() 67 67 { … … 95 95 { 96 96 97 97 98 98 int ret = 0; 99 99 100 100 /* DOWNSTREAM */ 101 101 102 PRINT(0)("\n\n"); 103 PRINT(0)("============= DOWNSTREAM:===============\n"); 102 104 /* first of all read the synchronizeable's data: */ 103 105 ret = this->synchronizeables->readBytes((byte*)downBuffer); 104 106 105 107 /* send the received data to connectionMonitor */ 106 108 this->connectionMonitor->processPacket((byte*)downBuffer, ret + sizeof(Header)); … … 108 110 this->networkProtocol->createHeader((byte*)downBuffer, ret, DATA_STREAM_BUFFER_SIZE, 109 111 *(this->synchronizeables), 12); 110 112 111 113 /* pass the data to the network socket */ 112 114 ret = this->networkSocket->writeBytes((byte*)downBuffer, PACKAGE_SIZE + sizeof(Header)); 113 115 /* check if there was an error */ 114 116 if( ret == -1) { PRINTF(0)("Error in writing data to the NetworkSocket\n");} 115 117 116 118 117 119 118 120 /* UPSTREAM */ 119 120 ret = 0;121 121 122 ret = 0; 123 PRINT(0)("============== UPSTREAM:================\n"); 122 124 /* first of all read data from networkSocket*/ 123 125 ret = this->networkSocket->readBlock((byte*)upBuffer, PACKAGE_SIZE + sizeof(Header)); … … 130 132 /* extract Header */ 131 133 this->networkProtocol->extractHeader((byte*) upBuffer , PACKAGE_SIZE + sizeof(Header)); 132 134 133 135 /* now pass the data to the sync object */ 134 this->synchronizeables->writeBytes((byte*)upBuffer, PACKAGE_SIZE);136 this->synchronizeables->writeBytes((byte*)upBuffer, ret); 135 137 136 138 } -
branches/network/src/subprojects/network/network_unit_test.cc
r5798 r5800 144 144 145 145 /* 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++) { 147 147 nm->synchronize(); 148 148 } 149 149 150 150 printf("Test finished\n"); 151 152 151 152 153 153 /* delete the network manager again */ 154 154 delete nm; -
branches/network/src/subprojects/network/simple_sync.cc
r5798 r5800 1 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 4 4 Copyright (C) 2004 orx 5 5 6 6 This program is free software; you can redistribute it and/or modify 7 7 it under the terms of the GNU General Public License as published by 8 8 the Free Software Foundation; either version 2, or (at your option) 9 9 any later version. 10 10 11 11 ### File Specific: 12 12 main-programmer: Patrick Boenzli 13 co-programmer: 13 co-programmer: 14 14 */ 15 15 … … 24 24 #include "debug.h" 25 25 26 26 27 /** 27 28 * default constructor … … 31 32 { 32 33 this->outLength = 10; 34 this->recLength = 0; 33 35 this->inLength = 40; 34 36 this->outData = new byte[this->outLength]; 35 37 this->inData = new byte[this->inLength]; 36 38 37 39 for( int i = 0; i < this->outLength; i++) 38 40 { 39 41 this->outData[i] = i; 40 42 } 43 for( int i = 0; i < this->inLength; i++) 44 { 45 this->inData[i] = 0; 46 } 47 41 48 } 49 42 50 43 51 /** … … 48 56 } 49 57 58 50 59 /** 51 60 * write data to Synchronizeable … … 53 62 void SimpleSync::writeBytes(byte* data, int length) 54 63 { 64 PRINTF(0)("SimpleSync: got %i bytes of data\n", length); 65 this->recLength = length; 55 66 if(this->inLength < length) 56 67 PRINTF(0)("ERROR: local buffer is smaller than the data to receive.\n"); 57 68 /* copy the data localy */ 58 for( int i = 0; i < this->inLength; i++)69 for( int i = 0; i < length; i++) 59 70 { 60 71 this->inData[i] = data[i]; … … 70 81 int SimpleSync::readBytes(byte* data) 71 82 { 83 PRINTF(0)("SimpleSync: sent %i bytes of data\n", this->outLength); 72 84 /* write the test message */ 73 85 data = this->outData; … … 78 90 } 79 91 92 80 93 void SimpleSync::writeDebug() 81 94 { 82 95 PRINTF(0)("Write in: |"); 83 for(int i = 0; i < this-> inLength; i++)96 for(int i = 0; i < this->recLength; i++) 84 97 { 85 98 PRINT(0)(" %i ",this->inData[i]); … … 88 101 } 89 102 103 90 104 void SimpleSync::readDebug() 91 105 { … … 93 107 for(int i = 0; i < this->outLength; i++) 94 108 { 95 PRINT(0)(" % i",this->outData[i]);109 PRINT(0)(" %c ",this->outData[i]); 96 110 } 97 111 PRINT(0)("|\n"); -
branches/network/src/subprojects/network/simple_sync.h
r5650 r5800 15 15 SimpleSync(); 16 16 ~SimpleSync(); 17 17 18 18 virtual void writeBytes(byte* data, int length); 19 19 virtual int readBytes(byte* data); 20 20 21 21 private: 22 22 virtual void writeDebug(); 23 23 virtual void readDebug(); 24 24 25 25 26 26 private: 27 27 byte* inData; 28 28 int inLength; 29 int recLength; 29 30 byte* outData; 30 31 int outLength;
Note: See TracChangeset
for help on using the changeset viewer.