-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathiperf.h
76 lines (56 loc) · 1.69 KB
/
iperf.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#pragma once
#include <QObject>
#include <QPoint>
#include <QThread>
#include <optional>
#include "measurements.h"
class Iperf : public QObject {
Q_OBJECT
private:
std::string mHost;
int mPort;
public:
Iperf(std::string host, int port, QObject *parent = nullptr);
void run();
public slots:
void server_hostname(QString host);
void server_port(int port);
signals:
void Failed(int err, QString errstr);
void Finished(double sent_bits_per_second, double sent_retransmits,
double received_bits_per_second);
};
class IPerfScan : public QObject { // FIXME: Name scan?
Q_OBJECT
Q_PROPERTY(QString serverHost READ serverHost WRITE setServerHost NOTIFY
serverHostChanged)
Q_PROPERTY(int serverPort READ serverPort WRITE setServerPort NOTIFY
serverPortChanged)
public:
explicit IPerfScan(QObject *parent);
~IPerfScan();
bool measure(MeasurementEntry measurementEntry);
void setServerHost(QString serverHost);
void setServerPort(int serverPort);
QString serverHost();
int serverPort();
public slots:
void onData(double sent_bits_per_second, double sent_retransmits,
double received_bits_per_second);
void onFailed(int err, QString errstr);
void setInterfaceIndex(int index);
signals:
void scanFinished(QVector<MeasurementEntry> results);
void scanFailed(int err, QString message);
void triggerScan();
void serverHostChanged(QString serverHost);
void serverPortChanged(int serverPort);
private:
bool mScanning{false};
QString mServerHost{"127.0.0.1"};
int mServerPort{5201};
QThread workerThread;
Iperf *iperf;
int mInterfaceIndex{0};
std::optional<MeasurementEntry> mMeasurementEntry;
};