Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Transmission Control Protocol
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Data transfer=== The Transmission Control Protocol differs in several key features compared to the [[User Datagram Protocol]]: * Ordered data transfer: the destination host rearranges segments according to a sequence number<ref name=comer/> * Retransmission of lost packets: any cumulative stream not acknowledged is retransmitted<ref name=comer/> * Error-free data transfer: corrupted packets are treated as lost and are retransmitted{{sfn|RFC 9293|loc=2.2. Key TCP Concepts}} * Flow control: limits the rate a sender transfers data to guarantee reliable delivery. The receiver continually hints the sender on how much data can be received. When the receiving host's buffer fills, the next acknowledgment suspends the transfer and allows the data in the buffer to be processed.<ref name=comer/> * Congestion control: lost packets (presumed due to congestion) trigger a reduction in data delivery rate<ref name=comer/> ====Reliable transmission==== TCP uses a ''sequence number'' to identify each byte of data. The sequence number identifies the order of the bytes sent from each computer so that the data can be reconstructed in order, regardless of any [[out-of-order delivery]] that may occur. The sequence number of the first byte is chosen by the transmitter for the first packet, which is flagged SYN. This number can be arbitrary, and should, in fact, be unpredictable to defend against [[TCP sequence prediction attack]]s. Acknowledgments (ACKs) are sent with a sequence number by the receiver of data to tell the sender that data has been received to the specified byte. ACKs do not imply that the data has been delivered to the application, they merely signify that it is now the receiver's responsibility to deliver the data. Reliability is achieved by the sender detecting lost data and retransmitting it. TCP uses two primary techniques to identify loss. Retransmission timeout (RTO) and duplicate cumulative acknowledgments (DupAcks). When a TCP segment is retransmitted, it retains the same sequence number as the original delivery attempt. This conflation of delivery and logical data ordering means that, when acknowledgment is received after a retransmission, the sender cannot tell whether the original transmission or the retransmission is being acknowledged, the so-called ''retransmission ambiguity''.{{sfn|Karn|Partridge|1991|p=364}} TCP incurs complexity due to retransmission ambiguity.{{sfn|RFC 9002|loc=4.2. Monotonically Increasing Packet Numbers}} =====Duplicate-ACK-based retransmission===== If a single segment (say segment number 100) in a stream is lost, then the receiver cannot acknowledge packets above that segment number (100) because it uses cumulative ACKs. Hence the receiver acknowledges packet 99 again on the receipt of another data packet. This duplicate acknowledgement is used as a signal for packet loss. That is, if the sender receives three duplicate acknowledgments, it retransmits the last unacknowledged packet. A threshold of three is used because the network may reorder segments causing duplicate acknowledgements. This threshold has been demonstrated to avoid spurious retransmissions due to reordering.<ref>{{cite journal|last1=Mathis|last2=Mathew|last3=Semke|last4=Mahdavi|last5=Ott|title=The macroscopic behavior of the TCP congestion avoidance algorithm|journal=ACM SIGCOMM Computer Communication Review|volume=27|issue=3|pages=67β82|year=1997|doi=10.1145/263932.264023|citeseerx=10.1.1.40.7002|s2cid=1894993}}</ref> Some TCP implementations use [[selective acknowledgement]]s (SACKs) to provide explicit feedback about the segments that have been received. This greatly improves TCP's ability to retransmit the right segments. Retransmission ambiguity can cause spurious fast retransmissions and congestion avoidance if there is reordering beyond the duplicate acknowledgment threshold.{{sfn|RFC 3522|p=4}} In the last two decades more packet reordering has been observed over the Internet<ref>{{cite journal |last1=Leung |first1=Ka-cheong |last2=Li |first2=Victor O.k. |last3=Yang |first3=Daiqin |date=2007 |title=An Overview of Packet Reordering in Transmission Control Protocol (TCP): Problems, Solutions, and Challenges |url=https://ieeexplore.ieee.org/document/4118693 |journal=IEEE Transactions on Parallel and Distributed Systems |volume=18 |issue=4 |pages=522β535 |doi=10.1109/TPDS.2007.1011}}</ref> which led TCP implementations, such as the one in the Linux Kernel to adopt heuristic methods to scale the duplicate acknowledgment threshold.<ref>{{cite thesis |last=Johannessen |first=Mads |date=2015 |title=Investigate reordering in Linux TCP |publisher=University of Oslo |url=http://urn.nb.no/URN:NBN:no-51662 |degree=MSc}}</ref> Recently, there have been efforts to completely phase out duplicate-ACK-based fast-retransmissions and replace them with timer based ones.<ref>{{cite conference |url=https://www.ietf.org/proceedings/94/slides/slides-94-tcpm-6.pdf |title=RACK: a time-based fast loss detection for TCP draft-cheng-tcpm-rack-00 |last1=Cheng |first1=Yuchung |date=2015 |publisher=IETF |location=Yokohama |conference=IETF94}}</ref> (Not to be confused with the classic RTO discussed below). The time based loss detection algorithm called Recent Acknowledgment (RACK){{Sfn|RFC 8985}} has been adopted as the default algorithm in Linux and Windows.<ref>{{cite conference |url=https://datatracker.ietf.org/meeting/100/materials/slides-100-tcpm-draft-ietf-tcpm-rack-01.pdf |title=RACK: a time-based fast loss recovery draft-ietf-tcpm-rack-02 |last1=Cheng |first1=Yuchung |last2=Cardwell |first2=Neal |last3=Dukkipati |first3=Nandita |last4=Jha |first4=Priyaranjan |date=2017 |publisher=IETF |location=Yokohama |conference=IETF100}}</ref> =====Timeout-based retransmission===== When a sender transmits a segment, it initializes a timer with a conservative estimate of the arrival time of the acknowledgment. The segment is retransmitted if the timer expires, with a new timeout threshold of twice the previous value, resulting in [[exponential backoff]] behavior. Typically, the initial timer value is {{math|smoothed RTT + max(''G'', 4{{times}}RTT variation)}}, where {{mvar|G}} is the clock granularity.{{sfn|RFC 6298|p=2}} This guards against excessive transmission traffic due to faulty or malicious actors, such as [[man-in-the-middle attack|man-in-the-middle]] [[denial of service attack]]ers. Accurate RTT estimates are important for loss recovery, as it allows a sender to assume an unacknowledged packet to be lost after sufficient time elapses (i.e., determining the RTO time).{{sfn|Zhang|1986|p=399}} Retransmission ambiguity can lead a sender's estimate of RTT to be imprecise.{{sfn|Zhang|1986|p=399}} In an environment with variable RTTs, spurious timeouts can occur:{{sfn|Karn|Partridge|1991|p=365}} if the RTT is under-estimated, then the RTO fires and triggers a needless retransmit and slow-start. After a spurious retransmission, when the acknowledgments for the original transmissions arrive, the sender may believe them to be acknowledging the retransmission and conclude, incorrectly, that segments sent between the original transmission and retransmission have been lost, causing further needless retransmissions to the extent that the link truly becomes congested;{{sfn|Ludwig|Katz|2000|p=31-33}}{{sfn|Gurtov|Ludwig|2003|p=2}} selective acknowledgement can reduce this effect.{{sfn|Gurtov|Floyd|2004|p=1}} {{harvtxt|RFC 6298}} specifies that implementations must not use retransmitted segments when estimating RTT.{{sfn|RFC 6298|p=4}} [[Karn's algorithm]] ensures that a good RTT estimate will be produced—eventually—by waiting until there is an unambiguous acknowledgment before adjusting the RTO.{{sfn|Karn|Partridge|1991|p=370-372}} After spurious retransmissions, however, it may take significant time before such an unambiguous acknowledgment arrives, degrading performance in the interim.{{sfn|Allman|Paxson|1999|p=268}} TCP timestamps also resolve the retransmission ambiguity problem in setting the RTO,{{sfn|RFC 6298|p=4}} though they do not necessarily improve the RTT estimate.{{sfn|RFC 7323|p=7}} ====Error detection==== Sequence numbers allow receivers to discard duplicate packets and properly sequence out-of-order packets. Acknowledgments allow senders to determine when to retransmit lost packets. To assure correctness a checksum field is included; see {{slink||Checksum computation}} for details. The TCP checksum is a weak check by modern standards and is normally paired with a [[cyclic redundancy check|CRC]] integrity check at [[layer 2]], below both TCP and IP, such as is used in [[Point-to-Point Protocol|PPP]] or the [[Ethernet]] frame. However, introduction of errors in packets between CRC-protected hops is common and the 16-bit TCP checksum catches most of these.<ref>{{Cite conference|last1=Stone |last2=Partridge |title=Proceedings of the conference on Applications, Technologies, Architectures, and Protocols for Computer Communication |chapter=When the CRC and TCP checksum disagree |journal=ACM SIGCOMM Computer Communication Review |pages=309β319 |year=2000 |chapter-url=http://citeseer.ist.psu.edu/stone00when.html |doi=10.1145/347059.347561 |citeseerx=10.1.1.27.7611 |isbn=978-1581132236 |s2cid=9547018 |access-date=2008-04-28 |archive-date=2008-05-05 |archive-url=https://web.archive.org/web/20080505024952/http://citeseer.ist.psu.edu/stone00when.html |url-status=live }}</ref> ====Flow control==== TCP uses an end-to-end [[flow control (data)|flow control]] protocol to avoid having the sender send data too fast for the TCP receiver to receive and process it reliably. Having a mechanism for flow control is essential in an environment where machines of diverse network speeds communicate. For example, if a PC sends data to a smartphone that is slowly processing received data, the smartphone must be able to regulate the data flow so as not to be overwhelmed.<ref name=comer/> TCP uses a [[sliding window]] flow control protocol. In each TCP segment, the receiver specifies in the ''receive window'' field the amount of additionally received data (in bytes) that it is willing to buffer for the connection. The sending host can send only up to that amount of data before it must wait for an acknowledgment and receive window update from the receiving host. [[File:Tcp.svg|right|thumbnail|250px|TCP sequence numbers and receive windows behave very much like a clock. The receive window shifts each time the receiver receives and acknowledges a new segment of data. Once it runs out of sequence numbers, the sequence number loops back to 0.]] When a receiver advertises a window size of 0, the sender stops sending data and starts its ''persist timer''. The persist timer is used to protect TCP from a [[deadlock (computer science)|deadlock]] situation that could arise if a subsequent window size update from the receiver is lost, and the sender cannot send more data until receiving a new window size update from the receiver. When the persist timer expires, the TCP sender attempts recovery by sending a small packet so that the receiver responds by sending another acknowledgment containing the new window size. If a receiver is processing incoming data in small increments, it may repeatedly advertise a small receive window. This is referred to as the [[silly window syndrome]], since it is inefficient to send only a few bytes of data in a TCP segment, given the relatively large overhead of the TCP header. ====Congestion control==== {{Main|TCP congestion control}} The final main aspect of TCP is [[congestion control]]. TCP uses a number of mechanisms to achieve high performance and avoid [[congestive collapse]], a gridlock situation where network performance is severely degraded. These mechanisms control the rate of data entering the network, keeping the data flow below a rate that would trigger collapse. They also yield an approximately [[max-min fair]] allocation between flows. Acknowledgments for data sent, or the lack of acknowledgments, are used by senders to infer network conditions between the TCP sender and receiver. Coupled with timers, TCP senders and receivers can alter the behavior of the flow of data. This is more generally referred to as congestion control or congestion avoidance. Modern implementations of TCP contain four intertwined algorithms: [[TCP congestion control#Slow start|slow start]], [[TCP congestion avoidance algorithm|congestion avoidance]], [[fast retransmit]], and [[fast recovery]].{{sfn|RFC 5681}} In addition, senders employ a ''retransmission timeout'' (RTO) that is based on the estimated [[round-trip time]] (RTT) between the sender and receiver, as well as the variance in this round-trip time.{{sfn|RFC 6298}} There are subtleties in the estimation of RTT. For example, senders must be careful when calculating RTT samples for retransmitted packets; typically they use [[Karn's Algorithm]] or TCP timestamps.{{sfn|RFC 7323}} These individual RTT samples are then averaged over time to create a smoothed round trip time (SRTT) using [[Jacobson's algorithm]]. This SRTT value is what is used as the round-trip time estimate. Enhancing TCP to reliably handle loss, minimize errors, manage congestion and go fast in very high-speed environments are ongoing areas of research and standards development. As a result, there are a number of [[TCP congestion avoidance algorithm]] variations.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)