# BNS: A Framework for Wireless Body Area Network Realistic Simulations
## 3 Proposed BNS Framework
### Healthcare Application Layer  
In this work a Healthcare Application Layer for the BNS framework is implemented. It implements data representation and a communication protocol between the application layers of PHD in correspondence with the ISO/IEEE 11073 standard [27]. Therefore, real traffic ISO/IEEE 11073 Personal Health Devices (X73-PHD) for WBAN are implemented. This standard defines two types of PHD: agents and managers. The agent devices are sensors or actuators and the manager device corresponds to the network coordinator. Additionally, BNS has different specifications for each PHD, called specializations. Specializations define a set of standards for each of the PHD. Each specialization has its own Domain Information Model (DIM), i.e., which attributes and objects a device must have. It is important to define a DIM separately for each device, since an electrocardiogram has different technical needs than a pulse oximeter. All specializations follow a unique service and communication model, defined in the Optimized Exchange Protocol (OEP). The OEP protocol is the heart of the ISO/IEEE 11073 standard and is where the DIMs common to all devices are defined, as well as the service model and the communication model [1]. The BNS Healthcare Application Layer provides five different X73-PHD agents for WBAN simulations: pulse oximeter, glucose meter, thermometer, blood pressure monitor and a basic ECG. Their implementation in BNS follows the specifications for transmission rate and sample generation as described in [1]. Figure 5: Class diagram of the BNS temperature model. The character \({}^{\prime\bullet\bullet}\) refers to pointer-type variables. Following the ISO/IEEE 11073 standard, the BNS Healthcare Application Layer is agent and manager-initiated, providing the _confirmed_ and _unconfirmed events_, and defining three modes of manager-initiated measurement data transmission: _Single Response_, _Time Period_ and _No Time Limit Mode_. All these modes defined in the standard are covered in [1] and implemented in the Healthcare Application Layer provided in the BNS framework. The BNS framework also provides the _Retransmission Mode_ proposed in [1]. This mode is a new proposal, not present in the ISO/IEEE 11073 standard. _Retransmission Mode_ consists of a stop-and-wait system as a sub-application-layer to retransmit agent packets whose Acknowledgments (ACKs) have not been received. This interesting solution covered in [1] reduces the unnecessary exchange of several control packets made in association procedures. In addition, it is an alternative to fill the lack of a reliable transport layer in the ISO/IEEE 11073 standard. In the Healthcare Application Layer proposed in the BNS framework, the user can set several simulation parameters, such as the medical device type, operation mode and the number of transmission retries. Table 2 summarizes all parameters and their possible values are shown. Implementation of the Application Layer  
Antidote [28] is an IEEE 11073 protocol stack library developed to work with real medical and health devices. To provide communication between Antidote and other systems, communication plug-ins are required, because it has a plug-in-based architecture. For that, a BNS plug-in was developed to support communication between Antidote and the BNS framework modules. In addition, some necessary modifications to the communication, encoders, agent and manager modules of the Antidote, covered in [1], are implemented in the BNS framework. The proposed BNS plug-in allows the BNS framework and Antidote to talk with each other. Inside the BNS framework, we can call any function from the Antidote Library and retrieve any information from it, but transmitting data from the BNS framework to the Antidote Library is not a simple task. To solve this, we first use external variables to make the data exchange between the BNS framework and the BNS plug-in module. Then, to obtain the data from the BNS plug-in, Antidote uses pointers to the plug-in functions that we call _callback functions_.