Skip to main content
BlogNewsTop News

Simulating NB-IoT networking in Renode

By May 30, 2023No Comments

This blog was originally published on the Antmicro website. Click here  for more articles like this one.

Repeatable testing and debugging are notoriously difficult in IoT system development, as they typically involve multiple devices connected by different networks, making it hard to pinpoint the exact root of a problem and reliably fix it. Renode, Antmicro’s open source simulation framework, is built to address this problem with its deterministic, repeatable, multi-node simulation capabilities that allow our customers to build massive regression testing CIs which ensure their projects work regardless of circumstances.

Renode is constantly gaining new capabilities which expand its potential use cases, and one of the latest developments is support for NB-IoT (Narrowband Internet of Things) which lets you test and fine-tune your simulated device’s cellular network modem connection.

Simulating NB-IoT networking in Renode

NB-IoT in Renode

As part of a customer project, we were tasked with developing a Renode model for the Quectel BC66-NA, a low-power multi-band LTE Cat NB2 module for IoT devices such as wearables, smart city, security, etc. To simulate all the necessary functionalities of Quectel BC66-NA, we implemented high-level, transport-layer (as in TCP) networking using emulated network services. This enables easy support for cellular modems and other peripherals that have their own network stack.

NB-IoT device simulation capabilities are not specific to the Quectel BC66-NA and paved the way for modeling similar modules. The implementation is compatible with any peripheral that supports AT commands, e.g., BC66, BC660K, and BG96. While the protocol used by the emulated MCU to communicate with the modem is based on the AT command set, it is not limited to that and allows you to easily add more custom commands to your model.

One of the reasons for developing a Renode model for the BG96 module as well as its support in the Zephyr RTOS with the quectel_bg9x driver, which allows you to develop and run your embedded software based fully on open source. Thanks to a number of integrations between Zephyr, Renode and a variety of testing frameworks, you can use e.g. Robot or CMock/Unity to test your Zephyr-based software in simulation in Renode in a repeatable way without having to put physical boards into your server room.

Simulated NB-IoT environment

The simulated cellular network model gives you access to parameters such as NetworkLocationAreaTrackingAreaCode, or NetworkIp, letting you simulate and fine-tune all aspects of the connection. Adding an emulated network service to your simulation is straightforward – you only need to specify the class that implements it and the hostname and port you want it reachable at:

Once the modem is added to your simulation, CustomServiceImplementation (or whatever name you decide to give to your type) will handle any connection initiated with the specified address and port. You can use the EchoService sample implementation as a base for your solution.

The goal for the near future is to implement a TCP/IP stack in Renode itself, which would enable communication between emulated network services and network peripherals that operate on a lower level (such as Ethernet controllers), as well as communication between machines using modems and the host network.

Testing real-life IoT scenarios

The newly simulated modem opens up an entire new realm of possible test scenarios for your IoT project. NetworkRegistrationState can be used to simulate the modem connecting and disconnecting from the cellular network, which is difficult to test but common in real-world scenarios. To test your software’s behavior, you could start the emulation in the NotRegisteredNotSearching state and verify that your software does not start trying to send data until the state changes to RegisteredHomeNetwork. Theoretically, in a scenario like this, testing the behavior of your software on physical hardware would be possible, but it would require a complicated, completely isolated environment and would be difficult to automate efficiently.

You can see the simulated modem in action on your local machine and freely modify its settings using one of the built-in Renode scripts.

The script will run the Zephyr echo_client sample, which will connect to the emulated EchoService, which sends all received data back to the sender.

Simulate your IoT project’s environment with Renode

Renode is a flexible framework that enables you to simulate many aspects of the environment surrounding your IoT project, from sensor inputs such as temperature or ECG signals, to a cellular network connection. With Renode, you can reliably and repeatably test your IoT projects in scenarios closely mimicking real-life uses of your product, letting you accelerate your development and increase the quality and security of your software.

Antmicro can help you simulate and test your next NB-IoT project at any stage of development in a fully deterministic and controllable environment. If you are interested in building your next cutting-edge product with open source tools like Renode and Zephyr, reach out to us at contact@antmicro.com.

Zephyr Resources: