Method and system for realizing low power consumption of wireless sensor network based on CoAP protocol

By using the Etag mechanism of the CoAP protocol, changes in wireless sensor network resources are detected, and new content is returned only when resources change, thus solving the problem of high power consumption in wireless sensor networks and realizing low-power wireless sensor networks.

CN121924573APending Publication Date: 2026-04-24CHINA RAILWAY 11TH BUREAU GRP CORP LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511862543.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-11
Publication Date
2026-04-24

AI Technical Summary

Technical Problem

The power consumption problem of existing wireless sensor networks, especially the short battery life of sensor nodes, makes it difficult for existing technologies to effectively reduce the energy consumption of wireless sensor networks.

Method used

Using the CoAP protocol, the client requests resources by carrying an ETag value. The server compares the ETag values ​​to determine if the resource has changed, and only returns new content when the resource has changed; otherwise, it returns empty content, reducing unnecessary polling requests.

Benefits of technology

Significantly reduces the power consumption of wireless sensor networks, extends the battery life of sensor nodes, and reduces unnecessary data transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121924573A_ABST
    Figure CN121924573A_ABST
Patent Text Reader

Abstract

According to the low-power-consumption implementation method of the wireless sensor network based on the CoAP protocol, when the client requests the resource, the first ETag value obtained before can be carried as a part of the request, after the server receives the request, the ETag value of the current resource is compared with the ETag value provided by the client, if the ETag value of the current resource is different from the ETag value provided by the client, it is indicated that the resource is changed, and if the ETag value of the current resource is not changed, it is indicated that the resource is not changed. According to the method, the server returns new resource content and the updated ETag value, if the resource content and the updated ETag value are the same, the resource does not change, the server can return empty content, and the resource cached by the client is still effective, so that the energy consumption of the wireless sensor network can be remarkably reduced by reducing unnecessary polling requests.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of network communication, and in particular to a low-power implementation method and system for wireless sensor networks based on the CoAP protocol. Background Technology

[0002] Wireless Sensor Networks (WSNs) are distributed sensor networks composed of numerous wireless sensor nodes capable of sensing, processing, and transmitting various information from the environment. A typical wireless sensor node consists of a microprocessor, sensors, a communication module, and a power supply. They interconnect and work collaboratively via wireless communication protocols. Sensors in a WSN communicate wirelessly, allowing for flexible network deployment, easy relocation of devices, and wired or wireless connections to the internet. It can form a multi-hop, self-organizing network through wireless communication. Low-power wireless sensor networks (WSNs) consist of a large number of miniature sensor nodes deployed within a monitoring area. These nodes form a multi-hop, self-organizing network system via wireless communication. The sensor nodes in this system are typically battery-powered, and the battery life directly determines the lifespan of the sensor nodes. Therefore, research on the power consumption of wireless sensor networks is of great significance.

[0003] In existing technologies, battery management techniques, such as sleep mechanisms and dynamic power consumption adjustment, are typically used to extend the battery life of sensor network nodes. Since wireless sensor nodes are energy-constrained, in addition to reducing their own power consumption through the use of low-power devices and optimized design, power consumption is further reduced by increasing the signal acquisition cycle. This means that wireless sensor nodes spend most of their time in a low-power sleep state. Summary of the Invention

[0004] To address the shortcomings of existing technologies, the present invention aims to propose a low-power implementation method for wireless sensor networks based on the CoAP protocol, which can effectively reduce the energy consumption of data transmission in wireless sensor networks.

[0005] On the one hand, a low-power implementation method for wireless sensor networks based on the CoAP protocol is provided, including the following steps: Step S1: The client sends a GET request with the Observe option to the server; Step S2: The server records the client address, adds the client to the observer list, and returns the first metadata and the first ETag; Step S3: The sensor metadata is changed, and second metadata is generated; Step S4: The server determines whether the key fields of the second metadata have changed relative to the first metadata; Step S5: When the second metadata changes relative to the first metadata, the server generates a second ETag; otherwise, the server returns a status code indicating that the resource cached by the client is still valid.

[0006] Preferably, in step S4, the key field is the Payload field of the CoAP data packet.

