Internet Protocol is the most popular technology on today’s networks. In this video, you’ll learn about the basics of IP, the differences between TCP and UDP, and how port numbers are used to transfer data between devices.
<< Previous Video: Mobile Device Synchronization Next: Common Network Ports>>
TCP/IP is one of the most popular protocols in use today. And in this video, I’ll give you an overview of how IP is used on today’s networks. If you need to move the contents of your house from one place to the other, then you would probably use a moving truck to do that.
It’s a similar idea for moving data from one side of the network to the other. We have a road that’s built, which is our network. It’s an ethernet network or a cable network or a DSL network. And on this network, we put a moving truck. This truck is TCP/IP, or the Internet Protocol for short. We have specifically designed these roads to be able to transport this specific kind of moving truck.
Inside of the moving truck is all of our belongings or our data when we’ve separated this data into UDP data and TCP data. We’ll talk about those two types of data in just a moment.
Inside the boxes, of course, are even more of the things that we own. That’s more of the application data and the information that we’re sending from point A to point B. In reality, we don’t usually have multiple boxes inside of our moving truck. We’re usually on an ethernet network that is sending data using IP, which is using TCP, which has application data inside of that.
If we were to visualize how this would look going across our network, we would have a client on one side sending information to a server on the other side, and it would be sending this information using an ethernet frame. Inside of this ethernet frame is a header at the beginning of the frame and a trailer at the end of the frame. And in the middle is what we call our ethernet payload.
Inside of this ethernet payload is an IP header, which is followed by an IP payload. We can break out our IP payload into perhaps a TCP header, which has its own TCP payload. And ultimately, what’s inside of that TCP payload is application data. For example, HTTP data that’s being sent to a web server.
With this nesting of information, we have ethernet, which has IP. And inside of IP is either TCP or UDP. We call this an encapsulation of protocols as we begin putting one protocol within another within another. This gives us a couple of ways to move data from one side to the other. We can put information into a TCP box, or we can put information into a UDP box. There are different features for the different protocols, depending on the type of application that we’re using.
You might also see this referred to as an OSI layer reference. In the case of TCP and UDP, this operates at OSI layer 4. This idea of being able to put multiple applications inside of different frames and send them all across the network at one time is a concept we call multiplexing, and allows us to perform many different functions simultaneously over the same network connection.
Let’s look at the differences between the TCP protocol and the UDP protocol. Let’s start with TCP. It stands for Transmission Control Protocol. We refer to TCP as a connection-oriented protocol, which means there is a formal process when you start the communication and a formal process when you end the communication.
You can think of this as making a phone call. You type in the numbers on your phone. You hit Send. When someone answers, you say, hello? And then after that point begins the conversation. At the end of the conversation, both sides say goodbye, and you hang up the phone.
It’s similar to how TCP operates. You might also see that TCP is called a reliable form of delivery. We call it reliable, because if any errors occur during that communication, there’s a process for retransmitting that data to make sure that everything gets through the network without any problems.
The way that TCP is able to resend data or slow down or speed things up is that there is an acknowledgment every time data is sent. So if station A is communicating to station B and sending some data, Station B will always respond back that it received the data without any problems. If station A does not receive an acknowledgment, then it assumes that data didn’t get through, and they can resend that data to the other side.
The UDP protocol is the User Datagram Protocol. This is a connection list protocol. There’s no formal call setup. Data simply is sent through the network, and it arrives on the other side without any hellos or goodbyes.
We also consider UDP to be unreliable in its form of delivery. This doesn’t mean that the data has any more or less chance of making it to the other side. It only means that there’s no acknowledgment to the data. So station A will send data down to station B, and station A will never receive an acknowledgment that that data is received. UDP doesn’t provide any acknowledgment.
This doesn’t mean that UDP works any better or worse than TCP. Different applications use different protocols for different reasons. There might be an application that doesn’t need any type of acknowledgment that information was received, so it sends it through the network without any type of receipt that it was received at the other end. Some applications really want to be sure the data gets through, and in those cases, those applications may use TCP so it effectively gets a return receipt of that information being sent through the network.
Now that we’ve looked at the data that we put inside of our TCP box or our UDP box, let’s look at how we get the box from one location to the other. The way that we do that is using IP, the internet protocol. Just as every house on your block has a different street address, every computer on the internet has a different IP address. So we can send information from one IP address to the other, and we know exactly where it’s going.
Once the boxes arrive at the house or the IP address that we’ve sent it to, we need to know which room in the house we’re going to put that box. As the movers are coming in, someone is going to be looking at the box, seeing what’s labeled, and then sending that mover to the correct room of the house.
For example, the boxes may arrive at the house. They may be marked bedroom, living room, kitchen, or bath. And now you know exactly where that box goes inside of that house.
With IP, the process is similar, but instead of using a room name, we use what’s called a port number. This way, we can send information into a server and we know exactly which service on that server needs to receive that data.
For example, a box of data arrives at this house. There’s many different services running inside of that server. And some of the data will go to port 80. Some of the data will go to port 443. Other boxes of data will go to port 123, and other services will provide access over port 25.
Putting these all together then, we have what’s known as an IP socket, which means we have a server’s IP address. We have a protocol such as TCP or UDP, and we have a port number that’s used. The same thing applies on the client side. We can have a client IP address, a protocol, and a client port number. All of these together would be IP version 4 sockets.
To be able to communicate this way, we need to be able to use many different port numbers all at the same time. There are different types of port numbers. One type is a non-ephemeral port. Ephemeral means temporary, so these would be non-temporary ports, or permanent port numbers.
These are usually port numbers that are assigned to an application. This would usually be a port number assigned to an application. Very commonly, these non-ephemeral ports are numbered 0 through 1,023. For example, a web server may be using TCP port 80. That would be a non-ephemeral port associated with that web service on that server.
Just as we’re communicating to the server using the server’s port numbers, the server also has to communicate back to the client using the client’s port numbers. A client is usually choosing a random set of port numbers between 1,024 and 65,535. These port numbers are used only for that session. They are temporary port numbers, or what we call ephemeral ports. And they’re usually chosen at random by the client so that it’s able to send information to the server, and the server would have a way to get that information back to the client.
This means we have a wide range of port numbers that we could use. We could have a TCP port number range between 0 and 65,535. We could also have a UDP range of port numbers between 0 and 65,535.
If we’re communicating to a server then, we’re probably using a non-ephemeral port number, and it’s probably a port number that’s in the range between 0 and 1,023. But you may find that some servers use different port numbers that are outside of that range, and that’s perfectly fine. These numbers are just a way to signify what room that particular data goes to, and there are no hard and fast rules over what port number an application happens to use.
That’s because these port numbers are used for communication. They’re not a security mechanism. We don’t decide on the port number based on any type of security requirement. We’re simply setting the port number so that we know where to send the data.
The one thing that is important about the port number is that the client that you’re using needs to be able to know the port number that’s open on the server. For example, if you’re using a web browser, the web browser expects that the web server is going to be using TCP port 80. If that web server is using any other port, than your browser by default will not be able to communicate to that server, and you would have to specify inside of your browser to use a different port number on that server.
As you can imagine, that becomes more complicated if everybody gets to decide a different number for their web servers. That’s why we’ve centralized on everyone using a well-known TCP port 80 so that everyone’s browser knows exactly how to access all of the other web servers on the internet.
Also keep in mind that TCP port numbers are not the same as UDP port numbers. There could be an application running on a server using TCP 80. There could be another application on that same server that uses UDP 80, and neither of those applications will be communicating with each other.
Here’s a practical view of how this might work. We have a client on one side that has an IP address of 10.0.0.1. We have a server on the other side that has an IP address of 10.0.0.2.
There’s three application communications that are taking place. One is a web server that communicates on TCP port 80 on the server. There’s also a voiceover IP service running on that server that uses UDP port 5,004. And that server also provides an email service on TCP port 143.
If the client needs to communicate to the web server that’s on that service, then it knows it needs to send from 10.0.0.1, the IP address of the client, to 10.0.0.2, the IP address of the server. We also know on the server that our destination port number is going to be TCP 80.
But for this client to be able to communicate to that server, it also needs to randomly choose a port number that it can use to begin the communication. And in this case, the client has chosen TCP port 3,000. When the client sends data to the server, the server knows to send the data back to the client using that port number as the destination as it goes to the other direction.
At the same time, this client could be communicating to that server over voiceover IP using UDP port 5,004. You can see that’s the destination port in that second frame. And you can see that randomly, that client chose UDP port 7,100 to communicate for this particular flow.
And lastly, we can see that the client is also sending email communication to that server, sending it to TCP destination port 143. And the client has chosen the random TCP port number of 4,407 to be able to send that email communication to the server.