Skip to content

Commit fcf0bcc

Browse files
authored
Merge pull request #21 from dist-sys/add-tls-auth
Add TLS authentication
2 parents 45c6db6 + 9e07cf3 commit fcf0bcc

13 files changed

+769
-321
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
# Gradle related files
55
.gradle/
66
build/
7+
8+
# TLS-related files
9+
*.jks

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# MQTTLoader
22
MQTTLoader is a load testing tool (client tool) for MQTT.
3-
It supports both MQTT v5.0 and v3.1.1.
3+
It supports both MQTT v5.0 and v3.1.1, as well as TLS authentication is available.
44

55
- [Usage (English)](https://github.com/dist-sys/mqttloader/blob/master/doc/usage_en.md)
6-
- [Usage (Japanese)](https://github.com/dist-sys/mqttloader/blob/master/doc/usage_jp.md)
6+
- [Usage (日本語)](https://github.com/dist-sys/mqttloader/blob/master/doc/usage_jp.md)
77

88
Below is an execution result sample.
99

@@ -26,7 +26,9 @@ Average latency[ms]: 1.39
2626
MQTTLoader is licensed under the Apache License, Version2.0.
2727

2828
## Publications
29-
- R. Banno, K. Ohsawa, Y. Kitagawa, T. Takada, T. Yoshizawa, "Measuring Performance of MQTT v5.0 Brokers with MQTTLoader", IEEE Consumer Communications & Networking Conference (CCNC), January 2021. (accepted)
29+
- R. Banno, K. Ohsawa, Y. Kitagawa, T. Takada, T. Yoshizawa, "Measuring Performance of MQTT v5.0 Brokers with MQTTLoader", IEEE Consumer Communications & Networking Conference (CCNC), January 2021. (Demo paper)
3030

3131
## Contact
3232
https://www.banno-lab.net/en/contact/
33+
34+
We welcome enquiries for research collaborations.

build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ wrapper {
88
}
99

1010
mainClassName = 'mqttloader.Loader'
11-
applicationDefaultJvmArgs = ['-Djava.util.logging.config.file=src/dist/logging.properties', '-Dfile.encoding=UTF-8', '--illegal-access=deny']
11+
applicationDefaultJvmArgs = ['-Djava.util.logging.config.file=src/dist/logging.properties', '-Dfile.encoding=UTF-8', '--illegal-access=deny', '--add-opens=java.base/java.net=ALL-UNNAMED']
1212

1313
repositories {
1414
mavenCentral()
@@ -26,7 +26,7 @@ compileJava {
2626
}
2727

2828
run {
29-
args '-h'.split('\\s+')
29+
// args '-h'.split('\\s+')
3030
}
3131

3232
CreateStartScripts startScripts = project.startScripts

doc/usage_en.md

+158-108
Large diffs are not rendered by default.

doc/usage_jp.md

+156-104
Large diffs are not rendered by default.

src/dist/mqttloader.conf

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
### MQTTLoader CONFIGURATION FILE ###
2+
3+
## ----- Mandatory parameters -----
4+
5+
## Broker's IP address or FQDN.
6+
## e.g., 127.0.0.1
7+
broker = 127.0.0.1
8+
9+
## ----- Optional parameters -----
10+
11+
## Broker's port number.
12+
## DEFAULT: 1883 (non-TLS), 8883 (TLS)
13+
broker_port = 1883
14+
15+
## MQTT version. You can specify "3" for MQTT v3.1.1 and "5" for MQTT v5.0.
16+
## DEFAULT: 5
17+
mqtt_version = 5
18+
19+
## The number of publishers and subscribers.
20+
## DEFAULT: 1
21+
num_publishers = 1
22+
num_subscribers = 1
23+
24+
## QoS level of publishers and subscribers. Valid values are 0/1/2.
25+
## DEFAULT: 0
26+
qos_publisher = 0
27+
qos_subscriber = 0
28+
29+
## Flag for enabling shared subscription. You can specify "true" or "false".
30+
## DEFAULT: false
31+
shared_subscription = false
32+
33+
## Flag for enabling retained messages. You can specify "true" or "false".
34+
## DEFAULT: false
35+
retain = false
36+
37+
## Topic name to be used.
38+
## DEFAULT: mqttloader-test-topic
39+
topic = mqttloader-test-topic
40+
41+
## Payload size of publish messages in bytes. It must be equal to or larger than 8.
42+
## DEFAULT: 20
43+
payload = 20
44+
45+
## The number of messages sent by each publisher.
46+
## DEFAULT: 100
47+
num_messages = 100
48+
49+
## Ramp-up/down time in seconds.
50+
## DEFAULT: 0
51+
ramp_up = 0
52+
ramp_down = 0
53+
54+
## Publish interval in milliseconds.
55+
## DEFAULT: 0
56+
interval = 0
57+
58+
## Timeout for receiving messages by subscribers in seconds.
59+
## DEFAULT: 5
60+
subscriber_timeout = 5
61+
62+
## The maximum execution time for measurement in seconds.
63+
## DEFAULT: 60
64+
exec_time = 60
65+
66+
## Log level. Valid values are SEVERE/WARNING/INFO/ALL.
67+
## DEFAULT: INFO
68+
log_level = INFO
69+
70+
## NTP server's IP address or FQDN.
71+
## e.g., ntp.nict.jp
72+
## DEFAULT: (not set)
73+
# ntp = ntp.nict.jp
74+
75+
## Directory path to write out measurement record. If not set, MQTTLoader run by in-memory mode.
76+
## e.g., /home/testuser
77+
## e.g., C:\\Users\\testuser
78+
## DEFAULT: (not set)
79+
# output = .
80+
81+
## User name and password for password authentication.
82+
## DEFAULT: (not set)
83+
# user_name = john
84+
# password = mypassword
85+
86+
## File path of truststore file in JKS (Java Key Store) format for TLS authentication. By specifying this parameter, TLS authentication is enabled.
87+
## e.g., C:\\Users\\testuser\\truststore.jks
88+
## DEFAULT: (not set)
89+
# tls_truststore = truststore.jks
90+
91+
## Password for the truststore file.
92+
## DEFAULT: (not set)
93+
# tls_truststore_pass = mypassword
94+
95+
## File path of keystore file in JKS (Java Key Store) format for TLS client authentication. By specifying this parameter, TLS client authentication is enabled.
96+
## e.g., C:\\Users\\testuser\\keystore.jks
97+
## DEFAULT: (not set)
98+
# tls_keystore = keystore.jks
99+
100+
## Password for the keystore file.
101+
## DEFAULT: (not set)
102+
# tls_keystore_pass = mypassword
103+
104+

src/main/java/mqttloader/Constants.java

+63-32
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
import java.text.SimpleDateFormat;
2020

2121
public class Constants {
22-
public static final String VERSION = "0.7.3";
22+
public static final String VERSION = "0.8.0";
23+
public static final String BROKER_PREFIX_TCP = "tcp://";
24+
public static final String BROKER_PREFIX_TLS = "ssl://";
25+
public static final String BROKER_PORT_TCP = "1883";
26+
public static final String BROKER_PORT_TLS = "8883";
2327
public static final String FILE_NAME_PREFIX = "mqttloader_";
2428
private static final String HOST_ID = Util.genRandomChars(4);
2529
public static final String SUB_CLIENT_ID_PREFIX = "ml-"+HOST_ID+"-s-";
@@ -32,43 +36,25 @@ public class Constants {
3236
public static final SimpleDateFormat DATE_FORMAT_FOR_FILENAME = new SimpleDateFormat("yyyyMMdd-HHmmss");
3337

3438
public enum Opt {
35-
BROKER("b", "broker", true, "Broker URL. E.g., tcp://127.0.0.1:1883", null, true),
36-
MQTT_VERSION("v", "version", true, "MQTT version (\"3\" for 3.1.1 or \"5\" for 5.0).", "5"),
37-
NUM_PUB("p", "npub", true, "Number of publishers.", "1"),
38-
NUM_SUB("s", "nsub", true, "Number of subscribers.", "1"),
39-
PUB_QOS("pq", "pubqos", true, "QoS level of publishers (0/1/2).", "0"),
40-
SUB_QOS("sq", "subqos", true, "QoS level of subscribers (0/1/2).", "0"),
41-
SH_SUB("ss", "shsub", false, "Enable shared subscription.", null),
42-
RETAIN("r", "retain", false, "Enable retain.", null),
43-
TOPIC("t", "topic", true, "Topic name to be used.", "mqttloader-test-topic"),
44-
PAYLOAD("d", "payload", true, "Data (payload) size in bytes.", "20"),
45-
NUM_MSG("m", "nmsg", true, "Number of messages sent by each publisher.", "100"),
46-
RAMP_UP("ru", "rampup", true, "Ramp-up time in seconds.", "0"),
47-
RAMP_DOWN("rd", "rampdown", true, "Ramp-down time in seconds.", "0"),
48-
INTERVAL("i", "interval", true, "Publish interval in milliseconds.", "0"),
49-
SUB_TIMEOUT("st", "subtimeout", true, "Subscribers' timeout in seconds.", "5"),
50-
EXEC_TIME("et", "exectime", true, "Execution time in seconds.", "60"),
51-
LOG_LEVEL("l", "log", true, "Log level (SEVERE/WARNING/INFO/ALL).", "INFO"),
52-
NTP("n", "ntp", true, "NTP server. E.g., ntp.nict.jp", null),
53-
IN_MEMORY("im", "inmemory", false, "Enable in-memory mode", null),
54-
USERNAME("un", "username", true, "User name for authentication", null),
55-
PASSWORD("pw", "password", true, "Password for authentication", null),
56-
HELP("h", "help", false, "Display help.", null);
39+
CONFIG("c", true, "Configuration file's path.", "mqttloader.conf"),
40+
HELP("h", false, "Display help.");
5741

5842
private String name;
59-
private String longOpt;
6043
private boolean hasArg;
6144
private boolean required;
6245
private String description;
6346
private String defaultValue;
6447

65-
private Opt(String name, String longOpt, boolean hasArg, String description, String defaultValue) {
66-
this(name, longOpt, hasArg, description, defaultValue, false);
48+
private Opt(String name, boolean hasArg, String description, String defaultValue) {
49+
this(name, hasArg, description, defaultValue, false);
6750
}
6851

69-
private Opt(String name, String longOpt, boolean hasArg, String description, String defaultValue, boolean required) {
52+
private Opt(String name, boolean hasArg, String description) {
53+
this(name, hasArg, description, null, false);
54+
}
55+
56+
private Opt(String name, boolean hasArg, String description, String defaultValue, boolean required) {
7057
this.name = name;
71-
this.longOpt = longOpt;
7258
this.hasArg = hasArg;
7359
this.description = description;
7460
this.defaultValue = defaultValue;
@@ -79,10 +65,6 @@ public String getName() {
7965
return name;
8066
}
8167

82-
public String getLongOpt() {
83-
return longOpt;
84-
}
85-
8668
public boolean hasArg() {
8769
return hasArg;
8870
}
@@ -99,4 +81,53 @@ public String getDefaultValue() {
9981
return defaultValue;
10082
}
10183
}
84+
85+
public enum Prop {
86+
BROKER("broker"),
87+
BROKER_PORT("broker_port"), // Default value is configured not here but in Loader class, because it has different default values according to protocol.
88+
MQTT_VERSION("mqtt_version", "5"),
89+
NUM_PUB("num_publishers", "1"),
90+
NUM_SUB("num_subscribers", "1"),
91+
QOS_PUB("qos_publisher", "0"),
92+
QOS_SUB("qos_subscriber", "0"),
93+
SHARED_SUB("shared_subscription", "false"),
94+
RETAIN("retain", "false"),
95+
TOPIC("topic", "mqttloader-test-topic"),
96+
PAYLOAD("payload", "20"),
97+
NUM_MSG("num_messages", "100"),
98+
RAMP_UP("ramp_up", "0"),
99+
RAMP_DOWN("ramp_down", "0"),
100+
INTERVAL("interval", "0"),
101+
SUB_TIMEOUT("subscriber_timeout", "5"),
102+
EXEC_TIME("exec_time", "60"),
103+
LOG_LEVEL("log_level", "INFO"),
104+
NTP("ntp"),
105+
OUTPUT("output"),
106+
USERNAME("user_name"),
107+
PASSWORD("password"),
108+
TLS_TRUSTSTORE("tls_truststore"),
109+
TLS_TRUSTSTORE_PASS("tls_truststore_pass"),
110+
TLS_KEYSTORE("tls_keystore"),
111+
TLS_KEYSTORE_PASS("tls_keystore_pass");
112+
113+
private final String name;
114+
private final String defaultValue;
115+
116+
Prop(String name) {
117+
this(name, null);
118+
}
119+
120+
Prop(String name, String defaultValue) {
121+
this.name = name;
122+
this.defaultValue = defaultValue;
123+
}
124+
125+
public String getName() {
126+
return name;
127+
}
128+
129+
public String getDefaultValue() {
130+
return defaultValue;
131+
}
132+
}
102133
}

0 commit comments

Comments
 (0)