## 4 Main Tools of the WSN-DPCM Platform
### Tool for WSN Application Development and Simulation
#### 4.2.1 Network Simulation  
The goal of the Network Simulator component is to design and execute whole-network simulations of WSN applications, with minimum developer effort. It supports the estimation of network-wide performance metrics via discrete-event simulation (e.g., end-to-end network latency), at the level of local network neighborhood (e.g., packet loss at link level), or at the level of individual nodes (e.g., per-node power consumption or buffer overruns).  
The tool plays an integral part in at least two locations in the design flow. During network design, it can assist decisions regarding node number and placement in the deployment field, for different WSN topologies. During node-level application development, the tool can provide guidance for selection and parameterization of alternative node-level functions, for example the choice of routing protocol and related parameters, or tuning of periodic tasks. Additionally, the tool supports Hardware-in-the-Loop (HiL) simulation.  
Figure 12: Simplified example of metadata and synthesis.  
Creating a network simulation is more than executing a WSN system model. There are at least two additional tasks, which can require non-negligible effort for large networks:  
* In order to test a WSN system under different scenaria, the user must provide a simulation of the \"environment\", which includes generation of values sensed at the motes, and exceptional events, such as random node failures.
* A simulation may produce copious amounts of output, which requires statistical analysis and graphical visualization, in order to be useful to the user.  
In WSN-DPCM, our aim was to improve on the state of the art in network simulation, well beyond previous work, along the following lines:  
* Accuracy: it is important to use high-quality, accurate simulation models and algorithms, in order to trust the simulation results.
* Versatility: our tool should allow complex environment simulation, sophisticated result post-processing, seamless integration with HiL, _etc._ In contrast, many frameworks offer restricted facilities in this respect.
* Correctness: the user should trust that the results reflect the actual behavior of the simulated WSN, and are not due to incorrect simulation setup.
* Reduced effort: the effort needed to create a simulation should be minimal.
* Smooth learning curve: learning to use the network simulator should not require extensive effort.  
To achieve high accuracy, we employed the Castalia library of components, which runs on the OMNeT++ simulation engine. Castalia is a mature, well-tested and widely used library, regarded as one of the best available. We adapted Castalia's basic models to suit the requirements of WSN-DPCM and we augmented its model library with additional models for routing and radio devices.  
Castalia is highly versatile, allowing arbitrary environment models to be added to the simulation, and providing detailed output. However, exposing the WSN-DPCM user to Castalia would have severe drawbacks, in terms of correctness, effort and learning curve.  
* Castalia's simulation models are very detailed; however, this comes at the price of having to configure hundreds, or even thousands of model parameters in a large simulation.
* The coding of the environment simulation must be done in C++, which is problematic, because (a) it may be hard to debug and (b) requires familiarity with the Castalia and OMNeT++ API, steepening the learning curve.  
For these reasons, the underlying Castalia/OMNeT++ implementation is completely opaque to the user.