Background technology
Existing along with microelectric technique, computer networking technology and development of Communication Technique, wireless sensor network day by day becomes one of focus of internet arena research.Wireless sensor network is the self-organizing system that the microsensor node by the low rate of One's name is legion in the surveillance zone, low-power consumption, low cost, low complex degree constitutes, and is a kind of multi-hop mobility peer-to-peer network that adopts communication, dynamic group net.Sensor network is the center with the microsensor node, sensor node generally possesses data processing and communication capacity, and utilize the subsidiary sensing circuit of node that relevant environmental condition is measured on every side and they are converted into the signal of telecommunication, handle for these signals according to place target and characteristic that incident takes place around it by transducer.Sensor network can be realized collection fusion, transmission and the Long-distance Control visit of data, it is widely used in fields such as military affairs, Smart Home, environmental monitoring and forecast, medical treatment and nursing, building condition monitoring, Industry Control, utilize state parameters such as various transducer sensing temperatures, sound, pulse, pressure, the user is provided information needed, thereby improves people's quality of life and operating efficiency.
Wireless sensor network is a kind of network system of self-organizing, its objective is the information of perceptive object in perception collaboratively, collection and the processing network's coverage area, and sends to the observer, greatly expands the ability in the existing network ground function and the human knowledge world.Wireless sensor network is called as one of three following big high and new technology industries of the whole world.For Research on sensor networks, the μ AMPS of the PrcoRadio of Univ. of California, Berkeley and Massachusetts science and engineering has the architecture of moulding.
Fig. 1 shows the wireless sensor network architecture of refinement.Physical layer provides sensing, carrier sense and simply sends and receiver module; Data link layer provides medium access, error control and frame measuring ability; The Application in Sensing protocol stack mainly comprises transmission control and data acquisition, and wherein Routing Protocol is the part of transmission control, and energy management in addition, system management, safety and timing need the support of application protocol stack and data link layer.
Wireless sensor network Routing Protocol emphasis is considered energy consumption, only selects suitable path based on the topology information of part, and the Routing Protocol of sensor network and application program have very strong correlation, and the Routing Protocol difference is very big in the different application.
There is following defective in the architecture of traditional sensor network:
For traditional sensor network, wireless sensor network is considered to a kind of data-centered network, be unfavorable for that advantage merges mutually with Next Generation Internet with sensor network is ubiquitous, flexible, efficient etc., make sensor network can only carry out local application like this, be unfavorable for forming ubiquitous sensor network
Traditional sensor network is unfavorable for bringing into play the advantage of layered architecture, is difficult to finish real end-to-end communication.Lack the communication mechanism guarantee for important data communication
Routing Protocol carries out routing based on the topology information of part, needs to safeguard a large amount of topology informations that possesses, and has increased the traffic and energy consumption
The Routing Protocol relevant with application program, the autgmentability of practical application is not high.For example, in sensitive zones, rearrange new application node, can't make full use of the route of original application.Traditional IP v6 routing appliance protocol stack system structure
In recent years, the paces of global IT application were obviously accelerated, and the Internet development is maked rapid progress especially with application.IPv6 can make the all-network equipment that is connected on the Internet realize intercommunication mutually on the meaning as the basic agreement of Next Generation Internet more widely.The Internet development is so fast, and its core component---router is performed meritorious deeds never to be obliterated.Router is the special computers that can transmit packet that has a plurality of interfaces.It is a kind of typical network layer device, and major function is to carry out the forwarding of route calculating and packet.Wherein, route calculation is meant and is optimal path from the source address to the destination address of packet selection.Therefore, how to select simply, route will become one of decisive factor whether the IPv6 network can efficiently move efficiently.For appliance protocol stack system structure, Traditional IP v6 wireless router adopts the abstract of hardware platform to realize with realizing the method that the IPv6 protocol stack sofeware combines.Protocol stack sofeware be divided into again hardware-related part, with hardware independent part and three aspects, administration configuration unit: comprise partly that with hardware independent forwarding engine, message handle, transmit modules such as processing, other processing, data transmission; Hardware-related part then comprises Data Receiving, Message Processing, task management, real-time processing section, should comprise file system and the memory management module of keeping system's operation in addition; Administration configuration is mainly used in revises the abstract parameter of hardware relevant portion, and our protocol stack sofeware is moved on different hardware platforms.Fig. 2 has shown the architecture of the whole protocol stack of IPv6 router.IPv6 routing appliance protocol stack software is realized dynamic routing protocol such as RIPng, OSPFv3, BGP4+ etc.
For Routing Protocol, wireless self-organization network Ad-Hoc is extensive use of a kind of Routing Protocol AODV (Ad-hoc On Demand Distance Vector) that drives as required, it has defined RREQ, RREP, RERR and four kinds of type of messages of RREP-ACK, every kind of type of message has complicated message field (MFLD), and the size of corresponding four kinds of type of messages is 24 bytes, 20 bytes, 12+8n (n is the number of unreachable destination location) byte and 2 bytes.And AODV has defined the Hello message format in the RREP message, is used for judging whether neighbor node is reliable.If do not receive the hello packet of neighbor node within a certain period of time then think that neighbor node is unreliable, then carry out route maintenance.
The architecture of the protocol stack of Traditional IP v6 router and design and realization are not suitable for the ubiquitous sensor network of IPv6, are mainly reflected in following several aspect:
Route that the architecture of IPv6 routing appliance protocol stack is mainly router is calculated and forwarding capability designs, and in wireless sensor network, every kind of sensor node with routing function also need possess sensing functions such as data acquisition and processing (DAP), and Traditional IP v6 routing appliance protocol stack does not have active data and handles and send needed transport layer and application layer framework and interface;
IPv6 routing appliance protocol stack design process is mainly considered processing speed, forward delay, the data throughout of router, and sensor network nodes has the characteristics of low rate, low-power consumption, low cost, low complex degree, and that the design of agreement must take into account is low in energy consumption, cost is cheap and simple.IPv6 routing appliance protocol stack traditionally can't satisfy this key property of sensor network.
The routing Design of IPv6 router is mainly considered the stability of route, so the routing policy of Routing Protocol is quite complicated, and takes regularly the efficient of the stable and data forwarding of updating strategy assurance route, and the advertising of route strategy guarantees the routing table consistency.But these routing mechanisms increase the traffic load of wireless sensor network, cause the loss of energy.
Routing Protocol need be in the support of IPv6 in the architecture of IPv6 routing appliance protocol stack, thereby realize the forwarding of advertising of route and packet, but the route of sensor network is set up process in the inner realization of sensor network, finish by the sensor network convergent point with the Internet interconnection, therefore the routing protocol packet form complexity that realizes by IPv6, increase the sensor node reception and send bit number, cause the loss of energy.
AODV routing protocol packet form complexity according to sensor node energy consumption situation, transmits 1 bit information 100m and is about as much as the energy of carrying out 3000 instruction consumes apart from the energy of needs, is unfavorable for reducing the energy consumption of sensor node; AODV Routing Protocol maintenance process complexity has increased the complexity of node processing message; Adopt hello packet to judge the reliability of neighbor node in addition, both increased the consumption of energy, cause broadcast storm in the sensor network again, cause the obstruction of data.
Summary of the invention
In order to overcome the deficiency of prior art structure, realize that sensor network combines with IPv6, make sensor network really become the part of Next Generation Internet, the present invention proposes a kind of IPv6 micro sensing routing appliance protocol stack system structure and implementation method, designs and Implements this architecture key component---the working mechanism of micro sensing routing appliance protocol stack.The present invention program can be deployed in low hardware resource and not have in the embedded platform of operating system support, support the IEEE802.15.4 standard criterion comprehensively, the data acquisition, dynamic routing, data fusion, network management, safety certification of sensor network, function such as location automatically both can have been realized, can make sensor node equipment insert the Internet again, realize end-to-end communicating by letter with user terminal.
A kind of architecture that is applicable to the micro sensing routing of sensor network environment:
The micro sensing routing architecture comprises IEEE802.15.4 physical layer, IEEE802.15.4 media access control layer, adaptation layer, micro sensing routing appliance protocol stack and application layer from bottom to top.
IEEE802.15.4 physical layer and IEEE802.15.4 media access layer meet the standard that IEEE802.15.4 working group formulates at the low-speed wireless personal area network, for unified physical layer and medium access control interface is provided between low rate, low energy consumption, the low-cost device.
Adaptation layer meets the working group draft of the 6Lowpan working group of internet engineering task group (IETF) at the proposition of wireless personal domain network framework IPv6 agreement, it provides the Processing Interface of miniature protocol stack of IPv6 and IPv6 micro sensing Routing Protocol, and is responsible for the data delivery of two kinds of agreements is encapsulated, modulates and send to IEEE802.15.4 media access layer and IEEE802.15.4 physical layer.
Micro sensing routing appliance protocol stack is the core and the key component of micro sensing routing architecture.It comprises two parts: miniature protocol stack of IPv6 and IPv6 micro sensing Routing Protocol, the miniature protocol stack of IPv6 provide the IPv6 encapsulation of application layer data and resolve, and realize communicating with the network of existing TCP/IPv6 protocol architecture; IPv6 micro sensing Routing Protocol is a kind of Routing Protocol that is applicable to sensor network environment that the present invention proposes, and sets up and safeguard route when being used in the sensor network transfer of data.
Application layer: application layer is the set that sensor network nodes provides various Application in Sensing procedure service, mainly comprises data acquisition and fusion, location, tracking, network management etc.
A kind of IPv6 micro sensing routing appliance protocol stack system structure implementation method:
The present invention designs and key component---the micro sensing routing appliance protocol stack of realizing this architecture on the basis of the micro sensing routing architecture that proposes.Mainly comprise the miniature protocol stack of a kind of IPv6 and a kind of IPv6 micro sensing Routing Protocol;
The miniature protocol stack of a kind of IPv6, the miniature protocol stack of IPv6 of the present invention mainly comprises:
(1) simplifies the TCP/IPv6 protocol stack, design IPv6, ICMPv6, ND, TCP and udp protocol handling process and satisfy the low storage of embedded system, low complex characteristics;
(2) be independent of the scheduling scheme of operating system, finish between the protocol stack scheduling and handle the Application in Sensing data;
(3) the Memory Allocation mode of Maximum tolerance control is preserved the data that protocol stack transmission, the message that receives and application program generate.
Step (1) is simplified the TCP/IPv6 protocol stack, and realization sensor node and existing TCP/IPv6 terminal are carried out end to end communication, mainly comprise following aspect:
(a) simplify the basic header of IPv6 agreement: IPv6 and simplify traffic classes and flow label field processing, because adaptation layer has jumping limit field, ignore simultaneously the hop count field inspection;
(b) simplify ICMPv6 agreement: ICMPv6 and be responsible for the diagnostic network state, comprise two kinds of ICMPv6 error messages and ICMPv6 informational message type.In order to reduce the size of protocol stack, ICMPv6 processing IC MPv6 informational message do not handled for the ICMPv6 error message;
(c) simplify the ND agreement: the ND agreement is encapsulated by the ICMPv6 agreement, handles router solicitation, router advertisement, neighbor request, neighbor advertisement and ICMP and is redirected five kinds of option type message formats.Because router solicitation, router advertisement and redirect message function are finished by the micro sensing Routing Protocol, the ND agreement of simplifying is only handled neighbor request and two kinds of message formats of neighbor advertisement;
(d) simplify udp protocol: protocol stack is simplified the udp protocol scheduling process, safeguards that the UDP listening port is connected table with UDP, is used for filling source port and destination interface field in the UDP message;
(e) simplify Transmission Control Protocol: change according to 11 kinds of basic status of Transmission Control Protocol and carry out the TCP flow processing, and safeguard that the tabulation of TCP listening port is connected table with TCP, be used for filling source port, destination interface, sequence number and affirmation field, cancellation software error report mechanism and counting messages mechanism; Do not use sliding window mechanism and use fixed window size 32768 to receive and send data; Removed support to TCP COS TOS and secure option.
Step (2) configuration operation system on sensor node is very high to the requirement of hardware, memory space and processing energy consumption for economize on hardware, protocol stack of the present invention is independent of the scheduling of operating system: Frame is received by hardware interrupts, parse the load of protocol stack data by IEEE802.15.4 physical layer and media access control layer, at adaptation layer scheduling IPv6 receiver function, resolve after the basic header of IPv6, judge next header fields, initiatively dispatch next protocol processes function.After the protocol stack header disposes, dissimilar sensing datas is handled by the application programming interfaces of data-oriented type.
Step (3) needs a kind of memory mechanism to preserve and sends and receive the packet of handling based on above-mentioned scheduling mode.In order to reduce the memory fragmentation that the embedded system dynamic assigning memory produces, the present invention sets two global variable array inBuffer and outBuffer preserves the packet that receives and send processing respectively, according to IEEE802.15.4 Frame size regulation, distribute inBuffer and outBuffer102 byte, encapsulate and resolve the different agreement data.
A kind of IPv6 micro sensing Routing Protocol.The IPv6 micro sensing Routing Protocol that is applicable to sensor network environment of the present invention's design mainly comprises:
(1) three kinds of message formats of definition sensing Routing Protocol are used for sending request and safeguard route messages;
(2) a kind of to go into two list item sensing routing mechanisms that oral thermometer and routing table combine, be used for handling and the storage route messages;
(3) a kind of sensing path by routing and decision process, when being used for route and setting up to the processing of route message;
(4) a kind of route maintenance and fault-tolerant processing process are used in time declaring the inefficacy route and reduce maintenance costs.
The demand that step (1) is set up according to route, sensor network route requests message RREQSN (Router Request for Sensor Network) and sensing network route response message RREPSN (Router Reply for Sensor Network) have been defined, demand according to route maintenance, defined sensing network routing error message RERRSN (Router Error for Sensor Network) form, the size of RREQSN message and RERRSN message is respectively 21 bytes, 19 bytes, 9 bytes of RERRSN message fundamental length, both carry necessary routing iinformation, greatly reduced the energy consumption that sends and receive routing iinformation again;
Step (2) is gone into oral thermometer and routing table maintenance mechanism.The source address of inlet table record route requests message and ID number of the information of transmission when the route requests message that repeats abandons during through node, reduce the generation of route loop and send the energy loss of redundancy message and handle burden; Routing table record route destination address, next hop address and jumping figure restriction etc. are routing iinformation substantially, comprises tolerance and forerunner's route table items of link-quality simultaneously.Link-quality and jumping figure information are as route essential information relatively, and forerunner's node address of forerunner's route table items record route is used to declare the inefficacy route;
Step (3) sensing path by routing and decision process, mainly comprise following aspect:
(a) sensor network exists two types of equipment---global function node device FFD and partial function node device RFD, constitute two kinds of topological structure stars and network structure, at different equipment and topological structure, move different routing policies: RFD equipment does not carry out route requests and response, only safeguard a default route to father node FFD equipment, father node FFD equipment replaces RFD equipment to carry out route requests and response, saves the RFD plant capacity;
(b) intermediate node receives the RREQSN message that source node sends, and inlet porting statistical tables and reports literary composition indicates, upgrades the jumping figure and the smallest link mass value of RREQSN message simultaneously;
(c) destination node receives the RREQSN message, waits for effective time, simultaneously according to the present invention propose with jumping figure and link quality values as the optimum route discriminant function of parameter, judge optimum route.Stand-by period finishes, to optimum route clean culture RREPSN message.
Step (4) route maintenance and fault-tolerant processing.In order to reduce the mutual amount of information of sensor network nodes, the micro sensing Routing Protocol is not the cycle to send route maintenance message, but in data transmission procedure, detect the inaccessible while of neighbor node, to the unreachable message of forerunner's node announcement route, delete unreachable route, reduce losing of packet.
Beneficial effect of the present invention: the present invention proposes a kind of nucleus equipment---the design and the implementation method of the architecture of IPv6 micro radio sensing router based on the ubiquitous sensor network of IPv6.By this equipment, can combine sensor network with IPv6, make it really to become the part of Next Generation Internet.Networking separately, also can insert Internet, support multiple hommization configuration modes such as long-range, serial ports, have advantages such as volume is little, energy consumption is low, adaptivity is strong, cost is low, simple and flexible, have a wide range of applications in fields such as industrial and agricultural production, military and national defense, medical treatment and nursing, environmental monitoring, Smart Homes.
Embodiment
Embodiment 1: the architecture of micro sensing routing appliance protocol stack:
The present invention proposes a kind of architecture that is applicable to the micro sensing routing of sensor network environment.This architecture comprises IEEE802.15.4 physical layer, IEEE802.15.4 media access control layer, adaptation layer, protocol stack and application layer from bottom to top.Fig. 3 has provided the framework of IPv6 micro sensing routing architecture.
IEEE802.15.4 physical layer: according to the IEEE802.15.4 consensus standard, physical layer is made of the control module of radio-frequency (RF) transceiver and bottom, it has defined the interface of physical radio channel and media access control layer, the data, services of physical layer and the management service of physical layer are provided, the data, services of physical layer transceive data from the wireless channel, the management service of physical layer is safeguarded a database of being made up of the physical layer related data.The function that physical layer is finished comprises the activation of detection, channel idle monitoring and evaluation, transmission and receiver of modulation and demodulation, system capacity of Frame and dormancy etc.
IEEE802.15.4 media access control layer (MAC): according to the IEEE802.15.4 consensus standard, data frame transfer between the service realization equipment that media access control layer use physical layer provides, it provides two kinds of service MAC layer data services and the service of MAC layer-management.MAC layer data service guarantees Medium Access Control (MAC) Protocol Data Unit is correctly transmitting-receiving in the physical layer data service, and the database of a status related information is safeguarded in the service of MAC layer-management.The function that media access control layer is finished comprises channel access way, device association and synchronous.
The packet size (1280 bytes~1500 bytes) that adaptation layer: IPv6 supports is far longer than IEEE802.15.4 frame sign (128 byte), in order in the IEEE802.15.4 network, to support the IPv6 packet, the 6Lowpan working group of internet engineering task group (IETF) proposes the notion of adaptation layer, is used for the IPv6 packet is carried out burst and compression.The miniature protocol stack that the present invention proposes carries out the transmission of data with regard to the interface that is to use adaptation layer
Micro sensing routing appliance protocol stack: micro sensing routing appliance protocol stack comprises two parts: miniature protocol stack of IPv6 and IPv6 sensing Routing Protocol.The miniature protocol stack of IPv6 provides the IPv6 encapsulation of application layer data and resolves, and realizes communicating with the network of existing TCP/IPv6 protocol architecture; IPv6 sensing Routing Protocol is a kind of Routing Protocol that is applicable to sensor network environment that the present invention proposes, and sets up and safeguard route when being used in the sensor network transfer of data.
Application layer: application layer is the set that sensor network nodes provides various Application in Sensing procedure service, mainly comprises data acquisition and fusion, location, tracking, network management etc.
Embodiment 2:IPv6 micro sensing routing appliance protocol stack system structure implementation method;
The present invention has designed and Implemented the core of micro sensing routing---micro sensing routing appliance protocol stack, and it is made up of miniature protocol stack of IPv6 and IPv6 micro sensing Routing Protocol.
1.IPv6 miniature protocol stack;
Along with the success of Internet, the ICP/IP protocol stack has become the global standards of network service.The ICP/IP protocol stack is used for transfer of data and point-to-point networking etc. as the Internet underlying protocol.But traditional ICP/IP protocol stack needs too many resource, is the size of code of several kilobytes or the requirement that the data storage area size of several kilobytes all can't reach sensor network nodes low cost, low energy consumption.The present invention designs a kind of miniature TCP/IPv6 protocol stack of simplifying, and size of code is little, simple and easy light-duty and can communicate with the peer node of using complete TCP/IPv6 protocol stack.
1.1 the performing step of the miniature protocol stack of TCP/IPv6:
The application specific according to sensor network, TCP/IPv6 protocol stack of the present invention comprises IPv6 agreement, Transmission Control Protocol, udp protocol, ICMPv6 agreement, five main agreements of ND agreement, and reserve the interface of other protocol contents in the realization flow of protocol stack, other agreement can be used as extension header and calls.The IPv6 agreement of simplifying, ICMPv6 agreement, ND agreement and udp protocol, Transmission Control Protocol are achieved as follows:
The realization of IPv6 agreement and simplification process: Fig. 4 have provided the handling process of the basic header of IPv6 agreement.After IPv6 processing function receives the IPv6 data, judge the version number of IP packet, whether the length of judgment data bag and the length of net load mate, check destination address field (DAF), the address style field is set, resolves next header type then, be delivered to the corresponding protocol processing function; When carrying out the IPv6 encapsulation, ipv6 traffic classification, stream label are filled 0, because adaptation layer comprises " jumping figure " field, and adaptation layer has simple forwarding capability, receive the IPv6 packet of issuing destination node when intermediate node, can not carry out packet IPv6 and resolve and directly transmit, so when carrying out the IPv6 packet encapsulation, ignore " jumping figure " field.
ICMPv6 agreement and ND agreement realize and the simplification process: the effect of ICMPv6 agreement is the state of diagnostic network, has two types: icmp error message and ICMP informational message.In order to simplify the protocol stack size, only use the ICMPv6 informational message, and the ICMPv6 error message is not handled.Fig. 5 provides ICMPv6 and handles the response request message and respond the response message flow process.The ICMPv6 agreement receives the packet that the IPv6 agreement is submitted, and judges verification and whether correct, obtains ICMPv6 source and destination address then, judges ICMPv6 protocol encapsulation type, handles the request of response respectively and responds response message.The ND agreement is encapsulated by ICMPv6, handles router solicitation, router advertisement, neighbor request, neighbor advertisement and ICMP and is redirected five kinds of option type message formats.Because router solicitation, router advertisement and redirect message function are finished by the micro sensing Routing Protocol, the ND agreement of simplifying is only handled neighbor request and two kinds of message formats of neighbor advertisement.Fig. 5 has provided neighbor request and neighbor advertisement handling process.In ICMPv6 protocol processes function, judge type field for neighbours resolve and the neighbor advertisement message format, change neighbours over to and resolve and announce and handle.
Udp protocol is simplified process: Fig. 6 and is provided the udp protocol handling process.Udp protocol receives the message that the IPv6 agreement is submitted, and judges verification and whether correct, inquires about local UDP connection table then, if there is no then preserves source, destination interface and purpose IP address that UDP connects, and resolution data is delivered to application layer and handles then
FINWAIT1、FINWAIT2、TIMEDWAIT、CLOSING、CLOSEWAIT、LASTACK。Each connects and all to start from the CLOSED state, when a side has carried out the connection of active or passive connection, just can break away from the CLOSED state.If this moment, the opposing party carried out corresponding connection, just connect and can set up, and state-transition is the ESTABLISHED state, and this moment, data can be transmitted.Either party all can at first ask to discharge and connect.After connecting release, get back to the CLOSED state again.The present invention designs the Transmission Control Protocol processing procedure and changes according to 11 kinds of states: at first check TCP check and whether correct, search local TCP connection table then, preservation source, destination interface and purpose IP address, upgrade receive sequence number and send and confirm number, according to the TCP sign of preserving, change the state processing of response over to then.Other processing procedure is carried out its corresponding simplified: cancellation software error report mechanism and counting messages mechanism; Do not use sliding window mechanism and use fixed window size 32768 to receive and send data; The TCP message that arrives does not cushion but directly is submitted to application program and handles; Removed support, ignored the tcp option of reception etc. TCP COS TOS and secure option.
1.2 be independent of the protocol stack scheduling step of operating system:
Traditional ICP/IP protocol stack is called by the interface core of operating system, yet the configuration operation system is very high to the requirement of node hardware on sensor node, in order to save the node device memory space and to handle energy consumption, the TCP/IPv6 protocol stack of the present invention's design is independent of operating system, the data that bottom receives are notified the reception interrupt function by the mode of interrupting, and directly are submitted to adaptation layer by the reception interrupt function again and dispatch the TCP/IPv6 protocol stack.The scheduling process that Fig. 7 shows is as follows: after node receives packet, behind the IEEE802.15.4 frame head of reception interrupt function resolution data bag, by the type that adaptation layer is come the judgment data bag, call the IPv6 receiver function and resolve ipv6 header; Judge next header type then, dispatch corresponding TCP/IPv6 protocol stack program and handle.Resolve the application programming interfaces that back application program message proposes according to the present invention, carry out application data and handle.In order to prevent to receive a plurality of packet, take place to handle conflict, the present invention is provided with the reception formation, and the packet of a plurality of receptions is carried out buffer memory.
1.3 the Memory Allocation step of Maximum tolerance control:
The miniature TCP/IPv6 protocol stack of the present invention's design does not adopt the mode of dynamic assigning memory, but adopts two global variable inBuffer and outBuffer to preserve entire I Pv6 packet, respectively each byte of TCP/IPv6 protocol stack is handled.Two global variable sizes all are 102 bytes, satisfy IEEE802.15.4 regulation (maximum packet length 127 bytes one minimum data frame head 15 bytes).After packet receives, resolve IEEE802.15.4 data frame header and adaptation layer head, load with the adaptation layer Frame is stored among the inBuffer then, global variable buflen represents loaded length, the protocol stack scheduling mechanism that proposes according to the present invention, protocol stack is handled each protocol fields of pointed inBuffer, call TCP/IPv6 protocol processes function and resolve, carry out the processing of application data by application programming interfaces at last.The specific implementation method is as follows: at first IPv6 handles function and receives packet, stem with the pointed inBuffer of IPv6 structure type, simplify the IPv6 protocol procedures according to what the present invention proposed, take out the thresholding of structured fingers and carry out IPv6 data processing and preservation, then according to the next header field values of IPv6 structured fingers, packet data delivery is sent to next header handle function, next header is handled the position of function with the IPv6 agreement length of next header structure pointed inBuffer, handle the length of buflen sign application data according to next header process of simplifying; Call at last to use and handle function, carry out the inBuffer data processing.In order to prevent in the packet process of transmitting, the next packet that is stored in inBuffer is covered, application layer is according to the agreement of calling, the data encapsulation that produces is arrived the invocation protocol header length of outBuffer and the position of the basic header length of IPv6, be delivered to protocol processes function and the IPv6 agreement called and carry out protocol encapsulation, buflen identifies the length of whole protocol stack data.At last, outBuffer as adaptation layer load, is entered into IEEE802.15.4 medium access control layer (MAC) and physical layer (PHY) and finishes Frame encapsulation and send.
2.IPv6 sensing Routing Protocol;
The present invention proposes a kind of Routing Protocol MSRP (Micro Sensor RouterProtocol) that is applicable to sensor network.The multi-hop route can be set up and safeguard to the proposition of MSRP based on the design philosophy of AODV between the IEEE802.15.4 node in wireless sensor network.The MSRP Routing Protocol is operated on the adaptation layer, in order to reduce the size of storage item and transmission and reception message, MSRP uses 64 bit interface identifier of IEEE802.15.4 definition, rather than routing procedure is carried out in the IPv6 address, the IPv6 address is determined by 64 bit interface identifier of unique IEEE802.15.4 definition according to the address mapping ruler.Therefore the miniature protocol stack of IPv6 can carry out transfer of data according to the route that MSRP sets up.The sensor network Routing Protocol mainly comprises summary of the invention:
2.1 sensing routing protocol packet form;
In order to reduce the consumption of sensor node energy, it is crucial that effective routing protocol packet form is simplified in design.The characteristics of combined sensor network of the present invention, the type of message of MSRP Routing Protocol of design comprises three kinds of RREQSN, RREPSN and RERRSN, the size of type of message is respectively 8 bytes, 7 bytes and 1+2n byte (n is the numerical value of " unreachable address number "), thereby reduce the packet size that sends when setting up route, reduce the energy loss of sensor node when sending packet.Type of message is respectively:
RREQSN: route requests message;
Table 1 RREQSN message format
Type: 000, expression RREQSN type of message;
Jumping figure: the jumping figure from the source node to the present node that the RREQSN message carries;
Route requests ID: unique identification RREQSN message;
Source address: 64 bit interface identifier of the IEEE802.15.4 definition of certain RFD node of initiation RREQSN node or this node;
64 bit interface identifier of the purpose IEEE802.15.4 definition of destination node: RREQSN request route;
Minimum LQI: message carries the link quality metric value minimum value from the RREQSN source node to present node;
RREPSN: route response message;
Table 2 RREPSN message format
Type: 001, expression RREPSN type of message;
Jumping figure: the jumping figure from the source node to the present node that the RREPSN message carries;
Source address: 64 bit interface identifier of the IEEE802.15.4 definition of certain RFD node of initiation RREPSN node or this node;
Destination node: 64 bit interface identifier of initiating the IEEE802.15.4 definition of node corresponding to RREQSN;
Minimum LQI: message carries the minimum value of the link quality metric value from the RREPSN source node to present node;
RERRSN: routing error message;
Table 3 RERRSN message format
Type: 010, expression RERRSN type of message;
The number of unreachable address: the number of the inefficacy neighbor node of certain node detection;
Unreachable destination location: 64 bit interface identifier of the IEEE802.15.4 definition of the inefficacy neighbor node of certain node detection (number of the number decision unreachable destination location of unreachable address, in order to meet the IEEE802.15.4 standard, the size of an IEEE802.15.4 packet is no more than 128 bytes, and the unreachable destination location number that RERRSN carries at most can not be above 4);
2.2 two list item sensing routing mechanisms;
Under the sensor network specific environment, Routing Protocol will be avoided the generation of loop, reduce the transmission of invalid packets, and effectively write down route, adapt to the dynamic change of network topology structure, improve the efficient of transmission of messages, so MSRP need safeguard a kind of oral thermometer of going into, and the routing table form of safeguarding is changed accordingly;
Go into oral thermometer:
Table 4 inlet list item form
RREQSN source address (8 byte) | RREQSN ID (2 byte) | Life span (1 byte) |
RREQSN source address: 64 bit interface identifier of the IEEE802.15.4 definition of certain RFD node of initiation RREQSN node or this node;
RREQSN ID: the sign of this RREQSN type of message;
Life span: this goes into the life span of oral thermometer list item;
Routing table:
Table 5 route table items form
Type: two kinds of device types that are used to distinguish the IEEE802.15.4 standard definition: global function node device (FFD) and partial function node device (RFD).FFD is 0, and RFD is 1.
PAN ID:PAN (individual territory net) identifier;
Jumping figure restriction: the jumping figure of this route;
Life span: the life span of this routing table list item;
Route LQI value: the LQI value of the minimum of this route;
The interface identifier of destination address: 64 bit interface identifier of the IEEE802.15.4 definition of this route final address;
Next hop address interface identifier: 64 bit interface identifier of the IEEE802.15.4 definition of the next hop address of this route place present node;
Forerunner's node address identifier: last one of this route place present node is jumped 64 bit interface identifier (more than one of possibility is used to send the RERRSN advertising of route) of the IEEE802.15.4 definition of address;
2.3 sensing path by routing and decision process;
The MSRP Routing Protocol is the Routing Protocol of driving as required truly, is a kind of routing algorithm of route of just searching when needing to send data.In this Routing Protocol, node does not need to safeguard routing iinformation promptly and accurately, and when when destination node sends message, source node is just initiated the route querying process in network, find corresponding route.It is little to drive routing protocol overhead so as required, the energy-conservation requirement of coincidence senser network node.
IEEE802.15.4 defines two kinds of device types, RFD and FFD, and RFD can only communicate with the FFD that it adds network, and FFD can communicate with neighbours' FFD, so just reaches into two kinds of topological structures: star structure and fully connected topology, as Fig. 8.
In order to be applicable to this mixed topological structure and equipment characteristic, the present invention designs a kind of route and distinguishes mechanism, promptly for RFD equipment, only keep a single-hop adds the FFD of network to RFD default route, when RFD sends data, directly data are sent to its default route FFD, carry out route querying and transfer of data, thereby may preserve the energy of RFD equipment to the greatest extent greatly by this FFD.Therefore RFD does not carry out the configuration of MSRP Routing Protocol, reduces the RFD memory requirement.For FFD equipment, the route below carrying out is set up process.
(1) send RREQSN:
In sensor network, when FFD node device sends data or receives RFD when being forwarded to the data of other destination node, at first search local routing table, if being found to the route of destination address does not exist, then the buffer memory current data packet is carried out the MSRP route and is set up process---and encapsulation RREQSN message, carry out broadcast transmission RREQSN message.
(2) intermediate node receives RREQSN:
As shown in Figure 9, the node that at first receives the RREQSN message judges whether RREQSN message destination address is own or the RFD neighbours of oneself, if not, inquire about the oral thermometer of going into of oneself so, if there has been the inlet list item, this shows and receives identical ID number the RREQSN message that this RREQSN source address sends, and for the energy loss that reduces sensor network nodes and the obstruction that floods of broadcast packet, this node is abandoned this RREQSN message; If there is not this inlet item, then carry out arriving in the table of query and routing route of RREQSN source address, if there has been this route, compare these two routes so, select best route to store, revise the RREQSN message information simultaneously, if there is no this route is then set up a reverse route to the RREQSN source address; Then in the table of query and routing in the RREQSN message route of destination address, if there has been this route,, otherwise continue broadcasting RREQSN message so to this route clean culture RREQSN message.
(3) destination node receives RREQSN and sends RREPSN:
If whether node is judged RREQSN message destination address is own or the RFD neighbours of oneself, this node enters the RREPSN message process that sends so:
Nodal cache RREQSN message message at first, because broadcasting RREQSN pathfinding process, node receives the message message that many routes send, so need to wait for reasonable time T, judge the quality of multirouting, the present invention constructed an optimum route discriminant function f (x, y):
Wherein x is the jumping figure that source node arrives destination node, and y is among the LQI of each jumping of route from the source node to the destination node, minimum LQI value.N is the undetermined parameter under the different network environments, and span is 2~4.Under the outdoor network environment of opening, getting the n value is 2.
Destination node is that the RREQSN of each arrival and the route (if existing in the routing table) of present node arrival RREQSN source node are calculated its f value, jumping figure x value is more little and link quality values is big more, then the f value is high more, selects the maximum route of f value to reply.
The present invention is based on destination node and judge optimum routing policy, select an optimum route to carry out clean culture RREPSN message, rather than every RREQSN route requests responded, than judging optimum route by intermediate node and RREQSN source node, reduce the data traffic in the sensor network more, reduce the energy consumption that sends data.
(4) receive RREPSN:
As shown in figure 10, when node receives the RREPSN message, judge that at first the RREPSN destination address is own or RFD neighbours, if then be established to the route table items of RREPSN source address, send data cached in the buffer queue, otherwise set up or be updated to the route table items of RREPSN source address, find RREPSN destination address route, and next hop address is write routing table entry forerunner node address option.Continue clean culture RREPSN message then.
2.4 sensing route maintenance and fault-tolerant processing process;
The MSRP Routing Protocol that the present invention proposes does not adopt traditional AODV agreement hello packet to safeguard, but judge the neighbor node reliability according to the ack msg frame of IEEE802.15.4 standard code, if send the ACK frame that data do not receive that in the regular hour neighbor node is confirmed to neighbor node, retransmit after these data if still do not receive the ACK frame that this neighbor node is confirmed, show that this neighbor node lost efficacy, current data of buffer memory then, again carry out route requests, the forerunner's node to this route sends the RERRSN message simultaneously.The benefit of doing like this is to save the energy consumption that sends and receive Hello message on the one hand, and sensor node is not very high to delay requirement on the other hand, safeguards more effective to route as driving Routing Protocol as required when data send.
When detecting certain neighbor node, sensor node lost efficacy, at first search routing table with the route table items of this neighbor node for next jumping, take out forerunner's node address, encapsulation RERRSN message, to these forerunner's node clean cultures RERRSN message, delete then in the routing table with the route table items of this neighbor node for next jumping and final address.Forerunner's node receives the RERRSN message, handles this unreachable address equally in routing table, continues to search forerunner's node simultaneously and sends the RERRSN message, and all notified these node addresss of forerunner's node all in this route lost efficacy.
Embodiment 3: following is technical solution of the present invention giving an example in concrete the application, as shown in figure 11.
Sensor network disposition is made up of a large amount of temperature sensors, humidity sensor, light intensity sensor and firing equipment, light intensity equipment and sprinkler in extensive houseplant garden.Each class transducer all disposes micro sensing routing appliance protocol stack system structure of the present invention, and each kind equipment control section links to each other with the infrared module of transducer.Sensor network is provided with a convergent point as gateway device, carries out exchange message with subscriber's main station.Convergent point can pass through Radio Link, and satellite equipment is delivered in transmission, hands to through the satellite-signal receiver on the server of subscriber's main station, and perhaps convergent point arrives the server of subscriber's main station by wire link through Internet.Subscriber's main station obtains data from server, perhaps sends the operation of order.
Server comprises necessary functional modules such as database, command program, management station's program.Wherein database comprises inner all information of sensor network, for example the data message that obtains of sensor node number, node type, operating state and cycle etc.; Command program comprises sensor node and Equipment Control command history; Management station's program is a snmp management person module.User with authority passes through visit WEB server, the program that operation is relevant, access control sensor network inside indirectly at local computer.Operating procedure is as follows:
(1) node initial condition:
Behind the sensor node deployment, start, be in the order wait state, sensing module and processing module enter dormancy, and the radio receiving transmitting module channel monitoring is partly waited for;
(2) sensor network initialization:
1, the user sends starting command by server, wakes convergent point up;
2, user's invoking server management station program, the short address information of configuration wireless channel parameter, PANID and convergent point;
3, convergent point receives order, and parameter is deposited in the MIB storehouse, starts to allow to add network parameter, serves as coordinator role;
4, the transducer channel monitoring partly scans the sensor node that allows adding, adds the PAN network, obtains short address information, the configuration link-local address, and, carry out work with FFD or RFD according to self node type;
5, after sensor node adds network, start locating module and position.
6, sensor node is applied for the global unicast address network prefix to the coordinator, and the network prefix by the coordinator broadcasts global unicast address disposes overall clean culture IPv6 address after node receives.
7, sensor node sends to server with node configuration parameter and locating information with the form of UDP message bag, and server deposits information in database;
(3) the sensor network course of work
1, the user sends the sensor acquisition order, and collection period is set simultaneously.Server encapsulation UDP/IPV6 packet through convergent point, sends to sensor node;
2, transducer receives the laggard line period image data of acquisition, sets up route, and data message is sent to server with the UDP/IPv6 data packet form;
3, the user changes in terminal real-time monitored Data Dynamic;
4, the domain of walker of user configuration surroundings parameter if the data value of gathering surpasses this scope, is warned at user terminal, and the user regulates according to the then corresponding starting device device of positional information of data.Set environment temperature normal variation scope for example, if the zone 1 real time environment temperature value that transmits is low excessively, then according to regional 1 positional information, the user manually/server initiatively announces this regional sensor node, starts firing equipment by node and carry out dynamic adjustments;
5, because energy consumption and accidental cause cause sensor node to lose efficacy, neighbor node monitors sensor node and lost efficacy, and starts route RERRSN message, notifies this failure node address;
6, the current application data of sensing data source node buffer memory is initiated route requests message RREQSN again, propagates RREQSN message message in the sensor network scope;
7, the sensing data destination node receives the RREQSN message, according to the optimal path discriminant function, selects optimal path to reply route response message RREPSN;
8, the sensing data source node receives the RREPSN message, upgrades routing table, sends the data of buffer queue.