Designing for IoT—Part III—Internet Usage and Protocols

April 29, 2014 // By Christian Legare, Micrium
In this segment of this 4-part article, I will look at the Internet, its usage by IoT devices, and the existing and new Internet protocols supporting the explosive growth of this new industry.

The previous two articles in this series (here, and here) described the hardware and software required to build an IoT device. These devices (the “Things” in the Internet of Things) are an essential part of an IoT system. There are two more building blocks to complete our system design.

The Internet

The Internet is the sum of all the network equipment used to route IP packets from a source to a destination. The World Wide Web, by comparison, is an application system that runs on the Internet. The Web is a tool built for people to exchange information, and in the last twenty years, we have developed and refined the Web so that ordinary, non-technical people can use the Internet easily and productively. The human interface for the Internet now includes e-mail, search engines, browsers, mobile apps, Facebook and Twitter, and other popular social media.

By comparison, in IoT, the idea is for electronic devices to exchange information over the Internet. But these devices don’t yet have the machine equivalent of browsers and social media to facilitate communication. IoT is also different from the Web because of the speeds, scales, and capabilities that IoT devices require in order to work together. These requirements are far beyond what people need or use. We are at the beginning of the development of these new tools and services, and this is one of the reasons why a definition for IoT is difficult to lock down. Many visions about what it can, or could be, collide.

TCP/IP Protocol Stack

The TCP/IP protocol stack is at the heart of the Internet and the Web. It can be represented using the OSI seven-layer reference model, as illustrated in Figure 1. The top three layers are grouped together, which simplifies the model.

Figure 1 The TCP/IP reference model

The following is a quick description of the important layers from the perspective of embedded system integration:

Physical and Data Link Layers

The most common physical layer protocols used by embedded systems are:

- Ethernet (10, 100, 1G)

- WiFi (802.11b, g, n)

- Serial with PPP (point-to-point protocol)

- GSM 3G, LTE, 4G

Network Layer

This is where the Internet lives. The Internet — short for Inter-Network — is so named because it provides connections between networks, between the physical layers. This is where we find the ubiquitous IP address.

Transport Layer

Above IP, we have TCP and UDP, the two transport protocols. Because TCP is used for most of our human interactions with the Web (e-mail, Web browsing, etc.), it is often believed that TCP should be the only protocol used at the transport layer. TCP provides the notion of a logical connection, acknowledgement of packets transmitted, retransmission of packets lost, flow control, all of which are great things. But for an embedded system, TCP can be overkill. This is why UDP, even if it has long been relegated to network services such as DNS and DHCP, is now finding its place in the domains of sensor acquisition and remote control. If you need some type of management of your data, you can even write your own lightweight protocol on top of UDP and avoid the overhead imposed by TCP.

UDP is also better suited than TCP for real-time data applications such as voice and video. The reason is that TCP’s packet acknowledgement and retransmission features are useless overhead for those applications. If a piece of data (such as a bit of spoken audio) does not arrive at its destination in time, there is no point in retransmitting the packet, as it would arrive out of sequence and would garble the message.

TCP is sometimes preferred to UDP because it provides a persistent connection. So to do the same thing with UDP, you have to implement this feature yourself in a protocol layer above UDP.

When you are deciding how to move data from the Thing’s local network onto an IP network, you have several choices. Because the technologies used are familiar and available from a wide range of sources, you can link the two networks via a gateway, or you can build this functionality into the Thing itself. Many MCUs now have an Ethernet controller on chip, which makes this an easier task.

next: The Protocols...