Make sure the socket allows fragmenting

This commit is contained in:
Atlante45 2016-04-20 15:58:25 -07:00
parent 492bc75d68
commit 778c19d7e4
3 changed files with 19 additions and 4 deletions

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 1492)", "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 = udt::MAX_PACKET_SIZE_WITH_UDP_HEADER * MEGABITS_PER_BYTE;
static const double PPS_TO_MBPS = udt::MAX_PACKET_SIZE * MEGABITS_PER_BYTE;
if (!_target.isNull()) {