744 IEEE TRANSACTIONS ON INSTRUMENTATION AND MEASUREMENT, VOL. 65, NO. 4, APRIL 2016 System Support for the In Situ Testing of Wireless Sensor Networks via Programmable Virtual Onboard Sensors Manos Koutsoubelias, Nasos Grigoropoulos, Spyros Lalis, Petros Lampsas, Serafeim Katsikas, and Dimitrios Dimas Abstract— Wireless sensor networks (WSNs) can be extensively tested before they are deployed in the field. However, it is equally important to test a WSN after it has been deployed, to verify that it will work as expected in certain situations of interest, which are hard to reproduce in reality. In this paper, we introduce the mechanism of programmable virtual onboard sensors, for letting sensor nodes produce artificial sensor values as dictated by the user, transparently to the application. Virtual onboard sensors are programmed using a simple script-like language, which is interpreted at runtime on the wireless sensor nodes. The user can deploy sensor scripts in the WSN and activate the virtual sensor mode for selected nodes and sensors at any point in time, without changing the node firmware and without stopping the application that runs on the nodes. We also describe and evaluate an implementation of the virtual onboard sensor mechanism on a commercial WSN platform. Our implementation requires little memory and has negligible runtime overhead, and thus can be adopted even for resource-constrained sensor nodes. Index Terms— Artificial sensor signals, hardware in the loop (HIL), in situ testing, nondestructive testing, sensor instrumentation, tiny virtual machines (VMs), wireless sensor networks (WSNs). I. I NTRODUCTION W IRELESS sensor networks (WSNs) are becoming an increasingly important part of the computing land- scape in the era of cyber-physical systems [25], supporting a wide range of monitoring and control applications. Testing WSN-based applications is hard due to the typically complex and dynamic nature of the sensed environment, as well as the inherent unpredictability of ad hoc wireless communication. During the development of WSN software, emulators and simulators can be used to perform tests for different scenarios in a systematic way. Once the node firmware reaches a mature state, it can be tried out on real hardware using a WSN testbed, Manuscript received June 3, 2015; revised July 28, 2015; accepted September 3, 2015. Date of publication November 15, 2015; date of current version March 8, 2016. The Associate Editor coordinating the review process was Dr. Deniz Gurkan. This work was partially supported by the SYNERGASIA program of the GSRT, project MariBrain, grant 11SYN-6-288. M. Koutsoubelias, N. Grigoropoulos, and S. Lalis are with the Centre for Research &Technology Hellas and the University of Thessaly, Volos, Greece (e-mail: emkouts@uth.gr). P. Lampsas is with the Centre for Research & Technology Hellas and the Technological Educational Institute of Central Greece, Lamia, Greece. S. Katsikas and D. Dimas are with Prisma Electronics, Alexandroupoli, Greece. Color versions of one or more of the figures in this paper are available online at http://ieeexplore.ieee.org. Digital Object Identifier 10.1109/TIM.2015.2494630 also combining real with simulated nodes. A complementary approach is hardware in the loop (HIL), where the simulation engine is tightly coupled with the hardware that runs the software. This way, the very same hardware/software package that will be used in the real world can be tested in a controlled and safe manner. HIL is extensively used in the automotive and avionics industry and has also been proposed for WSNs (discussed in more detail in Section II). The above tools and facilities are used to test WSN-based systems before they are deployed. However, in real-world installations, it is also important to test the system after it has been deployed. One reason is that, even if tested extensively before deployment, the WSN may still perform in a different way during operation [18]. Furthermore, it may be desirable to conduct robustness tests on a regular basis to verify that the entire system works as expected in critical situations— including the back-end information processing logic and the human processes that ought to be put in motion in case of problems. Note that pure monitoring merely confirms that the system works for the current conditions, but says little about how it will actually behave in the typically exceptional situ- ations of interest. In fact, for some applications, reproducing these conditions in reality is not an option. For example, one cannot change the temperature and vibrations of an engine in operation. It is also quite unlikely that one will set a building or a forest on fire, for testing purposes. Clearly, it is desirable to have a mechanism for performing nondestructive tests in a WSN that is already deployed. We refer to such tests as drills. This paper presents work we have done to include such capability in the PrismaSense/ LAROS platform [6]. We introduce the concept of virtual onboard sensors, a system-level mechanism for producing artificial sensor values, and propose a script-like language for programming virtual onboard sensors in a flexible way without having to reflash the WSN nodes. The user can write and deploy virtual sensor scripts in the WSN and activate/deactivate the virtual onboard sensor mechanism in order to run a drill at any point in time. The application programs on the WSN nodes remain untouched and continue running in exactly the same way as if the artificially produced sensor values were for real. The main contributions of this paper are as follows: (i) we introduce the concept of virtual onboard sensors as a general mechanism for supporting in-situ and non-destructive drills in a WSN that has already been deployed; (ii) we propose a 0018-9456 © 2015 IEEE. Personal use is permitted, but republication/redistribution requires IEEE permission. See http://www.ieee.org/publications_standards/publications/rights/index.html for more information.