## 6 Evaluation
### Experimental Results  
The goal of the experiments presented is three-fold: (1) they quantify the memory footprint used and the spent battery by the new security self-adaptation (_i.e._, self-protection) mechanism of FamiWare; (2) they evaluate the scalability of FamiWare, regarding the number of security policies and reconfiguration plans; and (3) they calculate the overhead produced by the security self-adaptation mechanism, measuring the latency, since the new configuration model has been generated and the reconfiguration has been accomplished. For the experiments, we have measured the FamiWare implementation realized for MICAz motes with TinyOS [27]. Resource consumption: Since FamiWare is composed of a variable set of services (including the new security and reconfiguration modules, among others), the memory usage on a sensor depends on how many services are in the current configuration and on the size of each one. Furthermore, since any TinyOS application is compiled together with the OS in one image, we also have to include the OS as part of our measures. Specifically, to perform the reconfiguration mechanism of the security policies, apart from a WSN routing protocol to transmit data, the minimal instantiation must have one security monitoring service, the context awareness service and the reconfiguration service plus a simple security module. Therefore, in this case, using, for instance, the Drip [28] routing protocol, the memory footprint is greatly reduced. Considering that typical MICAz nodes have 4 KB of RAM, this instantiation consumes 51% (21,340 bytes) of RAM. On the other hand, the maximum architectural configuration for reconfiguring the middleware, considering all of the security monitoring services to observe different kinds of security contexts, the microkernel, Drip protocol and a simple application (123 bytes) and several security modules, uses 80% (3400 bytes) of the memory, so there is still 20% free for other services and applications. Note that this maximum configuration, which includes services to monitor the global status of a part of the network, is only instantiated in cluster heads, which are usually device sensors with higher capacities than the regular MICAz. With respect to the evaluation of the energy consumption of the security dynamic reconfiguration of FamiWare, we have measured the battery waste of such process in a WSN. The battery capacity of the MICAz motes is 2000 mAh and lasts about a year. We have simulated several reconfigurations of a 20-node network using security reconfiguration plans similar to the ones defined in the previous sections (Sections 4 and 5), when the energy of the nodes is around 30% (600 mAh) on average. We compare these results with the energy expenditure of the same system, but without reconfiguration and, therefore, maintaining the same security policy defined at design time. The average of the network residual energy starts to decrease when the reconfiguration is being performed (simulation interval from 0 to 1000 s). This is due to the extra cost of operations for reconfiguring the nodes and the sink. For instance, they must be in the \"active\" state with the radio chip \"on\", and they must access their flash memory. During the reconfiguration, the remaining energy average drops to 59,984 mAh for the first 1000 s simulated, while in the system without reconfiguration, it only drops to 599,911 mAh. There is a difference of 0.071 mAh, which is the price of reconfiguration in terms of energy, but after it finishes, the energy expenditure is more or less equal for the reconfigured system as for the static one (depending on the security policy installed, since some of them consume more energy than others). This amountof spent battery (0.071 mAh) is similar to the amount that the same WSN wastes when the sensors are monitoring several issues (e.g., temperature and humidity) with 1 s of frequency, and they spread this sensed information throughout the network.