Publication

Explanations & Tutorials

Messaging Protocols - How Do Machines Talk to Each Other?

A simple, non-technical explanation of messaging protocols.

Calum McClelland
March 17, 2017

Do you know what messaging protocols are?

We’ve all this experience before. You hear a word in a sentence and you understand it just fine. You could even use it in a sentence yourself if you wanted. But then your friend asks you what the words means, and you’re at a total loss.

That’s how I felt about “messaging protocols” until recently.

I work at Leverege, an Internet of Things startup, so I’m often around the engineering team and, despite being non-technical myself, I’ve picked up a decent amount of the language . Although I’ve become familiar with the term “messaging protocol” and even knew the names of some of them like MQTT and XMPP, recently I realized that I didn’t know what “messaging protocol” actually meant!

James Schaefer was kind enough to fill me in, so now I’m sharing what I learned with you all in this most recent installment of our #askIoT series.

It Takes Two to Connect

The whole idea behind the Internet of Things is that machines of all kinds (whether they’re sensors, lights, refrigerators, cars, manufacturing robots, irrigation systems, you name it), are being connected to each other and to the internet at an accelerating pace. Depending on your sources, anywhere from 20–50 billion devices are projected to be connected by 2020.

By its very definition, a connection means that at least two machines are involved and have some way of passing data to one another. While you could certainly connect two machines directly to each other using wires, this would severely limit the distance between them.

Instead, we use wireless connections, the internet, or a combination of both to connect machines to each other across distances.

Connected world
‍Image Credit: Sydney Democracy Network

The Internet, Explained (Quickly)

“A global computer network providing a variety of information and communication facilities, consisting of interconnected networks using standardized communication protocols.”

Computers, routers, and servers are all connected to each other to create networks and these networks are likewise connected to each other, creating the internet as we know it.

When we send information from one computer to another, it isn’t sent in one big chunk and it isn’t sent directly. Instead, the information is broken up into data packets which may travel different routes through the internet to arrive at their destination. Once they’ve arrived, the data packets are reassembled into the original file. Known as packet switching, this method allows each packet to find the most efficient path and is therefore, more efficient overall.

But how do the various routers and servers encountered by the data packet know where to send it next?

Internet Protocol (IP)

If you were going to send a letter to a friend, it would be pretty silly to put your letter in a blank envelope and just hope that it gets to them. Instead, you write the recipient’s address on the envelope, you write your return address on the envelope, you stamp it, and then you put it in the mail.

This shared set of rules, formats, and functions for sending mail allows all of us to use the postal service and send letters to one another. In the same way, messaging protocols are the rules, formats, and functions for messages sent between machines.

Essentially, everyone has agreed on the types of information to include with data packets (i.e. like an address) and the way of formatting that information so everyone can read it.

You’ve probably heard of IP addresses before. An IP address is the unique identifier that every computer has, much like an address in real life. The Internet Protocol (IP) is the most basic level of messaging protocol. Using just 20 bytes of data, it includes things like the destination IP address and the sender IP address, among a few other things.

TCP and UDP Messaging Protocols
‍Image credit: Miriade

There are two types of Internet Protocol traffic and they are User Datagram Protocol (UDP) and Transmission Control Protocol (TCP).

UDP is for fast, efficient transmission but it’s only single direction. UDP sends a bunch of packets out and then it’s done. TCP takes slightly longer, but it’s more reliable because it’s bi-directional. This means that there’s confirmation that the message was received on the other end.

However, there are many other features/benefits that you might want when sending data. UDP and TCP represent the most basic level, but other protocols can be built on top of them because you may have specific needs for your application, which is why…

There Are Hundreds of Messaging Protocols

When it comes to the Internet of Things, there’s such a wide variety of applications and use cases. The great potential of IoT is extremely exciting, but it also means that there’s no one-size-fits-all solution. Different IoT applications require different hardware, software, connectivity, and messaging protocols.

Sometimes you want to send information from a device to a server, in which case you probably want to use Message Query Telemetry Transport (MQTT). MQTT is great for collecting data from large networks of small devices into a single location (e.g. in the cloud) for analysis.

Sometimes you want devices to communicate directly with one another, in which case you probably want to use Data Distribution Service (DDS). DDS has roots in defense and industrial settings, where you need to make complex, real-time decisions. DDS efficiently delivers millions of messages per second to many simultaneous receivers.

And sometimes you have other key requirements for your IoT system that need a different, specialized protocol.

In an effort to stay out of the nitty-gritty and remain high-level, I’ll leave it there. Hopefully this has helped you to understand messaging protocols and how machines communicate, but if you have any additional questions please let me know!

Calum McClelland

Chief Operating Officer

Calum graduated from Brown University with a major in Philosophy. Striving to change himself and the world for the better, Calum values active living, life-long learning, and keeping an open mind.

View Profile

Explore More from the Publication