mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 14:32:38 +02:00
Only increase/decrease rate when we want to send more/have sent more than the
minimum, respectively.
This commit is contained in:
parent
705445ce62
commit
5effcd24ff
3 changed files with 31 additions and 5 deletions
|
@ -79,11 +79,30 @@ ReliableChannel* DatagramSequencer::getReliableInputChannel(int index) {
|
|||
return channel;
|
||||
}
|
||||
|
||||
int DatagramSequencer::startPacketGroup() {
|
||||
int DatagramSequencer::startPacketGroup(int desiredPackets) {
|
||||
// figure out how much data we have enqueued and increase the number of packets desired
|
||||
int totalAvailable = 0;
|
||||
foreach (ReliableChannel* channel, _reliableOutputChannels) {
|
||||
totalAvailable += channel->getBytesAvailable();
|
||||
}
|
||||
desiredPackets += (totalAvailable / _maxPacketSize);
|
||||
|
||||
// increment our packet counter and subtract/return the integer portion
|
||||
_packetsToWrite += _packetsPerGroup;
|
||||
int wholePackets = (int)_packetsToWrite;
|
||||
_packetsToWrite -= wholePackets;
|
||||
wholePackets = qMin(wholePackets, desiredPackets);
|
||||
|
||||
// if we don't want to send any more, push out the rate increase number past the group
|
||||
if (desiredPackets <= _packetsPerGroup) {
|
||||
_packetRateIncreasePacketNumber = _outgoingPacketNumber + wholePackets + 1;
|
||||
}
|
||||
|
||||
// likewise, if we're only sending one packet, don't let its loss cause rate decrease
|
||||
if (wholePackets == 1) {
|
||||
_packetRateDecreasePacketNumber = _outgoingPacketNumber + 2;
|
||||
}
|
||||
|
||||
return wholePackets;
|
||||
}
|
||||
|
||||
|
|
|
@ -100,8 +100,9 @@ public:
|
|||
ReliableChannel* getReliableInputChannel(int index = 0);
|
||||
|
||||
/// Starts a packet group.
|
||||
/// \param desiredPackets the number of packets we'd like to write in the group
|
||||
/// \return the number of packets to write in the group
|
||||
int startPacketGroup();
|
||||
int startPacketGroup(int desiredPackets = 1);
|
||||
|
||||
/// Starts a new packet for transmission.
|
||||
/// \return a reference to the Bitstream to use for writing to the packet
|
||||
|
|
|
@ -147,6 +147,8 @@ static int bytesSent = 0;
|
|||
static int bytesReceived = 0;
|
||||
static int maxDatagramsPerPacket = 0;
|
||||
static int maxBytesPerPacket = 0;
|
||||
static int groupsSent = 0;
|
||||
static int maxPacketsPerGroup = 0;
|
||||
static int highPriorityMessagesSent = 0;
|
||||
static int highPriorityMessagesReceived = 0;
|
||||
static int unreliableMessagesSent = 0;
|
||||
|
@ -508,10 +510,12 @@ bool MetavoxelTests::run() {
|
|||
}
|
||||
|
||||
qDebug() << "Sent" << streamedBytesSent << "streamed bytes, received" << streamedBytesReceived;
|
||||
qDebug() << "Sent" << datagramsSent << "datagrams with" << bytesSent << "bytes, received" <<
|
||||
datagramsReceived << "with" << bytesReceived << "bytes";
|
||||
qDebug() << "Sent" << datagramsSent << "datagrams in" << groupsSent << "groups with" << bytesSent <<
|
||||
"bytes, received" << datagramsReceived << "with" << bytesReceived << "bytes";
|
||||
qDebug() << "Max" << maxDatagramsPerPacket << "datagrams," << maxBytesPerPacket << "bytes per packet";
|
||||
qDebug() << "Average" << (bytesReceived / datagramsReceived) << "bytes per datagram";
|
||||
qDebug() << "Max" << maxPacketsPerGroup << "packets per group";
|
||||
qDebug() << "Average" << (bytesReceived / datagramsReceived) << "bytes per datagram," <<
|
||||
(datagramsSent / groupsSent) << "datagrams per group";
|
||||
qDebug() << "Speed:" << (bytesReceived / SIMULATION_ITERATIONS) << "bytes per iteration";
|
||||
qDebug() << "Efficiency:" << ((float)streamedBytesReceived / bytesReceived);
|
||||
}
|
||||
|
@ -821,6 +825,8 @@ bool Endpoint::simulate(int iterationNumber) {
|
|||
_remainingPipelineCapacity += datagram.size();
|
||||
}
|
||||
int packetCount = _sequencer->startPacketGroup();
|
||||
groupsSent++;
|
||||
maxPacketsPerGroup = qMax(maxPacketsPerGroup, packetCount);
|
||||
for (int i = 0; i < packetCount; i++) {
|
||||
oldDatagramsSent = datagramsSent;
|
||||
oldBytesSent = bytesSent;
|
||||
|
|
Loading…
Reference in a new issue