Performance Evaluation of Magnetic Wireless Sensor Networks Algorithm for Traffic Flow Monitoring in Chaotic Cities

Traffic flow monitoring involves the capturing and dissemination of real-time traffic flow information for a road network. When a vehicle, a ferromagnetic object, travels along a road, it disturbs the ambient Earth’s magnetic field, causing its distortion. +e resulting distortion carries vehicle signature containing traffic flow related information such as speed, count, direction, and classification. To extract such information in chaotic cities, a novel algorithm based on the resulting magnetic field distortion was developed using nonintrusive sensor localization. +e algorithm extracts traffic flow information from resulting magnetic field distortions sensed by magnetic wireless sensor nodes located on the sides of the road. +e model magnetic wireless sensor networks algorithm for local Earth’s magnetic field performance was evaluated through simulation using Dar es SalaamCity traffic flow conditions. Simulation results for vehicular detection and count showed 93% and 87% success rates during normal and congested traffic states, respectively. Travel Time Index (TTI) was used as a congestion indicator, where different levels of congestion were evaluated depending on the traffic state with a performance of 87% and 88% success rates during normal and congested traffic flow, respectively.


Introduction
Magnetic-based wireless sensor networks (WSN) offer installation and implementation costs flexibility advantage when used to monitor traffic flow in cities with chaotic traffic mostly in developing countries [1].However, the major constraint is powering the sensors [2] which require an independent source away from the main power supply.Other challenges include cost and technological limitation [3,4].A vehicle detection wireless sensor node has four main components, namely, a sensor to sense physical signals modified by vehicles passing, a processor to process the sensed data, a communication unit to transfer the processed data to the base station for further processing, and an energy source [5,6].Conventional vehicle detection technologies, such as inductive loop detectors, are not preferable for largescale deployment in developing country cities with chaotic traffic because they are intrusive and disruptive to traffic and have high installation and maintenance costs [5].e advancement in microelectronics and MEMS technologies [7] provides an alternative solution where a single board wireless sensor node can be assembled combining all the necessary components with energy harvesting capability.
is alternative can lower installation and maintenance costs when sensor nodes are located on the roadside, powered by a renewable energy source, and operated with energyefficiency algorithms.Due to easy availability, installation, and maintenance of magnetic WSN, they can be installed all over the city road networks to perform traffic flow monitoring and management [8].
erefore, a wireless sensor node processes the sensed data locally and sends traffic flow information to the base station hence optimizing bandwidth requirement [9,10].
Most signal processing algorithms used for traffic flow monitoring in magnetic WSN were designed for developed countries traffic conditions where sensor nodes are buried under the road surface [11].Developing countries face many challenges to implementing such systems.We observed that mostly in developing countries traffic monitoring systems should be cost-effective to realize and maintain.It is a big challenge to implement the sensor buried under the road surface due to economical and maintenance factors.e alternative and effective implementation strategy are to localize the magnetic wireless sensor nodes on the roadside, thus creating a new challenge in developing an effective algorithm for detection and extraction of traffic flow information.
is research deployed a newly developed wireless sensor node called KiliNode depicted in Figures 1 and 2. KiliNode is built based on the PIC24FJ128GC006 microcontroller which has a number of features suitable for high signal processing in energy efficient environment such as high-performance CPU: (i) 17 bit × 17 bit single-cycle hardware fractional/integer multiplier (ii) 32 bit by 16 bit hardware divider (iii) 16 × 16 bit working register array KiliNode integrated with HMC1052 AMR magnetometer from Honeywell has two-axis high sensitivity and is reliable for low field sensing which had the following characteristics: (i) sensitivity 1 mV/V/gauss (ii) resolution 120 nT (iii) maximum current consumption 0.5 A (iv) low voltage supply 1.8 V (v) set/reset strap current 0.5 A

