The Architecture of IoT Gateways
An IoT gateway is an important aspect of building an efficient, secure, and easy-to-maintain system.
Join the DZone community and get the full member experience.Join For Free
the typical architecture of iot solutions is usually far more complex than the architecture of most enterprise systems. one of the main factors that increases the complexity of iot systems is that backend services residing in the data center, which is the heart of most enterprise systems, are actually just a piece of the bigger iot picture. with iot solutions, we have to deal with a myriad of devices working in the field. because the nature of these devices is very different from web, desktop, or even mobile clients, we need an intermediate architectural element that will act as a proxy between the world of field devices and the enterprise data center. what we need is an iot gateway.
why you need an iot gateway
you may be wondering now: what exactly are the key reasons behind introducing a gateway into your iot architecture? let me shed some light on this issue by discussing some of the most important aspects of how gateway architecture functions.
first, sensors usually have very limited capabilities in terms of networking connectivity. your sensors can likely utilize bluetooth low energy (ble), just as the majority of beacons available on the market can; there is also the possibility that some of your sensors offer connectivity using the zigbee protocol. there are also a bunch of other protocols that can be found in the local area network (lan), home area network (han), or personal area network (pan). all of these protocols have one thing in common—they can’t directly connect to larger networks like wide area network (wan) or the internet. you need a gateway that can provide your sensors with a single point of contact with external networks by using wifi, gsm, or some other type of connectivity.
keep in mind that a gateway is not just a dump proxy that forwards data from sensors to backend services. sending all the information collected by sensors to a data center would be highly ineffective in terms of performance and network utilization. an iot gateway is needed to perform the pre-processing of information in the field, before they’re sent to the data center. such pre-processing includes message filtering and aggregation.
the gateway should also act as a single point of access for monitoring the selected area of the operational field. you don’t want to connect to every sensor with your monitoring software; it is easier to monitor only the gateway, which in turn is responsible for gathering all the necessary metrics from the sensors.
the following gateway architecture diagram is the most common architectural design where the gateway itself is not equipped with sensors. the gateway software installed on the device is responsible for collecting data from the sensor, pre-processing that data, and sending the results to the data center.
keep in mind that it is possible to have variations on this sensor architecture where some of the sensors are located at the gateway device, as illustrated in the following diagram.
embedded sensors that might be present at the gateway could include options like a gps unit or a temperature sensor connected to the gateway using the gpio interface.
the gateway software
the software application is the heart of the gateway. the gateway software is responsible for collecting messages from the sensors and storing them appropriately until they can be pre-processed and sent
to the data center. the gateway software decides if the data at a given stage of processing should be temporary, persistent, or kept in-memory.
the gateway software should be designed with failure and disaster recovery in mind. since gateway devices are often operated in the field, you should prepare for working conditions that are far from ideal. for example, the gateway software should be prepared for a power outage or other actions that may result in an interruption of gateway processing. the gateway software should be bootstrapped and started automatically as soon as power returns to the device, and it should continue to work from the point where it was interrupted.
gateway software should also be smart enough to properly handle system logging. it has to find the right balance between the number of log entries stored on the device and those sent to the data center.
software installation and updates
how does the gateway software get into the device? there are three main approaches for this issue.
the first approach is pre-installing the software on the gateway disk (or memory card). this approach is called factory bootstrap. as you may guess, this technique doesn’t scale well if your solution includes a larger number of the gateways.
the second approach is the server-initiated bootstrap. in this mode, the central software management server communicates with the gateway device and deploys the proper version of the software to it. this approach scales much better than the factory bootstrap, but still requires the initiation of deployment action on the server side.
the third approach is the client-initiated bootstrap. this mode assumes that it is the gateway’s responsibility to connect to the central repository server and download the proper version of the software. in this scenario, the gateway is required to have lightweight bootstrap software installed so it can communicate with the software management server. this approach is the most scalable one, as it doesn’t require any centralized coordination of the deployment action. every gateway device downloads the software as soon as it is powered on.
one extremely important feature of iot gateways is the ability to download updates over-the-air. keep in mind that after you install the gateway software onto a device and deliver it into the field, you have very limited capabilities in terms of the gateway software maintenance. the ability to download software updates over-the- air is particularly important from a security perspective, as it can affect the delivery time of critical security fixes.
if the software application is the heart of the gateway, then the sensors are the eyes and ears of the gateway. sensors are small hardware devices that can measure some aspects of the real world. common types of data collected by the sensors are temperature, gps coordinates, humidity, air pressure, and so on.
the messages collected by the gateway from the sensors are usually small in size. for example, the current value of the temperature measured by the sensor is just a decimal number. gps coordinates are two decimal numbers, which represent longitude and latitude. this is an important thing to remember: the gateway operates on a large number of small messages.
while the sensors themselves can generate messages frequently, it is important to anticipate how many messages we really need to gather from the sensors. for example, we can read the temperature from a sensor every millisecond, but do we really need this kind of precision when measuring temperature changes? in the majority of cases, reading the sensor value a few times per second is more than enough, as we are more interested in the metric changing over a longer period of time. gateway software usually polls the sensor data periodically. good gateway software allows you to easily configure the polling interval for every sensor. you definitely don’t want to put unnecessary sensor data into the gateway, as obsolete messages consume the precious processing power of your constrained gateway device.
gateway data transfer
usually gateways are connected to the internet using gps, wifi, or ethernet. some gateways can also work in both gps and wifi modes (for example, gateways mounted in moving vehicles). in general, non-gps connectivity is preferred to send data, as it doesn’t require a subscription to a paid mobile plan. some gateways will be constantly connected to inexpensive local networks, but those using gps connectivity should be very conservative in terms of what data they send to the data center. the gateway should apply business logic against the data it collects to understand which messages should be sent over expensive gps networks, and which data can be cached on the device for deferred offline processing.
the gateway is a key component of every iot solution. before you decide what kind of hardware you would like to purchase as your gateway platform, spend some time analyzing your message f low and the data formats of the payloads, and try to filter out or aggregate as much data as you can before sending it from the gateway to the data center. also, while the choice of proper hardware for your iot solution is very important, you have to keep in mind that picking up the right gateway software and management infrastructure (like the lwm2m server for managing your devices) is a factor that will highly impact the total maintenance cost of your system.
for more insights on iot security, protocols, and standards, get your copy of the guide to the internet of things – 2015 edition now!
Opinions expressed by DZone contributors are their own.