Skip to content

Commit

Permalink
Merge pull request #4 from dist-sys/add-rampup-rampdown
Browse files Browse the repository at this point in the history
Add ramp-up/ramp-down
  • Loading branch information
nabon authored Aug 21, 2020
2 parents 00f0695 + c50edc4 commit 62922bb
Show file tree
Hide file tree
Showing 15 changed files with 526 additions and 393 deletions.
37 changes: 17 additions & 20 deletions doc/usage_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,13 @@ You can display the help by:

```
usage: mqttloader.Loader -b <arg> [-v <arg>] [-p <arg>] [-s <arg>] [-pq
<arg>] [-sq <arg>] [-ss] [-r] [-t <arg>] [-d <arg>] [-m <arg>] [-i
<arg>] [-st <arg>] [-et <arg>] [-l <arg>] [-n <arg>] [-tf <arg>]
[-lf <arg>] [-h]
<arg>] [-sq <arg>] [-ss] [-r] [-t <arg>] [-d <arg>] [-m <arg>] [-ru
<arg>] [-rd <arg>] [-i <arg>] [-st <arg>] [-et <arg>] [-l <arg>]
[-n <arg>] [-tf <arg>] [-lf <arg>] [-h]
-b,--broker <arg> Broker URL. E.g., tcp://127.0.0.1:1883
-v,--version <arg> MQTT version ("3" for 3.1.1 or "5" for 5.0).
-p,--npub <arg> Number of publishers.
-s,--nsub <arg> Number of subscribers.
-pq,--pubqos <arg> QoS level of publishers (0/1/2).
-sq,--subqos <arg> QoS level of subscribers (0/1/2).
-ss,--shsub Enable shared subscription.
-r,--retain Enable retain.
-t,--topic <arg> Topic name to be used.
-d,--payload <arg> Data (payload) size in bytes.
-m,--nmsg <arg> Number of messages sent by each publisher.
-i,--interval <arg> Publish interval in milliseconds.
-st,--subtimeout <arg> Subscribers' timeout in seconds.
-et,--exectime <arg> Execution time in seconds.
-l,--log <arg> Log level (SEVERE/WARNING/INFO/ALL).
-n,--ntp <arg> NTP server. E.g., ntp.nict.jp
-tf,--thfile <arg> File name for throughput data.
-lf,--ltfile <arg> File name for latency data.
-h,--help Display help.
:
:
```

For example, you can run MQTTLoader with one publisher that sends 10 messages and one subscriber by:
Expand Down Expand Up @@ -77,6 +62,8 @@ For example, the following command uses a public MQTT broker provided by HiveMQ.
| -t \<arg\> | mqttloader-test-topic | Topic name to be used. |
| -d \<arg\> | 1024 | The size of data (payload of messages to be published) in bytes. |
| -m \<arg\> | 100 | Number of messages sent by **each** publisher. |
| -ru \<arg\> | 0 | Ramp-up time in seconds. The beginning data within the specified time are excluded. |
| -rd \<arg\> | 0 | Ramp-down time in seconds. The trailing data within the specified time are excluded. |
| -i \<arg\> | 0 | Publish interval in milliseconds. |
| -st \<arg\> | 5 | Timeout for receiving messages by subscribers in seconds. |
| -et \<arg\> | 60 | Maximum execution time for measurement in seconds. |
Expand Down Expand Up @@ -133,6 +120,16 @@ Below is an example of calculating throughputs in the case that two publishers,
| 7 | 0 | 0 | Excluded |
| 8 | 0 | 0 | Excluded |

By using the parameterse `-ru` and `-rd`, you can further exclude the beginning and trailing data.
If you set `-ru 1 -rd 1` in the above example, the following data is used.

| Elapsed seconds from starting measurement | # of meessages from A | # of messages from B | Throughputs |
|:-----------|:------------|:------------|:------------|
| 2 | 4 | 3 | 7 |
| 3 | 5 | 5 | 10 |
| 4 | 0 | 0 | 0 |
| 5 | 3 | 4 | 7 |

