How TCP does what it does?

How TCP does what it does?

Understanding the TCP and its operation is difficult considering the depth of the protocol.

The trick lies in understanding the TCP frame structure, sliding window system, data flow control, how connections are identified, and congestion control and avoidance.

Data handling - TCP stream orientation

TCP stream orientation refers to the way data is managed and transmitted over a TCP connection. TCP is a connection-oriented protocol, which means it establishes a connection between the sender and receiver before data is transmitted. It ensures that data is delivered in the same order it was sent and provides mechanisms for error checking and correction. This allows for reliable communication over networks, making it suitable for applications where data consistency and integrity are critical, such as web browsing and email.

TCP accepts application data of any size and structure, without requiring it to be in discrete pieces. More specifically, it is said to treat data coming from an application as a stream; thus, TCP is stream-oriented. Each application sends the data it wishes to transmit as a steady stream of octets (bytes). It doesn't need to carve them into blocks or worry about how lengthy streams will get across the internetwork. It just “pumps bytes” to TCP.

Data packaging - TCP segments

TCP is designed to have applications send data to it as a stream of bytes, rather than requiring fixed-size messages to be used. This provides maximum flexibility for a wide variety of uses, because applications don’t need to worry about data packaging, and can send files or messages of any size. TCP takes care of packaging these bytes into messages called segments.

The TCP layer on a device accumulates data it receives from the application process stream. It forms segments to be transmitted using IP in regular intervals. The size of the segment is controlled by two primary factors. The first issue is that there is an overall limit to the size of a segment, chosen to prevent unnecessary fragmentation at the IP layer. This is governed by a parameter called the maximum segment size (MSS), which is determined during connection establishment. The second is that TCP is designed so that once a connection is set up, each of the devices tells the other how much data it is ready to accept at any given time. If this is lower than the MSS value, a smaller segment must be sent. This is part of the sliding window system which will be a part of another article in this newsletter.

Data identification - TCP sequence number

Since TCP works with individual bytes of data rather than discrete messages, it must use an identification scheme that works at the byte level to implement its data transmission and tracking system. This is accomplished by assigning each byte TCP processes a sequence number.

Since TCP is reliable, it needs to keep track of all the data it receives from an application so it can make sure the same data is received by the destination. It must also make sure the data is received in the order it was sent and must retransmit any lost data.

Each byte/segment of data is assigned a sequence number which is used to keep track of it through the process of transmission, reception and acknowledgment. These sequence numbers are used to ensure that data sent in segments is reassembled into the original stream of data transmitted by the sending application. They are required to implement the sliding window system that enables TCP to provide reliability and data flow control.


NOTE:

An important point to keep in mind here is that the applications send data to TCP as a stream of bytes and not prepackaged messages. Each application must use its own scheme to determine where one application data element ends and the next begins. TCP provides no such mechanism as it treats the incoming data as a stream.


In the next article, I will cover the TCP frame and the meaning of every field in the frame.

要查看或添加评论,请登录

Hilal Saeed的更多文章

  • Overview

    Overview

    TCP has consistently been a subject of perplexity for me. Notably, its extensive nature necessitates continuous…

社区洞察

其他会员也浏览了