## 5 WirelessHART Simulators  
When developing a new protocol or algorithm for WSN, it is very important to measure the performance of the proposal in order to determine the most adequate scenarios for it, its strong points and downsides. It is also important to compare the proposal's performance to that of other already implemented solutions. To do this, there are two possibilities: the implementation of a testbed with real devices and computer simulation. Although testbeds provide realistic results, the costs and the complexity of the test environment, mainly in its early development stages, may make that option not viable. Thus, computer simulations can be used as a low-cost and scalable solution for testing new proposals before investing resources into real networks. Furthermore, simulations may also be used to guide the choice of users that are trying to decide on a WSN technology. In face of this situation, we will present in this section a description of the main available WirelessHART simulators, their features and where to find them. The COOJA (Contiki OS Java) simulator is a Contiki OS simulator. The Contiki OS is an operating system (OS) developed to run on devices with limited resources (for example, battery, memory, processing), like sensors [101]. As the COOJA simulates each node, like devices that run an actual OS, the code developed for the real OS can be used in the simulator. The main goal of the COOJA is to provide extensibility to the simulation. To achieve this, the simulator implements two different structures: plugins and interfaces. Plugins are registered often at start up before being used and allow interaction with the simulator. Interfaces interact with the sensor nodes, simulating hardware peripherals, or monitor interest values. In order to simulate WirelessHART, [102] developed a solution, which is to add a WirelessHART-enabled intermediary device operating at the physical and data link layers, which can handle the time-critical tasks of the protocol. Furthermore, with regard to the Zhang policy, [82] claim to have used COOJA, but few details about the simulator were provided. Finally, it is worth noting that COOJA is open source software. Network Simulator 2 (NS-2) is an open source discrete event simulator for network research. The first NS began as a modification of the REALNetwork Simulator in 1989. Nowadays, the NS development is maintained by a collaborative effort of diverse institutions and researchers. The simulator provides support to TCP simulation, routing and multicast protocols in wireless or wired networks, local or satellite communications [103]. The NS-2 uses two programing languages: C++ is used to code the protocols to be used and the interpreted programming language OTCL (Object-oriented Tool Command Language) to configure the simulation parameters. In order to provide a better understanding of the simulations, NS-2 provides Network Animator (NAM), a tool that animates the traces of a completed simulation. A WirelessHART implementation for the NS-2 can be found in [55]. Although NS-2 is a very popular simulator, it has issues with regard to scalability, memory use and simulation time [104]. Furthermore, it has an outdated documentation and and great abstractions in the lower layers [103]. In order to address these issues, its developers have started the open source NetworkSimulator 3 (NS-3) project, a natural successor to NS-2. The new simulator uses an updated, modular and object-oriented structure with a vast available documentation. The modular structure is such that modules can be implemented in way that they can be reused in different technologies modules. The NS-3 will work with the C++ language and, optionally, Python scripts. A WirelessHART module for NS-3 with a focus on modeling the lower layers, providing energy consumption and independent error rates for each link, can be found in [100, 105]. MATLAB(r) is a well-known (proprietary) tool for the scientific community, providing tools for a wide range of fields, from neural networks to aeronautics.