mirror of
https://github.com/overte-org/overte.git
synced 2025-04-26 03:56:11 +02:00
add a constants file for UDT
This commit is contained in:
parent
7602c352d6
commit
85156b9d0f
8 changed files with 39 additions and 37 deletions
|
@ -33,8 +33,6 @@
|
||||||
#include "UUID.h"
|
#include "UUID.h"
|
||||||
#include "NetworkLogging.h"
|
#include "NetworkLogging.h"
|
||||||
|
|
||||||
#include "udt/udt.h"
|
|
||||||
|
|
||||||
const char SOLO_NODE_TYPES[2] = {
|
const char SOLO_NODE_TYPES[2] = {
|
||||||
NodeType::AvatarMixer,
|
NodeType::AvatarMixer,
|
||||||
NodeType::AudioMixer
|
NodeType::AudioMixer
|
||||||
|
@ -81,9 +79,6 @@ LimitedNodeList::LimitedNodeList(unsigned short socketListenPort, unsigned short
|
||||||
qCDebug(networking) << "NodeList DTLS socket is listening on" << _dtlsSocket->localPort();
|
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
|
// check for local socket updates every so often
|
||||||
const int LOCAL_SOCKET_UPDATE_INTERVAL_MSECS = 5 * 1000;
|
const int LOCAL_SOCKET_UPDATE_INTERVAL_MSECS = 5 * 1000;
|
||||||
QTimer* localSocketUpdate = new QTimer(this);
|
QTimer* localSocketUpdate = new QTimer(this);
|
||||||
|
|
|
@ -17,11 +17,10 @@
|
||||||
#include <QtCore/QIODevice>
|
#include <QtCore/QIODevice>
|
||||||
|
|
||||||
#include "../HifiSockAddr.h"
|
#include "../HifiSockAddr.h"
|
||||||
|
#include "Constants.h"
|
||||||
|
|
||||||
namespace udt {
|
namespace udt {
|
||||||
|
|
||||||
static const int MAX_PACKET_SIZE = 1450;
|
|
||||||
|
|
||||||
class BasePacket : public QIODevice {
|
class BasePacket : public QIODevice {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "CongestionControl.h"
|
#include "CongestionControl.h"
|
||||||
|
#include "Packet.h"
|
||||||
|
|
||||||
using namespace udt;
|
using namespace udt;
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
@ -19,6 +20,8 @@ static const double USECS_PER_SECOND = 1000000.0;
|
||||||
void DefaultCC::init() {
|
void DefaultCC::init() {
|
||||||
_lastRCTime = high_resolution_clock::now();
|
_lastRCTime = high_resolution_clock::now();
|
||||||
|
|
||||||
|
_mss = udt::MAX_PACKET_SIZE;
|
||||||
|
|
||||||
_slowStartLastAck = _sendCurrSeqNum;
|
_slowStartLastAck = _sendCurrSeqNum;
|
||||||
_lastDecreaseMaxSeq = SequenceNumber { SequenceNumber::MAX };
|
_lastDecreaseMaxSeq = SequenceNumber { SequenceNumber::MAX };
|
||||||
|
|
||||||
|
|
26
libraries/networking/src/udt/Constants.h
Normal file
26
libraries/networking/src/udt/Constants.h
Normal 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
|
|
@ -22,6 +22,8 @@ using namespace udt;
|
||||||
Socket::Socket(QObject* parent) :
|
Socket::Socket(QObject* parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
|
setSystemBufferSizes();
|
||||||
|
|
||||||
connect(&_udpSocket, &QUdpSocket::readyRead, this, &Socket::readPendingDatagrams);
|
connect(&_udpSocket, &QUdpSocket::readyRead, this, &Socket::readPendingDatagrams);
|
||||||
|
|
||||||
// make sure our synchronization method is called every SYN interval
|
// make sure our synchronization method is called every SYN interval
|
||||||
|
@ -38,17 +40,21 @@ void Socket::rebind() {
|
||||||
_udpSocket.bind(QHostAddress::AnyIPv4, oldPort);
|
_udpSocket.bind(QHostAddress::AnyIPv4, oldPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Socket::setBufferSizes(int numBytes) {
|
void Socket::setSystemBufferSizes() {
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
QAbstractSocket::SocketOption bufferOpt;
|
QAbstractSocket::SocketOption bufferOpt;
|
||||||
QString bufferTypeString;
|
QString bufferTypeString;
|
||||||
|
|
||||||
|
int numBytes = 0;
|
||||||
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
bufferOpt = QAbstractSocket::SendBufferSizeSocketOption;
|
bufferOpt = QAbstractSocket::SendBufferSizeSocketOption;
|
||||||
|
numBytes = udt::UDP_SEND_BUFFER_SIZE_BYTES;
|
||||||
bufferTypeString = "send";
|
bufferTypeString = "send";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
bufferOpt = QAbstractSocket::ReceiveBufferSizeSocketOption;
|
bufferOpt = QAbstractSocket::ReceiveBufferSizeSocketOption;
|
||||||
|
numBytes = udt::UDP_RECEIVE_BUFFER_SIZE_BYTES;
|
||||||
bufferTypeString = "receive";
|
bufferTypeString = "receive";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,6 @@ public:
|
||||||
void setPacketFilterOperator(PacketFilterOperator filterOperator) { _packetFilterOperator = filterOperator; }
|
void setPacketFilterOperator(PacketFilterOperator filterOperator) { _packetFilterOperator = filterOperator; }
|
||||||
void setPacketHandler(PacketHandler handler) { _packetHandler = handler; }
|
void setPacketHandler(PacketHandler handler) { _packetHandler = handler; }
|
||||||
|
|
||||||
void setBufferSizes(int numBytes);
|
|
||||||
|
|
||||||
void addUnfilteredHandler(const HifiSockAddr& senderSockAddr, BasePacketHandler handler)
|
void addUnfilteredHandler(const HifiSockAddr& senderSockAddr, BasePacketHandler handler)
|
||||||
{ _unfilteredHandlers[senderSockAddr] = handler; }
|
{ _unfilteredHandlers[senderSockAddr] = handler; }
|
||||||
|
|
||||||
|
@ -68,6 +66,8 @@ private slots:
|
||||||
void rateControlSync();
|
void rateControlSync();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void setSystemBufferSizes();
|
||||||
|
|
||||||
QUdpSocket _udpSocket { this };
|
QUdpSocket _udpSocket { this };
|
||||||
PacketFilterOperator _packetFilterOperator;
|
PacketFilterOperator _packetFilterOperator;
|
||||||
PacketHandler _packetHandler;
|
PacketHandler _packetHandler;
|
||||||
|
|
|
@ -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"
|
|
|
@ -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
|
|
Loading…
Reference in a new issue