Internet of Things middleware is software that serves as an interface between components of the IoT, making communication possible among elements that would not otherwise be capable. Middleware connects different, often complex and alwatchy existing programs that were not originally designed to be connected.
Ubiquitous computing is the core of the Internet of Things, which means incorporating computing and connectivity in all the things around us. Interoperability of such heterogeneous devices needs well-defined standards. But standardization is difficult because of the varied requirements of different applications and devices. For such heterogeneous applications, the solution is to have a middleware platform, which will abstract the details of the things for applications. That is, it will hide the details of the smart things. It should act as a software bridge between the things and the applications. It needs to provide the required services to the application developers  so that they can focus more on the requirements of applications rather than on interacting with the baseline hardware. To summarize, the middleware abstracts the hardware and provides an Application Programming Interface (API) for communication, data management, computation, security, and privacy.
The challenges, which are addressed by any IoT middleware, are as follows: [20, 71, 72].(1)Interoperability and programming abstractions: for facilitating collaboration and information exchange between heterogeneous devices, different types of things can interact with each other easily with the help of middleware services. Interoperability is of three types: network, semantic, and syntactic. Network interoperability deals with heterogeneous interface protocols for communication between devices. It insulates the applications from the intricacies of different protocols. Syntactic interoperability ensures that applications are oblivious of different formats, structures, and encoding of data. Semantic interoperability deals with abstracting the meaning of data within a particular domain. It is loosely inspired by the semantic web.(2)Device discovery and management: this feature enables the devices to be aware of all other devices in the neighborhood and the services provided by them. In the Internet of Things, the infrastructure is mostly dynamic. The devices have to announce their presence and the services they provide. The solution needs to be scalable because the devices in an IoT network can increase. Most solutions in this domain are loosely inspired by semantic web technologies. The middleware provides APIs to list the IoT devices, their services, and capabilities. In addition, typically APIs are provided to discover devices based on their capabilities. Finally, any IoT middleware needs to perform load balancing, manage devices based on their levels of battery power, and report problems in devices to the users.(3)Scalability: a large number of devices are expected to communicate in an IoT setup. Moreover, IoT applications need to scale due to ever increasing requirements. This should be managed by the middleware by making required changes when the infrastructure scales.(4)Big data and analytics: IoT sensors typically collect a huge amount of data. It is necessary to analyze all of this data in great detail. As a result a lot of big data algorithms are used to analyze IoT data. Moreover, it is possible that due to the flimsy nature of the network some of the data collected might be incomplete. It is necessary to take this into account and extrapolate data by using sophisticated machine learning algorithms.(5)Security and privacy: IoT applications are mostly related to someones personal life or an industry. Security and privacy issues need to be addressed in all such environments. The middleware should have built in mechanisms to address such issues, along with user authentication, and the implementation of access control.(6)Cloud services: the cloud is an important part of an IoT deployment. Most of the sensor data is analyzed and stored in a centralized cloud. It is necessary for IoT middleware to seamlessly run on different types of clouds and to enable users to leverage the cloud to get better insights from the data collected by the sensors.(7)Context detection: the data collected from the sensors needs to be used to extract the context by applying various types of algorithms. The context can subsequently be used for providing sophisticated services to users.
There are many middleware solutions available for the Internet of Things, which address one or more of the aforementioned issues. All of them support interoperability and abstraction, which is the foremost requirement of middleware. Some examples are Oracles Fusion Middleware, OpenIoT , MiddleWhere , and Hydra . Middlewares can be classified as follows on the basis of their design :(1)Event based: here, all the components interact with each other through events. Each event has a type and some parameters. Events are generated by producers and received by the consumers. This can be viewed as a publish/subscribe architecture, where entities can subscribe for some event types and get notified for those events.(2)Service oriented: service oriented middlewares are based on Service Oriented Architectures (SOA), in which we have independent modules that provide services through accessible interfaces. A service oriented middleware views resources as service providers. It abstracts the underlying resources through a set of services that are used by applications. There is a service repository, where services are published by providers. The consumers can discover services from the repository and then bind with the provider to access the service. Service oriented middleware must have runtime support for advertising services by providers and support for discovering and using services by consumers. HYDRA  is a service oriented middleware. It incorporates many software components, which are used in handling various tasks required for the development of intelligent applications. Hydra also provides semantic interoperability using semantic web technologies. It supports dynamic reconfiguration and self-management.(3)Database oriented: in this approach, the network of IoT devices is considered as a virtual relational database system. The database can then be queried by the applications using a query language. There are easy to use interfaces for extracting data from the database. This approach has issues with scaling because of its centralized model.(4)Semantic: semantic middleware focuses on the interoperation of different types of devices, which communicate using different formats of data. It incorporates devices with different data formats and ontologies and ties all of them together in a common framework. The framework is used for exchanging data between diverse types of devices. For a common semantic format, we need to have adapters for communication between devices because; for each device, we need adapters to map standards to one abstract standard . In such a semantic middleware , a semantic layer is introduced, in which there is a mapping from each resource to a software layer for that resource. The software layers then communicate with each other using a mutually intelligible language (based on the semantic web). This technique allows multiple physical resources to communicate even though they do not implement or understand the same protocols.(5)Application specific: this type of middleware is used specifically for an application domain for which it is developed because the whole architecture of this middleware software is fine-tuned on the basis of requirements of the application. The application and middleware are tightly coupled. These are not general purpose solutions.
8.1. Popular IoT Middleware
FiWare is a very popular IoT middleware framework that is promoted by the EU. It has been designed keeping smart cities, logistics, and shop floor analytics in mind. FiWare contains a large body of code, reusable modules, and APIs that have been contributed by thousands of FiWare developers. Any application developer can take a subset of these components and build his/her IoT application.
A typical IoT application has many producers of data (sensors), a set of servers to process the data, and a set of actuators. FiWare refers to the information collected by sensors as context information. It defines generic REST APIs to capture the context from different scenarios. All the context information is sent to a dedicated service called a context broker. FiWare provides APIs to store the context and also query it. Moreover, any application can register itself as a context consumer, and it can request the context broker for information. It also supports the publish-subscribe paradigm. Subsequently, the context can be supplied to systems using context adapters whose main role is to transform the data (the context) based on the requirements of the destination nodes. Moreover, FiWare defines a set of SNMP APIs via which we can control the behavior of IoT devices and also configure them.
The target applications are provided APIs to analyze, query, and mine the information that is collected from the context broker. Additionally, with advanced visualization APIs, it is possible to create and deploy feature rich applications very quickly.
OpenIoT is another popular open source initiative. It has 7 different components. At the lowest level, we have a physical plane. It collects data from IoT devices and also does some preprocessing of data. It has different APIs to interface with different types of physical nodes and get information from them.
The next plane is the virtualized plane, which has 3 components. We first have the scheduler, which manages the streams of data generated by devices. It primarily assigns them to resources and takes care of their QoS requirements. The data storage component manages the storage and archival of data streams. Finally, the service delivery component processes the streams. It has several roles. It combines data streams, preprocesses them, and tracks some statistics associated with these streams such as the number of unique requests or the size of each request.
The uppermost layer, that is, the application layer, also has 3 components: request definition, request presentation, and configuration. The request definition component helps us create requests to be sent to the IoT sensors and storage layers. It can be used to fetch and query data. The request presentation component creates mashups of data by issuing different queries to the storage layer, and finally the configuration component helps us configure the IoT devices.