Index ¦ Archives ¦ Atom

IoT Device simulation with IoSynth

Summary: In this article, I will show you how to build a test environment to simulate 1000 IoT devices connected to MQTT broker.

Update: New snapshot have new configuration. To get the new version and documentation go to IoSynth site.

When developing new IoT products it is usually useful to have controlled and reproducible environment of IoT devices for testing and experimenting. Scaling such environment to hundreds of thousands devices can help evaluating the products with realistic load.

MQTT protocol has been widely used in various industries to communicate between IoT devices. It is a machine-to-machine connectivity protocol.

I have created small Java package that simulates IoT devices. Each device contains a set of sensors with different behavior. The program connects to MQTT broker and publishes data from devices in predefined topics.

To start playing with the package you will need a MQTT broker. You may install one of the many available implementations such as Mosquitto, or you can use some of the publically accessible sandbox servers like

The MQTT works around the concept of “topics”. That is a directory like structure where the MQTT clients publish messages to broker and other clients subscribe to these broker topics to receive messages.

IoSynth package simulate multiple devices that generate synthetic data and publish messages to e MQTT broker topics. I use the Paho client library to implement MQTT protocol.

The simulator library creates Device objects that are containers for Sensor objects. Each sensor have predefined generation function (Random Walk, Cycle through values, etc.…). There are generally two types of devices: devices with fixed sampling rate and devices with variable rate. The sensors produce numerical and categorical data. If you do not want to write java code to create devices and sensors, I have provided some ready to use applications with predefined sensors and devices. Currently appliications a very limited in configuration options.

You can run the application from command line like this:

/home/user> java -cp iosynth-0.0.1.jar -c MqttConfig.json

Where the configuration file MqttConfig.json is like this:


This will run the default application provided in the jar file assuming you have Java 7 installed in your PATH. The jar contains prepackaged dependencies (Paho Library), so you don't need to search and install them. This will create a set of 10 devices that will publish the data on “” topic on you localhost:1883 MQTT broker. The session specify random string used to create unique topic. If omitted, one will be generted for each run.

If you do not have broker installed you can use one public broker like the following:


Now you can see the published messages using a MQTT client by subscribing to the topics. I use the client provided with the Mosquitto installation:

/home/user> mosquitto_sub -v -t "iosynth/+/device/#" -h localhost -p 1883

The result should be like this:

iosynth/mdejsighzne/device/0010 {"time":"2016-12-23 15:42:12.870","door":"OF","1st floor":"elevator_02","state":18,"count":401}
iosynth/mdejsighzne/device/0003 {"time":"2016-12-23 15:42:13.436","state":7,"level":1.3000,"temp":18.2241,"semafor":"green","word":"Golf","prime":281}
iosynth/mdejsighzne/device/0001 {"time":"2016-12-23 15:42:13.667","state":7,"level":1.3000,"temp":16.1164,"semafor":"green","word":"Sierra","prime":181}
iosynth/mdejsighzne/device/0005 {"time":"2016-12-23 15:42:14.111","state":7,"level":1.3000,"temp":18.4741,"semafor":"green","word":"Xray","prime":313}
iosynth/mdejsighzne/device/0004 {"time":"2016-12-23 15:42:14.247","state":7,"level":1.3000,"temp":16.4652,"semafor":"green","word":"Lima","prime":461}
iosynth/mdejsighzne/device/0002 {"time":"2016-12-23 15:42:14.513","state":7,"level":1.3000,"temp":19.4194,"semafor":"green","word":"Foxtrot","prime":43}
iosynth/mdejsighzne/device/0007 {"time":"2016-12-23 15:42:15.270","door":"ON","1st floor":"elevator_03","state":1,"count":307}
iosynth/mdejsighzne/device/0009 {"time":"2016-12-23 15:42:16.973","door":"ON","1st floor":"elevator_03","state":13,"count":439}
iosynth/mdejsighzne/device/0003 {"time":"2016-12-23 15:42:23.436","state":8,"level":1.2000,"temp":18.2490,"semafor":"yellow","word":"Whiskey","prime":503}
iosynth/mdejsighzne/device/0001 {"time":"2016-12-23 15:42:23.667","state":8,"level":1.2000,"temp":16.0466,"semafor":"yellow","word":"Charlie","prime":3}
iosynth/mdejsighzne/device/0005 {"time":"2016-12-23 15:42:24.111","state":8,"level":1.2000,"temp":18.4225,"semafor":"yellow","word":"Papa","prime":467}
iosynth/mdejsighzne/device/0004 {"time":"2016-12-23 15:42:24.247","state":8,"level":1.2000,"temp":16.5070,"semafor":"yellow","word":"Kilo","prime":373}
iosynth/mdejsighzne/device/0002 {"time":"2016-12-23 15:42:24.513","state":8,"level":1.2000,"temp":19.4637,"semafor":"yellow","word":"Juliett","prime":149}
iosynth/mdejsighzne/device/0007 {"time":"2016-12-23 15:42:25.000","door":"OF","1st floor":"elevator_04","state":1,"count":79}
iosynth/mdejsighzne/device/0006 {"time":"2016-12-23 15:42:26.330","door":"ON","1st floor":"elevator_03","state":9,"count":37}
iosynth/mdejsighzne/device/0008 {"time":"2016-12-23 15:42:26.737","door":"ON","1st floor":"elevator_03","state":16,"count":307}

The “#” character at the end is topic filter that shows all topics starting with the given prefix.

You can subscribe to individual device like this:

/home/user> mosquitto_sub -v -t "iosynth/+/device/0006" -h localhost -p 1883

This will show the device with Id 0006:

iosynth/mdejsighzne/device/0006 {"time":"2016-12-23 16:20:11.215","door":"ON","1st floor":"elevator_03","state":20,"count":409}
iosynth/mdejsighzne/device/0006 {"time":"2016-12-23 16:20:21.865","door":"OF","1st floor":"elevator_04","state":21,"count":151}
iosynth/mdejsighzne/device/0006 {"time":"2016-12-23 16:20:38.786","door":"ON","1st floor":"elevator_01","state":20,"count":443}
iosynth/mdejsighzne/device/0006 {"time":"2016-12-23 16:20:58.338","door":"OF","1st floor":"elevator_02","state":20,"count":181}

In case you do not have Mosquitto client installed you can use one of the chrome mqtt plugins like MQTTBox.

Here is a list of simulated devices/sensors:

  • 5 devices with fixed sample rate (10s) with following sensors.
    • sensor that cycle through list of integer numbers (state)
    • sensor that cycle through list of double numbers (level)
    • sensor that produce random numbers between 15 and 25 (temp)
    • sensor that cycle through list of strings (semafor)
    • sensor that produce random string from list of strings (word)
    • sensor that random random integer number from list of integers (prime)
  • 5 devices with variable sample rate (with uniform arival times between 1s and 25s).
    • sensor that cycle through list of strings (door)
    • sensor that cycle through list of strings (1st floor)
    • sensor that produce random numbers between 0 and 25 (state)

I have also created some other applications with more sensors that preferably should be run only on your own servers.

/home/user> java -cp iosynth-0.0.1.jar -c MqttConfig.json

The App1000 application is the same as AppMqtt but creates 500+500 devices.

List of public MQTT brokers

Server Port 1883 / 8883 1883 1883 / 8883 / 8884 1883 1883

© Ross.