Understanding TCP

This tutorial is going to be talking about the TCP protocol. Every time you connect to a website you are using the HTTP protocol, but below that you are also using a TCP protocol. The nature of TCP is to provide error recovery; there are other services or applications that use TCP. HTTP however is a common protocol that is used in online applications. 

Remember TCP is not the only protocol in the transport layer of the OSI model, there is another called UDP but that’s another day. 🙂 TCP stands for (Transmission Control Protocol) what makes TCP shine is its error recovery, this helps other protocols below not worry about if the packet was dropped because TCP will request that packet again. With all of that overhead in TCP it does require more bandwidth, and processing compared to the UDP protocol. TCP has several fields in the header as pictured below.  The TCP Header Field

Like mentioned TCP has reliability (error recovery) this is made possible by using sequence and acknowledgment numbers (bytes) in the TCP header field. Take the example below the acknowledgment field in the TCP header that was sent by the web browser was 4000, this implies the next byte to be received will have a sequence number of 4000.  TCP SEQ and ACK

Since the sequence and acknowledgment numbers count the number of bytes, this helps with error control if a TCP segment was lost or caused an error the web browser would send an acknowledgment that the web server that would not be expecting and resend any lost data. An example would be if the web browser only received 2000 bytes, the client would send an acknowledgment of 3000 bytes. When the web server received that information it knows that it sent 3000 bytes of data and the acknowledgment field should be 4000. The web server would resend the third segment again and wait of an acknowledgment of 4000.  TCP Drop

Another feature TCP has is called flow control; this uses the window field which determines the maximum amount unacknowledged bytes at a given time. The size starts out small and if no errors occur then the window size increases the number of unacknowledged bytes. This speeds up time needed to download the information. If errors start to occur then the windows size decreases, keep in mind that this field will change often as it will continue try to raise the number of unacknowledged bytes.  TCP Window

TCP is also does a connection establishment and termination. This happens before any data is sent is it will also start the sequence numbers, acknowledgment numbers and agree on the port numbers to use. This three-way handshake happens in beginning and at the end when the data transfer is complete. The flags it uses in the TCP header are “SYN” which means synchronize the sequence numbers. “ACK” which is an acknowledgment field and to terminate or finish the connection it will send a “FIN” bit.

Although this a brief tutorial and how TCP works in gives you an understanding of the main components that are involved in setting up a TCP connection and finishing a connection. Like always I encourage you if you would like more information a web search will do, along with visiting Cisco.com. I hope this tutorial was helpful.

Advertisements

One thought on “Understanding TCP

Comments are closed.