For subscribers, throughputs are calculated as same as the above for the received messages.
In addition, the maximum latency and the average latency are calculated.
Latency is the required time from sending out by a publisher to receiving by a subscriber.
Expand Down
37 changes: 17 additions & 20 deletions doc/usage_jp.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,13 @@ Windowsユーザはmqttloader.bat(バッチファイル)を、Linux等のユ

```
usage: mqttloader.Loader -b <arg> [-v <arg>] [-p <arg>] [-s <arg>] [-pq
<arg>] [-sq <arg>] [-ss] [-r] [-t <arg>] [-d <arg>] [-m <arg>] [-i
<arg>] [-st <arg>] [-et <arg>] [-l <arg>] [-n <arg>] [-tf <arg>]
[-lf <arg>] [-h]
<arg>] [-sq <arg>] [-ss] [-r] [-t <arg>] [-d <arg>] [-m <arg>] [-ru
<arg>] [-rd <arg>] [-i <arg>] [-st <arg>] [-et <arg>] [-l <arg>]
[-n <arg>] [-tf <arg>] [-lf <arg>] [-h]
-b,--broker <arg> Broker URL. E.g., tcp://127.0.0.1:1883
-v,--version <arg> MQTT version ("3" for 3.1.1 or "5" for 5.0).
-p,--npub <arg> Number of publishers.
-s,--nsub <arg> Number of subscribers.
-pq,--pubqos <arg> QoS level of publishers (0/1/2).
-sq,--subqos <arg> QoS level of subscribers (0/1/2).
-ss,--shsub Enable shared subscription.
-r,--retain Enable retain.
-t,--topic <arg> Topic name to be used.
-d,--payload <arg> Data (payload) size in bytes.
-m,--nmsg <arg> Number of messages sent by each publisher.
-i,--interval <arg> Publish interval in milliseconds.
-st,--subtimeout <arg> Subscribers' timeout in seconds.
-et,--exectime <arg> Execution time in seconds.
-l,--log <arg> Log level (SEVERE/WARNING/INFO/ALL).
-n,--ntp <arg> NTP server. E.g., ntp.nict.jp
-tf,--thfile <arg> File name for throughput data.
-lf,--ltfile <arg> File name for latency data.
-h,--help Display help.
:
:
```

例えば以下のように実行すると、MQTTLoader は publisher と subscriber をひとつずつ立ち上げ、publisher からは10個のメッセージが送信(PUBLISH)されます。
Expand Down Expand Up @@ -78,6 +63,8 @@ MQTTLoaderの動作を確認するだけなら、パブリックブローカを
| -t \<arg\> | mqttloader-test-topic | 測定で用いられるトピック名 |
| -d \<arg\> | 1024 | publisherが送信するメッセージのデータサイズ(MQTTパケットのペイロード部分のサイズ)。単位はbyte。 |
| -m \<arg\> | 100 | ****publisherによって送信されるメッセージの数。 |
| -ru \<arg\> | 0 | ランプアップ時間。単位は秒。スループットやレイテンシの計測データのうち、最初から指定秒数までのデータが除外される。 |
| -rd \<arg\> | 0 | ランプダウン時間。単位は秒。スループットやレイテンシの計測データのうち、最後から指定秒数前までのデータが除外される。 |
| -i \<arg\> | 0 | 各publisherがメッセージを送信する間隔。単位はミリ秒。 |
| -st \<arg\> | 5 | subscriberの受信タイムアウト。単位は秒。 |
| -et \<arg\> | 60 | 測定の実行時間上限。単位は秒。 |
Expand Down Expand Up @@ -135,6 +122,16 @@ MQTTLoaderは、各publisherごとに、毎秒の送信メッセージ数をカ
| 7 | 0 | 0 | 集計対象外 |
| 8 | 0 | 0 | 集計対象外 |

