Any one starting to learn about computer networking will be faced with learning about the OSI and TCP/IP networking models, and the TCP/IP protocol suite.
In this tutorial we will look at networking protocols, and explain how and why they are structured into layers.
We will then look at the most common protocol suite, the TCP/IP protocol suite and the 4 layer model.
What you will Learn
- What are Protocols and what is a protocol suite
- Why Protocols use a stack model
- The OSI and TCP/IP networking models
- How Protocols work across Networks.
- The TCP/IP protocol layers and the main protocols at each layer.
- Networking equipment and networking levels
What is a Protocol ?
A protocol is a set of rules that govern how systems communicate. For networking they govern how data is transferred from one system to another.
What is a Protocol Suite ?
A protocol suite is a collection of protocols that are designed to work together.
Before TCP/IP became the de-facto standard other protocol suites like IPX and SPX were common (Novell).
It is possible to write a single protocol that takes data from one computer application and sends it to an application on another computer.- A Single stack Protocol
The problem with this approach is that it very inflexible, as any changes require changing the entire application and protocol software.
The approach used in networking is to create layered protocol stacks.
Each level of the stack performs a particular function and communicates with the levels above and below it.
This layered arrangement is not confined to networking, and how it works is probably best understood if you compare it to real life example.
Lets take an example of a parcel service between two offices.
The task is simple – send parcels between people in each office.
We will divide the task into two distinct processes as follows:
- Take a package, wrap it and address it.
- Send it to the destination
at the receiving end
- Receive the package
- Deliver it to the recipient
Typically you would have an internal mail man that:
- Collects the parcels from the senders and takes then to a mail dispatch room.
- The parcels are placed in a van by the dispatcher and then driven to the remote office.
At the remote office
- The parcels are received by the dispatcher and placed into a tray for the mail man
- The mail man collects the parcels and delivers them to the recipients,
Here is a simple diagram to illustrate the process:
The question really is what is the advantage of splitting the task into different layers/tasks?
The answer is that any of the layers/tasks can be changed without affecting the other layers.
So if for example, if we decide to use a train instead of a van to transport the messages between the offices we could do so without affecting the mail man.
In fact the mail man doesn’t know, and doesn’t care, how the parcels are transported between the offices, as all he does is collect them, and pass them to the delivery man.
Although this appears very simple, and maybe trivial, it does illustrate some very important points that are crucial when it comes to understanding networking protocols and how they are organised.
The OSI and TCP/IP Networking Models
All networking courses teach the 7 layer OSI model.
It is important to understand that this model provides for a conceptual framework, and no modern protocols implement this model fully.
The TCP/IP protocol suite uses a 4 layer model.
The diagram shows how the TCP/IP and OSI models compare
This article has a good overview of the OSI protocol layers and their functions
What is important to understand is that the interfaces between the interfaces are well defined so that it is theoretically possible to replace a particular protocol with another one that operates at that level.
For example you should theoretically be able to replace the IP networking protocol with the IPX networking protocol without affecting how the application e.g. POP3 works.
Although this doesn’t always apply the application protocols like SMTP ,POP3 etc will work Okay across different data link protocols like Ethernet,Token ring etc.
End to End Connections- Routers,Switches and OSI
When two computers communicate across a network the data must travel through various items of networking equipment.
You will often hear the terms level 2 and level 3 equipment used. These terms refer to the OSI levels of the protocol stack that the device operates at.
A router for example works at the networking layer and is a level 3 device.
A switch operates at the Ethernet level and is a level 2 device.
Because a router operates at the networking layer it doesn’t need to support the upper layer application protocols like HTTP,FTP etc.
The router works on network address which are part of the networking protocol (IP or IPX).
A router can route many different protocols at the same time, but it doesn’t do protocol conversion.
An IP packet coming in will be an IP packet going out and an IPX packet coming in will be an IPX packet going out.
Likewise a switch doesn’t have level 3,4,5,6 or 7 protocol stacks as it doesn’t need them, and so it doesn’t care about the routing protocol IP,IPX etc or the application FTP,HTTP etc that passes through it.
Because the switch operates at level 2 (data link layer) it only needs to understand the MAC addresses that are part of the Ethernet protocol.
The TCP/IP Protocol Suite
The TCP/IP protocol suite consists of many protocols that operate at one of 4 layers.
The protocol suite is named after two of the most common protocols – TCP (transmission Control Protocol) and IP (internet Protocol).
TCP/IP was designed to be independent of networking Hardware and should run across any connection media.
The earliest use, and the most common use is over Ethernet networks.
Ethernet is a 2 layer protocol/standard covering the physical and data link layer, shown in the diagram above.
HTTP (hypertext transfer protocol) -This is the workhorse of the Web.
SMTP,POP3,IMap4 – These are email protocols
TCP (Transmission control protocol) is a connection orientated protocol and is used to provides a reliable end to end connection.
UDP (used datagram protocol) is connection less protocol and doesn’t guarantee delivery. See UDP vs TCP- what is the Difference?
Applications will choose which transmission protocol to use based on their function. HTTP, POP3, IMAP4, SMTP and many more use TCP.
ARP (address resolution Protocol) -Translates an IP address to a MAC or physical address.(IP4 networks)
TCP vs UDP
You are probably wondering why there are two transport layer protocols- ( TCP and UDP ).
Why don’t we just have one? After all TCP seems to be the best option anyway.
Both TCP and UDP sit at the transport layer of the TCP/IP protocol stack and both use the IP protocol.
Applications are designed to use one or the other protocol depending on their requirements.
TCP- Transmission Control Protocol
TCP is a connection orientated protocol with built in error recovery and re transmission.
You can liken a TCP connection to a telephone connection.
With a telephone connection you first need to setup the connection by dialing the number, and once the calling party answers you have a both way communications channel.
You then proceed to speak and once done you hang up the connection.
With TCP you set up the connection using the 3 way handshake as shown below:
The TCP transport takes care of errors on the link, and the application can be confident that the data received is error free.
TCP is used by applications that need guaranteed message delivery. HTTP,FTP, SMTP, POP3, IMAP4 and many other common Internet application protocols use TCP.
UDP- User Datagram Protocol
UDP is a connectionless protocol. You can liken UDP to email or the normal post.
With email or a written message you send your message, but have no idea whether or not that message was received.
UDP does not correct or recover errors in the message. Any error detection and recovery is the responsibility of the receiving application.
Because there is no connection setup, UDP is faster than TCP and results in less network traffic.
In addition it doesn’t consume resources on the receiving machine as it doesn’t hold a connection open.
Utility applications like DNS, DHCP, RIP and others use UDP.
The use of UDP is expected to increase with IOT as sensor type data is ideal for sending via UDP.
For more details there is a very useful side by side comparison here
Common Questions and Answers
Q- Can I change what protocol my application uses?
A- No the choice of transport protocol is done by the application developer.
Q- Are TCP ports different than UDP ports?
A- Yes a machine can be communicating on UDP port 2000 and TCP port 2000 at the same time.
The TCP/IP protocol suite is a collection of protocols that are used on the Internet.
It is named after two of the main protocols (TCP and IP) and uses a 4 layer networking model.
Related Articles and resources:
- Understanding TCP/IP ports and sockets
- Internet protocol suite-wiki
- The OSI 7 Layer Model
- Basic networking course