In this chapter an approach to improve road monitoring through wireless sensor networks is described: several sensors may be distributed along a road in order to detect traffic flows, speed, and the continued occupation of the road. Each WSN cluster offers a monitoring system based on videotapes and, at the same time, produces information which can be processed to provide a clear interpretation of the road situation regardless of weather conditions , . Therefore, it is necessary to integrate video monitoring information with parameters measured by other sensors, e.g. magnetometer or power sensors, for traffic detection , , . Advantages about WSN usage in this area are several. Some of them have been already shown in literature. Others derive by the proposed approach.
A WSN can monitor and evaluate roads automatically and continuously, with little human effort
A WSN can work during night even with poor weather conditions, when there is fog or presence of dust (pollution, volcanic ash) in the air
WSNs are low cost and low power 
A WSN allows the integration of video monitoring with magnetic or power sensor. In this way, it is possible to obtain complete and integrated information (video-images and traffic volumes information) 
WSNs allow dynamic changes to network topology based on real needs and reports coming from sensors located along the road.
When needed, the number of cameras which control a specific area may increase to produce more detailed information. However, it may increase network workload that will be properly managed by the proposed approach.
The idea is to distribute many sensors along a road to detect traffic flows, speed and the continued roadway occupation. At first, the chapter will show most common wireless technologies used in WSNs in order to select the protocol to meet main system requirements. A system for road traffic monitoring, operating in adverse environmental conditions, involves the coexistence of a large number of devices that, working together, ensure proper analysis of vehicular traffic situation. Our goal is to show a flexible architecture in which information of specific road sections are provided and, in case of queue or traffic jam, a mechanism for traffic detection is activated. In particular, this chapter introduces an algorithm that, based on traffic volume measured values through magnetic sensor located on the ground, dynamically enables or disables cameras according to the real need to monitor the given area. Moreover, in order to manage power consumption, the proposed architecture is based on an innovative approach, using IEEE 802.15.4/ZigBee standard protocol . As described in next section, IEEE 802.15.4/ZigBee is able to satisfy main system requirements. The proposed algorithm dynamically varies active devices number based on loading conditions through a fuzzy logic controller. The role of fuzzy logic controller is useful in terms of network load and power consumption management. In order to satisfy several Quality of Service requirements (QoS) and real-time constraints, the network coordinator dynamically manages the data sampling period of cluster coordinator nodes. They give the new sampling period to its end-nodes representing local monitoring stations. The algorithm is characterized by predetermined "membership" functions used to process some network information (e.g. Deadline Miss, Power Consumption). The architecture proposed and the algorithms shown will be evaluated using TrueTime  and OmNet++  simulators.
2. System requirements and wireless sensor network protocols
2.1. System requirements
In order to make a wireless sensor network suitable for road monitoring, some requirements have to be met. In the following we give a brief overview of requirements that drove the design of the proposed architecture and the choice of the wireless protocol to use.
Predictability and system performance simulation: The system shall implement a WSN that allows to simulate its network environment and to determine in advance end-to-end performance of the monitored system: power consumption, end-to-end latency (min, max, average), jitter, throughput.
Quality of Service provisioning: The WSN shall implement advanced QoS mechanisms and a clear policy to ensure guaranteed performance. QoS will be ensured also when nodes number increase.
The network should cover harsh large area: The WSN should be able to work in a harsh and dynamic environments taking into account factors like high temperature, dust, vibrations, humidity, poor visibility, fog or heavy rain, etc.
High density of nodes: Nodes density should be high.
High communication reliability: The WSN shall provide high reliability in terms of communication services. Error message rate will be kept acceptable for the road monitoring application.
Fault tolerance: The WSN shall prevent performance degradation in case of fault to any part of the system. It is mandatory to conduct a fault analysis of the monitored system in order to provide fault tolerance mechanisms. The WSN shall be self healing: i.e. the WSN detects communication errors and heals these errors by its own means.
Mechanism to support dynamic environment: The working conditions in road monitoring systems are not static.
Network ability to transmit video traffic flows: WSNs should be able to transmit video traffic flows using an appropriate video compression algorithm. The WSN must be able to manage QoS associated with this type of traffic flows.
2.2. Wireless sensor network protocols
Most important standard for communication in WSNs are IEEE 802.15.4, IEEE 802.15.4/a, IEEE 802.15.1 Bluetooth, 6LoWPan and WilressHART. Among these protocols IEEE 802.15.4/ZIgBee and IEEE 802.15.1 Bluetooth have been extensively explored. Even if they were born with the same purpose (to define a standard for small wireless networks) IEEE 802.15.4/ZigBee  and IEEE 802.15.1 Bluetooth  are characterized by several differences. In the following, a brief overview of these protocols.
Bluetooth is an economical and secure standard (IEEE 802.15.1) to exchange information among devices through a short-range radio frequency. Bluetooth operates between 2.4 and 2.5 GHz (ISM) frequencies, using a FSK modulation with a data rate of 720Kbps. Simple topologies can be realized using Bluetooth devices. Bluetooth networks are called piconets and are characterized by eight elements: a master and seven slaves. The master node works as network coordinator and performs clocks synchronization. Slave nodes work as passive nodes, accepting conditions coming from the master node. Each device can use adaptive transmission in order to save batteries.
IEEE 802.15.4 standard protocol has been defined for short-range, low cost, low speed and low power wireless communications. It is useful for WPANs characterized by low bit rate and devices powered by batteries which can not be frequently replaced, e.g. sensor nodes. Its main features are: coverage of about 50-100 meters; maximum data rate of 250 Kbps; low transmission power and lower power consumption; a network level to ensure routing procedures; use of ACK messages to perform data retransmission in case of absence of receipt or transmission error.
Bluetooth has been thought for audio applications by creating a Frequency Hopping Spread Spectrum scheme (FHSS), and a master/slave protocol. IEEE 802.15.4/ZigBee, instead, focuses the attention on sensors and controllers. It is based on short messages and a Direct Sequence Spread Spectrum system (DSSS). In this case, to decide the reference protocol, it is important to remember the central theme of this work: wireless sensor networks. Bluetooth is characterized by higher data rate and a massive device diffusion, which can be integrated in all the latest laptop models, mobile phones and PDAs. However, IEEE 802.15.4/ZigBee has been designed for low power consumption (batteries of these devices can last several years) and for a simple and fast communication among terminals. So, IEEE 802.15.4/ZigBee is the best candidate for sensor networks development and presents new and interesting perspectives in this field.
2.2.1. IEEE 802.15.4 ZigBee
The standard  defines physical layer (PHY) and datalink specifications (MAC) in order to ensure low data-rate wireless communications among devices requiring low power consumption. A LP-WPAN may include two different devices: FFD (Full Function Device) and RFD (Reduced Function Device). An FFD node can operate as network coordinator, as cluster coordinator or as simple communication terminal. An FFD (Coordinator and Router) can communicate with all devices, while an RFD (End Device) can communicate with an FFD only.
Main features provided by Physical layer (PHY) are radio transceiver activation and deactivation, energy detection (ED), link quality indication (LQI), channel selection, channel availability estimation and the transmission and reception of packets through the physical medium (radio channel). The standard offers two possibilities for transmission/reception based on different frequencies. Both methods use DSSS (Direct Sequence Spread Spectrum) modulation technique. Transmission rate is 250 kbit/s (2.4 GHz), 40 kbit/s (915 MHz) and 20 kbit/s (868 MHz). Between 868 Ã· 868.3 MHz there is only one channel, while there are 10 channels between 902.0MHz and 928.0MHz. Finally, between 2.4GHz and 2.4835GHz there are more than 16 channels.
The IEEE 802.15.4 supports the ability to dynamically select the channel using a scanning function that allows to search the beacon frame (synchronization) in a useful channels list. The main characteristic of the IEEE 802.15.4 PHY layer allows to satisfy power consumption requirements. In fact, it allows to perform other tasks, including receiver energy detection (ED). It is a feature used by the network layer for channel selection. MAC layer performs several tasks including: Mean access coordination; Packets creation and forwarding; Generation and address recognition; Packets sequence number control. It must also manage nodes detection process (Discovery). Time required to do this is about 30 ms, while other technologies like Bluetooth, need 5-6 s before they can fully use a device. Four frame types at MAC layer are possible: Data Frame; ACK Frame; MAC Command Frame; Beacon Frame. Data Frame consists of a maximum of 128 bytes numbered to ensure all packets routing. The "Frame Check Sequence" ensures that all packets are received without errors. This greatly improves transmission reliability in adverse conditions. Another important frame is the ACK frame. It provides confirmation that the sent packet has been correctly received. This solution ensures data consistency, but obviously increases latency. The MAC command frame provides a mechanism to monitor and configure client nodes. Finally, the beacon frame "wakes up" client devices, which are listening to their address and go into "sleep" mode if they do not receive it. Beacons (which are basically sync signals) are important for mesh and cluster tree networks to keep all nodes synchronized in order to save batteries. Since transmission medium (radio) is shared by all devices, it is necessary to use a transmission mechanism to avoid that two devices send packets simultaneously. There are two techniques: CSMA-CA and Beacon. Through CSMA-CA each device, before starting a transmission, performs a channel listening to understand if there is already another transmission. If so, the retransmission will be done later with a random delay. Through Beacon technique the coordinator sends a superframe (beacon mode) at regular time intervals (multiples of 15.38 ms, up to 252 s). Between a beacon and another one there are 16 time slots where the absence of collision is guaranteed.
All devices contend for first 9 time slots, while remaining time slots are assigned by the coordinator to a specific node and are called GTS (Guaranteed Time Slot). If a node has to transmit many information, the coordinator may give it more than one GTS. This structure guarantees dedicated bandwidth and low latency compared to the first technique. Furthermore, it also reduces battery consumption, because each device knows exactly when to transmit and it is sure there will not be collisions.
3. Video monitoring over wireless sensor networks
Main requirement of a road monitoring scenario is the ability to guarantee Quality of Service for video monitoring traffic flows. However QoS management in a wireless sensor network is something difficult to ensure because of several factors:
Sensors with limited power, energy, memory and processing capacity
Nodes heterogeneity: each node should manage different tasks and different hardware
Network topology may change over time due to nodes mobility, removal or addition of a node
Environment conditions in which sensor work are often unpredictable
All these situations can cause "delays" and/or "packet loss rate" too high which damage predictability and reliability system requirements. It is therefore necessary to use a QoS management paradigm to ensure network flexibility, adaptability and scalability. Some of these problems have been already investigated in literature (par. 3.2) while others are unresolved yet. Finally, the last paragraph of this section shows video transmission over IEEE 802.15.4/ZigBee.
3.2. Road monitoring through WSNs in literature
Traffic congestion is a problem of many big city of the world since vehicles number increase. Research in Intelligent Transportation System (ITS) is often focused on optimization of urban traffic flows. ITS main goal is to improve safety, mobility and efficiency. In recent years researchers studied and analyzed wireless sensor networks, communication technologies and algorithms targeted for ITS applications. WSNs can be deployed and organized in a very short time and can measure sevaral parameters related to vehicular traffic. Furthermore, sensors nodes have reduced size, are often low power and can be positioned in various places along the road. A wireless sensor network is able to detect vehicular flow, speed and occupation with high spatial and temporal resolutions, providing a possible solution to traffic congestion. To improve road monitoring reducing, at the same time, waiting and travel time, techniques for efficient traffic management are necessary. A large number of methods and approaches have been proposed in literature to reach this goal. In  the effectiveness of a WSN to take real-time traffic information has been studied. A first analysis is performed using a single sensor to detect vehicles approaching to traffic lights. In a second analysis, two sensors are positioned on each traffic lane to calculate the queue length. Results show that the use of one sensor is not enough to obtain best performance. Instead the distance between two sensors, located in the same traffic lane , does not have a great influence on traffic flow. A sensors based Traffic Light Controller (TLC) is implemented thanks to the Green Light District Simulator  and it is compared with an existing real TLC that does not use sensors. Results show that the proposed sensor network based TLC, has good performance but it was never able to draw up the exact number of queued vehicles at the traffic lights. In fact, the use of not many sensors does not guarantee a full and complete management of traffic in a road intersection. A new decentralised TLC based on WSNs is proposed in . Its main aim is to improve road monitoring maximising vehicles flow and reducing waiting time at traffic lights. Each intersection is characterized by an Intersection Control Agent (ICA) that receive information from wireless sensors distributed along roads and determines the traffic flow model . Another research  shows how it is possibile to equip vehicles with an electronic tag that can be mainly used for management traffic application. This solution would remove the sensor network infrastructure, since vehicles could easily exchange information each other. However, this approach is too invasive to be applied in a traffic management context. To improve real-time road monitoring, in addition to WSN, the fuzzy theory can be used. In fact, in the approach proposed in , a wireless sensor network collects traffic information  while fuzzy logic allows a dynamic and real-time traffic control. Based on number of detected vehicles by sensors, a profile is applied to manage the traffic flow. Performance are determined by calculating the Average Waiting Time Trip (AWTT) and results show wireless sensor network capabilities to quickly collect traffic information. In  is proposed a wireless sensor network to collect information on road intersections. These information can be transmitted to users that make requests about traffic. Indeed, the driver through his cell phone can receive traffic information of an interested area. The main goal of  is to design and implement an algorithm and, through several simulations, to evaluate road traffic management and control. The proposed system is able to detect ferrous objects in movement, e.g. vehicles, through a wireless sensors network. Furthermore, it is able to calculate the appropriate duration of green and red time of traffic lights in a road intersection. In this way, the system should help to solve traffic congestion problems. In any case, it is necessary to use many sensor nodes to increase system accuracy.
3.3. Video transmission problems over IEEE 802.15.4/ZigBee
In order to adapt video signal to the available bandwidth provided by IEEE 802.15.4/ZigBee protocol , it is really important to choose the best video coding approach. Surely IEEE 802.15.4/ZigBee is not a high performance protocol, but it is possible to transfer audio and video through an appropriate compression algorithm. Also, it is necessary to consider other characteristics in terms of video resolution and number of frames per second . These specifications are used to adapt video signal to the available bandwidth (250 kbps) for each of sixteen channels in the ISM band (2.4 GHz).
3.3.1. Video compression
Video compression technologies  are intended to reduce and remove redundant information. In this way, digital video file can be transmitted over a network and stored on computer hard drives more efficiently. With effective compression techniques, it is possible to obtain a considerable file size reduction with minimal effects on image quality. However, it is possible that images quality is compromised if file size is further reduced increasing the compression level. There are various compression technologies, both proprietary and industrial standards. Standards are important to ensure compatibility and interoperability. They are particularly useful for video compressions because a video can be used for different purposes. For example, in many surveillance applications, it must be viewable even many years after the registration date. Among various surveillance systems , end users can choose among different suppliers, rather than being tied to one vendor. Motion JPEG , MPEG-4  and H.264  are most used algorithms in video surveillance. H.264 is the most recent and effective video compression standard. The compression process applies an algorithm to the source video in order to create a compressed file ready for transmission or storage. When the compressed file is played, an inverse algorithm is applied to produce a video with the original content. Time required to compress, transmit, decompress and display a file is called latency. An algorithm pair used together determine a video codec (encoder/decoder). Video codecs of different standards are generally not compatible each other. For example, an MPEG-4 decoder can not be used with a H.264 encoder, simply because one of two algorithms is not able to properly decode the output of the other. However, it is possible to implement multiple algorithms in the same software or hardware in order to allow different formats coexistence.
3.3.2. Image compression Vs. video compression
Compression standards use different methods and have various transmission rate, quality and latency. Compression algorithms are divided into two types: images compression and videos compression. Image compression uses "intra - frame" encryption technology . Data is reduced within an image frame removing unnecessary information that may not be visible by human eye. In fact, human eye is more sensitive to luminance characteristics respect to chrominance characteristics. Motion JPEG is a typical example of this type compression standard. In a Motion JPEG sequence images are compressed or encoded as a single JPEG image.
Video compression algorithms, like MPEG-4 and H.264, use inter-frame prediction  to reduce video data from a frames series. Furthermore, there are techniques, such as differential encoding , where each frame is compared with a reference frame; pixels are encoded only if they have been modified respect to the reference frame.
3.3.3. Motion JPEG
Motion JPEG or M-JPEG is a digital video sequence that consists of individual JPEG images. When 16 or more image frames per second are displayed, images are in motion perceived. Full motion videos are collected at 30 frames per second (NTSC) or 25 frames per second (PAL). One of Motion JPEG advantages is that various images of a video sequence can have the same quality, which varies depending on chosen compression level for the network camera or video encoder. If compression level is greater, then, image quality and file size will be smaller. Since there are no links between frames, a Motion JPEG video is "solid", i.e. if during transmission a frame is lost, the rest of the video will not be compromised. This format is characterized by a wide compatibility and it is prevalent in many applications. In particular, it is used when individual frames of a video sequence are needed and when there are reduced transmission rate, usually 5 or less frames per second. Main disadvantage of Motion JPEG is that it does not use video compression techniques to reduce data, since it consists of a complete images series. Result is a relatively high bit transmission rate or a low compression ratio to obtain performance comparable with to MPEG-4 and H.264.
Usually, in video surveillance applications MPEG-4 Part 2 standard is used, also known as MPEG-4 Visual. Like other standards, MPEG license is purchasable, then users must pay a license fee associated with each monitoring station. MPEG-4 is used in applications characterized by limited bandwidth or requiring high images quality.
H.264 is used in high data rate and high resolution applications, (highways and airports) where 30/25 frames (NTSC / PAL) per second are needed. In fact, in these contexts, where it is necessary bandwidth and required storage space reduction, H.264 can offer the most significant advantages. This standard is also intended to accelerate network cameras diffusion with megapixels resolution because the efficient compression technology is able to reduce large files size and bit transmission rate without compromising images quality. However, H.264 requires the deployment of high performance network cameras and monitoring stations. Figure 6 shows performance of video encoding techniques described. Considering a sample video sequence, H.264 standard generates up to 50% bits per second less than an encoder which supports MPEG-4 with motion compensation. Furthermore, it is 3 times more efficient than MPEG-4 without motion compensation and at least 6 times more efficient than Motion JPEG.
4. System model
As said, some problems remained open challenges such as the system ability to interact in harsh environments ensuring QoS for video monitoring traffic flows, and network predictability and reliability. The main goal of this work is to resolve these management issues through a fuzzy logic controller, highlighting improvements in terms of reduced packet loss and an increased number of packets successfully received by destination nodes. A network controller manages sampling period of each sensor node at run time, in order to maintain deadline miss ratio, associated with real time traffic flows, inside a desired level. In other words, the network controller dynamically determines the sampling period based on current value of deadline miss using apposite membership functions as provided by Fuzzy logic .
4.2. Network architecture
A road traffic monitoring system, working in adverse environmental conditions, needs the coexistence, in a WSN (based on IEEE 802.15.4), of several devices, which working together, provide a correct road traffic analysis. Figure 7 shows the system architecture here proposed. It integrates sensors connected to cameras with several magnetic sensor to reveal traffic flows.
The circled area in figure represents a cluster in which, when high traffic volume is detected, more monitoring cameras are dynamically activated. Surveillance cameras have the following characteristics to satisfy the available bandwidth (250 kbps) for each channel:
Resolution 640 x 480
Magnetic sensors are RFD nodes (included in black nodes in Figure 7) that, based on magnetic field distortion caused by the presence of ferrous objects like cars, provide basic information for traffic volume estimation. Subsequently, they send data detected to their cluster coordinator node (FFD). Its main task is to transmit data to and from other devices especially to the First Pan Coordinator (FPC), which is able to store and process network information and send, in case of high traffic volume detected, an activation message to "sleeping" nodes using the IEEE 802.15.4/ZigBee protocol. WSN functioning is appropriately and dynamically adapted to critical conditions in terms of congestion increase in order to optimize information quality. When a critical situation needs a more accurate monitoring, the system here proposed activates more video control nodes based on traffic volume information detected. The increase of nodes in the network can cause a workload increase and then higher delay and packet loss. It is necessary to use a QoS management paradigm to ensure WSN flexibility, adaptability and scalability, considering network conditions changes. To this end, two basic features have been combined:
smart network manager to optimize power consumption using a "low rate" protocol (IEEE 802.15.4/ZigBee)
dynamic management of critical situations (also unexpected) which may lead network overloading.
4.2.1. Magnetic sensors
Magnetic field detection has enjoyed a significant growth thanks to several application fields: magnetic sensors can be used to detect the presence, strength or direction of magnetic field distortion caused not only by earth, but also by vehicles . These sensors can measure these properties without physical contact and this is the reason why they have become so important for industrial control systems. We need to consider that magnetic sensors are never used to measure the magnetic field. Usually they are used to evaluate parameters like speed or vehicles presence. These parameters can not be directly calculated, but can be extracted based on magnetic field variation and distortion. Conventional sensors (temperature or pressure), can directly convert the desired parameter to a proportional voltage or current output. Using a magnetic sensor, it is necessary to measure the magnetic field variation and then process the measured signal in order to obtain the desired output. Figure 8 shows the difference between conventional sensors and magnetic sensors.
Figure 9 show how a ferrous object, like a car, can create a local distortion. Vehicle detection applications can take different forms. A single axis sensor can detect vehicle presence. Magnetic distortion caused by a large ferrous object metals, like a car, can be modeled as a set of many magnetic dipoles.
Figure 10 clarifies how a uniform magnetic field is "distorted" by the presence of a ferrous object.
4.2.2. Vehicle classification
Magnetic distortions can be used to classify different types of vehicles , . When a vehicle passes over the magnetic sensor, it will detect all different dipole moments. The field variation is a real "magnetic" signature of the vehicle. A three-axis magnetic sensor, positioned on the traffic lane, will provide a rich output signal related to vehicles passing over its area. Figure 11 shows a three-axis magnetic sensor output after detection of two vehicles (a pick up and a sedan respectively). The four curves represent the magnetic field variation of X, Y and Z axis respectively and amplitude caused by the vehicle proceedings towards the south. Vehicle type can be classified based on these variations using pattern recognition or matching algorithms. Magnetometer output curves in Figure 11, reveal how vehicles vary Earth's magnetic field. The greatest variation, in each curve, occurs when the engine block is exactly opposed to the sensor.
4.2.3. Vehicle direction and presence
Detection of vehicle presence and direction , does not require a high degree of detail in terms of magnetic field distortion. Example in Figure 12 evaluates the detection of a car driven at a distance from sensor of 1 and 3 foot respectively.
Curves X, Y and Z obtained are shown in Figure 13. On the left results obtained by a sensor positioned at a distance of 1 foot with car travelling from north towards south are shown. On the right, instead, results obtained by a sensor positioned at a distance of 3 foot with car travelling from east toward ovest are shown. Each curve has two deviations: the first one represents the car traveling in direction of travel, while second one represents the car in reverse.
4.3. Dynamic video-monitoring algorithm
The approach here proposed (described through flow chart in figure 15), called Dynamic Video Monitoring Algorithm (DVMA), allows to activate more monitoring nodes in case of critical traffic situations detected by the WSN through magnetic sensors. Moreover, our approach controls the network load through a fuzzy controller whose task is to dynamically manage quality of service of data flows ensuring good performance. The DVMA evaluates, through magnetic sensors, the instantaneous magnetic field distortion value (VT). If VT measured value exceeds a threshold value, i.e. queue or traffic jam occur, and additional nodes are off, the FPC (green node in figure 7) sends an activation request to FFD nodes which, using the sleep/wakeup mechanism described in the IEEE 802.15.4 , forward the request to the sleeping RFD nodes. The idea is to forward an activation request setting to 1 the bit "High Traffic" introduced in the free reserved subfield of standard MAC control field frame as shown in figure 16.
Sequence diagram in figure 14 shows DVMA functions. Threshold_inizialization() function defines the minimum traffic density. Beyond this limit, additional controls must be activated. According to magnetic field distortion, detected by RFD sensors, traffic volume trend can be analytically represented as shown in Figure 17.
VT_acquisition() function acquires data collected by magnetic sensors placed along roads. Send_request_activation() function, sends an activation request from the First Pan Coordinator to "sleeping" RFD nodes through the FFD nodes (ZigBee routers) using 802.15.4/ZigBee standard protocol. Sleeping nodes wake up periodically, as described by standard , for channel control.
4.3.1. Fuzzy logic controller
The fuzzy logic controller manages network topology and workload. A similar approach has been applied in a context of WSAN  (Wireless Sensor Actuator Network). In our case, we have designed a fuzzy controller to dynamically change the sampling period of RFD nodes, determining the new sampling period (NST) based on two input values, as shown in figure 18:
Deadline Miss Ratio Measured of packets (DMRM)
Current Sampling Time (CST)
Based on predetermined "membership" functions , inputs are converted into "language" values: Positive Big (PB), Positive Small (PS), Zero (ZE), Negative Small (NS), Negative Big (NB). Subsequently, an inference mechanism, based on several IF-THEN rules, determines the output linguistic value representing the new sampling time NST (Positive Big, Positive Small, Zero, Negative Small, Negative Big). Figure 19 shows our inference mechanism functioning scheme.
To better understand Figure 19, IF CST value is NS (Negative Small) and DMRM value is ZE (Zero), THEN NST value will be ZE (Zero). Finally, this value is defuzzified into a numeric value, which represents the new sampling period (NST) of RFD nodes. In our algorithm, for each variable, a range of value has been defined. Therefore the range has been divided in sub-ranges (called fuzzy sets). Established that Deadline Miss Ratio Measured (DMRM) can assume values between 0 and 1.25, this range can be divided into fuzzy sets as shown in Figure 20.
In other words, if the value of DMRM is between 0 and 0.03, it will be fuzzyfied as Negative Big (NB). Similarly, Current Sampling Time (CST) can assume values inside a range divided in fuzzy sets too, as shown in Figure 21.
So, if Current Sampling Time has a value between 0 and 4, it will be fuzzyfied as Negative Big (NB). As seen previously, outputs are input functions. According to fuzzy logic, these functions are expressed through IF-THEN constructs. To better understand, the following construct (from figure 19) can be taken as model:
5. Performance evaluation
To demonstrate benefits introduced by the DVMA, several simulations were carried out using:
TrueTime : it is a real-time simulation environment that allows co-simulation control tasks performed in real-time kernels.
Simulink/Matlab has been used to test the DVMA in a WSN 802.15.4 based.
OMNeT++: it ensure WSN evaluation 
TrueTime and Simulink/Matlab have been used to test DVMA performance in a single cluster network. OMNeT++ has been used to test performance of entire WSN system. The simulated network consists of a central FPC node. It covers 480 meters of road section in every direction thanks to FFD nodes located at a distance of about 50 meters from each other. Each FFD node (ZigBee router) provides a magnetic sensor, for traffic measures, and two cameras in "sleeping mode". These cameras will be activated only in case of real need. In other words, when magnetic sensors detect traffic volume increase.
The simulation campaign refers to periodic and aperiodic traffic flows. A periodic real-time traffic flow has regular arrival times (arrival time is equal to sampling time value). An aperiodic real-time traffic flow has irregular and unpredictable arrival times (it can be even one-shot). The first concerns video monitoring traffic flows, while aperiodic packets concerns data sent by magnetic sensors for traffic volume detection. During simulations, have been evaluated: number of packets received and lost for image traffic and network management traffic respectively. Packet size considered is 18 Kb, data-rate equal to 180 Kbps, Simulation Time equal to 30s. Figure 23 shows results obtained with fuzzy logic controller OFF while Figure 24 shows what obtained switching ON the controller. Results indicate a great improvement when the controller is ON: a higher number of image packets rightly received (230-270 Vs. 80-90) and, at the same time, a strong decrease of lost packets (80-120 Vs. 410-400). It is easy to observe that when the controller is OFF (Figure 22) the workload related to periodic traffic is higher than the case with the controller ON. The fuzzy logic controller adjusting the periodic traffic (determining sampling times) reduces network traffic (workload) improving the throughput. In fact Figure 23 shows a number of periodic packet loss undoubtedly lower. Considering the aperiodic traffic, even if the network maintains the same workload, the DMVA improves performance because decreases general network workload.
We also analyzed network performance in terms of Throughput (Th) / Workload (Wl) (1). In other words:
Figure 25, Figure 26 and Figure 27 show how the fuzzy controller reacts to network degradations.
Figures 25,26,27 show how performance get worse when the controller is OFF. At each time window, in fact, the number of packets that correctly reach their destination, decreases till a minimum value measured of about 44% (total traffic sent), 41% (image traffic sent) and 59% (aperiodic traffic sent). Instead using the fuzzy logic controller, Th/Wl measured is equal to about 80% (total traffic sent), 76% (image traffic sent) and 82% (aperiodic traffic sent). The DVMA dynamically responds to an overloaded scenario. It has been simulated a generic situation adding and removing stations (due to fast road traffic variation) which generate additional traffic to the network. The network become able to prevent network collapse, while adding more monitoring nodes or when network conditions are close to saturation.
6. Conclusions and future works
This work discussed an algorithm to manage road traffic volume through a hybrid architecture that integrates magnetic sensors for vehicular traffic detection, with several cameras to ensure better monitoring. The possibility to activate more devices only in case of real need, ensures energy savings. Furthermore, using a fuzzy logic controller, we can manage easily and in a better way network workload changes. The controller works dynamically, based on QoS measured parameters and results are really promising. We are currently working on the implementation of the proposed architecture using COTS devices, with panels which indicate, along the monitored road section, the presence of heavy traffic and suggesting, where possible, alternative routes or estimated time to reach the desired destination. Moreover, our research will focus on real-time scheduling algorithms having as input data acquired through WSNs for road monitoring near traffic lights. In particular we are developing a mechanism to allow dynamic management of queues at traffic lights in order to give more green time to road sections with longest queues. In addition, we are studying a smart paradigm based on neural networks in order to predict, with mean square error as small as possible, vehicular traffic behavior based on values previously measured. As everybody knows, during the day streets are jammed in the morning (people go to work or accompany their children to school), lunchtime and late afternoon (work out). The Network Controller, after an accurate training phase, may cleverly monitor the established area in a soft way, dynamically determining the awakening of video surveillance cameras only when really necessary based on values detected by magnetic sensors and predictions determined by the neural algorithm. Another important research aspect concerns the study of power consumption within WSNs. Dynamic sampling times management allows us to assume a lower average power consumption of batteries used by the sensors. This leads an increase of batteries duration and network lifetime. Our goal is thus to measure energy savings that can be obtained through our approach and determine if the approach can be further improved by using a neural network system or a neuro-fuzzy combination.