## 4 Design and Implementation of the Optimization Framework
### Performance Metrics  
Despite the widespread use of wireless sensor networks and the variability in various application-specific requirements, the performance metrics that reflect the most fundamental characteristics of wireless sensor networks have always been the same, and can be classified into three major aspects: energy consumption, network reliability, and network delay.  
* _Energy Consumption_: in most application scenarios, the sensor network must run for a long period of time to fulfill the given task without human interference (e.g., for battery recharge), thus, energy saving has always been a significant concern for extending the lifetime of the sensor network/node. Otherwise, the network will not remain operational until the required task is completed. As the energy consumption of the microcontroller (\(\mu\)_CEEnergy_) and transceiver (_TraEnergy_) are the most power consuming parts, most works focus on saving the energy from these two parts at both the hardware and software levels. In hardware, ultra low power devices are used, especially in medical/health-care applications [2, 35, 36]. In software, as mentioned in Section 1, various kinds of energy-efficient MAC protocols, duty-cycling based communication strategies and data aggregation routings are proposed and measured. All kinds of efforts are made to achieve an energy-aware sensor network, and according to different requirements, energy performance could be measured and expressed in many ways (e.g., power consumption-\(mW\), \(\mu W\), lifetime-_days_, _months_, _years_). A taxonomy of energy related performance metrics is summarized in [37].
* PDR_). If a MAC layer algorithm is used, such as the unslotted/slotted CSMA/CA algorithm of IEEE 802.15.4, the packet loss can take place due to the packet drop in channel access failures (_PktCAFs_) and collision failures (_PktCFs_). _PktCAFs_ denotes that a packet encounters (\(1+macMaxCSMABackoffs\)) consecutive CCA failures, while _PktCFs_ occurs when it suffers (\(1+macMaxFrameBackoffs\)) times of collision failures, which take place during the packet transmission or transmission of the ACK frame. Besides, the loss of packet can also be caused by packet overflow (_PktOverfhw_), which means that before starting to transmit the pending data packet (pending in MCU), a new data packet is sensed and replaces the pending packet. Therefore, evaluations can be made in detail with _PktCAFs_, _PktCFs_, and _PktOverfhw_ in addition to _PktLossPro_ and _PDR_.
* _Network Delay_: packet latency is usually used to evaluate network delay. Packet latency can be divided into three sub-types: successful packet latency (_SucPktLatency_), all packet latency (_AllPktLatency_), and data packet latency (_DataPktLatency_). _SucPktLatency_ is defined as the time interval between the instant at which the data packet is sensed and the instant at which is successfully transmitted by receiving its ACK frame. Compared to _SucPktLatency_, _AllPktLatency_ takes both successful packet transmission and failure packet transmission (caused by _PktCAFs_ or _PktCFs_) into consideration. _DataPktLatency_ is calculated as the time interval from sensing the data packet to the receipt of this packet by the sink node (or coordinator).  
To sum up, the fundamental features of varying WSN applications can be evaluated from the above three major aspects, and the detailed performance metrics presented in each of the three major aspects can be used simultaneously to provide a more comprehensive insight for the given scenario.