パラメータ`-ru``-rd`を用いると、集計対象データからさらに最初と最後の一定秒数分を計算から除外することができます。
上記の例にて、 `-ru 1 -rd 1` と設定した場合、以下のデータが集計対象として扱われることになります。

| 測定開始からの秒数 | Aの送信メッセージ数 | Bの送信メッセージ数 | スループット集計値 |
|:-----------|:------------|:------------|:------------|
| 2 | 4 | 3 | 7 |
| 3 | 5 | 5 | 10 |
| 4 | 0 | 0 | 0 |
| 5 | 3 | 4 | 7 |

subscriberに関しても、上記と同様にして、受信メッセージのスループットが計算されます。
これに加えて、subscriber側では、最大レイテンシと平均レイテンシも計算されます。
レイテンシは、publisherが送信したメッセージがsubscriberに届くまでの時間です。
Expand Down
74 changes: 74 additions & 0 deletions src/main/java/mqttloader/Constants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package mqttloader;

public class Constants {
public static final String SUB_CLIENT_ID_PREFIX = "mqttloaderclient-sub";
public static final String PUB_CLIENT_ID_PREFIX = "mqttloaderclient-pub";

public enum Opt {
BROKER("b", "broker", true, "Broker URL. E.g., tcp://127.0.0.1:1883", null, true),
VERSION("v", "version", true, "MQTT version (\"3\" for 3.1.1 or \"5\" for 5.0).", "5"),
NUM_PUB("p", "npub", true, "Number of publishers.", "10"),
NUM_SUB("s", "nsub", true, "Number of subscribers.", "0"),
PUB_QOS("pq", "pubqos", true, "QoS level of publishers (0/1/2).", "0"),
SUB_QOS("sq", "subqos", true, "QoS level of subscribers (0/1/2).", "0"),
SH_SUB("ss", "shsub", false, "Enable shared subscription.", null),
RETAIN("r", "retain", false, "Enable retain.", null),
TOPIC("t", "topic", true, "Topic name to be used.", "mqttloader-test-topic"),
PAYLOAD("d", "payload", true, "Data (payload) size in bytes.", "1024"),
NUM_MSG("m", "nmsg", true, "Number of messages sent by each publisher.", "100"),
RAMP_UP("ru", "rampup", true, "Ramp-up time in seconds.", "0"),
RAMP_DOWN("rd", "rampdown", true, "Ramp-down time in seconds.", "0"),
INTERVAL("i", "interval", true, "Publish interval in milliseconds.", "0"),
SUB_TIMEOUT("st", "subtimeout", true, "Subscribers' timeout in seconds.", "5"),
EXEC_TIME("et", "exectime", true, "Execution time in seconds.", "60"),
LOG_LEVEL("l", "log", true, "Log level (SEVERE/WARNING/INFO/ALL).", "WARNING"),
NTP("n", "ntp", true, "NTP server. E.g., ntp.nict.jp", null),
TH_FILE("tf", "thfile", true, "File name for throughput data.", null),
LT_FILE("lf", "ltfile", true, "File name for latency data.", null),
HELP("h", "help", false, "Display help.", null);

private String name;
private String longOpt;
private boolean hasArg;
private boolean required;
private String description;
private String defaultValue;

private Opt(String name, String longOpt, boolean hasArg, String description, String defaultValue) {
this(name, longOpt, hasArg, description, defaultValue, false);
}

private Opt(String name, String longOpt, boolean hasArg, String description, String defaultValue, boolean required) {
this.name = name;
this.longOpt = longOpt;
this.hasArg = hasArg;
this.description = description;
this.defaultValue = defaultValue;
this.required = required;
}

public String getName() {
return name;
}

public String getLongOpt() {
return longOpt;
}

public boolean hasArg() {
return hasArg;
}

public boolean isRequired() {
return required;
}

public String getDescription() {
return description;
}

public String getDefaultValue() {
return defaultValue;
}
}
}
Loading

0 comments on commit 62922bb

Please sign in to comment.