Skip to content

Commit

Permalink
bug fix to translate macros in GUI speed sending #370
Browse files Browse the repository at this point in the history
  • Loading branch information
dannagle committed May 27, 2024
1 parent 3d2fa4e commit be23394
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/udpflooding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ void UDPFlooding::on_startButton_clicked()
thread->port = static_cast<quint16>(ui->portEdit->text().toUInt(&ok1));
thread->delay = ui->delayEdit->text().toInt(&ok2);


// do a swap test to see if it is used.
QString swapped = Packet::macroSwap(thread->ascii);
QString data = Packet::ASCIITohex(swapped);

// Note this can be a performance hit. Don't check if not used.
thread->hasMacros = swapped != thread->ascii;
QDEBUGVAR(thread->hasMacros);

// Do it.
thread->start();
}
Expand Down Expand Up @@ -157,6 +166,13 @@ double ThreadSender::getRatekHz(QElapsedTimer eTimer, quint64 pkts)
int ThreadSender::short_burst_of(int number, QUdpSocket *socket, QHostAddress *resolved)
{
for (int i = 0; i < number; i++) {

if(hasMacros) {
QString swapped = Packet::macroSwap(ascii);
QString data = Packet::ASCIITohex(swapped);
hex = Packet::HEXtoByteArray(data);
}

qint64 byteSent = socket->writeDatagram(hex, *resolved, port);
if (byteSent > 0) {
packetssent++;
Expand Down
1 change: 1 addition & 0 deletions src/udpflooding.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ThreadSender : public QThread
bool speedSendEnabled;
QString ascii;
QByteArray hex;
bool hasMacros;
bool issending;
bool stopsending;
quint64 packetssent;
Expand Down

0 comments on commit be23394

Please sign in to comment.