Related Works
Most signal processing algorithms based on magnetic field for vehicular traffic detection are deployed on sensor nodes buried under the road.
e adaptive threshold detection algorithm (ATDA) is an efficient vehicle detection algorithm with high precision of 97%, but its classification scheme is not efficient having a low performance where the overall recognition rate is below 60% [12].Its implementation depends mostly on sensors buried under the road surface to monitor single lane individually, which is demanding for multilane and chaotic environments.is drawback will be similar to all other intrusive algorithms based on ATDA such as magnetic sensors-based vehicle classification algorithm (MVSCA) [13,14].
Earth magnetic fields depend on geographical location.e field strength differs from the North poles to the Equator.On the poles, the field is about 50,000 nT, and on the Equator, it is about 30,000 nT.Most detection algorithms using magnetic field were conducted in America and Europe with stronger Earth magnetic fields compared to East Africa which lies near the Equator with a less strong field.erefore, the vehicular magnetic anomaly detection requires high-resolution sensors and alternative signal processing algorithms to extract desired traffic flow information.

Theoretical Model Formation
is work assumes that magnetic wireless sensor nodes are installed on the sides of the road, above the ground for traffic flow monitoring.When a vehicle travels along a road, it disturbs local ambient Earth's magnetic field causing changes in its direction and strength.Magnetic wireless sensor node senses both Earth's magnetic field and magnetic   [16] has the same direction as inducing field.e magnetic moment of any ferromagnetic object is caused by induced and permanent magnetization [17]. is research assumes that vehicles can be modelled as a dipole moment, which is influenced by only induced magnetization due to its soft-iron composition [15].Each ferromagnetic part of a vehicle has its own induced moment based on the inducing field.e total magnetic moment of a vehicle is the vector sum of individual ferromagnetic part moments based on the inducing total Earth magnetic field B e .erefore, the total induced vehicular magnetic moment m is given by Equation ( 1). e shortest proximity distance r between the wireless sensor node (x o , y o , z) and vehicular current location at coordinate (x, y, z o ) is given by Equation (2): where N is the total number of ferromagnetic parts within a vehicle, m i is the vehicle's ferromagnetic part moment, k i is the vehicle's ferromagnetic part volumetric susceptibility constant, V i is the vehicle's ferromagnetic part volume, and B e is the total Earth's magnetic field.e vehicle is travelling along a straight line (road) near an observation spot (magnetic wireless sensor node).
erefore, y and z can be treated as constant distances measured during wireless sensor node installation, and x varies as the vehicle moves.
e vehicle can be considered as a dipole model if its total length is very small compared to a distance between its centre and observation spot.Basic expression for establishing the maximum amplitude of an anomaly due to the magnetization [17] is given by where T is the magnetic anomaly in nanotesla (nT), m is the target magnetic moment in Ampere-meter 2 (Am 2 ), r is distance between observation spot and dipole in meters (m), and n is a measure of the rate of decay with distance or falloff rate (n � 3 for dipole; n � 2 for monopole).e total magnetic anomaly of a dipole (vehicle) B a at distance r from the vehicle to the observation spot (wireless sensor node) based on Equation ( 3) is given by the following equation: where B a is the total magnetic anomaly (vehicular target) due to magnetization, m is the vehicular magnetic moment, and r is a proximity distance between a vehicle and wireless sensor node.e dipole (vehicular target) magnetic anomaly B a can be resolved into two components in spherical coordinates at any distance r from the centre of a dipole with magnetic moment m on a radius that makes an angle θ to the dipole axis [17,18].As depicted in Figure 4, the magnetic anomaly B a has radial component B r and tangential component B θ given in the following equation: ( α is an angle between vehicle instant position on the road and y-axis.When a vehicle is moving, α changes depending on the current position and direction.When α � 0, r is the shortest proximity distance between a vehicle and the wireless sensor node.θ is the angle between vehicle current position in the x-y plane and r. e two anomaly magnetic components B r and B θ are resolved into the horizontal component H a and the vertical component Z a [19] as shown in Equations ( 6) and (7), respectively.In this case, the vehicle is moving along the road at a distance r away from the wireless sensor node: Modelling and Simulation in Engineering Model formation established the localization of the magnetic wireless sensor node on the roadside for traffic flow monitoring.When a vehicle travels along a road, it disturbs local ambient Earth's magnetic fields, causing its anomaly scattering in all directions [16].e anomaly reaches the magnetic wireless sensor node and then senses and processes to extract vehicular signature and traffic flow information.However, locating the magnetic wireless sensor node on the roadside causes an increase in the proximity distance to the vehicle target resulting in the dipole anomaly field to weaken.erefore, the wireless magnet sensor node with high resolution will give an added advantage when selected for traffic flow monitoring.Model formation showed how to extract magnet anomaly components in the horizontal and vertical directions.
ese fields are essentials in magnetic signal models for traffic flow monitoring.

Magnetic Signal Models
e construction of vehicular magnetic signals B ax , B ay , and B az at the respective direction of the wireless sensor node is presented.e signals are the functions of space and time.Figure 5 shows the summary of all the magnetic field components and their directions in a horizontal x-y plane and vertical z-y plane, respectively.Figure 5 where B ax , r, θ, and α are functions of time and space; D and H e are the angles of declination and the horizontal component of total Earth's field B e , respectively; and φ is the angle between magnetic north X e and magnetometer north. is angle is measured during wireless sensor node installation.w is a noise due to different environmental sources.According to research, the noise influencing the magnetometer is regarded as White Gaussian Noise, that is normally distributed [20].e magnetic anomalous signal B ax in Equation ( 9) depends on vehicular moment m and sensor location relative to the moving vehicle.

4.2.
Anomalous Signal B ay .Total magnetic signal observable at the magnetometer in the y-direction is composed of two magnetic field components: total Earth's field horizontal component H e and horizontal vehicular anomaly H a .Both were aligned to the wireless sensor node East, given by where B ay , r, θ, and α are functions of time and space; D and H e are the angles of declination and the horizontal component of total Earth's field B e , respectively; φ is the angle between magnetic Earth's North X e and magnetometer's North B ax ; and magnetic anomalous signal B ay in Equation (11) sensed by the magnetometer depends on vehicular moment m and sensor location relative to the moving vehicle r.

4.3.
Anomalous Signal B az .Total magnetic signal observable at the magnetometer in the z-direction is composed of two magnetic field components: total Earth's field downward component Z e and vertical vehicular magnetic anomaly Z a .Both signals have the same downward direction as B az .e magnetic anomalous B az is given as follows: where B az , r, and θ are functions of time and space; I and B e are the angle of inclination and total Earth's magnetic field; and magnetic anomalous signal B az Equation ( 13), sensed by a magnetometer, depends on vehicular moment m and magnetometer location relative to the moving vehicle.

Anomalous Signal Graphs.
Considering traffic monitoring in Dar es Salaam City located at latitude −6.8 °and longitude 39.1 °, the total Earth magnetic field at this geographical location is approximately 33,125 nT [21].e magnetic sensor node (KiliNode) is located at z � 3 m above the ground and y � 5 m from the road.Assume sensor observability is between x � −30 m and 30 m.A small car such as the Toyota Vitz moves along the road (x-axis).e magnetic susceptibility of a ferromagnetic parts content of a car is quite high, ≈ 1000 [22].Assume the wireless sensor node and road are aligned to the Earth magnetic North direction (φ � 0 0 ). Figure 6 depicts magnetic anomalous field plots using Matlab; Figure 6(a) shows magnetic anomalous field B ax sensed by the magnetic wireless sensor node in the x-direction and plotted against the vehicle position x.

Proposed Signal Processing Algorithm
Scanning and decision algorithm (SDA) is a novel energy efficient, time-domain signal processing algorithm for vehicular detection and extraction of traffic flow information such as count, speed, and Travel Time Index (TTI) based on three axes magnetic WSNs located noninvasive on sides of the road. is algorithm is a combination of mathematical and logical operations on the observed magnetic signal to extract output traffic flow information.

Algorithm Development.
e magnetic anomalous signals B ax , B ay , and B az are sensed by the wireless sensor node in x, y, and z-direction, respectively, are sent into the system through the A/D converter block as depicted in Figure 7. e anomalous signal magnitudes are then converted to digital x(n), y(n), and z(n) signal, respectively.From the A/D converter, the digital signals are then sent into the difference equation (moving average filter) and adaptive baseline blocks.e content of the input signal x(n) could be either baseline x(n) or anomalous x(n).When the magnetometer senses Earth magnetic field without any moving vehicle, the signal captured is referred to as baseline, while when sensing Earth magnetic field together with the moving object the captured signal is referred to as anomalous.Adaptive baseline block is controlled by the error signal e(n) to identify whether the input signal is anomalous or baseline using logical operations: Baseline signals are updated and stored to be used by the difference equation block.Earth magnetic fields are not constant over a period of time.It is influenced by small fluctuation due to factors such as noise, magnetic storms, or temperature drift [21,23].erefore, the baseline signals are updated periodically by repeating the logical operations at some fixed intervals of time.
Difference equation filters in Equations ( 14)-( 16) are used to extract the error signal e(n) from anomalous and baseline signals: where n is the sample size; e x (n), e y (n), and e z (n) are the error signals; andx(n), y(n), and z(n) are the anomalous e square decimator [•] 2 block [5] is used to calculate the signal energy E y in Equation ( 17) and E z in Equation ( 18) from the error signals e y and e z and then put into the SDA blocks.Signal e x is used to deduce the vehicular direction, and therefore, it is not necessary to calculate its energy:   Modelling and Simulation in Engineering SDA logic has two blocks depicted in Figure 7: "SDAscanning" and "SDA-decision."When the energy signal enters the SDA-scanning block, it is sliced into small segments x(k), y(k), and z(k).eir width T s depends on the sampling frequency of the wireless sensor node f s .Each segment contains traffic flow raw data that will be used for further operations within SDA-decision block to extract vehicular traffic flow information.

SDA Finite State Machine.
is section presents SDA state machine for calculating vehicle counts, speed, and TTI by using only a single energy signal E y (n).However, both energy signal E y (n) and E z (n) can be used for the same operation for high precision results.

Vehicular Detection, Count, and Average Speed.
In the scanning state as depicted in Figure 8, the signal segment y(k) is tested whether it is anomalous by comparing the transition condition y(k) > 0. If the transition is true, the detection is made by updating the detection flag d(w), where w is the current window.Otherwise, the operation will proceed to the decision state either Decision_1 or De-cision_2 depending on the current w value.In the decision state, there are three options in each depending on the transition condition: either Decision_11, Decision_12, De-cision_13 or Decision_21, Decision_22, Decision_23.e Decision_11 or Decision_21 states are used to update vehicular count variable C and increment period (T s ) counter j. e Decision_12 or Decision_22 is used to calculate total observation time t, average speed v arg , and Travel Time Index TTI.Decision_13 or Decision_23 states are used to increment period (T s ) counter j.Finally, the Init_12 or Init_22 states are used to update local variables before completing and exiting the cycle.Vehicular speeds were calculated based on a single sensor node: where v(t) is the vehicle speed, v avg (t) is the average vehicle speed for N vehicles, L is the estimated vehicle length, and t is the vehicle observation time by the wireless sensor node.e main inputs into the algorithm are magnetic signals (B ax , B ay , and B az ) and the constant free flow speed v ff .e main outputs are vehicle count C and TTI.

Congestion State.
Traffic congestion can be described as the condition that occurs when the traffic flow demand exceeds by far the infrastructure supply resulting in long queues, travel delays, and increased travel costs [24].Expressing the congestion state of a road segment is one of the key aspects of traffic flow monitoring.Many research works were conducted to study the congestion behaviour and formation.e challenges still remain due to the nonlinearity nature of congestion formation [24].Selection of congestion metric is paramount; how do we measure the congestion state of a road network or city? is work adopted a congestion metric called TTI, proposed by Schrank and Lomax [25], which is a ratio of travel time in the peak period to travel time at free-flow conditions while accounting for both recurring and incident delays such as traffic accident.It determines how long it takes to travel during a peak hour and uses both main and arterial travel rates.
is index has the advantage of expressing traffic congestion in terms of space and time, given by the following equation: where TTI is the Travel Time Index, t is the average peak period travel time, t ff is the free-flow travel time, v ff is the free-flow travel speed, and v arg is the average peak period travel speed.TTI of 1.35 indicates a 20-minute free-flow trip takes 27 minutes at the peak.Note that free-flow speed of 50 km/h at arterial roads in Dar es Salaam is used in this study.e TTI can be understood by relating the value to a percentage.If the TTI is 1, then the average travel time is the same as the free flow travel time, meaning there is no delay.If the TTI is 1.5, then the actual travel time is 150% of the free flow time, or it takes 1.5 times longer to travel a road segment than it would under uncongested conditions.For this analysis, it was assumed that the TTI cannot be less than 1, which occurs when the average speed is greater than v ff .TTI requires only two parameters on its calculation as shown by Equation ( 21) erefore, the TTI computation is simple and suitable for deployment in the wireless sensor networks in an energy efficient environment.

Simulation
A simulator for traffic flow monitoring was developed using Matlab based on discrete-event simulation formalization [26,27].It simulates the proposed SDA algorithm and other wireless sensor events.Figures 9 and 10 show the simulator interfaces, respectively.e simulation was conducted along a designated double road network of the city.e v ff for the road system was set to 50 km/hour.e road segment was installed with four sensor nodes, one sink node, and TMC.Each sensor node detects a vehicular presence, travel speed, and count.It then computes v avg and TTI.ese data are sent to the TMC so that the average TTI and the vehicular count will be calculated and stored in the database periodically.e stored data are useful for estimating traffic congestion for the designated road network or city.Perforated lines show the wireless communication links between sensor nodes based on the IEEE 802.15.4 protocol [28,29].Communication between a base station and TMC is achieved through mobile communication technology such as GPRS, LTE, or EDGE.e simulator has a specific discrete event to record manually vehicular counts, speed, and calculate TTI.
e manual traffic flow data are used to validate the data from the wireless sensor node.e two road signs show the manual vehicle count over a road segment and a maximum free flow speed.

Results and Evaluation
e simulation was conducted for 30 minutes, where normal and congested traffic flows were simulated on eastbound and westbound lane, respectively, of the double road system.
Congested traffic flow results were plotted in Figure 11.Two sensor nodes were installed on eastbound lanes (nodes 1 and 5).e threshold line has TTI � 1, and the area above the threshold line represents high delays (congested) while below represents normal traffic flow.
Normal traffic flow was depicted in Figure 12.Two sensor nodes were installed on westbound lanes (nodes 2 and 6). Figure 12(a) shows vehicle count graphs performed manually, by the sensor nodes 2 and 6. Figure 12(b) shows the TTI calculation graph done manually and by the sensor nodes 2 and 6.
Table 1 summaries the performance based on traffic flow data captured by four sensor nodes with respect to the manual counts.
e manual count was used to validate wireless sensor nodes performance.On the westbound, normal traffic flow was simulated and results on vehicular counts were 462 manually and 428.5 average counts on nodes.
erefore, the wireless sensor node missed 33.5 counts out of 462 during normal traffic flow.It is equivalent to 93% success rate.On the eastbound, congested traffic flow was simulated and results on vehicle counts were 1022 manually and 781 average counts on nodes.Wireless sensor nodes missed 241 out of 1022 during the congested traffic flow state.It is equivalent to 76% success rate.
Table 2 summaries the performance based on traffic flow data captured by four sensor nodes with respect to manual TTI calculation.Manual TTI was used to validate TTI based on wireless sensor nodes.During normal traffic flow, TTI of 1.1 for manual and 0.96 for wireless sensor nodes were calculated.erefore, wireless sensor node showed 87% success rate.During congested traffic flow state, TTI of 2.8 for manual and 2.48 for wireless sensor node was calculated.Wireless sensor node showed 88% success rate.

Conclusion
is work proposed a novel traffic flow monitoring algorithm called SDA based on magnetic WSNs installed on the sides of the road above the ground.e model formation and performance evaluation of the proposed magnetic-based WSNs algorithm for vehicular traffic flow monitoring in a chaotic environment were studied.
e performance evaluation of simulation results for traffic flow monitoring in chaotic cities of developing countries using SDA based on WSNs showed 93% vehicular detection and count success rate for the normal traffic flow state and 76% for the congested traffic flow state.Congestion state metric, TTI, was used to measure the congestion state of the road segment with a performance of 87% and 88% success rates during normal and congested traffic flow states, respectively.is research suggests further studies on microscopic and macroscopic mathematical algorithms to improve detection, especially during the congested traffic flow.

Data Availability
e data used to support the findings of this study are available from the corresponding author upon request.

Figure 3 :
Figure 3: Model formation showing wireless sensor node location with respect to the origin, total Earth's magnetic field and its components, wireless sensor node and its directions, road link, and a moving vehicle.
(a)  shows horizontal x-y plane magnetic fields; Earth's magnetic North X e , East Y e , and horizontal H e are components of total Earth's Magnetic field B e .D is the declination angle between X e and H e .Wireless sensor node horizontal plane (B ax − B ay ) is aligned at an angle φ with Earth's magnetic plane (X e − Y e ).Vehicular magnetic anomaly horizontal component H a is at an angle α with sensor node East B ay .Figure5(b) shows vertical z-y plane magnetic fields; total Earth's magnetic field B e is at an angle I with the horizontal plane x-y.Earth's magnetic downward component Z e is a vertical component of B e .B az is a wireless sensor node downward component in a vertical plane x-y.Z a is a vertical component of the vehicular magnetic anomaly.ese fields are the basis of magnetic signal models to be sensed by the wireless sensor node for further processing and extraction of traffic flow information of the designated road network.4.1.Anomalous Signal B ax .Total magnetic signal observable at the magnetometer in the x-direction is composed of two magnetic field components: total Earth's field horizontal component H e and horizontal vehicular anomaly H a .Both were aligned to the wireless sensor node North, given by

Figure 4 :
Figure 4: Model formation showing tangential B θ and radial B r components of the induced vehicular magnetic anomaly at r distance from the vehicle's current position.

Figure 6 (
b) shows magnetic anomalous field B ay sensed by the magnetic wireless sensor node in the y-direction and plotted against the vehicle position x.Figure6(c)shows magnetic anomalous field B az sensed by the magnetic wireless sensor node in the z-direction and plotted against the vehicle position x.

Figure 6 :
Figure 6: (a) B ax , (b) B ay , and (c) B az present in vehicular magnetic anomalous fields in x, y, and z directions.

Figure 7 :
Figure 7: Block diagram of the SDA algorithm for magnetic WSNs showing data inputs, processes, and the outputs.

Figure 9 :Figure 8 :
Figure 9: Simulator interface shows road link and the total Earth's magnetic field contours in Dar es Salaam City located at latitude −6.8 °and longitude 39.1 °.
Figure 11(a) shows vehicle count graphs performed manually and by sensor nodes 1 and 5. Figure 11(b) shows the TTI calculation graph done manually and by sensor nodes 1 and 5.

Figure 10 :Figure 11 :Figure 12 :
Figure 10: Simulator interface showing sensor nodes and their coverages on the sides of the road 3 m above the ground and 5 m from the centre of the lane.

2
[15]lling and Simulation in Engineering distortions due to vehicular ferromagnetic contents.ewirelesssensornode is integrated with three axes anisotropic magnetoresistance (AMR) sensor[15]which is installed at Cartesian coordinates (x o , y o , z) relative to the origin (x o , y o , z o ) at the ground as depicted in Figure3.A road link is located at Cartesian coordinates (x o , y, z o ) perpendicular to the origin (x o , y o , z o ).