mirror of
https://github.com/lubosz/overte.git
synced 2025-04-09 09:44:33 +02:00
Add basic test to send packetList in udt-test
This commit is contained in:
parent
97bb36add4
commit
74547777df
2 changed files with 42 additions and 13 deletions
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include <udt/Constants.h>
|
||||
#include <udt/Packet.h>
|
||||
#include <udt/PacketList.h>
|
||||
|
||||
#include <LogHandler.h>
|
||||
|
||||
|
@ -42,6 +43,9 @@ const QCommandLineOption MAX_SEND_PACKETS {
|
|||
const QCommandLineOption UNRELIABLE_PACKETS {
|
||||
"unreliable", "send unreliable packets (default is reliable)"
|
||||
};
|
||||
const QCommandLineOption ORDERED_PACKETS {
|
||||
"ordered", "send ordered packets (default is unordered)"
|
||||
};
|
||||
|
||||
const QStringList CLIENT_STATS_TABLE_HEADERS {
|
||||
"Send Rate (P/s)", "Bandwidth (P/s)", "RTT(ms)", "CW (P)", "Send Period (us)",
|
||||
|
@ -129,6 +133,10 @@ UDTTest::UDTTest(int& argc, char** argv) :
|
|||
if (_argumentParser.isSet(UNRELIABLE_PACKETS)) {
|
||||
_sendReliable = false;
|
||||
}
|
||||
|
||||
if (_argumentParser.isSet(ORDERED_PACKETS)) {
|
||||
_sendOrdered = true;
|
||||
}
|
||||
|
||||
if (!_target.isNull()) {
|
||||
sendInitialPackets();
|
||||
|
@ -151,7 +159,7 @@ void UDTTest::parseArguments() {
|
|||
|
||||
_argumentParser.addOptions({
|
||||
PORT_OPTION, TARGET_OPTION, PACKET_SIZE, MIN_PACKET_SIZE, MAX_PACKET_SIZE,
|
||||
MAX_SEND_BYTES, MAX_SEND_PACKETS, UNRELIABLE_PACKETS
|
||||
MAX_SEND_BYTES, MAX_SEND_PACKETS, UNRELIABLE_PACKETS, ORDERED_PACKETS
|
||||
});
|
||||
|
||||
if (!_argumentParser.parse(arguments())) {
|
||||
|
@ -206,20 +214,40 @@ void UDTTest::sendPacket() {
|
|||
int randomPacketSize = rand() % _maxPacketSize + _minPacketSize;
|
||||
packetPayloadSize = randomPacketSize - udt::Packet::localHeaderSize(false);
|
||||
}
|
||||
|
||||
auto newPacket = udt::Packet::create(packetPayloadSize, _sendReliable);
|
||||
newPacket->setPayloadSize(packetPayloadSize);
|
||||
|
||||
_totalQueuedBytes += newPacket->getDataSize();
|
||||
|
||||
// queue or send this packet by calling write packet on the socket for our target
|
||||
if (_sendReliable) {
|
||||
_socket.writePacket(std::move(newPacket), _target);
|
||||
|
||||
if (_sendOrdered) {
|
||||
static int call = 0;
|
||||
call = (call + 1) % 4;
|
||||
if (call == 0) {
|
||||
auto packetList = std::unique_ptr<udt::PacketList>(new udt::PacketList(PacketType::BulkAvatarData, QByteArray(), true, true));
|
||||
for (int i = 0; i < 4; i++) {
|
||||
packetList->writePrimitive(0x1);
|
||||
packetList->writePrimitive(0x2);
|
||||
packetList->writePrimitive(0x3);
|
||||
packetList->writePrimitive(0x4);
|
||||
packetList->closeCurrentPacket(false);
|
||||
}
|
||||
_totalQueuedBytes += packetList->getDataSize();
|
||||
|
||||
_socket.writePacketList(std::move(packetList), _target);
|
||||
}
|
||||
_totalQueuedPackets += 4;
|
||||
} else {
|
||||
_socket.writePacket(*newPacket, _target);
|
||||
auto newPacket = udt::Packet::create(packetPayloadSize, _sendReliable);
|
||||
newPacket->setPayloadSize(packetPayloadSize);
|
||||
|
||||
_totalQueuedBytes += newPacket->getDataSize();
|
||||
|
||||
// queue or send this packet by calling write packet on the socket for our target
|
||||
// if (
|
||||
if (_sendReliable) {
|
||||
_socket.writePacket(std::move(newPacket), _target);
|
||||
} else {
|
||||
_socket.writePacket(*newPacket, _target);
|
||||
}
|
||||
++_totalQueuedPackets;
|
||||
}
|
||||
|
||||
++_totalQueuedPackets;
|
||||
}
|
||||
|
||||
void UDTTest::sampleStats() {
|
||||
|
|
|
@ -45,7 +45,8 @@ private:
|
|||
int _maxSendBytes { -1 }; // the number of bytes to send to the target before stopping
|
||||
int _maxSendPackets { -1 }; // the number of packets to send to the target before stopping
|
||||
|
||||
bool _sendReliable { true }; // wether packets are sent reliably or unreliably
|
||||
bool _sendReliable { true }; // whether packets are sent reliably or unreliably
|
||||
bool _sendOrdered { false }; // whether to send ordered packets
|
||||
|
||||
int _totalQueuedPackets { 0 }; // keeps track of the number of packets we have already queued
|
||||
int _totalQueuedBytes { 0 }; // keeps track of the number of bytes we have already queued
|
||||
|
|
Loading…
Reference in a new issue