What is the transmission control protocol?
The Transmission Control Protocol (TCP) and the Internet Protocol (IP) provide a standard way of moving files over the Internet, such as in the form of messages that contain a request for delivery of data followed by the location of the data on a remote machine. Although it's become more or less a universal protocol nowadays, the TCP/IP architecture had actually been created for the purpose of making sure that all the different machines talking to each other would use the same rules.
While it's easy to think that the TCP/IP design ensures that your files move in an ordered fashion - they are sent by the sender, they are received and acknowledged by the recipient - this is not quite the case. The real purpose of the design was to ensure that data would be received by an intended recipient in the same order that it was sent by the sender.
If you receive a sequence number 100 times from two different places that happen to have different IP addresses, but those two messages have the same sequence number, you can be sure that the data came from a machine that has a particular address, say 192.168.1 and also that your machine has a 192.1 IP address, and so the packets have moved into your file system in order from the first to the last.
However, if the destination machine can only send back to you those message with a certain sequence number, there are no guarantees that your machine will receive all the 100 packages in the order they arrived at the destination. The machine may get stuck waiting for a 100-01 package. Or maybe it receives a packet for a 100-16 packet first, then 100-19, then 100-36 and 100-45, and finally gets 100-48. How do you ensure that they arrive in the proper order? The solution is for the data sender to inform the data receiver of the number of messages that have been sent so far, then the machine is able to keep track of the total.
TCP/IP defines three different states: connection, synchronisation and final delivery. For example, if you log in to your web browser and download your favourite news stories, the file-transfer protocol used by the browser is responsible for setting up the socket connection and initialising the TCP connection, and then sending back the 100-48 data file once it is ready to go.
How does the TCP protocol work?
The TCP protocol is a reliable protocol.
That is, it guarantees delivery. If any message is dropped along the way (ie, lost), the protocol will use the lost data to reconstruct the packet that was dropped and deliver that message to the receiver. If the receiver does not have all the data that was sent, then it will use the partial data to reconstruct the missing data and deliver it. This means that there is no need for ACKs to indicate receipt of a message, because the protocol will try to deliver the message as soon as it can. In this way, the reliability of the protocol is achieved without requiring expensive overhead.
Why use TCP instead of UDP? To understand why TCP is used, we must first understand how it compares to UDP. UDP works in an unreliable fashion. It provides no mechanism for ensuring delivery of a message. In fact, it does not guarantee that it will even send a message to the destination (that's the whole purpose of the protocol). For example, if the UDP message gets corrupted in transit, then the destination may never receive the message.
Because of this, it is always better to use TCP than UDP for reliable messaging. Why does TCP guarantee delivery of messages? TCP uses a three-way handshake to exchange state information between the sender and the receiver. As such, it needs to know where the other end is to tell it how to reach that other end. If the TCP message gets corrupted, then the TCP state machine may crash. This can cause the TCP receiver to never receive the message. But TCP will still honor a successful delivery of the message because it knows that the message was received before the TCP state machine crashed. TCP sends the ACK before the TCP state machine crashes so that the TCP receiver knows to wait for the next message from the TCP sender.
How can TCP determine if it is dropping the message? B: How can the TCP protocol ensure delivery of messages?
Related Answers
What is the CSMA CD and CSMA?
In the following article we will give you an introduction on what is the CSMA...
Why is slotted Aloha more efficient?
The answer is very simple. Aloha means love and good fr...
What is the best MTU setting for PS4?
Ok. I have a Dlink wireless USB card, model number DWL-U122. It work...