## 9 Major Components of Proposed Virtualization Model  
When application directly communicates with the hardware without management of the services and the hardware, it usually results in wastage of the resources. Middleware is responsible for all the management of process between the application and the hardware. Virtualization middleware consist of a number of components few of the major components of the proposed middleware are discussed in this section. The services offered by the proposed middleware at the gateway and the node are of two types, the application dependent services and the network dependent services. First of all, in middleware design, programming models are to be taken under consideration. Consequently, none of programming models alone seem to promise a generic programming solution and non can efficiently support and manage the sensor network. This investigation has motivated us to consider a hybrid programming model that is event based and utilizes modules that can be invoked whenever they are required according to the context. Virtualization middleware requirements match well with the publish/subscribe communication mode, as WSN are an event-based system. The middleware design utilizing the hybrid programming model will be more concerned with the resources of the sensor network. The proposed programming model is based on the macro programming approach, providing a high level abstraction of the low level details. The modular approach is one of the key driving force, in the making the virtualization of networks successful. The component based model is used that supports SOA. Furthermore, an event based modular approach is used that also supports the asynchronous execution models. Thread abstraction is more expensive at the sensor node level as we have to dedicate a stack per thread that consumes a lot of memory. However, for real time applications and federated WSN multi-threading technique reduces the processing time quite significantly and the gateway being a powerful node with less memory constraints uses multi-threading model in the proposed middleware. Middleware manages all the service provisioning stages between the user/application and the WSN nodes. Albeit, the data is managed well by virtualization, but checking all the parameters, delay the process, so the middleware components should be invoked in such a way that the latency is reduced as much as possible. Software model of the proposed middleware is based on Non-blocking and split phase  
Figure 5: Proposed middleware design. techniques. Moreover, imperative programming components ensure the QoS. However, proposed middleware also provides few components supporting declarative commands to provide high level abstraction and ease of programming for the developer. The event driven model is more suitable for microcontrollers as of their sleep nature, and can also achieve energy-efficiency. Figure 5 shows that the major components of application and network dependent services and their interaction. The proposed middleware design, resides at the gateway as well as the sensor node. Service discovery is one of the key modules of the middleware design. It resides both on the gateway and the sensor node in order to efficiently provide and keep a record of all the services offered by the WSN. Service discovery module at the sensor node keeps the record of the one hop neighboring services and also updates the gateway about the services offered. Resource discovery is more related to the hardware components and their capabilities such as how much battery life is left, the number of radios a node can support and the memory available, all these parameters are taken into consideration before forming a virtual network. It is more related to the infrastructure providers. Furthermore, this module keeps the record updated; it also resides at the node as well as the gateway. The device manager and the energy manager are the supporting components of the resource discovery module.