Cluster forming based on spatial information using HMAC in WSN

The wireless sensor can be considered as one of the most major technologies through using it in different application such as environmental applications, military applications, commercial applications, health applications and agriculture applications. Due to the sensor networks may be deployed in open area (uncontrolled area), especially in military applications. In such situations, the nodes are vulnerable to be captured. Moreover, data/control packets may be intercepted and/or modified due to the transmission nature. Consequently, security services such as authentication and encryption done by key management which is not trivial task. The key management is important to maintain the network operations. The proposed scheme the nodes based on spatial information with data sequence then sends encryption message to each other in secure way by HMAC for providing safe links between the nodes in the network and forming the clusters. Consequently, the proposed scheme covers the security goals and authentication of each node.


Introduction
The wireless sensor has become an essential component of modern life and its technologies have seen great development in the last decade.Moreover, Wireless Sensor Networks (WSNs) are used in many applications such as monitoring, target tracking and military applications.However, because the sensors resources are constraint; providing security services in sensor networks and cover the security goals are not trivial problem [1].There are two kinds of key cryptography: First, Symmetric key cryptography uses a single key, called a secret, which is used to encrypt and decrypt a message by the sender and receiver.In this sense, the sender and the receiver share the same secret key to exchange encrypted messages and to be able to decrypt them [2].Second, Asymmetric key, the sender/ receiver have their own private keys, which are secrets, and a public key which is known to all nodes in the network.Furthermore, the sender/receiver use both the secret and the public key for encryption and decryption [3].Secure Hash Algorithm 1 (SHA-1) cryptography which is a type of symmetric key cryptography and it is an essential component of modern cryptography.Furthermore, it is defined as a deterministic procedure that generates a fixed-length bit string, called a digest.In Hash function cryptography, a message with any-length bit string is executed by taking inconstant bit patterns as an input, which then produces constant bit patterns of output.Subsequently, it is interesting to observe for an output message as it computes a unique digest [4,5] as shown in figure 1.

