We're going to break down TCP/IP in this section. TCP/IP allows communication between clients. IP provides addressing that allows devices to be identified on a network. IP addressing is just like a regular house address. If you were to write a letter you would put a destination address on the envelope which would tell the post office where to send the letter. Using this analogy the address we put on the envelope would be the IP address, the post office itself would be something like the router, and the mail man would be the routing protocol that is getting you to your destination. So where does TCP come in to play in all of this? Well TCP would be like sending certified mail. Sending certified mail means that when the mail is delivered you will be notified, or in other words, you would receive an acknowledgement of receipt when your mail is delivered. This process is a simplified version of what TCP is really, but you get the idea.
TCP operates by taking data from applications, breaking it down into segments and transmitting these segments, it then waits for acknowledgement from the receiver before it begins sending more segments. We know that TCP will send a certain number of segments defined by the window size before an acknowledgement must be received. If any segments are missing or corrupt then TCP will resend them. When TCP encapsulates data it adds a header to the data which contains information on the source port, the destination port, sequence number, ACK number, window size, checksum, and a few other pieces of information.
The source and destination ports are how TCP addresses different programs. Port numbers are used to identify individual programs apart from each other. For example when a host receives website traffic TCP will look at the TCP header and check the destination port field which in this case the port number is 80. This port number tells the host that the traffic is destined for HTTP which is web traffic. Some port numbers for common applications are static like HTTP however some port numbers can be dynamically assigned. When the host receives the traffic if it were to inspect the source port field it would find a dynamically defined port instead of port 80. This occurs in order to assure that the receiver can identify different conversations. Take a look at the following image.
As you can see host 1 is receiving HTTP traffic from both host 2 and host 3. If host 2 and 3 used a source port of 80 TCP would have no way of telling them apart. When host 1 replies to host 2 it will send with a destination port 32436 and a source port of 80. When replying to host 3 host 1 will use destination port 8654 and source port 80. Port numbers simply allow upper layers to keep track of conversations between different hosts. Dynamically defined port numbers must be within the range of 1024-65535. Everything under 1024 is reserved for common applications, these ports are referred to as well known port numbers. The following image displays some of these well known port numbers.
In the previous section, Internetworking Basics, we discussed how UDP was the connectionless unreliable transport layer protocol. If we take a look at the UDP header below we can see that it is a much simpler version of the header than TCP.
As you can see there is a lot less information in the UDP header. There is no sequence or acknowledgment fields that TCP uses for reliable communications. Also you can see UDP lacks a window field which means that it doesn't have any method of flow control.