Cloud to IoT Device Reachability with Super SIM IP Commands

December 07, 2021
Written by

IP Commands - Twilio Super SIM

A requirement we have seen often from developers who use Super SIM in their IoT devices is to be able to “reach out” to a device from a server in their cloud. There are a number of use cases that require this kind of functionality asking the device to: 

  • Initiate a connection to a server
  • Report on the status or upload some data (for example sensor data)
  • Download a config or firmware update
  • Take an action and then go back to sleep

A solution that is used most often is to have the IoT devices set up and maintain a data connection to their cloud. Once connected, the cloud server can send commands via IP messages to the device. However, maintaining a persistent connection from the devices to the cloud comes at a cost: higher data usage and lower battery life.

We're excited to announce that Twilio now has a new solution for this – IP Commands. Using IP Commands, you can send short IP/UDP messages from your application cloud to your Super SIM-enabled IoT devices without the device having to maintain a persistent connection to your cloud, requiring a static public IP address for each device or using a VPN (Virtual Private Network) between your cloud and the cellular network. While the cellular VPNs achieve the same results, they are more expensive and complex to deploy. For device reachability alone, IP Commands is an elegant and lightweight solution.

Why you can’t simply send traffic to the IP address you see

A cellular network typically has firewalls that block incoming connections from the Internet to the devices attached to it. In addition, due to a process called Network Address Translation (NAT, also known as “NATing” of IP addresses), the IP address you see when you receive a packet from a device is not the same as the private IP address allocated to the device within the cellular network. If your IoT device is using a cellular connection to connect to the Internet or your cloud, you can’t reach the device until the device sets up an outbound connection to your cloud. This problem is exacerbated by timers in the NAT and firewalls (in the cellular network), which results in the TCP/UDP sessions getting torn down when the timers expire. In order to prevent these timers from expiring, IoT devices have to send periodic messages to keep the sessions active, resulting in battery drain.

IP Commands enable cloud-to-device reachability 

IP Commands are a secure and lightweight solution to send UDP messages from your cloud to your Super-SIM enabled devices via Twilio’s REST API. We convert your request into an IP/UDP datagram and forward it to the device. To send an IP Command, you simply make an API request to the IP Commands API by providing the:

  • the SIM identifier
  • the payload (the main content of your message)
  • the destination port. 

We convert the received payload into an IP/UDP message and send that message from the Twilio Mobile Core to the corresponding device through the existing cellular connection. When the device receives the IP/UDP message (which will appear like a regular IP/UDP message from your application cloud), it will process the message and respond with the required action.

To use IP Commands, your devices don’t need any additional functionality, apart from being able to send and receive IP/UDP messages. 

IP Command from Cloud to IoT Device

IP Command from Cloud to Device

By using IP Commands, you don’t have to invest in other expensive solutions to maintain device reachability:

  • Your devices don’t have to be active/awake all the time, saving battery life. When the network receives an IP packet for a device that is sleeping, it pages the devices to wake it up and delivers the IP message when the device establishes radio bearers. The device can go back to sleep soon after.
  • Your devices don’t have to maintain an outbound persistent connection using periodic keepalives, again saving battery life
  • You don’t have to setup and maintain expensive VPN infrastructure
  • You don’t have to pay extra for static public IP addresses, which some connectivity providers charge, to support device reachability

Mobile Originated IP Commands

IP Commands work in both directions. We also support Mobile Originated (MO) IP Commands from the device to the cloud. MO IP Commands can either be sent as a response to an MT IP Command, or as an unsolicited message originated by the device. To use MO IP Commands, you must first configure a webhook on the corresponding Fleet. Your device then needs to send an IP/UDP message to a dedicated IP address configured on the Twilio Mobile Core. When this IP/UDP message is received in the mobile core, we extract the payload and send the payload via a callback to the configured webhook.

IP Command from IoT Device to Cloud

IP Command from Device to Cloud

Sample use cases for IP Commands

IP Commands enable true bi-directional communication between your IoT devices and your cloud. Here are a few examples of use cases enabled by IP Commands:

  • Send an IP Command to the IoT device to make it report its location, or upload sensor data. You can avoid expensive TCP/TLS/SSL handshakes to upload sensor data if you use MO IP Commands instead.
  • Send an IP Command to your IoT device to have it send information on-demand. You don’t have to wait for a periodic upload.
  • Send an IP Command to the IoT device to join a group VoIP/video call.

Next Steps

IP Commands are already enabled for all Super SIM devices. Sending and receiving IP Commands does not cost you anything apart from the data usage incurred by the IP/UDP messages between your devices and the Twilio Mobile Core. 

If you are new to Super SIM, have a look at our First Steps tutorial. 

If you are familiar with Super SIM and want to give IP Commands a go, here are a few resources from our documentation to get you started:

 

Vijay Devarapalli is a Principal Product Manager for Twilio IoT, responsible for the Twilio Distributed IoT Mobile Core that drives Super SIM and other IoT cellular connectivity products. Vijay is a telecom industry veteran, having designed and built 3G and LTE packet core and edge computing solutions, as well as technologies for improving radio network efficiency. He has also made significant contributions in the standards space, having authored 17 RFCs in the IETF and numerous contributions to 3GPP LTE specifications.