Related work
An important element in the cryptosystem is the key and managing this key in the way of generation and distribution between the nodes in the network is not a trivial task.Furthermore, it has become a hot topic.Key management, therefore, is basic to confirm the security of communication of a wireless sensor network.Henceforth, how to establish an efficient key management in a WSN is a basic challenging problem due to the energy constraints, memory and computational processing capabilities of the sensor nodes [6].Eschenauer and Gligor proposed the basic probabilistic key predistribution, in each sensor is apportioned a random subset of keys from a key pool before the deployment of the network in pre-distribution phase [1] In this scheme in pre-distribution phase, the two sensors can have a certain probability to share at least one key.Besides, each of them assigned more than one to communicate with other nodes that lead to save more key in their memories.Therefore, the nodes memory exhausted.Moreover, if the adversary captures each node he can get all keys which are assigned to the node.Chan and et al. in [7] developed the q-composite key pre-distribution schemes.The qcomposite key pre-distribution scheme is based on the basic probabilistic scheme in [1], but it requires two sensors share at least q pre-distributed keys to establish a pairwise key.In this scheme in predistribution phase still assign number of keys (q) in each sensor that lead to exhaust their memory.Also, if the enemy arrests each node he can catch the q of keys which are allocated to the node.W. Heinzelman and et al. in [8] proposed the LEACH protocol, where the nodes in the network are homogenous (each node has identical characteristics).After deployment, the sensors elect themselves to be the Cluster Head )CH( at any given time with a certain probability, after which they then broadcast their status to other nodes within the network.Other nodes select the CH sensor according minimum communication energy.In this scheme each nodes work as CH periodically that mean the sensor cost will be expensive because its properties larger than normal node.In [9] the author's scheme produced to provide the safe links between the nodes in the network and forming the clusters.The Elliptic curve EC is used for generating the seed keys of the pool.Since, the doubling and addition operations for Elliptic Curve (EC) points are used for generating the ring of the private keys.Moreover, EC has many operations for doubling and adding; therefore, the EC is not convenient for cryptography in WSN causes using more energy and exhaustion the sensor resources.The MAC function is a type of symmetric key cryptography.It meets different security requirements, resists existential bogus plaintext attacks and confirms that the data has not been changed.Consequently, it does not allow malicious nodes to join the network through exchange messages within the network.In addition, it supports data authentication and integrity.

Security goals
In each research, the analysis on security is an essential part.This proposed scheme has also been analyzed to reach the suitable level of security.The achieved securities in this scheme according to some fundamental terms of security are given below.1-Authenticity Authentication enables each node in the network to ensure the identity of the peer nodes, which communicate with each ot-her so as to eliminate any fake messages and to guarantee that messages come from a trusted node.Symmetric Key Cryptography (SKC) or Public Key Cryptography (PKC) and also the Message Authentication Code (MAC) are utilize to achieve data and node authentication [10].

2-Confidentiality
Confidentiality is an important stage to pr-otect and keep any data secret during transmission between sensors and also between Base Station (BS) and sensors within the network by concealing messages and then avoiding the enemy.Unauthorized sensors cannot understand the messages, therefore, they remain secret.This is achieved with cryptography [10].

3-Integrity
Integrity is of utmost importance to protect the data of received messages from alteration and modification by malicious nodes or adversaries.Until the network has confidentiality, there is still a possibility that data integrity or the message containing the data have been compromised by alterations or change.Integrity stops a malicious node present in the network from injecting bogus data.For this reason, MAC or Hash MAC (HMAC) is used to verify integrity 4-Availability Availability ensures the survivability of sensor network services to authorized parties even though there are attacks within the network.It also ensures the updating of the security mechanism and is not influenced and bordered on the network performance [11].

5-Freshness
Freshness ensures that all data and messages exchanged are modern and prevent the resending of old data.To prevent old messages from being sent again by an attacker, a timestamp can be added to the packet to achieve data freshness [11].

6-Resilience
The number of keys which an attacker gains by physically capturing some nodes is used by the attacker to hack the whole network and fail the system [12].The proposed scheme uses tamper resistance to solve this problem.

7-Scalability
Scalability means that network size is flexible and its size can increase after deployment, which also ensures the level of security, stability and node properties wh-en increasing the size of the network [11].

8-Connectivity
Connectivity is the proportion of the probability of the nodes that are in contact with each other to create a network after deployment in order to ensure better performance of the network.In addition, whenever the percentage of connectivity is hig-her, the quality of network performance is finest [2].

Attacks in WSN
Due of any lack of security, attackers can intercept and read the content of any message.In addition, they can introduce false messages into the system via the network.Moreover, an attacker can capture a sensor and physically capture a node from which the attacker can steal the key material [13].

1-Sybil attack
The attacking node is forged and it can disguise the identity of more than one node inside the network, thereby affecting data authenticity, confidentiality and data integrity [14].

2-Sinkhole attack
In general, malicious node disguises the victim nodes and is located near to the BS and persuades the victim nodes to send their messages to the BS at high power.Additionally, it may be likened to a black hole absorbing everything passing into it [13].

3-Wormhole attack
The malicious node uses a tunneling technique to establish itself between nodes in order to confuse the routing protocol.The malicious node disguises the victim nodes and shows itself as having higher communication resources than normal nodes in order to establish the best communication channels between them.Moreover, wrong routing of information leads to changes in the network topology and the stream of messages will change.It can alter the packet or modify it, thereby damaging the packet [13].

4-Hello flood attack
The intruder is a sink or BS and it broadcasts a hello message with strong transmission range and power to the network and acts as a fake sink to send their messages to it rather than to the legal sink.It disguises the BS by acting as a neighbor with many nodes in the network, thereby badly mixing the network routing [13].Proposed Scheme A WSN consists of a large number of small, selfpowered, and inexpensive devices that have ability to sense, compute, and communicate with each other through wireless techniques.Sensor nodes collect the sensing data from the environment then send collected data to the end user.Accordingly, the proposed scheme consists of the following:

The Network Model
The proposed method considered the heterogeneous structure for the network.The network consists of three levels: the top level comprises the BS with unlimited resources; the middle level consists of CH sensor which are high sensors working as CH with properties higher and operating with far more power than Low (L) sensors, which are also the sensors, but working at the last level of a network.Moreover, the routing of gathered information in the proposed network is central and prepared in a secure way by using the techniques of cryptography from the L sensors to the BS via the CH sensors.The latter works like a gateway.Furthermore, L sensors can be connected to the CH sensors directly or through other L sensors.

Assumption
The BS is trusted with a large memory size, high power processing, powerful transmission range, and unlimited battery energy.a) The deployment area is 50 * 50 m 2 .b) Number of CH sensor is one and the numbers of L sensors are 100.c) The CH has the ability for accessing to each L and not verse versa.d) The range of all L sensors nodes transmission range is 15 meters.e) After distribution (deployment) all sensors nodes (CH and L) are static and equipped with GPS (Global Positioning System).f) L sensors and CH sensor equipped with tamper resistance which consider as a compromised immune system [15], where the algorithms store in it.

