LAN Simulation using the IoTIFY Mailbox API

LAN (Local Area Network) simulation is an important aspect of IoT (Internet of Things) testing and development. In real-world scenarios, not every device in the IoT system has direct access to the Internet. This is especially evident in systems that use Z-wave or BLE devices that communicate through a Hub.

Test all possible communication topologies

By simulating diverse devices in a LAN scenario, you can validate several niche use cases that are specific to your IoT System architecture. Such testing may also bring certain vendor issues to the spotlight that would have been otherwise uncaught. One such issue is the AWS Limitation on ‘Max Subscription topics per call/connection’. Read more about it in this blog article.

Feature Spotlight: The IoTIFY Mailbox API

Being a platform purpose-built for IoT Testing, we wanted to provide a meaningful way of creating data pipelines between device models. This is where the IoTIFY Mailbox APIs come into play.

With Mailbox, you can create custom connections between your virtual devices to emulate ZigBee, Z-wave, BLE or any other LAN architecture. It is essentially a fast array that the devices can push to and read from. The following methods are available within the device template to use this feature:

  • : Pushes data into a specified mailbox
  • mailbox.pop : Pops data from a specified mailbox
  • mailbox.count : Returns the count of messages in a mailbox
  • mailbox.dump : Returns all data from a mailbox
  • mailbox.delete : Deletes a specified mailbox

Read on to see a simple example of a Smart Home use case where a Hub to thermostat interaction is modelled.

Creating a LAN simulation with IoTIFY

You can start by creating a free account at and familiarizing yourself with the basics of the platform with our Docs and the Meet IoTIFY playlist on YouTube.

For this example, we are going to model the simplest situation of a Hub interacting with a smart thermostat. The following is the behaviour captured:

  • The hub subscribes to the MQTT topic on behalf of the thermostat. When a message comes for the thermostat, the hub forwards it over Mailbox
  • The hub periodically checks its mailbox for new messages and publishes them to the relevant topics if any are present
  • The hub periodically sends a ping to the thermostat over Mailbox
  • The thermostat periodically sends a payload to the hub’s mailbox, which is intended to be published over MQTT

Please note that this is a one hub-one thermostat scenario modelled here. It is kept simple to focus on the communication interface. The same concept can be extended to one hub and many thermostats/other devices.

Let’s get started by creating the sample templates from the IoTIFY Tests section. Click on ‘Create from Sample’ and choose the ones shown below.

Sample Tests on IoTIFY

Taking a quick look at the code, you can see that there are two Mailboxes being created per device pair, gateway_x which is the incoming channel for the gateway, and thermostat_x which is the incoming channel for the thermostat. This means that if 100 gateway-thermostat pairs are run, 200 such channels will be created.

The following snippet checks for any incoming messages and calls a function to process them

					  let messageCount = mailbox.count(rx_channel_id)
  if (messageCount > 0) {
    console.log(messageCount + ' Message(s) are present for the gateway to process.')
    for (let i = 0; i < messageCount; ++i){

To run these tests, you will have to create a Run Setting from the sidebar with the following parameters

Run settings for Mailbox Simulation

Once the Run Setting has been created, you can run both tests with the same setting. Let us now take a look at the results.

In the results of the hub test run, you can see the Logs defined in the test.

You can check the Payload tab for the payloads that have been published on MQTT

Similarly, the logs of the Thermostat run will show the pings sent by the hub and the messages that the thermostat sent to the gateways’ mailbox.

In Summary

This barely scratches the surface of what can be accomplished with the IoTIFY Mailbox APIs. You can model many complex device interactions as well as test out methods for optimizing your architecture.

If you would like to discuss any of the topics mentioned in this post, please Contact Us, and we can offer a Free Consultation for your use case. You can try the platform out yourself by signing up at