mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 05:09:22 +02:00
Scale back on first dropped packet, use Qt send/receive buffer size options
rather than setsockopt/getsockopt.
This commit is contained in:
parent
0914101b3e
commit
c9b3b5ff7d
2 changed files with 14 additions and 21 deletions
|
@ -353,7 +353,7 @@ void DatagramSequencer::sendRecordLost(const SendRecord& record) {
|
||||||
if (_packetDropCount == 0 || record.packetNumber == _lastPacketDropped + 1) {
|
if (_packetDropCount == 0 || record.packetNumber == _lastPacketDropped + 1) {
|
||||||
_packetDropCount++;
|
_packetDropCount++;
|
||||||
_lastPacketDropped = record.packetNumber;
|
_lastPacketDropped = record.packetNumber;
|
||||||
const int CONSECUTIVE_DROPS_BEFORE_REDUCTION = 3;
|
const int CONSECUTIVE_DROPS_BEFORE_REDUCTION = 1;
|
||||||
if (_packetDropCount >= CONSECUTIVE_DROPS_BEFORE_REDUCTION && record.packetNumber >= _packetRateDecreasePacketNumber) {
|
if (_packetDropCount >= CONSECUTIVE_DROPS_BEFORE_REDUCTION && record.packetNumber >= _packetRateDecreasePacketNumber) {
|
||||||
_packetsPerGroup = qMax(_packetsPerGroup * 0.5f, 1.0f);
|
_packetsPerGroup = qMax(_packetsPerGroup * 0.5f, 1.0f);
|
||||||
_slowStartThreshold = _packetsPerGroup;
|
_slowStartThreshold = _packetsPerGroup;
|
||||||
|
|
|
@ -147,28 +147,21 @@ QUdpSocket& LimitedNodeList::getDTLSSocket() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LimitedNodeList::changeSocketBufferSizes(int numBytes) {
|
void LimitedNodeList::changeSocketBufferSizes(int numBytes) {
|
||||||
// change the socket send buffer size to be 1MB
|
|
||||||
int oldBufferSize = 0;
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
int sizeOfInt = sizeof(oldBufferSize);
|
|
||||||
#else
|
|
||||||
unsigned int sizeOfInt = sizeof(oldBufferSize);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
int bufferOpt = (i == 0) ? SO_SNDBUF : SO_RCVBUF;
|
QAbstractSocket::SocketOption bufferOpt;
|
||||||
|
QString bufferTypeString;
|
||||||
getsockopt(_nodeSocket.socketDescriptor(), SOL_SOCKET, bufferOpt, reinterpret_cast<char*>(&oldBufferSize), &sizeOfInt);
|
if (i == 0) {
|
||||||
|
bufferOpt = QAbstractSocket::SendBufferSizeSocketOption;
|
||||||
setsockopt(_nodeSocket.socketDescriptor(), SOL_SOCKET, bufferOpt, reinterpret_cast<const char*>(&numBytes),
|
bufferTypeString = "send";
|
||||||
sizeof(numBytes));
|
|
||||||
|
} else {
|
||||||
QString bufferTypeString = (i == 0) ? "send" : "receive";
|
bufferOpt = QAbstractSocket::ReceiveBufferSizeSocketOption;
|
||||||
|
bufferTypeString = "receive";
|
||||||
|
}
|
||||||
|
int oldBufferSize = _nodeSocket.socketOption(bufferOpt).toInt();
|
||||||
if (oldBufferSize < numBytes) {
|
if (oldBufferSize < numBytes) {
|
||||||
int newBufferSize = 0;
|
_nodeSocket.setSocketOption(bufferOpt, numBytes);
|
||||||
getsockopt(_nodeSocket.socketDescriptor(), SOL_SOCKET, bufferOpt, reinterpret_cast<char*>(&newBufferSize), &sizeOfInt);
|
int newBufferSize = _nodeSocket.socketOption(bufferOpt).toInt();
|
||||||
|
|
||||||
qDebug() << "Changed socket" << bufferTypeString << "buffer size from" << oldBufferSize << "to"
|
qDebug() << "Changed socket" << bufferTypeString << "buffer size from" << oldBufferSize << "to"
|
||||||
<< newBufferSize << "bytes";
|
<< newBufferSize << "bytes";
|
||||||
|
|
Loading…
Reference in a new issue