The Network Phases
The proposed scheme consists of three phases as depicted bellow: a-Pre-distribution phase The CH and Ls are preloaded with algorithm 1 and 2. Besides, the spatial information of the BS is stored in the CH memory, and the latter uses it as a key to communicate to BS. b-Distribution phase Due to the random distribute of the sensors, the network topology is unpredictable.The BS is setup in a safe area near deployment area but in controlled area to observe the uncontrolled area.Both of 100 L sensors and one CH scatter within 50*50 m 2 randomly in uncontrolled area.In addition, L sensors and CH are fixied after deployment and each L and CH uses their location as a key to communicate to each other.

c-Cluster forming phase
The clustering mechanisms used to enlarge the lifetime of WSN and to provide more efficient functioning procedures makes the algorithm economical than the flat sensor network [16].The cluster formation starts from the CH sensors and performs the following step: 1.After the deployment, To determine the absolute node positions in a relatively calibrated flat 2D net via GPS technique based on stored maps, landmarks [17].The BS computes its location (X-axis and Yaxis) via GPS.Then, broadcast it to the CH by equ.for making the message secure.Because, the coordination of the sensors are often represented as float number.The output of the SHA-1dosen't contains the float number.If we make a concatenation between the coordination values (x,y) with the output of SHA-1, then it will be very easy for the hacker to estimate the exact values of (x,y).Therefore, their values are converted to sequence of characters.This will be embedded with the output of SHA-1 in MAC and never understoodable.Because the output not repeated except who has the algorithm can get it.2. The CH sensor decrypts the received message according algorithm2.Then, extract s the location of the BS.
3. The CH sensor encrypts its location to stream of bits then broadcasts it to all nodes according equ.2 and algorithm 1. 4. Each L decrypts the received message according algorithm 2.Then, extracts the location of the CH; Each L sensor calculates the distance by Euclidean mechanism according to equ.3.In the end, each neighbor L sensor (L near ) which has distance less than 15 m can communicate directly with CH as equ.4 and algorithm 1. 5. The CH sensor decrypts the received message according algorithm2.Then, it extracts the location of the (L near ).Later, the CH sensor sends the ACK (location of L) according to equ.5 and algorithm 1. 6.Each (L near ) which is able to connect directly with the CH can decrypts the message and it makes the ACK true. 7.Each remote L sensor which doesn't receives the ACK because it is a long distance from the selected CH sensor (more than 15 m) sends a hello message to other L sensors according to equ.6 and algorithm 1. 8. Each neighbor L (L near ) receives the messages within its coverage, and before decrypting the message, it checks whether, if it has the ACK or not.If it has the ACK then it decrypts the message according algorithm 2; otherwise, it discards the message.9.The L near sensors send the ACK according to equ.7.execution.10.Each L remote which is able to connect directly with the L near can decrypts the message and it makes the ACK true.Moreover, the steps 8 and 9 repeat till all nodes conn-ects to each other as shown in figure 2, where it shows the number of simulation implementation. .

