Merge pull request #7726 from Atlante45/fix/pmtu-disc-fail

Fix for path MTU discovery fail
This commit is contained in:
Brad Hefta-Gaub 2016-04-22 12:24:44 -07:00
commit f0659a985c
4 changed files with 20 additions and 5 deletions

View file

@ -18,7 +18,7 @@
namespace udt {
static const int UDP_IPV4_HEADER_SIZE = 28;
static const int MAX_PACKET_SIZE_WITH_UDP_HEADER = 1500;
static const int MAX_PACKET_SIZE_WITH_UDP_HEADER = 1492;
static const int MAX_PACKET_SIZE = MAX_PACKET_SIZE_WITH_UDP_HEADER - UDP_IPV4_HEADER_SIZE;
static const int MAX_PACKETS_IN_FLIGHT = 25600;
static const int CONNECTION_RECEIVE_BUFFER_SIZE_PACKETS = 8192;

View file

@ -38,6 +38,21 @@ Socket::Socket(QObject* parent) :
_synTimer->start(_synInterval);
}
void Socket::bind(const QHostAddress& address, quint16 port) {
_udpSocket.bind(address, port);
setSystemBufferSizes();
#if defined(Q_OS_LINUX)
auto sd = _udpSocket.socketDescriptor();
int val = IP_PMTUDISC_DONT;
setsockopt(sd, IPPROTO_IP, IP_MTU_DISCOVER, &val, sizeof(val));
#elif defined(Q_OS_WINDOWS)
auto sd = _udpSocket.socketDescriptor();
int val = 0; // false
setsockopt(sd, IPPROTO_IP, IP_DONTFRAGMENT, &val, sizeof(val));
#endif
}
void Socket::rebind() {
quint16 oldPort = _udpSocket.localPort();

View file

@ -60,7 +60,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); setSystemBufferSizes(); }
void bind(const QHostAddress& address, quint16 port = 0);
void rebind();
void setPacketFilterOperator(PacketFilterOperator filterOperator) { _packetFilterOperator = filterOperator; }

View file

@ -25,8 +25,8 @@ const QCommandLineOption TARGET_OPTION {
"IP:PORT or HOSTNAME:PORT"
};
const QCommandLineOption PACKET_SIZE {
"packet-size", "size for sent packets in bytes (defaults to 1500)", "bytes",
QString(udt::MAX_PACKET_SIZE_WITH_UDP_HEADER)
"packet-size", "size for sent packets in bytes (defaults to " + QString(MAX_PACKET_SIZE) + ")", "bytes",
QString(udt::MAX_PACKET_SIZE)
};
const QCommandLineOption MIN_PACKET_SIZE {
"min-packet-size", "min size for sent packets in bytes", "min bytes"
@ -366,7 +366,7 @@ void UDTTest::sampleStats() {
static const double USECS_PER_MSEC = 1000.0;
static const double MEGABITS_PER_BYTE = 8.0 / 1000000.0;
static const double MS_PER_SECOND = 1000.0;
static const double PPS_TO_MBPS = 1500.0 * MEGABITS_PER_BYTE;
static const double PPS_TO_MBPS = udt::MAX_PACKET_SIZE * MEGABITS_PER_BYTE;
if (!_target.isNull()) {