# BNS: A Framework for Wireless Body Area Network Realistic Simulations
## 3 Proposed BNS Framework
### Mobility Model  
In WBAN, network topology can often vary due to the human body mobility. Furthermore, the quality of the channel between nodes varies according to the relative position of the sensor nodes. That is why accurate body mobility models are important for WBAN. The BNS framework provides a comprehensive and configurable mobility model for individual mobility, simulating intra-WBAN communication. This mobility model is MoBAN [25]. It determines the node positions at any instance of simulation time and so influences the network topology and link properties. MoBAN is built by two basic control units, which are the posture selector and movement module. The posture selector process determines the current posture at any instance of time; and then, according to the selected posture the individual movement of the node is determined. In [25], authors used an abstraction based on a Markov model to decide about the posture at any time considering the current posture and a transition probability matrix. Then, when a mobile posture is selected, a target position is chosen to start the movement of the whole WBAN. Additionally, spatial correlation was taken into account in MoBAN through the possibility of specifying location-dependent distributions for the posture pattern (Markov chain), and WBAN target position selection. Our implementation in the BNS framework follows the same principles. After selecting the posture, each node performs movements relative to its position in the body, in addition to individual random movements in the implementation of the proposed mobility model, focused on the individual movements for different postures. To this end, a marker was created for the position of the nodes in the body, with the following markings: head, left arm, left hand, chest, right arm, right hand, center of the waist, right of the waist, left leg, left foot, right leg, right foot. The positioning marks of the nodes follow the positions proposed in the channel model of [PERSON] et al. [44]. Thus, there is the possibility of using this channel model in conjunction with the mobility model. These markings are used as a reference for performing periodic movements for nodes in the legs, arms, hands and feet when the selected posture is walking or running. In other positions and postures, only random movement occurs. The class diagram in Figure 4 describes our implemented classes available in the BNS framework. The _VirtualMobilityManager_ is the virtual class with basic features to develop a mobility model. It has a structure for the location of the node, which stores the Cartesian coordinates and allows the use of spherical coordinates. It also has a node identifier and the methods for initializing and reading the parameters of the simulation configuration file, sending messages to the wireless channel module to notify changes in node position. For the implementation of MoBAN in the BNS framework, a body position identifier _bodyPlacement_ was added and a map was created to associate this position _string_ with a node location, so when the model is initialized, the _initPosition_ method places the node. There is also a queue of postures and the respective time for the posture to be adopted. We also defined the speed of the node, to differentiate if it is walking or running, the range of motion in the case of pendulum movement, the random movement area, the simulation area thresholds and the interval for updating the position of the node. Therefore, two timers are used, one scheduled at each _updateInterval_ to update the node position, which when triggered calls the method _moveNode()_, notifies the wireless channel, schedules the next update; while the other timer is used for posture update, responsible for changing the posture string, updating the node speed and scheduling a new timer for the next posture change. The _moveNode()_ procedure checks the posture and position of the nodes and calls the specific movement functions for it. The implementation in the BNS framework follows Algorithm 1.