Security goals analysis:
The security goals analysis is the main part in our proposed scheme as given below: 1) Authentication: This is achieved because each node has a unique key (location), as well as the use of HMAC in the deployment phase which acts as a one way function.
2) Confidentiality: The proposed scheme encrypts every message and makes it secrets by mean of the proposed algorithms using HMAC.In traditional Hash when Alice sends a message to Bob, initially she must send two messages (the digest and the plain text).This leads to make confidentiality failed.Also, same thing when utilizes traditional MAC.But, in the proposed method one encrypted message is sent rather than two.
3) Integrity: The proposed scheme protects the received messages from alteration and modification it by using HMAC in the proposed algorithms.4) Scalability: the proposed scheme is wor-king properly around 200 nodes.This is approved by simulating, as shown in figure 3 where the node ( 6) not connected.4.Moreover, hops numbers in the proposed scheme are lower than the compared scheme [18,19] as shown in adopted figure 3 and the connectivity rate in the proposed scheme is 100%;but, in [19] is not 100%.In addition, if comparing the proposed scheme with [9,18,19] in term of number of hops, the proposed scheme's hops are less than other schemes as shown in figure 4 and table 1.Also, when matching the proposed scheme with [9] in number of CH the last uses two CH; but, the proposed scheme uses one CH as shown in figure 4 which leads to reduce the cost.As well as, number of hops in [9] are five; but, the proposed scheme are four.Because that the proposed scheme better than [9,18,19] in term of energy consumption.Furthermore, we compare the proposed scheme with some existing schemes in term of security analysis as shown in table 2. 3. The proposed scheme rejects the sinkhole attack messages because only the CH sensors can communicate with the BS.Furthermore, in pre-distribution the spatial location of BS saved in CH, which uses to exchange the messages, where the attacker cannot know the spatial location of BS and the algorithms.Because that the attacker message will be discarded.4. Hello flood attack cannot affect the proposed scheme because it uses a hello message with spatial location converted to data sequence then encrypted by HMAC.The attacker message can be recognized from the nodes within the network.Therefore, it will be rejected.5. Wormhole attacks want to occur between two legal nodes and exchange fake massages with each legal node.Each CH and L can detect this attack because it uses HMAC to verify the message and discard any malicious node messages.In addition, we compare the proposed scheme with some existing schemes [23] in term of attacks as shown in table (3).

Conclusion
In a manner corresponding to the assessments metric in all previous papers in the field of security and key management for WSN, including the proposed scheme, it finds that all the key management schemes had cons encompasses the trade-off between network the security analysis, the attacks and energy consumption, time, scalability and connectivity.Hence, providing the ideal key management scheme which can cover all the challenges are still valuation searching area and difficult work.The proposed scheme focused on heterogeneous routing in WSNs over the use of a new enhanced reactive scheme, which aims at the achievement of power cluster forming due to decrease the number of hops in the routing, security analysis, scalability, connectivity and attacks in the WSN based on spatial location, which is used as a key to make secure link between the nodes in the network.

Figure 3 Comparison in term of connectivity 5 )
Figure 3 Comparison in term of connectivity 5) Connectivity: in the proposed scheme all nodes communicates to each other for creating the network, as shown in adapted Figure4.Moreover, hops numbers in the proposed scheme are lower than the compared scheme[18,19] as shown in adopted figure3and the connectivity rate in the proposed scheme is 100%;but, in[19] is not 100%.In addition, if comparing the proposed scheme with[9,18,19] in term of number of hops, the proposed scheme's hops are less than other schemes as shown in figure4and table 1.Also, when matching the proposed scheme with[9] in number of CH the last uses two CH; but, the proposed scheme uses one CH as shown in figure4

Figure 5
Figure 5 time consuming in hopsFinally, the figure6shows the time consuming measured in second for each L in one round.

Table 2 Comparison in term of security Requirements Proposed scheme Scheme[20] Scheme[21] Scheme[22]
2. Sybil attack tries to transmit a message to legitimate nodes within the network with a fake ID.But, the proposed scheme based on spatial location rather than ID.Therefore, it cannot affect the network.Furthermore, the message not contains the plaintext.Because that the attacker cannot gain the key.Tikrit Journal

Table 3
Comparison in Terms of attack In addition, the table 4 and figure 5 mention the L sensor time consuming measured in second, display time consuming in each L sensor for encryption/decryption when it simulating via MATLAB R2013a for Mica2 with processor 433 MHz and memory 128K bytes.