[0007] Preferably, in step S4, the server determines whether the key fields of the second metadata have changed relative to the first metadata, including: the server acquiring the first metadata and the second metadata; the server checking the Content-Format options of the first metadata and the second metadata to confirm the format type of the payload; the server reading the payload content of the first metadata and the second metadata and parsing the data according to the format; and comparing whether the key fields of the first metadata and the second metadata are the same.

[0008] Preferably, in step S4, the server's determination of whether the key fields of the second metadata have changed relative to the first metadata includes: the server acquiring the first metadata and the second metadata; the server checking the Content-Format option of the first metadata and the second metadata to confirm the format type of the payload; the server reading the payload content of the first metadata and the second metadata and parsing the data according to the format; and determining whether the difference between the key fields of the first metadata and the key fields of the second metadata is less than a preset threshold.

[0009] Preferably, the server generating the second Etag includes: the server generating the second Etag by updating the hash value, timestamp, or version number.

[0010] Preferably, after step S5, step S6 is further included: the client sends a Get request with a first Etag to the server.

[0011] Preferably, after step S6, the system further includes step S7, in which the server compares whether the second ETag value is the same as the first ETag value provided by the client.

[0012] Preferably, after step S7, the system further includes step S8: if the second Etag value is different from the first Etag value, the server sends the second metadata and the second Etag to the client; otherwise, the server returns empty content, indicating that the resource has not changed.

[0013] On the other hand, a low-power implementation system for a wireless sensor network based on the CoAP protocol is provided. The system includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the low-power implementation method for a wireless sensor network based on the CoAP protocol as described above.

[0014] This invention provides a low-power implementation method for wireless sensor networks based on the CoAP protocol. When a client requests a resource, it can carry a previously acquired first ETag value as part of the request. After receiving the request, the server compares the current ETag value of the resource with the ETag value provided by the client. If the two are different, it means that the resource has changed, and the server will return the new resource content and the updated ETag value. If the two are the same, it means that the resource has not changed, and the server can return empty content, indicating that the resource cached by the client is still valid. This method can significantly reduce the power consumption of the wireless sensor network by reducing unnecessary polling requests. Attached Figure Description

[0015] Figure 1 A flowchart of a low-power implementation method for a wireless sensor network based on the CoAP protocol provided by the present invention; Figure 2 The data format conforming to the CoAP protocol provided by this invention; Figure 3 This invention provides an implementation method for determining whether the first metadata and the second metadata have changed; Figure 4 This invention provides another implementation for determining whether the first metadata and the second metadata have changed. Figure 5 This is a schematic diagram of the physical structure of the low-power implementation method for wireless sensor networks based on the CoAP protocol provided by the present invention. Detailed Implementation

[0016] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0017] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments according to this application. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.

[0018] Example 1 like Figure 1 As shown, this embodiment provides a low-power implementation method for a wireless sensor network based on the CoAP protocol, which includes: Step S1: The client sends a GET request with the Observe option to the server; Step S2: The server records the client address, adds the client to the observer list, and returns the first metadata and the first ETag; Step S3: The sensor metadata is changed, and second metadata is generated; Step S4: The server determines whether the key fields of the second metadata have changed relative to the first metadata; Step S5: When the second metadata changes relative to the first metadata, the server generates a second ETag; otherwise, the server returns a status code indicating that the resource cached by the client is still valid.

[0019] Step S6: The client sends a GET request with the first ETag to the server.

[0020] Step S7: The server compares the second ETag value with the first ETag value provided by the client.

[0021] Step S8: If the second Etag value is different from the first Etag value, the server sends the second metadata and the second Etag to the client; otherwise, the server returns empty content, indicating that the resource has not changed.

[0022] This invention provides a low-power implementation method for wireless sensor networks based on the CoAP protocol. When a client requests a resource, it can carry a previously acquired first ETag value as part of the request. After receiving the request, the server compares the current ETag value of the resource with the ETag value provided by the client. If the two are different, it means that the resource has changed, and the server will return the new resource content and the updated ETag value. If the two are the same, it means that the resource has not changed, and the server can return empty content, indicating that the resource cached by the client is still valid. This method can significantly reduce the power consumption of the wireless sensor network by reducing unnecessary polling requests.

