Chapter 24. Transport-Layer Protocols 23.1 Introduction 23.2 User Datagram Protocol 23.3 Transmission Control Protocol 23.4 SCTP Computer Networks 24-1
Position of Transport-Layer Protocols UDP is an unreliable connectionless transport-layer protocol TCP is a reliable connection-oriented transport-layer protocol SCTP is a new protocol that combines the features of UDP and TCP Computer Networks 24-2
User Datagram Protocol (UDP) The User Datagram Protocol (UDP) is a connectionless, unreliable transport protocol. UDP is a very simple protocol using a minimum of overhead The calculation of checksum and its inclusion in the user datagram are optional Computer Networks 24-3
UDP: Checksum Checksum includes three section: a pseudoheader, the UDP header, and the data from the application layer Computer Networks 24-4
UDP Operation Connectionless services Flow and error control: no control without checksum Encapsulation and decapsulation Queuing Computer Networks 24-5
UDP Applications Features: Connectionless service, Lack of error control and congestion control Typical Applications: Suitable for a process that requires simple request-response communication with little concern for flow and error control Suitable for a process with internal flow and error control mechanisms such as TFTP Suitable for multicasting Used for management processes such as SNMP Used for some route updating protocols such as RIP Computer Networks 24-6
Transmission Control Protocol (TCP) Transmission Control Protocol (TCP) is a connection-oriented, reliable protocol. TCP explicitly defines connection establishment, data transfer, and connection teardown phases to provide a connection-oriented service. TCP uses a combination of GBN and SR protocols to provide reliability. TCP Services: Process-to-process communication Stream delivery service Full-duplex communication Multiplexing and demultiplexing Connection-oriented service Reliable service Computer Networks 24-7
Stream Delivery Service: TCP Unlike UDP, TCP is a stream-oriented protocol Buffering handles the disparity between the speed of the producing and consuming processes One example: to use a circular array of 1-byte locations Computer Networks 24-8
Segments: TCP IP layer needs to send data in packets not as a stream of byte Computer Networks 24-9
TCP Features Numbering system: sequence number and acknowledgment number Byte number: The bytes of data being transferred in each connection are numbered by TCP. The numbering starts with a randomly generated number The value in the sequence number field of a segment defines the number of the first data byte contained in that segment The value of the acknowledgment field in a segment defines the number of the next byte a party expects to receive. The acknowledgment number is cumulative Computer Networks 24-10
TCP Segment Format Computer Networks 24-11
TCP Control Field Computer Networks 24-12
Checksum: TCP The use of the checksum in TCP is mandatory Computer Networks 24-13
A TCP Connection: Establishment Connection establishment: Three-way handshaking A SYN segment cannot carry data, but it consumes one sequence number A SYN + ACK segment cannot carry data, but does consume one sequence number An ACK segment, if carrying no data, consumes no sequence number Simultaneous open and SYN flooding attack (denial-of service attack, cookie) Computer Networks 24-14
A TCP Connection: Data Transfer After connection is established, bidirectional data transfer can take place Pushing data and urgent data Computer Networks 24-15
A TCP Connection: Connection Termination Three-way handshaking The FIN segment consumes one sequence number if it does not carry data The FIN + ACK segment consumes one sequence number if it does not carry data Computer Networks 24-16
A TCP Connection: Connection Termination Half-Close Computer Networks 24-17
State Transition Diagram Computer Networks 24-18
States for TCP The state marked ESTABLISHED in the FSM is in fact two different sets of states that the client and server undergo to transfer data Computer Networks 24-19
FSM: Half-Close Scenario Computer Networks 24-20
Time-line Diagram for Common Scenario Computer Networks 24-21
Send Window in TCP Computer Networks 24-22
Receive Window in TCP rwnd = buffer size # of waiting bytes to be pulled Computer Networks 24-23
Flow Control Flow control balances the rate a producer creates data with the rate a consumer can use the data. TCP separates flow control from error control. We discuss flow control, ignoring error control. We assume that the logical channel between the sending and receiving TCP is error-free. Computer Networks 24-24
Opening and Closing Windows Computer Networks 24-25
Shrinking of Windows The receive window cannot shrink. The send window, on the other, can shrink if the receiver defines a value for rwnd that results in shrinking the window The receiver needs to keep the following relationship between the last and new ACK and the last and new rwnd values to prevent shrinking of the send window new ackno + new rwnd last ackno + last rwnd Window shutdown probing to prevent a deadlock Computer Networks 24-26
TCP Sliding Window The size of the window is the lesser of rwnd and cwnd. The source does not have to send a full window s worth of data. The window can be opened or closed by the receiver, but should not be shrunk. The destination can send an acknowledgment at any time as long as it does not result in a shrinking window. The receiver can temporarily shut down the window; the sender, however, can always send a segment of 1 byte after the window is shut down. Silly Window Syndrome Nagle s algorithm for syndrome created by the sender Clark s solution for syndrome created by the receiver (1) zero window announcement, (2) delayed ACK Computer Networks 24-27
Error Control Error detection and correction in TCP is achieved through the use of three simple tools: checksum, acknowledgment, and time-out Checksum: If corrupted, it is discarded and considered as lost Acknowledgment: ACK segments do not consume sequence numbers and are not acknowledged Two types of ACKs for TCP: Cumulative ACK (ACK) and Selective ACK (SACK) Retransmission: In modern implementations, a retransmission occurs if the retransmission timer expires or three duplicate ACK segments have arrived No retransmission timer is set for an ACK segment Retransmission after RTO (Retransmission Time-Out): RTO is updated based on the RTT (Round Trip Time) Retransmission after three duplicate ACK segments Out-of-order segments Data may arrive out of order and be temporarily stored by the receiving TCP, but TCP guarantees that no out-of-order segment is delivered to the process Computer Networks 24-28
Simplified FSM for TCP Sender Side Computer Networks 24-29
Simplified FSM for TCP Receiver Side Computer Networks 24-30
Normal Operation Scenarios Computer Networks 24-31
Lost Segment Scenarios Computer Networks 24-32
Fast Retransmission Scenarios Computer Networks 24-33
Lost ACK Scenarios Deadlock created by lost ACK: persistent timer needed Computer Networks 24-34
TCP Congestion Control Receive window, rwnd, is the size of the send window which is controlled by the receiver Congestion window, cwnd, whose size is controlled by the congestion situation in network Actual window size = minimum (rwnd, cwnd) Congestion Detection TCP sender uses the occurrence of two events as a sign of congestion in the network Time-out and three duplicate ACKs Taho TCP (earlier version) treated both events similarly Reno TCP treats these two signs differently Computer Networks 24-35
Slow Start: Exponential Increase In the slow-start algorithm, the size of the congestion window increases exponentially until it reaches a threshold Computer Networks 24-36
Slow Start: Exponential Increase If an ACK arrives, cwnd = cwnd + 1 Start cwnd = 1 2 0 After 1 RTT cwnd = cwnd + 1 = 1 + 1 = 2 2 1 After 2 RTT cwnd = cwnd + 2 = 2 + 2 = 4 2 2 After 3 RTT cwnd = cwnd + 4 = 4 + 4 = 8 2 3 Computer Networks 24-37
Congestion Avoidance: Additive Increase In the congestion-avoidance algorithm, the size of the congestion window increases additively until congestion is detected If an ACK arrives, cwnd = cwnd + (1/cwnd) Start cwnd = i After 1 RTT cwnd = i + 1 After 2 RTT cwnd = i + 2 After 3 RTT cwnd = i + 3 Computer Networks 24-38
Fast Recovery Three duplicated ACKs are interpreted as light congestion Use additive increase like congestion avoidance If a duplicated ACK arrives, cwnd = cwnd + (1/cwnd) Policy Transition When each of these congestion policies is used and when TCP moves from one policy to another? Three versions of TCP: Taho TCP, Reno TCP, and New Reno TCP Computer Networks 24-39
FSM for Taho TCP Computer Networks 24-40
Example 24.9: Taho TCP Computer Networks 24-41
FSM for Reno TCP Computer Networks 24-42
Example 24.10: Reno TCP Computer Networks 24-43
AIMD Additive Increase, Multiplicative Decrease Computer Networks 24-44
TCP Throughput If the cwnd is a constant (flat line) function of RTT, Throughput = cwnd/rtt (unrealistic) If each tooth were exactly the same, Throughput = [(maximum + minimum)/2]/rtt The max is twice the value of the min because in each congestion detection the value of cwnd is set to half of its previous value. Throughput = (0.75) W max /RTT Computer Networks 24-45
TCP Timers Computer Networks 24-46
Example 24.12: Retransmission Timer Computer Networks 24-47
Example 24.13: Karn s Algorithm TCP does not consider the RTT of a retransmitted segment in its calculation of a new RTO Use an exponential backoff strategy if a retransmission occurs Computer Networks 24-48
TCP Timers Persistence Timer: To deal with a zero-window-size advertisement ACK segment announcing nonzero window size is lost: deadlock Set to the value of the retransmission timer up to 60 seconds Keepalive Timer: To prevent a long idle connection between two TCPs Usually after 2 hours, send 10 probes, each of which is 75 seconds apart No response after 10 probes, terminate the connection TIME-WAIT Timer: 2MSL(maximum segment lifetime) during connection termination Common value of MSL is 30 seconds, 1 or 2 minutes Allow TCP to resend the final ACK in case of the ACK is lost Computer Networks 24-49
SCTP Stream Control Transmission Protocol (SCTP) is a new reliable, message-oriented transport layer protocol that combines the best features of UDP and TCP SCTP Services: Process-to-process communication: use all well-known ports in TCP Multiple streams Multihoming Full-duplex communication Connection-oriented service Reliable service Computer Networks 24-50
SCTP Services Multiple streams: An association in SCTP can involve multiple streams Multihoming: SCTP association allows multiple IP addresses for each end Computer Networks 24-51
SCTP Features Transmission sequence number is used to number a data chunk Stream identifier (SI) to distinguish between different streams Stream sequence number to distinguish between different data chunks belong to the same stream Packets: TCP has segments; SCTP has packets In SCTP, control information and data information are carried in separate chunks Computer Networks 24-52
Differences between SCTP and TCP 1. The control information in TCP is part of the header; the control information in SCTP is included in the control chunks 2. The data in a TCP segment treated as one entity; an SCTP packet can carry several data chunks 3. The option section, which can be part of a TCP segment, does not exist in an SCTP packet 4. The mandatory part of the TCP header is 20 bytes, while the general header in SCTP is only 12 bytes 5. The checksum in TCP is 16 bits; in SCTP, it is 32 bits 6. The verification tag in SCTP is an association identifier, which does not exist in TCP 7. TCP includes one sequence number in the header, which defines the number of the first byte in the data section. AN SCTP packet can include several different data chunks 8. Some segments in TCP that carry control information (such as SYN and FIN) need to consume one sequence number; control chunks in SCTP never use a TSN, SI, or SSN Computer Networks 24-53
Packet, Data Chunks, and Stream Data chunks are identified by three items: TSN, SI, and SSN. TSN is a cumulative number identifying the association; SI defines the stream; SSN defines the chunk in a stream Acknowledgment Number In SCTP, acknowledgment numbers are used to acknowledge only data chunks; control chunks are acknowledged by other control chunks if necessary Computer Networks 24-54
SCTP Packet Format In an SCTP packet, control chunks come before data chunks General Header Computer Networks 24-55
SCTP Chunks Computer Networks 24-56
SCTP Association SCTP, like TCP, is a connection-oriented protocol A connection in SCTP is called an association to emphasize multihoming Association establishment requires a four-way handshake No other chunk is allowed in a packet carrying an INIT or INIT ACK chunk. A COOKIE ECHO or a COOKIE ACK chunk can carry data chunks Computer Networks 24-57
SCTP Association: Data Transfer Bidirectional data transfer Like TCP, SCTP supports piggybacking In SCTP, only DATA chunks consume TSNs; DATA chunks are the only chunks that are acknowledged The acknowledgment defines the cumulative TSN, the TSN of the last data chunk received in order Computer Networks 24-58
Association Termination Computer Networks 24-59
SCTP Flow Control Flow control in SCTP is similar to that in TCP. But, SCTP use two units of data, the byte and the chunk. The value of rwnd and cwnd are expressed in byte; the value of TSN and acknowledgment are in chunks Computer Networks 24-60
Flow Control Scenario Computer Networks 24-61
SCTP Error Control SCTP, like TCP, is a reliable transport layer. It uses a SACK chunk to report the state of the receiver buffer to the sender Computer Networks 24-62
SCTP Error Control Sender site Computer Networks 24-63
Error Control Sending Data Chunks: Whenever there are data chunks in the sending queue with a TSN greater than or equal curtsn or if there are data chunks in the retransmission queue Retransmission: Using retransmission timers and receiving three SACKs with the same missing chunks Generating SACK Chunks: Similar rule used for ACK with the TCP ACK flag Congestion Control : The same strategies in TCP. SCTP has slow start (exponential increase), congestion avoidance (additive increase), and congestion detection (multiplicative decrease). SCTP also use fast retransmission and fast recovery Computer Networks 24-64