From e7f5bec3d0a45012e0c8e3f27c8029a8e040676b Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 30 Jul 2015 10:30:14 -0700 Subject: [PATCH 1/3] take out the incorrect attempt to cast for bitwise --- libraries/networking/src/udt/Connection.cpp | 4 ++-- libraries/networking/src/udt/SendQueue.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/networking/src/udt/Connection.cpp b/libraries/networking/src/udt/Connection.cpp index 690f47adab..f7f32d7480 100644 --- a/libraries/networking/src/udt/Connection.cpp +++ b/libraries/networking/src/udt/Connection.cpp @@ -228,9 +228,9 @@ SequenceNumber Connection::nextACK() const { bool Connection::processReceivedSequenceNumber(SequenceNumber sequenceNumber) { // check if this is a packet pair we should estimate bandwidth from, or just a regular packet - if (((uint32_t) sequenceNumber & 0xFF) == 0) { + if (((uint32_t) sequenceNumber & 0xF) == 0) { _receiveWindow.onProbePair1Arrival(); - } else if (((uint32_t) sequenceNumber & 0xFF) == 1) { + } else if (((uint32_t) sequenceNumber & 0xF) == 1) { _receiveWindow.onProbePair2Arrival(); } else { _receiveWindow.onPacketArrival(); diff --git a/libraries/networking/src/udt/SendQueue.cpp b/libraries/networking/src/udt/SendQueue.cpp index 628ac020f5..e6bc59c6cb 100644 --- a/libraries/networking/src/udt/SendQueue.cpp +++ b/libraries/networking/src/udt/SendQueue.cpp @@ -174,7 +174,7 @@ void SendQueue::loop() { sequenceNumber = getNextSequenceNumber(); // the first packet in the pair is every 16 (rightmost 16 bits = 0) packets - if (((uint32_t) sequenceNumber & 0xFF) == 0) { + if (((uint32_t) sequenceNumber & 0xF) == 0) { shouldSendSecondOfPair = true; } } From 3f0eecc599f044dc5a4991fc621ef42a83a6c45c Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 30 Jul 2015 15:04:48 -0700 Subject: [PATCH 2/3] actually change the system socket buffer size --- libraries/networking/src/udt/Socket.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/networking/src/udt/Socket.cpp b/libraries/networking/src/udt/Socket.cpp index a93a4d0e9e..3dd00d0834 100644 --- a/libraries/networking/src/udt/Socket.cpp +++ b/libraries/networking/src/udt/Socket.cpp @@ -39,7 +39,7 @@ void Socket::rebind() { quint16 oldPort = _udpSocket.localPort(); _udpSocket.close(); - _udpSocket.bind(QHostAddress::AnyIPv4, oldPort); + bind(QHostAddress::AnyIPv4, oldPort); } void Socket::setSystemBufferSizes() { @@ -63,6 +63,7 @@ void Socket::setSystemBufferSizes() { int oldBufferSize = _udpSocket.socketOption(bufferOpt).toInt(); if (oldBufferSize < numBytes) { + _udpSocket.setSocketOption(bufferOpt, QVariant(numBytes)); int newBufferSize = _udpSocket.socketOption(bufferOpt).toInt(); qCDebug(networking) << "Changed socket" << bufferTypeString << "buffer size from" << oldBufferSize << "to" From 8e55655ec3aed5698a9e724e1213ab9f3720e060 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 30 Jul 2015 15:07:49 -0700 Subject: [PATCH 3/3] call setSystemBufferSizes once bound --- libraries/networking/src/udt/Socket.cpp | 2 -- libraries/networking/src/udt/Socket.h | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/libraries/networking/src/udt/Socket.cpp b/libraries/networking/src/udt/Socket.cpp index 3dd00d0834..f8515affe6 100644 --- a/libraries/networking/src/udt/Socket.cpp +++ b/libraries/networking/src/udt/Socket.cpp @@ -24,8 +24,6 @@ using namespace udt; Socket::Socket(QObject* parent) : QObject(parent) { - setSystemBufferSizes(); - connect(&_udpSocket, &QUdpSocket::readyRead, this, &Socket::readPendingDatagrams); // make sure our synchronization method is called every SYN interval diff --git a/libraries/networking/src/udt/Socket.h b/libraries/networking/src/udt/Socket.h index 1827dc8234..e923f4b307 100644 --- a/libraries/networking/src/udt/Socket.h +++ b/libraries/networking/src/udt/Socket.h @@ -50,7 +50,7 @@ public: qint64 writeDatagram(const char* data, qint64 size, const HifiSockAddr& sockAddr); qint64 writeDatagram(const QByteArray& datagram, const HifiSockAddr& sockAddr); - void bind(const QHostAddress& address, quint16 port = 0) { _udpSocket.bind(address, port); } + void bind(const QHostAddress& address, quint16 port = 0) { _udpSocket.bind(address, port); setSystemBufferSizes(); } void rebind(); void setPacketFilterOperator(PacketFilterOperator filterOperator) { _packetFilterOperator = filterOperator; }