Information and Computer Science, King Fahd University of Petroleum and Minerals, Dhahran, Saudi Arabia
Received date: August 24, 2015; Accepted date: October 13, 2015; Published date: October 16, 2015
Citation: Shahzad F (2015) Extending the Functionality of Pymote: Low Level Protocols and Simulation Result Analysis. Sensor Netw Data Commun 4:125. doi: 10.4172/2090-4886.1000125
Copyright: © 2015 Shahzad F. This is an open-access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited.
Visit for more related articles at International Journal of Sensor Networks and Data Communications
Wireless sensor networks (WSNs) are utilized in various applications and are providing the backbone for the new pervasive Internet, or Internet of Things. The development of a reliable and robust large-scale WSN system requires that the design concepts are checked and optimized before they are implemented and tested for a specific hardware platform. Simulation provides a cost effective and feasible method of examining the correctness and scalability of the system before deployment. In this work, we study the performance of Pymote, a high level Python library for event based simulation of distributed algorithms in wireless ad-hoc networks. We extended the Pymote framework allowing it to simulate packet level performance. The extension includes radio propagation, energy consumption, mobility and other models. The extended framework also provides interactive plotting, data collection and logging facilities for improved analysis and evaluation of the simulated system.
Wireless sensor network; Simulation; Python; Distributed event modeling
Wireless Sensor Networks (WSNs) have been employed in many important applications such as intrusion detection, object tracking, industrial/home automation, smart structure and several others. The development of WSN system requires that the design concepts are checked and optimized using simulation .
The simulation environment for WSN can either be an adaptive development or a new development. The adaptive development includes simulation environments that already existed before the idea of WSNs emerged. These simulation environments were then extended to support wireless functionality and adapted for the use with WSNs. In contrast, new developments cover new simulators, which were created solely for simulating WSNs, considering sensor specific characteristics from the beginning .
Recently, several simulation tools have appeared to specifically address WSNs, varying from extensions of existing tools to application specific simulators. Although these tools have some collective objectives, they obviously differ in design goals, architecture, and applications abstraction level [3,4].
Simulators can be divided into three major categories based on the level of complexity:
• algorithm level,
• packet level, and
• instruction level.
In this work, our main contribution is the design and implementation of packet level modules for propagation, energy consumption and mobility models to extend the Pymote framework. Secondly, we also added graphing and data collection modules to enhance the Pymote base functionality and modified existing modules for node, network, algorithm and logging.
The rest of the paper is organized as follows: In section 4, we provide some background related to existing simulation tools and we discuss the python based simulation tool Pymote. We present our extension in section 5 and provide simulation examples and analysis in section 6. We conclude in section 7.
Simulation has always been very popular among network-related research. A large number of simulators have been proposed in literature in which algorithms for wireless ad hoc networks can be implemented and studied. These simulators have different design goals and largely vary in the level of complexity and included features. They support different hardware and communication layers assumptions, focus on different distributed networks implementations and environments, and come with a different set of tools for modeling, analysis, and visualization. Classical simulation tools include NS-2, OMNeT++, J-Sim, OPNET, TOSSIM, and others [2-4].
Pymote is a high level Python library for event based simulation of distributed algorithms in wireless networks . The library allows the user to make implementation of their ideas using Python-a popular, easy to learn, full featured, and objects oriented programming language. Functionalities provided by the library are implemented without additional layer of abstraction, thus harnessing full power of Python’s native highly expressive syntax. Using the library, users can quickly and accurately define and simulate their algorithms. The library particularly focuses on fast and easy implementation of ideas and approaches at algorithm level without any specification overhead using formally defined distributed computing environment.
We implemented two basic radio propagation models and the commonly used shadowing model for WSN in the Pymote framework. These models are used to predict the received signal power of each packet. At the physical layer of each wireless node, there is a receiving threshold (P_RX_THRESHOLD). When a packet is received, if its signal power is below the receiving threshold, it is marked as error and dropped by the MAC [10-12] layer. The free space propagation model assumes the ideal propagation condition that there is only one clear line-of-sight path between the transmitter and receiver, while the two-ray ground reflection model considers both the direct path and a ground reflection path which gives more accurate prediction at a long distance than the free space model. However, in reality, the received power is a random variable due to multipath propagation or fading (shadowing) effects. The shadowing model consists of two parts: path loss component and a Gaussian random variable with zero mean and standard deviation σDB, which represent the variation of the received power at certain distance. Table 1 lists parameters available for propagation module. The propagation model type (free space, tworay ground or shadowing) is a network level attribute, which should be selected before starting the simulation.
|Transmit Antenna gain||G_TX||1|
|Receive Antenna gain||G_RX||1|
|System Loss (>=1.0)||L||1|
|Min. Received signal power threshold||P_RX_THRESHOLD||-70 dbm|
|Path loss exponent||BETA||2.5|
|Gaussian noise standard deviation||SIGMA_DB||4 dbm|
Table 1: Propagation Model Parameters.
Energy consumption model
In our extended framework, the energy model object is implemented as a node attribute, which represents the level of energy in a node. Each node can be conFigured to be powered by external source (unlimited power), Battery (default) or energy harvesting (EH) sources . The energy in a node has an initial value which is the level of energy the node has at the beginning of the simulation. It also has a given energy consumption for every packet it transmits and receives which is a function of packet size, transmission rate and transmit (receive) power. The model also supports idle or constant energy discharge due to hardware/microcontroller consumption and energy charge for energy harvesting based WSN. During simulation, each node’s available energy is recomputed every second based on the charging and/or discharging rate. If it drops below minimum energy required to operate (Emin) then that node assumed to be dead (not available for communication) until energy reaches above Emin again later in simulation (for EH nodes). Table 2 lists parameters available for energy module which can be set differently for each node. The energy object keeps track of the energy available (for battery-operated or energy harvested nodes) and total energy consumption.
|Transmit power||P_TX||84 mW|
|Receive power||P_RX||73 mW|
|Initial Energy||E_INIT||2.0 Joules|
|Min. Energy required
|Charging rate (EH nodes)||P_CHARGING||2 mW/sec|
|Discharging rate||P_IDLE||0.1 mW/sec|
|Transmission rate||TR_RATE||250 kbps|
Table 2: Energy Model Parameters.
Our extended framework allows nodes to be mobile during simulation. Each node can be conFigured as fixed or mobile. The mobility module support three types of motion as summarized in Table 3. During simulation, each mobile node location is recomputed every second.
|1: Mobile (uniform velocity)||VELOCITY HEADING||20 m/s
|2: Mobile (uniform velocity, random heading)||VELOCITY||20 m/s|
|3: Mobile (random motion)||MAX_RANDOM_ MOVEMENT||30 m|
Table 3: Mobility Parameters.
Plotting and data collection
These modules allow real-time plotting and data collection during and after simulation for interactive analysis and comparisons of useful information. The modules implements generic helper methods. The simulation script is responsible for utilizing these methods to plot/chart and collect/log appropriate information as required by the simulated algorithm and application scenario. The output files are managed by utilizing separate folder for each type of files within the current working path (Table 4). Also for each simulation run, a separate folder, prefixed with the current date time is used for all files created during that simulation run.
|Data files||/data||CSV files containing energy consumption for each node, Message received/lost counts, etc.|
|Charts/plots||/charts||Line plots and/or bar charts of energy levels.|
|Topology||/topology||Topology map of all nodes used for simulation (before/after simulation)|
|Logging||/logs||Simulation run and module level logging|
|Combined||/yyyy-mm-ddThh-mm-ss||All files generated during a specific run|
Table 4: File Management.
Modified node module
Enhanced framework requires significant modification in the Node module. The Node object now contains node type, energy model object and mobility object. The modified send and receive methods check before transmission or reception whether node has enough energy to perform the operation. Also the propagation model dictates whether a packet is received without errors (i.e. when received signal power is greater than the threshold based on the distance between the sender and receiver nodes). The object also keeps track of number of messages transmitted, received, or lost.
We consider Internet of Things (IoT) application scenario where an energy  harvesting WSN (EHWSN) node is installed/embedded within the ‘Thing’ (object that need to be monitored). Several of such objects with EHWSN nodes form a cluster (in virtual star topology) around a high power coordinator node (or cluster head). EHWSN nodes can only communicate to its own coordinator (when they have enough energy). Coordinators are special wireless nodes which have sufficient power available and can send data to base station directly or via other coordinators (multi-hop) in a typical converge-cast application as illustrated in Figure 1. These objects are mobile and can move around its neighborhood or move to another neighborhood (within the range of a different coordinator). The coordinators are installed at strategic fixed locations throughout the facility.
Figure 2 illustrates the scheme on time scale and can be summarized as follows:
• The coordinator periodically (period=Tc=t4-t0) broadcasts a beacon pulse with 10% duty cycle. The pulse contains the MAC address (48 or 64 bytes) of the radio, which is universally unique, and the number of registered nodes. After transmitting the beacon, it goes in the listening mode to receive messages from any EHWSN mode which have any packets to send.
• The neighboring EHWSN nodes (which have enough power to operate) periodically wake up (period=Tn>Tb) with a certain duty cycle to receive the beacon pulse from the coordinator (t1 in Figure 2). If the received coordinator’s MAC address is different than the last communicated coordinator or the node has not communicated recently, then the node will send a registration message containing its MAC  address and the power status (t2 in Figure 2); otherwise node will go back to sleep or send the data packet if any. The destination address will be set to the coordinator address so that any other neighboring nodes which are listening will ignore it.
• On receiving the node’ registration message, the coordinator record the registration information and increment the number of registered nodes (t3 in Figure 2). If coordinator receives a data message then it will buffer it for future transmission to base station or for aggregation. The coordinator will acknowledge the received packet in both cases.
• The case of multiple child nodes transmitting in response to the same beacon pulse is also shown in Figure 2 during the second beacon period. The contention is avoided by using a random back off time before transmission. The wining node will transmit first (node A transmits at t7 in Figure 2) and other nodes will wait for the channel (e.g., node B transmits at t9 in Figure 2).
We only need to simulate the communication performance of one cluster formed by a coordinator and its children EHWSN nodes. The coordinator is placed in middle of n randomly deployed EHWSN nodes over a 600 m by 600 m area. We assumed that these nodes are constantly being charged during simulation and nodes are mobile (type=2, see Table 3). We consider beacon, registration and data packet sizes of 100 bytes while the acknowledgment packet size of 15 bytes. We used default parameters for different modules as listed in Tables 1-3. Some other parameters are shown in Table 5. The simulation script utilizes the plotting and data collection modules to generate image and data files for easy visualization and analysis of simulation results (Figure 3).
|Tb||Beacon period||1 sec|
|n||No. of nodes||5 - 100|
|Sd||Data packet size||100 bytes|
Table 5: Simulation Parameters.
Figure 4 shows a simple topology generated for simulation using the Pymote. The center node (#1) acts as the coordinator for the EHWSN nodes (numbered 2 to 26). The node in lighter color means that its available energy [16,17] is below E_MIN (=0.5 J).
We arbitrarily selected node 5 and node 10 as borderline in terms of energy available (i.e., the initial energy at start of simulation). Node 5 doesn’t have enough energy to transmit in the beginning but charged up above E_MIN (Table 2) during the simulation and start communicating. On the other hand, Node 10 just has enough energy  to send few messages before its energy level dropped below E_MIN. We set the charging rate to 0 for Node 10. The energy level change during the simulation run is shown in Figure 5.
Figure 6 shows the net node displacement during the simulation as they move around with constant speed but in random direction. Figure 7 illustrates the energy consumption of all EHWSN nodes. We can notice that some nodes never communicated due to low energy (like node 2, 4, 11, 15, 20, 21 and 26) whereas node 5 and 10 were only active during some part of the simulation as we discussed earlier. Finally Figure 8 shows the location of nodes at the end of simulation.
Secondly, we vary the number of EHWSN nodes in the network from 10 to 100 in the increment of 5. The extended framework generates simulation output files for each iteration. The output files also include the overall summary. Figure 9 shows the generated topology for 100 EHWSN nodes (2 to 101). Figure 10 shows energy consumption plots for coordinator and other nodes combined (sum of energy consumption for all EHWSN nodes). The chart also shows number of messages (packets) received and lost at coordinator for each iteration.
Table 6 presented the overall simulation summary for all iterations. Node displacement and energy level change during the simulation for 100 nodes are shown in Figure 11 and 12 respectively.
|Nodes||Coordinator Energy consumption
|Total EHWSN consumption
|Received Packets at Coordinator||Lost Packets at Coordinator|
Table 6: Simulation Statistics.
The development of a reliable and robust large-scale WSN system requires that the design concepts are checked and optimized before they are implemented and tested for a specific hardware platform. Simulation provides a cost effective and feasible method of examining the correctness and scalability of the system before deployment.
In this work, we utilized and extended the Python based Pymote framework to allow packet level simulation. We implemented modules for propagation, energy consumption and mobility models. We also added graphing and data collection modules to enhance the Pymote base functionality and modified existing modules for node, network, algorithm and logging to support the extended framework. Finally, we performed an example simulation for a scheme to efficiently utilize EHWSN in an IoT application. The simulation results presented include topology maps, plots for available energy, bar charts for node displacement and energy consumption and comparison of received and lost packets at the coordinator node.
I would like to acknowledge the support provided by College of Computer Science and Engineering (CCSE) and the Deanship of Scientific Research at King Fahd University of Petroleum and Minerals (KFUPM).