Bevywise IoT Simulator is a GUI based, data simulation tool which is used to load and test the MQTT/IoT Application to know the performance level of that Application. In IoT simulator, you can create virtual IoT network and device, publish events with normal or complex JSON payload, create subscription and more. IoT simulator help documentation will let you know how to simulate IoT networks & IoT devices. For reference, refer to our introduction video tutorial.
OS – Windows 7 or Windows 8 & 8.1, Ubuntu 14.04 or higher.
CPU – Pentium 4 or higher.
Memory – 512 MB RAM or more.
Hard drive – 100 MB of free disk space
$ sh runsimulator.sh
Manager Application has four options, they are
Note: The Manager Application and Broker IP address settings will not be modified after saving the Simulator settings.
Client IP address:
This feature will assign a separate IP address for each client in the Network. For example, if you create 5 devices, then by default the 5 devices will connect to the MQTT broker with the same IP address. But, when you enable “Client IP address” and give IP address range [like 192.168.1.2 to 192.168.1.5] in First & Last IP address, then the IoT simulator will automatically assign separate IP address for each created client or device. Now the device will connect to the MQTT Application with a different IP address. To enable, follow the below steps :
Random Start/Stop:
Bevywise IoT Simulator will randomly stop and start the created IoT Devices based on the minimum uptime or runtime using the “Random Start/Stop” feature. For example, if you specify the minimum uptime as 50%, then the devices will randomly stop when it reaches 50% running or uptime. To enable, follow the below steps :
Advanced Python Interceptor:
Bevywise IoT Simulator can be customized using a python-based interface called Python interceptor. This interceptor provides all the created clients’ information and its received payload via python file called “default_interceptor.py”. In that python file, you can write your own code based on the received payload and also it allows you to call API to simulate complex scenarios. To enable, please follow the below steps :
Edge device authentication will provide a secure connection between the MQTT application and device. Likewise, Bevywise IoT Simulator supports edge device authentication to connect the created device to the MQTT application securely. To enable Authentication,
IoT simulator has two types of Authentication which help you to connect to different MQTT/IoT applications. They're :
SAS : With a SAS token, you can grant created clients access to your MQTT Application. It will be useful when you connect to MQTT Applications like Azure.
Self Signed : If your MQTT application allows access to clients with client or device certificate and key, then you can select Self Signed. Here you should upload the client certificate and key which you have got from the MQTT Application.
Note: This Authentication type will appear when you select Azure and AWS in Manager Application on Simulator Settings.
For other MQTT Application, you can directly copy & paste the client.certificate and key inside the client folder[./Bevywise/IotSimulator/Certificate]. After pasting the certificate and key, you must rename the certificate client.crt and client.key. For Root certificate, you can add it via simulator settings.
In case, if one of the IoT devices got disconnected due to some issue it can publish the events to the subscriber(who subscribes to the topic in that device) only when the WILL message is enabled. To enable the WILL message, select the WILL checkbox and give the topic, message, QoS, etc.
Events are used to create a time-based publishing message for the IoT devices. Based on the time-based publishing Message, Broker will collect the data from IoT Device and send that data to the subscriber.
Before Configuring the IoT Events you must know about the Following Parameters:
1. System variables – This value is used to publish the events with the System variables like $Client_ID, $Current_time, etc.
2. Random – This value is used to publish the events in random like when the system is ON|OFF
3. Range – This value is used to publish the events for a certain range of numbers like 1-100
4. Constant – This value is used to publish the events in Alphabet and numbers
JSON syntax
{ “ KEY 1” : “ VALUE1 ” , “KEY2” : “ VALUE2 “ , “ KEY 3“ : “VALUE 3” }
Example For Nested JSON
{
“Accelerometer”:
{
“Status”: “On|Off-RANDOM”,
“Vibration_level”: “50-55-RANGE”,
“Sensor_On_Time”: “$Client_uptime-SYSTEMVARIABLE”
},
“Gas_Sensor”
{
“Status”:”On|Off-RANDOM”,
“Methane_level”: “10-20-RANGE”,
“Sensor_On_Time”: “$Client_uptime-SYSTEMVARIABLE”
}
}
Parameters
Parameters
Parameters
Parameters
Parameters
Parameters
Parameters
Example Topics
FIRST TOPIC | SECOND TOPIC |
---|---|
Subscribe on: On Start | Subscribe on: Specific Time |
Topic:Coal_Mines/Gas_Sensor/Harmful_gases_Level | Time: 10:00 AM Topic:Coal_Mines/Oxygen_Sensor/Oxygen_Percent | QoS: At most Once | QoS: At most once |
In Templates, you can create a pre-defined device with events, subscription and device response. This will save time by creating a new device and also help you to add a bulk number of devices.
Microsoft Azure has a built-in IoT application called IoT Hub. Azure will allow the client via TLS/SSL connection only. Message Broker will run with TLS/SSL at port 8883. There are two methods to connect to Azure IoT over TLS/SSL.
They’re as follows :
Requirements :
Self-signed
1. Install OpenSSL in your environment. For windows user, please set an environmental variable for OpenSSL
2. Open the terminal or command prompt and give the below command
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout private.key -out certificate.crt
3. Next, skip the all other steps by clicking enter and only give the Common Name as the device name
4. Now certificate.crt and private.key will be generated in the current location.
5. Next, you must get the fingerprint for the created certificate which is to be uploaded in Azure IoT Hub device as a thumbprint. Use the below command to get a fingerprint for the created certificate.
openssl x509 -noout -fingerprint -sha1 -inform pem -in certificate.crt
6. Output will be similar to
SHA1 Fingerprint= D7:A8:16:71:AF:22:DA:E0:AA:26:7A:48:4A:52:A5:83:B7:89:C7:96
7. Now, copy the fingerprint alone and paste it in any text editor and remove ‘:’
[For example, D7A81671AF22DAE0AA267A484A52A583B789C796]
8. Now copy the fingerprint from the text editor and paste it in both Primary and Secondary thumbprint.
9. Click save to create a Azure IoT Hub device.
Before starting the Simulator, you must need an Azure root certificate. To create, follow the below steps :
1. Clone or download the zip in the Azure IoT SDK for C from github
2. Extract the downloaded zip and go to the certs folder
3. Inside the certs folder, open certs.c and you can see many root Certificates for Azure IoT Hub.
4. Next, create the file with the name root.crt and copy & paste any one certificate [including the lines BEGIN CERTIFICATE and END CERTIFICATE, also remove“,\\r,\\n from all lines].
After creating a device in Azure IoT Hub, you can run the IoT Simulator in your environment.
“ < hostname>/ < devicename>“
1. hostname – Azure IoT Hub hostname
2. devicename – The name of the device
Leave the Access Token tab empty. Next, create events for the device by using the below topic syntax.
Note: Change the device name alone. Other than that don’t change any other field.
Start the network by clicking the start button and if the connection is successful, you can see the published message in the simulator Network log or device log.
AWS platform as a built-in IoT platform is called as AWS IoT core. AWS will allow client via TLS/SSL connection only and has Message Borker running with TLS/SSL at port 8883. Below steps will help you to connect IoT Simulator to AWS IoT core
AWS Configuration
1. Give policy name and in the action section select *
2. In the 'Resource ARN' field give *
Follow the below steps to create “Thing TYPE” :
Certificates needed to be downloaded :
Simulator Configuration
Note: Enabling authentication requires uploading individual client certificates and keys, each renamed for specific devices as client.crt, client.key, client1.crt, client1.key, client2.crt, client2.key, and so on.
Follow the below steps to create “Thing group”:
Following the steps above, the IoT simulator has been configured to connect seamlessly with AWS IoT Core.
Bevywise IoT platform configuration
Follow the below steps to connect IoT Simulator to the Bevywise IoT Platform.
There are three types of permission. They’re :
Click the ‘Add’ button.
Once you’re done, the newly created device along with its auth key and auth token will be displayed in the Authentication key list.
Here the Auth key will act as the username and Auth token as the password.
IoT Simulator Configuration
Note : To know the steps to create events, please refer the Configuration of IoT Events section.
If you’re using MQTT/IoT application other than AWS, Azure or Bevywise IoT platform,
Simulator Configuration
Note: If your MQTT Application has some topic restriction, then you must create an event with that topic format. For example, refer Azure IoT Hub.
Note: For more help and support to connect IoT Simulator to your own MQTT Application, please contact Bevywise Support team.
This section helps you to connect IoT Simulator to MQTT Broker. Below, we have shown the connection of IoT simulator to MQTT Broker with TLS/SSL and to MQTT Broker without TLS/SSL.
For more information, refer to our video tutorial .
Simulator Configuration
1. Manager Application – Others
2.Broker IP Address – IP address of PC or server where you run the MQTT Broker
3. TLS/SSL – Enable
4. Port – By default 8883, if your MQTT broker runs in a different port, specify here.
5. Root certificate – Upload the root.crt file which you have created or downloaded before[ Don’t forget to click upload]
Connecting to MQTT Broker running without TLS/SSL enabled.
Simulator Configuration
1. Click the red checkbox next to Authentication.
2. In drop-down, click the edit icon next to the Access key and paste the username from MQTT Broker and then save it
3. For Access token, paste password from the MQTT Broker and save it
Protocol buffers are Google’s structured format that are used to serialize and encode your data. You can specify how your data should be in a structured format and you can make such structured data easy to read & write using the language you prefer.
Here is the step by step procedure to use protocol buffers in python. You can follow the below steps to add Python support for MQTT payload of Protocol buffer type in Bevywise IoT Simulator.
Start compiling .proto file
syntax = “proto2”;
ackage screen;
message Payload {
optional string contrast_ratio = 1;
optional string viewing_tech = 2;
optional string color_depth = 3;
optional string touch_type = 4;
optional int32 ntsc = 5;
optional int32 temperature = 6;
optional int32 backlight_longevity = 7;
optional int32 luminance = 8;
}
Compiling the .proto file is the next step. You can compile it using protobuf compiler. The compiler then generates a python file.
Note : Protobuf compiler can be installed using the following command :
$ sudo apt install protobuf-compiler
For compiling the file use the following command :
$ protoc --python_out=. Documents/screen.proto
In the place of 'Documents' you have to give the path where your .proto file is located.
If you are using Bevywise MQTT Broker, you have to download binary MQTT broker to get utilized with the protocol buffer. The link to download binary MQTT broker is provided here. Then follow the similar steps of connecting Bevywise IoT simulator with MQTT broker. Before connecting the simulator, you have to add protocol buffer support to both simulator & MQTT broker. Let's start with it.
In the Simulator UI, choose an existing device or create a new device. Also create an event that corresponds to the .proto file which is used.
For instance, paste the following commands into the message text area.
{“luminance”: “100-1000-RANGE”, “color_depth”: “65M-CONSTANT”, “temperature”: “1-100-RANGE”, “ntsc”: “45-60-RANGE”, “contrast_ratio”: “200:1-CONSTANT”, “backlight_longevity”: “20000-60000-RANGE”, “touch_type”: “capacitive-CONSTANT”, “viewing_tech”: “oled-CONSTANT”}
By Default, IoT Simulator will run with SQLite. But for more device connection or load testing, SQLite is not efficient. For that case, you can change the storage configuration to MySQL. Before configuring MySQL in IoT Simulator, you must install MySQL 5.7 or higher on your PC. After installing MySQL, please follow the below steps.
For Linux Users:
For Window/Windows server users:
In the Edit System Variable (or New System Variable) window, specify the path where wget.exe is located. Click OK. Close all other remaining windows by clicking OK.
Note: The Above dependencies can skipped if it is already installed in PC.
In that file change the following :
Note: Check whether MySQL is running on 3306 port.
Note: Please don’t use XAMPP or MAMP for MySQL.
Python installation in windows
If you run the install_mysql_connector.bat file, python2.7 will be downloaded automatically and the installation will start at once it gets downloaded. [The python installation step can be skipped if it is already installed]
Follow the below steps in order to install python2.7: