add a constants file for UDT

This commit is contained in:
Stephen Birarda 2015-07-29 15:11:12 -07:00
parent 7602c352d6
commit 85156b9d0f
8 changed files with 39 additions and 37 deletions

View file

@ -33,8 +33,6 @@
#include "UUID.h"
#include "NetworkLogging.h"
#include "udt/udt.h"
const char SOLO_NODE_TYPES[2] = {
NodeType::AvatarMixer,
NodeType::AudioMixer
@ -81,9 +79,6 @@ LimitedNodeList::LimitedNodeList(unsigned short socketListenPort, unsigned short
qCDebug(networking) << "NodeList DTLS socket is listening on" << _dtlsSocket->localPort();
}
const int LARGER_BUFFER_SIZE = 1048576;
_nodeSocket.setBufferSizes(LARGER_BUFFER_SIZE);
// check for local socket updates every so often
const int LOCAL_SOCKET_UPDATE_INTERVAL_MSECS = 5 * 1000;
QTimer* localSocketUpdate = new QTimer(this);

View file

@ -17,11 +17,10 @@
#include <QtCore/QIODevice>
#include "../HifiSockAddr.h"
#include "Constants.h"
namespace udt {
static const int MAX_PACKET_SIZE = 1450;
class BasePacket : public QIODevice {
Q_OBJECT
public:

View file

@ -10,6 +10,7 @@
//
#include "CongestionControl.h"
#include "Packet.h"
using namespace udt;
using namespace std::chrono;
@ -19,6 +20,8 @@ static const double USECS_PER_SECOND = 1000000.0;
void DefaultCC::init() {
_lastRCTime = high_resolution_clock::now();
_mss = udt::MAX_PACKET_SIZE;
_slowStartLastAck = _sendCurrSeqNum;
_lastDecreaseMaxSeq = SequenceNumber { SequenceNumber::MAX };

View file

@ -0,0 +1,26 @@
//
// Constants.h
// libraries/networking/src/udt
//
// Created by Clement on 7/13/15.
// Copyright 2015 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#pragma once
#ifndef hifi_udt_Constants_h
#define hifi_udt_Constants_h
namespace udt {
static const int MAX_PACKET_SIZE = 1450;
static const int MAX_PACKETS_IN_FLIGHT = 25600;
static const int CONNECTION_RECEIVE_BUFFER_SIZE_PACKETS = 8192;
static const int CONNECTION_SEND_BUFFER_SIZE_PACKETS = 8192;
static const int UDP_SEND_BUFFER_SIZE_BYTES = 1048576;
static const int UDP_RECEIVE_BUFFER_SIZE_BYTES = 1048576;
}
#endif // hifi_udt_Constants_h

View file

@ -22,6 +22,8 @@ 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
@ -38,17 +40,21 @@ void Socket::rebind() {
_udpSocket.bind(QHostAddress::AnyIPv4, oldPort);
}
void Socket::setBufferSizes(int numBytes) {
void Socket::setSystemBufferSizes() {
for (int i = 0; i < 2; i++) {
QAbstractSocket::SocketOption bufferOpt;
QString bufferTypeString;
int numBytes = 0;
if (i == 0) {
bufferOpt = QAbstractSocket::SendBufferSizeSocketOption;
numBytes = udt::UDP_SEND_BUFFER_SIZE_BYTES;
bufferTypeString = "send";
} else {
bufferOpt = QAbstractSocket::ReceiveBufferSizeSocketOption;
numBytes = udt::UDP_RECEIVE_BUFFER_SIZE_BYTES;
bufferTypeString = "receive";
}

View file

@ -56,8 +56,6 @@ public:
void setPacketFilterOperator(PacketFilterOperator filterOperator) { _packetFilterOperator = filterOperator; }
void setPacketHandler(PacketHandler handler) { _packetHandler = handler; }
void setBufferSizes(int numBytes);
void addUnfilteredHandler(const HifiSockAddr& senderSockAddr, BasePacketHandler handler)
{ _unfilteredHandlers[senderSockAddr] = handler; }
@ -68,6 +66,8 @@ private slots:
void rateControlSync();
private:
void setSystemBufferSizes();
QUdpSocket _udpSocket { this };
PacketFilterOperator _packetFilterOperator;
PacketHandler _packetHandler;

View file

@ -1,12 +0,0 @@
//
// udt.cpp
//
//
// Created by Clement on 7/13/15.
// Copyright 2015 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "udt.h"

View file

@ -1,15 +0,0 @@
//
// udt.h
//
//
// Created by Clement on 7/13/15.
// Copyright 2015 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_udt_h
#define hifi_udt_h
#endif // hifi_udt_h