Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is TCP/IP a mandatory for MQTT?

Tags:

tcp

mqtt

If so, do you know examples of what can go wrong in a non-TCP network?

Learning about MQTT I came across several mentions of the fact that MQTT relies on TCP/IP stack. For example, from mqtt.org:

MQTT for Sensor Networks is aimed at embedded devices on non-TCP/IP networks, whereas MQTT itself explicitly expects a TCP/IP stack.

But if you read the reference documents, you won't finding anything like that. Moreover, there's QoS field that can be used for reliable delivery and whose values other than 0 are essentially useless in TCP/IP networks. Right now I see nothing that would prevent me from establishing an MQTT connection using UNIX pipe, domain or UDP socket rather than TCP socket.

like image 954
Alexander Solovets Avatar asked Sep 02 '16 06:09

Alexander Solovets


People also ask

Does MQTT use TCP IP?

Built on top of the TCP/IP stack, MQTT (Message Queue Telemetry Transport) has become the standard for IoT communications. MQTT can also run on SSL/TLS, which is a secure protocol built on TCP/IP, to ensure that all data communication between devices are encrypted and secure.

What is the difference between TCP and MQTT?

TCP is at network level and mqtt application layer. So Mqtt rely on tcp to work. With an application layer protocol you can build your business logic and sending message without having the knowledge of network things.. With MQTT the sender knows whether the message was received.


1 Answers

MQTT just needs a delivery that is ordered and reliable, it doesn't have to be TCP. SCTP works just fine, for example, but UDP doesn't because there is no way to guarantee your large PUBLISH packet made up of multiple UDP packets will arrive in order and complete.

With regards TCP reliability, in theory what you are saying is true, but in practice when an application calls write() and receives a successful return, it can't guarantee when the data has actually made it out of the computer to the remote host. All write() (or send()) does is copy the data to the kernel buffers, at which point you have no further control.

The only way to be sure that a message reaches the remote host at the application level is to have the remote host reply.

like image 141
ralight Avatar answered Oct 12 '22 18:10

ralight