Things fought · Basics 09- select MQTT agreement or the CoAP

  Previous chapters introduced, MQTT agreement and the CoAP Things are more popular protocols, all of the transmission capacity to do a lot of streamlining, small transmission overhead, in order to adapt to the network environment, the physical network.

  XMPP protocol was also said to be suitable for M2M communications, but it is based on XML, for embedded hardware devices, XML parsing is very difficult and resource-consuming.

  There are well-known HTTP protocol, it is for embedded hardware devices, it should belong to heavyweight, not very appropriate. At present, many things are resource constrained device type, memory space and computing power are limited.

  There are many on the CoAP about MQTT protocol and compare the article network, we are below the level of application scenarios from requirements, analysis how to choose which protocol to use.

  1, the server sends to the data the client (reverse control) timeliness (e.g., by APP control hardware operation)
  because MQTT protocol is still connected, the timeliness relatively good; the CoAP protocol is a connection response type communication, and therefore we can not take the initiative to push, to wait for client access can carry back, timeliness relatively poor.

  2, the device environment of the underlying protocol requirements or restrictions
  MQTT protocol is built on the basis of the TCP protocol, he also has the advantages and disadvantages of the TCP protocol; the CoAP protocol is built on the basis of the UDP protocol, he also has UDP advantages and disadvantages of the agreement.

  3, in a NAT environment, the need to adapt the network
  due to long holding MQTT protocol is connected, there is no problem in the NAT; protocol because the CoAP is no connection, require the use of NAT penetrating means.

  4, for communication or one-to-many to many communications
  message protocol model is due MQTT publish / subscribe style, it is many to many communication; CoAP message model protocol is a request / response type, it is a single on-one communication.

  5, quality of service levels and automatically reconnect retransmission
  because MQTT agreement QoS configuration, quality of service level support and automatic reconnection retransmission mechanism; CoAP itself does not have the need to write their own application layer to this logic.  

  6, the network stability requirements
  MQTT agreement with automatic reconnection retransmission mechanism to solve the problem of instability in the network, it will trigger off network reconnection; CoAP agreement only when the client sends the need to ensure that the network connection is normal, other times without connecting.

  7, impact on power consumption hardware
  MQTT agreement due to stay connected, power consumption is slightly higher than the CoAP.

  above, according to the actual requirements of the project, select reference. If there is anti-control requirements, as we choose MQTT protocol, but if the use of telecommunications NB-IoT, then the transport protocol does not require the hardware to process the server has been integrated in the module, and only the CoAP (for now), ignore this step will select protocol. Our telecom application server and server API communication of things can be. If by the WiFi module, cable broadband, 4G wireless network protocol and the like need to be considered in this step is selected.

  I witnessed most projects require recrimination, so I chose MQTT protocol (such as anti-control is not required, I would preferred the CoAP). This series, we are also to discuss MQTT as the transport protocol, relevant content of the CoAP you can search the network to find out, as we first do not involve this aspect.

  This section finished, be continued ......

Guess you like

Origin www.cnblogs.com/xueweisuoyong/p/11316293.html