[0023] like Figure 2 As shown, this embodiment provides a CoAP data structure with a fixed header of four bytes, including metadata such as version, message type (T), tag length (TKL), message code (Code), and message ID.

[0024] Version number (Ver): occupies 2 digits and indicates the version number of the CoAP protocol.

[0025] Message Type (T): 2 bits, indicating the type of message. CoAP supports four message types as follows: CON: A request that requires acknowledgment. If a CON request is sent, the recipient must respond. NON: A request that does not require acknowledgment. If a NON request is sent, the recipient does not need to respond. ACK: An acknowledgment message, a response to receiving a CON message. RST: A reset message, sent when the receiver receives a message containing an error or no longer cares about the content sent by the sender.

[0026] Token Length (TKL): 4 bits, representing the length of the token. A token is an identifier for CoAP messages, used to distinguish different messages.

[0027] Message Code: Occupies 8 bits and indicates the type of request or response. The Code has different representations in CoAP request and response messages, consisting of the first 3 bits and the last 5 bits, and is usually written as a c.dd structure for ease of description. 0.XX indicates a certain method of the CoAP request, while 2.XX, 4.XX, or 5.XX indicates a certain specific behavior of the CoAP response.

[0028] Message ID: A 16-bit unique identifier for each CoAP message. Each CoAP message has a unique ID that remains unchanged throughout a session but is recycled after the session ends.

[0029] A token is another representation of a message ID, and its content has a length specified by a TKL (Trusted Key Letter). Tokens are not required for messages, but can be used to distinguish different sessions or requests.

[0030] Options: CoAP options are similar to HTTP request headers. They contain additional information about the CoAP message, such as the CoAP port number, CoAP host, and CoAP query string. The options section is encoded in TLV (Type-Length-Value) format.

[0031] Payload: The payload is the part that actually stores the sensor data, and its specific format is defined by the Content-Format option. In a CoAP message, the payload follows the options section and is the actual content of the message. The 11111111 bytes preceding the payload are the separator between the CoAP message and the actual payload.

[0032] like Figure 3 As shown, the present invention provides an implementation method for determining whether the first metadata and the second metadata have changed, including the following: the server obtains the first metadata and the second metadata; the server checks the Content-Format option of the first metadata and the second metadata to confirm the format type of the payload; the server reads the payload content of the first metadata and the second metadata and parses the data according to the format; the server compares whether the key fields of the first metadata and the second metadata are the same. Specifically, if the format is application / json: a JSON parser is used to extract fields (such as temp); if the format is text / plain: the string is read directly; if the format is a custom binary format: it is decoded according to the protocol definition. In this embodiment, by only detecting the content of the key field payload, such as the sensor value field, and ignoring changes in irrelevant metadata, network overhead and power consumption of the wireless sensor network can be reduced.

[0033] like Figure 4 As shown, Figure 4 Another implementation of the present invention for determining whether the first metadata and the second metadata have changed includes the following steps: the server determines whether the key fields of the second metadata have changed relative to the first metadata: the server acquires the first metadata and the second metadata; the server checks the Content-Format options of the first metadata and the second metadata to confirm the format type of the payload; the server reads the payload content of the first metadata and the second metadata and parses the data according to the format; and the server determines whether the difference between the key fields of the first metadata and the key fields of the second metadata is less than a preset threshold. This is essentially a threshold filtering strategy that ignores minor changes that do not reach the threshold, such as not triggering an update when the temperature fluctuation collected by the temperature sensor is <0.1°C, thereby reducing detection overhead and power consumption of the wireless sensor network.

