## 3 Middleware for WSN Virtualization
### Middleware for Sensor Virtualization
**Mate** middleware [21] is a middleware designed based on Virtual Machine that support the non-expert programmers like civil engineers and biologists to program a sensor network efficiently without worrying about the timings, synchrony, interrupts, race conditions and memory constraints of TinyOS [21]. It hides the low level details of the hardware by providing higher level interfaces to the programmer. Mate is based on a virtual machine that shortens the complex programs and enables programmers to write the code in less than 100 bytes. Furthermore, the code is broken down into small chunks of 24 instructions; these instructions vary from basic instructions of sense like, _'copy'_ and _'get'_ to the complex instructions like _'blez'_, _'rand'_ and _'branch'_. Mate provides kernel boundaries that protect programmer to from making huge errors like disabling interrupts and memory overflow. Mate network is forced to be passive _i.e._, one job at a time. Moreover, Mate believes in the more processing at the node rather than transmitting, it is based on event driven programming. Huge tasks are divided into small chunks so as to avoid the stack overflow. Moreover, Mate hides the race condition from the programmer and provides support for heterogeneity of the sensors. The software architecture based on TinyOS, the tasks are queued and processed on FIFO bases in a pipelined fashion. Mate supports split-phase programming style and non-blocking execution. On the run programming can be efficiently done in Mate as it provides a concise representation of the program. Mate is preferable for small sensor nodes due to its less reprogramming overhead. Furthermore, the overhead of Mate execution grows with the passage of time and gets higher than the cost of installation. **Melete**[46] is based on Mate [21] by adopting tiny script language. Melete is based on Virtual Machine, its goal is to support concurrent multiple applications on the nodes as well as on the network with efficiency, flexibility and reliability over wireless sensor networks. Melete is the enhanced version of Mate, it supports event driven high level programming and couples it with Trickle [55] that enables well-organized code decimation across the sensor network and the subset of sensor networks. Moreover, the network is divided into groups and subgroups that work in collaboration to carry out applications' tasks concurrently, rather than activating whole network, only a group of sensor nodes are assigned to tasks. Melete supports selective distribution of code by limiting the, _i.e._, code is sent only within the region of interest, which covers the desired application code update [46]. Proactive distribution of code is infeasible due to the memory constraints, so Melete proposed group keyed method to decimate the code that is stored on the gateway. A dynamic grouping technique is used to support various applications along with the decoupling of the application from the sensor nodes. In order to avoid the redundancy in the transmission of the code and to make sure the request is coming from the neighboring nodes lazy forwarding approach is used. The lazy forwarding approach provides the maximum time to the neighbors to make sure that they respond to the request posed by requesting node which has not yet been fulfilled by any other neighboring node. The more the requests the better it is to make sure where to send data. Melete uses a group key method instead of multicast method; the newly joined node can request code from the nearest group. The Progressive flooding technique is used to send different codes to different groups forming concentric circles, n-ring technique is used to search the interested group of nodes [56]. Furthermore, the drawback of the n-ring model is with every next attempt the whole previously searched nodes are re-searched so [PERSON] propose a progressive flooding strategy which reduces the redundant search. Melete avoids the use of shared variables as the application object after the execution may drop the data.