Methods for Using Message Queuing Telemetry Transport for Sensor Networks to Support Sleeping Devices
Methods support a sleep mode for an embedded device. Embedded devices like sensors and actuators used in wireless sensor networks have a limited power supply. To conserve energy and thus increase the lifetime of these devices, the devices should be put into a stand-by mode (also called sleep-mode) when they are not used. These methods support the sleep mode at a higher level than the MAC layer, thus avoiding the problems of prior art approaches. Methods are exemplarily described for the case of the message queuing telemetry transport protocol for sensor networks. They can easily be adapted to other protocols.
BACKGROUND OF THE INVENTION
1. Field of the Invention
The present invention generally relates to support of sleeping devices on wireless sensor networks, and more particularly, to methods for using message queuing telemetry transport for sensor networks (MQTT-S) to support sleeping devices.
2. Description of Background
Wireless sensor networks (WSNs) are gaining increased attention because of their potential for enabling novel and attractive solutions in areas such as industrial automation, asset management, environmental monitoring, and transportation. In many of these applications, sensors remain idle for long periods of time if no sensing event occurs. In the context of WSNs, these sensors include transmitters capable of transmitting sensed information using radio frequency (RF) energy. To save as much energy as possible, it would be desirable for sensors to turn off their transmitters and sleep during idle times. Sensors would need to wake up only when they have acquired new information to send.
Message queuing telemetry transport (MQTT) is a published protocol designed for use with simple devices such as sensors and actuators (SAs). MQTT-S is an extension of MQTT to sensor networks. MQTT-S is designed to operate in conjunction with low-cost, low-power SA devices running over bandwidth constrained WSNs such as Zigbee-based networks. Zigbee is an open, global standard for WSNs based on the IEEE 802.15.4 standard. Essentially, Zigbee adds networking, security, and application support functionalities to IEEE 802.15.4, with the aim of providing interoperability between products from different vendors. Zigbee and IEEE 802.15.4 are designed such that implementation on the client side (i.e., the SA side) is comparatively simple relative to implementation on the broker side.
MQTT and MQTT-S support basic end-to-end Quality of Service (QoS). Depending upon how reliably messages should be delivered to their receivers, they distinguish between three QoS levels. QoS level 0 is the simplest level. It offers a best effort delivery service, in which messages are delivered either once, or not at all, to a destination. No retransmission or acknowledgement is defined. Thus, QoS level 0 is appropriate for applications which can tolerate loss of a few messages. QoS level 1 provides a more reliable transport: messages with QoS level 1 are retransmitted until they are acknowledged by a receiver at the destination. Consequently, QoS level 1 messages are certain to arrive, but they may arrive multiple times at the destination because of the retransmissions. The highest QoS level, level 2, ensures not only the reception of messages, but also that they are delivered only once to the destination. It is up to an application to select an appropriate QoS level for its publications and subscriptions. For example, a temperature-monitoring application could decide to use QoS level 0 for the publication of normal and regular measurement reports, but QoS level 1 for transferring alarm messages when the temperature exceeds a certain threshold.
MQTT and MQTT-S are connection-oriented protocols in the sense that they require a client to set up a connection with the broker before the client can exchange publications and subscriptions with the broker. To this end, a CONNECT message is defined which contains a Client ID. The Client ID enables the broker to identify the connected client, and also to ensure that QoS level 1 and level 2 publications are delivered correctly even when the client reconnects after a network failure. The broker supervises the level of activity of the client connection using a keep-alive timer that defines the maximum allowable time interval that may elapse between two messages received from that client. If, during this time interval, the client has no data-related messages to be transmitted, the client has to send a PINGREQ message to the broker which is then acknowledged by the broker. Thus, the keep-alive timer enables the broker to detect a failure of either the client or a network link. A related feature is the support of the so-called Will concept. At connection time, the client may ask the broker to store a Will message together with a Will topic. The broker sends this Will message as a publication to subscribers when the broker loses its connection with the client by the keep-alive timer timing out. Applications could use this feature to detect persistent failures of links and devices.
There is a very important feature that is not supported by the current MQTT/MQTT-S protocol, namely the handling of duty cycles of the client devices. In many sensor applications, the sensor devices are idle for a long time if no sensing event occurs. To save as much energy as possible, it would be desirable for the client devices to enter a sleep mode when they are not used. The clients can wake up and publish data whenever the clients acquire new data. However, existing publish/subscribe protocols do not support sleeping devices. In the context of WSNs, support for sleeping devices has heretofore only been provided at the media access control (MAC) layer. Thus, prior art methods place a device into a sleep-mode state using protocols at a very low level. This causes problems as the upper protocol levels are unaware of these state changes.
It is difficult or impossible to utilize MAC-based sleep control mechanisms in networks where the broker is not connected directly to a wireless network, but instead connected through a gateway or router. Although a router could be used to buffer messages until a client device wakes up, the sleeping time could be quite long, on the order of several minutes to several hours. Since the router may serve a large number of clients, the number of messages to be buffered could easily exceed the storage capacity of the router. Moreover, as mentioned previously, in the case of QoS levels 1 and 2, the broker or gateway needs to receive an acknowledgment from the client to be sure that the client has correctly received a published message. It would not be possible to support QoS levels 1 and 2 if the published messages were to be stored for a long time at a router. In view of the foregoing shortcomings, what is needed is an improved technique for supporting sleeping devices on a WSN.
SUMMARY OF THE INVENTION
Methods for using message queuing telemetry transport for sensor networks (MQTT-S) to support a sleeping client device on a wireless sensor network operatively coupled to a broker through a gateway, the methods comprising the broker receiving a CONNECT message from the client device, the CONNECT message specifying a client identifier and a keep-alive duration; monitoring the client device using a keep-alive timer set to the keep-alive duration wherein, if the broker does not receive a message from the client device for a period longer than the keep-alive duration, the broker associates the client device with a lost status and activates a will feature for that client device; the broker receiving a DISCONNECT message from the client device, the DISCONNECT message specifying a sleep duration; the broker acknowledging receipt of the DISCONNECT message to the client device; the broker associating the client device with an asleep status wherein, if the broker does not receive any message from the client device for a period longer than the sleep duration, the broker associates the client device with a lost status and activates the will feature and wherein, during the asleep status, the broker stores any messages for the client device as buffered messages; the broker receiving a PINGREQ message from the client device, the PINGREQ message specifying the client identifier, and in response to receipt of the PINGREQ message, associating the client device with an awake status; wherein, if the broker has no buffered messages for the client, the broker sends a PINGRESP message to the client device and associates the client device with the asleep status; wherein, if the broker has one or more buffered messages for the client device, the broker sends the one or more buffered messages to the client device upon receipt of the PINGREQ message by the broker; and wherein, after the one or more buffered messages are sent to the client device, the broker sends a PINGRESP message to the client device and associates the client device with the asleep status.
DETAILED DESCRIPTION OF THE INVENTION
FIG. 1 is a block diagram setting forth an illustrative wireless sensor network (WSN) for use with the methods of the present invention. A traditional network 100, such as a local area network (LAN), wide area network (WAN), Ethernet, or wireless network, includes a broker 130 to which a plurality of applications 121, 122, 123 are connected. The broker 130 is operatively coupled to a first WSN 101 via a first gateway 140. The broker130 is operatively coupled to a second WSN 102 via a second gateway 150. The first WSN 101 includes a plurality of sensors 181, 182, 183, 184,185 operatively coupled to the first gateway 140 over one or more wireless links. First WSN 101 also includes an actuator 161. The sensors 181,182, 183, 184, 185 and the actuator 161 each represent client devices. Similarly, the second WSN 102 includes a plurality of sensors 171, 172,173, 174, 175 operatively coupled to the second gateway 150 over one or more wireless links. The second WSN 102 also includes an actuator 162. The sensors 171, 172, 173, 174, 175 and the actuator 162 each represent client devices.
Due to the fact that the broker 130 is not connected directly to the first WSN 101 or the second WSN 102, prior art techniques for supporting sleeping devices cannot be used. If the first and second WSNs 101, 102 were based upon the IEEE 802.15.4 or Zigbee standard, the first gateway140 or the second gateway 150 could be used to buffer messages until a client device to which the message is directed wakes up. However, as the sleeping times of client devices could be very large (on the order of several minutes to several hours) and a gateway 140, 150 may serve a large number of clients, problems will result. As time goes by, the number of messages to be stored may exceed the capacity of the gateway 140, 150. Moreover, as mentioned previously, QoS levels 1 and 2 require the gateway 140, 150 or the broker 130 to receive an acknowledgment from the client device to be sure that the client has correctly received the published message. It would not be possible to support QoS levels 1 and 2 if the published messages were to be stored for a long time on the gateway 140, 150. Accordingly, pursuant to an illustrative embodiment disclosed herein, at least one of the gateway 140, the gateway 150, or the broker 130 are made aware of one or more sleeping times of a client device, and to store messages for the client device during the one or more sleeping times.
FIG. 2 illustrates an exemplary message flow between a client 201 and a gateway/broker 203 for implementing the methods of the present invention, and FIG. 6 is a state diagram describing the manner in which a broker sees the state of a client. Client 201 may represent any of sensors 171, 172,173, 174, 175, 181, 182, 183, 184, 185, or actuators 161, 162 (FIG. 1). Likewise, gateway/broker 203 (FIG. 2) may represent any of the broker 130, the first gateway 140, or the second gateway 150 (FIG. 1). From the perspective of the gateway/broker 203 (FIG. 2), a client 201 may be in one of the following states: client active 205 (FIGS. 2 and 6), client asleep 207, client awake 209, client lost 211, or client disconnected 213. A client 201 is in the active 205 state when the gateway/broker 203 receives a first message from that client 201, illustratively in the form of a CONNECT 215message. As with the current MQTT/MQTT-S protocol specification, the active 205 state is supervised by the gateway/broker 203 using a keep-alive timer, also referred to as a sleep timer. If the gateway/broker 203 does not receive any message from the client 201 for a period longer than a keep-alive time duration determined by the keep-alive timer (as indicated in the CONNECT 215 message), the gateway/broker 203 will consider that client 201 as being in the client lost 211 state and, for example, activates the will feature for that client 201.
A client 201 goes to the client disconnected 213 state when the gateway/broker 203 receives a second message from that client 201, illustratively in the form of a DISCONNECT 217 message without a sleep duration indication. The disconnected 213 state is not time-supervised by the gateway/broker 203. If a client 201 wants to sleep, the client 201 sends a DISCONNECT 217 message which contains a sleep duration. The gateway/broker 203 acknowledges that message with a DISCONNECT 217 message and considers the client 201 for being in the asleep 207 state. The asleep 207 state is supervised by the gateway/broker 203 with the aforementioned sleep duration. If the gateway/broker 203 does not receive any message from the client 201 for a period longer than the sleep duration, the gateway/broker 203 will consider that client 201 as being in the lost211 state. Accordingly, as with the keep-alive procedure discussed previously, the gateway/broker 203 may activate the will feature for the lost client 201. During the asleep 207 state, all messages that need to be sent to the client are buffered at the broker/gateway.
The time "tolerance" of the sleep supervision at the gateway/broker 203 depends upon the value of the sleep duration. For example, the current MQTT implementation has a tolerance of 10% of the time for durations larger than one minute, and 50% if less.
The keep-alive timer is restarted when the gateway/broker 203 receives a third message, such as a PINGREQ 219 message, from the client 201. Like the CONNECT 215 message, the PINGREQ 219 message contains a client identifier (i.e., a client ID) identifying the client 201. The client 201is then in the awake 209 state. If the gateway/broker 203 does not have any messages buffered for the client 201, the gateway/broker 203 answers the PINGREQ 219 message with a fourth message, such as a PINGRESP 221 message, and returns the client 201 to the asleep 207 state. If the gateway/broker 203 has one or more messages for the client 201, then the broker/gateway 203 sends these one or more messages to the client201 when the gateway/broker 203 receives the PINGREQ 219 message. The transfer of messages is closed by the gateway/broker 203 by means of the PINGRESP 221 message. In other words, the gateway/broker 203 will consider the client 201 as being in the asleep 207 state after having sent the PINGRESP 221 message.
After having sent the PINGREQ 219 message to the gateway/broker 203, the client 201 uses a Tretry timer to supervise the arrival of messages sent by the gateway/broker 203. Essentially, the client 201 starts the Tretry timer when the client 201 receives any message other than a PINGRESP 221message, and stops the Tretry timer when it receives the PINGRESP 221 message. The PINGREQ 219 message is retransmitted and the Tretry timer is started when the Tretry timer times out. To avoid unnecessary current drain in situations where the client 201 is powered by a battery, the client201 may limit the retransmission of the PINGREQ 219 message. One illustrative method for limiting retransmission of the PINGREQ 219 message is by using a retry counter that initiates putting the client 201 back to sleep when a retry limit count of the retry counter is reached and the client still does not receive the PINGRESP 221 message.
From the asleep 207 state or the awake 209 state, a client 201 can return either to the active 205 state by sending a CONNECT 215 message, or to the disconnected 213 state by sending a DISCONNECT 217 message with no duration field included. The client 201 can also modify its sleep duration by sending a DISCONNECT 217 message with a duration field that specifies a new value of the sleep duration.
FIG. 3 describes the meanings of several symbols used in the flowchart of FIGS. 4-5. A first symbol 10 is used to represent a program state. A second symbol 20 is used to represent internal processing. A third symbol 30 is used to represent a timeout or an internal event. A fourth symbol 40is used to represent a sending of a message. A fifth symbol 50 is used to represent a receiving of a message. A sixth symbol 60 is used to represent a decision.
FIGS. 4-5 together comprise a flowchart setting forth an illustrative operational sequence performed by a sleeping client 201 (FIG. 2) where the client first connects to a broker (such as gateway/broker 203) and then initiates a sleep state. Essentially, FIGS. 4-5 depict a state diagram for the client 201 (FIG. 2) in the context of the sleeping methodology previously described with reference to FIGS. 2 and 6. While in the sleep state, the client interacts periodically with the broker to tell the broker that the client is still available, and possibly to receive updates from the broker.
Referring to block 401 of FIG. 4, the client first connects to a gateway/broker 203 (FIG. 2), waits to receive an acknowledgment of the connection from the gateway/broker (FIG. 4, block 403), and either times out (block 407) while waiting for the acknowledgment, or receives the acknowledgment (block 405). If the time out occurs (block 407), a decision is made at block 409 to either try again by looping back to block 401, or to not try again by advancing ahead to block 423 where the gateway/broker is considered to be lost.
If the acknowledgment is received (block 405), the procedure advances to block 411 where the client goes into the active state. The client sends a DISCONNECT message that includes a sleep duration to the broker (block 413). The procedure temporarily remains in a wait DISCONNECT state (block 415), and either times out (block 419) or receives a DISCONNECT message (block 417). If the time out occurs (block 419), a decision is made at block 421 to either try again by looping back to block 413, or to not try again by advancing ahead to block 423 where the gateway/broker is considered to be lost. If the DISCONNECT message is received (block 417), the client enters the asleep state, also referred to as "sleeping mode" (block 425).
Referring now to block 501 (FIG. 5), the client enters the asleep state (i.e., sleep mode). At block 503, a transponder or transceiver (i.e., a radio) of the client is turned off. The client sleeps at block 505. A timeout occurs at block 507. The radio is turned on at block 509. A PINGREQ message is sent at block 511. At block 513, the client waits for a PINGRESP message. A timeout may occur (block 517), or a PINGRESP message may be received by the client (block 519), or another message may be received by the client (block 521). If the time out occurs (block 517), a decision is made at block 523 to either try again by looping back to block 511, or to not try again by advancing ahead to block 527 where the gateway/broker is considered to be lost. If the PINGRESP message is received (block 519), the procedure loops back to block 501. If another message is received by the client (block 521), then the client deals with this message (block 525), and the procedure loops back to block 513.
The procedures described with reference to FIGS. 2-6 permit one or more clients (such as client 201) to be easily implemented by low cost sensor devices. These procedures release gateways 140, 150 (FIG. 1), which are illustratively implemented using wireless routers, from buffering messages for the sleeping devices, thus allowing the routers to serve large numbers of sensor devices which may have relatively lengthy sleeping periods. The gateway/broker 203 (FIG. 2) is able to detect the loss of a client device (e.g., a persistent failure) not only while the client device is actively communicating, but also while the client device is sleeping.
SRC=http://www.freepatentsonline.com/y2009/0172117.html
Methods for Using Message Queuing Telemetry Transport for Sensor Networks to Support Sleeping Devices的更多相关文章
- Message Queuing(MSMQ)
一.前言 MicroSoft Message Queuing(微软消息队列)是在多个不同的应用之间实现相互通信的一种异步传输模式,相互通信的应用可以分布于同一台机器上,也可以分布于相连的网络空间中的任 ...
- Advanced Message Queuing Protocol ( 1 ) 概述
The Advanced Message Queuing Protocol (AMQP)是一个标准开放的应用层的消息中间件(Message Oriented Middleware)协议.AMQP定义了 ...
- AMQP(Advanced Message Queuing Protocol)
一套确定的消息交换功能,也就是“高级消息交换协议模型”.AMQP模型包括一套用于路由和存储消息的功能模块,以及一套在这些模块之间交换消息的规则. 一个网络线级协议(数据传输格式),客户端应用可以通过这 ...
- Index
我主要在研究.NET/C# 实现 PC IMERP 和 Android IMERP ,目的在解决企业通信中遇到的各类自动化问题 分布式缓存框架: Microsoft Velocity:微软自家分布 ...
- Mosquitto搭建Android推送服务(一)MQTT简介
总体概要: MQTT系列文章分为4部分 1.MQTT简介 2.mosquitto服务器搭建 3.编写Mosquitto的可视化工具 4.使用Mosquitto完成Android推送服务 文章钢要: 对 ...
- TCP/IP, WebSocket 和 MQTT
按照OSI网络分层模型,IP是网络层协议,TCP是传输层协议,而HTTP和MQTT是应用层的协议.在这三者之间, TCP是HTTP和MQTT底层的协议.大家对HTTP很熟悉,这里简要介绍下MQTT.M ...
- GitHub上整理的一些工具
技术站点 Hacker News:非常棒的针对编程的链接聚合网站 Programming reddit:同上 MSDN:微软相关的官方技术集中地,主要是文档类 infoq:企业级应用,关注软件开发领域 ...
- GitHub上整理的一些工具[转载]
Source:http://segmentfault.com/q/1010000002404545 技术站点 Hacker News:非常棒的针对编程的链接聚合网站 Programming reddi ...
- MQTT for UWP
老规矩,先简单介绍下MQTT: MQTT(Message Queuing Telemetry Transport,消息队列遥测传输)是IBM开发的一个即时通讯协议,有可能成为物联网的重要组成部分.该协 ...
随机推荐
- python课程:python3的数字与字符串
一下是基于python2的教程的 python中有 多个数据类型,和,两种字符串类型 他们都是不可变的.
- 芯片TPS76030、TPS76032、TPS76033、TPS76038、TPS76050 电源芯片
下图是从网上摘出来的图片:TPS76033 它的作用就是改变电压: 输入电压:3.5V到16V 通过芯片的处理后 输出电压:3.3V 要学会看图,从中提取有用的信息 再看一个数据手 ...
- Perl——正则表达式(四) 查找替换s///
转自http://blog.csdn.net/blog_abel/article/details/40589227 侵删 一. 介绍 使用 s/regex/replacement/modifiers ...
- 51NOD——N 1107 斜率小于0的连线数量
https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1107 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 ...
- [Angular] Setup automated deployment with Angular, Travis and Firebase
Automate all the things!! Automation is crucial for increasing the quality and productivity. In this ...
- swift 利用 Reflect(字典转模型)
1. 导入Reflect(字典转模型)框架 2. 让它继承Reflect这个类,如下代码所示: class IWUser: Reflect { /** * 用户的ID */ var idstr:N ...
- layer iframe 之间传值和关闭iframe弹窗
1.访问父页面元素值 var parentId=parent.$("#id").val();//访问父页面元素值 2.访问父页面方法 var parentMethodValue=p ...
- Gcc 的使用
Gcc 的使用前言 编译器在编译过程中,先将程序代码编译成 object 文件,然後再和程序库联结,成为可执行文件.因此一个编译器须提供的参数主要有几类: 1.指定编译器编出的object 文件或 ...
- 【35.43%】【hdu 4347】The Closest M Points
Time Limit: 16000/8000 MS (Java/Others) Memory Limit: 98304/98304 K (Java/Others) Total Submissio ...
- ArcEngine数据编辑--选择要素
转自原文ArcEngine数据编辑--选择要素 好久没有写博文了,这段时间相对空闲一点,把AE数据编辑实现总结下. 要编辑要素,首先要选中要素,按shift键进行多选,按esc键清空选择. 个人了解的 ...