[0034] Example 2 Figure 5 A schematic diagram of the physical structure of this embodiment is illustrated, such as... Figure 5As shown, the electronic device may include: a processor 301, a memory 302, a communication interface 303, and a communication bus 304, wherein the processor, communication interface, and memory communicate with each other through the communication bus. The processor can call logical instructions in the memory to execute the energy-saving control method of the present invention. The method includes: a client sending a Get request with observation options to a server; the server recording the client address, adding the client to the observer list, and returning first metadata and a first ETag; when sensor metadata changes, second metadata is generated; the server determines whether the key fields of the second metadata have changed relative to the first metadata; when the second metadata has changed relative to the first metadata, the server generates a second ETag; otherwise, the server returns a status code indicating that the resource cached by the client is still valid. The client sends a Get request with the first ETag to the server. The server compares the second ETag value with the first ETag value provided by the client. If the second ETag value is different from the first ETag value, the server sends the second metadata and the second ETag to the client; otherwise, the server returns empty content, indicating that the resource has not changed.

[0035] In summary, the present invention provides a low-power implementation method for wireless sensor networks based on the CoAP protocol. When a client requests a resource, it can carry the previously acquired first ETag value as part of the request. After receiving the request, the server compares the current ETag value of the resource with the ETag value provided by the client. If the two are different, it means that the resource has changed, and the server will return the new resource content and the updated ETag value. If the two are the same, it means that the resource has not changed, and the server can return empty content, indicating that the resource cached by the client is still valid. This method can significantly reduce the power consumption of the wireless sensor network by reducing unnecessary polling requests.

[0036] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0037] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0038] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to operate in a manner specifically described herein, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0039] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to operate in a manner specifically described herein, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0040] It should be noted that the technical features in the above embodiments can be combined arbitrarily, and the resulting technical solutions all fall within the protection scope of this application. Furthermore, in this document, terms such as "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0041] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A low-power implementation method for wireless sensor networks based on the CoAP protocol, characterized in that, Includes the following steps: Step S1: The client sends a GET request with the Observe option to the server; Step S2: The server records the client address, adds the client to the observer list, and returns the first metadata and the first ETag; Step S3: The sensor metadata is changed, and second metadata is generated; Step S4: The server determines whether the key fields of the second metadata have changed relative to the first metadata; Step S5: When the second metadata changes relative to the first metadata, the server generates a second ETag; otherwise, the server returns a status code indicating that the resource cached by the client is still valid.

2. The low-power implementation method for wireless sensor networks based on the CoAP protocol as described in claim 1, characterized in that, In step S4, the key field is the Payload field of the CoAP data packet.

3. The low-power implementation method for wireless sensor networks based on the CoAP protocol as described in claim 2, characterized in that, In step S4, the server determines whether the key fields of the second metadata have changed relative to the first metadata, including: the server obtains the first metadata and the second metadata; the server checks the Content-Format option of the first metadata and the second metadata to confirm the format type of the payload; the server reads the payload content of the first metadata and the second metadata and parses the data according to the format; and the server compares whether the key fields of the first metadata and the second metadata are the same.

4. The low-power implementation method for wireless sensor networks based on the CoAP protocol as described in claim 2, characterized in that, In step S4, the server determines whether the key fields of the second metadata have changed relative to the first metadata, including: the server obtains the first metadata and the second metadata; the server checks the Content-Format option of the first metadata and the second metadata to confirm the format type of the payload; the server reads the payload content of the first metadata and the second metadata and parses the data according to the format; and determines whether the difference between the key fields of the first metadata and the key fields of the second metadata is less than a preset threshold.

5. The low-power implementation method for wireless sensor networks based on the CoAP protocol as described in claim 1, characterized in that, The server generates the second Etag by updating the hash value, timestamp, or version number.

6. The low-power implementation method for wireless sensor networks based on the CoAP protocol as described in claim 1, characterized in that, After step S5, step S6 is also included: the client sends a Get request with the first Etag to the server.

7. The low-power implementation method for wireless sensor networks based on the CoAP protocol as described in claim 6, characterized in that, After step S6, the system further includes step S7, where the server compares the second ETag value with the first ETag value provided by the client to see if they are the same.

8. The low-power implementation method for wireless sensor networks based on the CoAP protocol as described in claim 7, characterized in that, After step S7, step S8 is also included: if the second Etag value is different from the first Etag value, the server sends the second metadata and the second Etag to the client; otherwise, the server returns empty content, indicating that the resource has not changed.

9. A low-power implementation system for a wireless sensor network based on the CoAP protocol, the system comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement a low-power implementation method for a wireless sensor network based on the CoAP protocol as described above.