I’ve been doing the An Introduction to Programming the Internet of Things (IOT) specialization on Coursera. One question asks about the difference between TCP and IP. This is my expanded essay based on my answer.
The OSI networking model provides a typology for networking types. We can watch a video on YouTube on a phone or a television, but the hardware is completely different. Your television is, typically, connected via a wire to the network. But your phone is connected through a radio, or more euphemistically, thin air. But the video is the same. And the data carried to each device to show the video is the same, even though there are substantially differences between the cellular network and the high-speed cable network.
The OSI model allows us to distinguish among the different types of connections by breaking these network into different layers, and allowing us to treat the surrounding layers abstractly. For decades, we have used something called TCP/IP, or the Internet protocol suite, to manage connections on the Internet. These protocols have become de facto standards, but the two most prominent components TCP and IP have different roles.
IP, short for Internet Protocol, fits into the OSI in layer 3. The lower layers, 1 and 2, provide physical connection and link, the ability to transfer data from two physically connected nodes. Up a layer, to IP at 3, does something more interesting. It provides a translation layer between logical addresses and physical. It also, importantly, provides routing. Routing is the ability to transfer data between two physical networks. In your house, you might have 3 or 4 computers or tables, and they are all connected to the same physical network (even if wireless). But the router and IP provide the ability to get information from that local physical network to someone else’s physical network, like YouTube’s video servers.
IP, however, has some severe limitations. With IP, data is not guaranteed to arrive. You can send it out into the world, and it may or may not get there. And if you send more than one, there is no guarantee they will arrive in the same order. Finally, it only uses datagrams, little packets of data. You can stuff a bunch of data, up to a limit of 65,535 bytes, into a packet. And that’s not a lot, that’s well under a second of compressed video.
TCP, short for Transmission Control Protocol fits into layer 4. It lives above IP and TCP packets are built using IP packets as the core. Layer 4 is called the transmission layer, and it provides error corrections, flow control, and other niceties. What that means is that TCP provides ordering, and some level of guarantee of delivery. That is, it does not provide a true guarantee, but if data arrives, it will arrive in the correct order and that’s important. A lot of the tools you use every day for sending email, reading web pages, and downloading files use TCP.
The downside to TCP is that it is slow and has a lot of overhead. In order to implement even weak guarantees, TCP has to include a lot of overhead to explain where a packet fits in the sequence and provide a check to ensure the data delivered is correct. But for applications that need these features, it is worth while.
There are other protocols that work with IP and, frankly, TCP can use any datagram protocol for the network layer. A revised IP protocol, called IPv6 provides new services, improved security, and more room for addresses. Over time, this new protocol will become the new standard.
Image of an old ISA NE2000 card by EJSawyer / Wikimedia Commons.