480 likes | 1.34k Vues
Chapter 12 Transmission Control Protocol (TCP). Mi-Jung Choi Dept. of Computer Science and Engineering mjchoi@postech.ac.kr. Contents . 12.1 TCP SERVICES 12.2 TCP FEATURES 12.3 SEGMENT 12.4 A TCP CONNECTION 12.5 STATE TRANSITION DIAGRAM 12.6 FLOW CONTROL 12.7 ERROR CONTROL
E N D
Chapter 12 Transmission Control Protocol (TCP) Mi-Jung Choi Dept. of Computer Science and Engineering mjchoi@postech.ac.kr
Contents 12.1 TCP SERVICES 12.2 TCP FEATURES 12.3 SEGMENT 12.4 A TCP CONNECTION 12.5 STATE TRANSITION DIAGRAM 12.6 FLOW CONTROL 12.7 ERROR CONTROL 12.8 CONGESTION CONTROL 12.9 TCP TIMERS 12.10 OPTIONS 12.12 TCP PACKAGE
Objectives • Be able to name and understand the services offered by TCP • Understand TCP’s flow and error control and congestion control • Be familiar with the fields in a TCP segment • Understand the phases in a connection-oriented connection • Understand the TCP transition state diagram • Be able to name and understand the timers used in TCP • Be familiar with the TCP options
12.8 Congestion Control • Congestion in a network may occur if the load on the network is greater than the capacity of the network • Congestion control refers to the mechanism and techniques to control the congestion and keep the load below the capacity • Congestion in a network or internetwork occurs because routers and switches have queues
Congestion Control (cont’d) • Network performance • Delay versus Load
Congestion Control (cont’d) • Throughput versus Load • the reason is the discarding of packets by the routers
Congestion Control (cont’d) • Congestion control mechanisms • refers to techniques and mechanisms that can either prevent congestion, before it happens, or remove congestion, after it has happened • open-loop congestion control (prevention) and closed loop congestion control (removal)
Congestion Control (cont’d) • Open-loop congestion control • Retransmission policy • The retransmission policy and the retransmission timers must be designed to optimize efficiency and at the same time prevent congestion • Acknowledgment policy • If the receiver does not acknowledge every packet it receives, it may slow down the sender and help prevent congestion • Discard policy • In audio transmission, if the policy is to discard less sensitive packets when congestion is likely, the quality of sound is still preserved and congestion is prevented
Congestion Control (cont’d) • Closed-loop congestion control • Back pressure • informing the previous upstream router to reduce the rate of outgoing packets • Choke point • is a packet sent by a router to the source to inform it of congestion • is similar to ICMP’s source quench packet • Implicit signaling • Detecting an implicit signal warning of congestion and slow down its sending rate. Ex) receiving delayed ACK • Explicit signaling • Router experiencing congestion can send an explicit signal by setting a bit in a packet to the sender or the receiver
Congestion Control in TCP • Congestion window • Today, TCP protocols include that the sender’s window size is not only determined by the receiver but also by congestion in the network • Actual window size = minimum (rwnd, cwnd)
Congestion Control in TCP (cont’d) • Slow start: exponential increase MSS (max. segment size)
Congestion Control in TCP (cont’d) • In the slow start algorithm, the size of the congestion window increases exponentially until it reaches a threshold Start cwnd = 1 After 1 RTT cwnd = 1 x 2 = 2 21 After 2 RTT cwnd = 2 x 2 = 4 22 After 3 RTT cwnd = 4 x 2 = 8 23
Congestion Control in TCP (cont’d) • Congestion avoidance: additive increase • When the size of the congestion window reaches the slow start threshold, in the congestion avoidance algorithm, the size of the congestion window increases additively until congestion is detected
Congestion Control in TCP (cont’d) • Congestion detection: Multiplicative Decrease • Most implementations react differently to congestion detection: • If detection is by time-out, a new slow start phase starts • If detection is by three ACKs, a new congestion avoidance phase starts
Congestion Control in TCP (cont’d) • TCP congestion policy summary
Congestion Control in TCP (cont’d) • Congestion example
12.9 TCP Timers • To perform its operation smoothly, most TCP implementations use at least four timers
TCP Timers • Round Trip Time (RTT) • To calculate the retransmission (RTO), we first need to calculate the round-trip time (RTT) • In TCP, there can be only one RTT measurement in progress at any time • Measured RTT (RTTM) : how long it takes to send a segment and receive an acknowledgment of it
TCP Timers • Smoothed RTT (RTTS) : Weighed average of RTTM and previous RTTS Original No Value After first measurement RTTS = RTTM After any other measurement RTTS = (1- ) RTTS + · RTTM The value of is implementation-dependent, but it is normally set to 1/8
TCP Timers • RTT Deviation (RTTD) • Original No Value • After first measurement RTTD = RTTM/2 • After any other measurement RTTD = (1- ) RTTD + · l RTTS – RTTM I The value of is also implementation dependent, but is it is usually is sent to ¼.
TCP Timers • Retransmission Timeout (RTO) Original Initial Value After any measurement RTO = RTTS + 4 RTTD
Example 10 Let us give a hypothetical example. Figure 12.38 shows part of a connection. The figure shows the connection establishment and part of the data transfer phases. 1. When the SYN segment is sent, there is no value for RTTM , RTTS , or RTTD . The value of RTO is set to 6.00 seconds. The following shows the value of these variables at this moment: RTO = 6 2. When the SYN+ACK segment arrives, RTTM is measured and is equal to 1.5 seconds. The next slide shows the values of these variables: RTTM = 1.5 RTTS = 1.5 RTTD = 1.5 / 2 = 0.75 RTO = 1.5 + 4 * 0.75 = 4.5
Example 10 (cont.) 3. When the first data segment is sent, a new RTT measurement starts. Note that the sender does not start an RTT measurement when it sends the ACK segment, because it does not consume a sequence number and there is no time-out. No RTT measurement starts for the second data segment because a measurement is already in progress. RTTM = 2.5 RTTS = 7/8 (1.5) + 1/8 (2.5) = 1.625RTTD = 3/4 (0.75) + 1/4 |1.625 − 2.5| = 0.78 RTO = 1.625 + 4 (0.78) = 4.74
TCP Timers • Persistence Timer • When acknowledgment with non-zero window size after zero window size is lost, to correct deadlock, TCP uses a persistence timer for each connection • When the sending TCP receives an acknowledgment with a window size of zero, the persistence timer is started • When persistence timer goes off, the sending TCP sends a special segment called a probe • The probe alerts the receiving TCP that the acknowledgment was lost and should be resent • If a response is not received, the sender continues sending the probe segments and doubling, and resetting the value of the persistence timer until the value reaches a threshold (usually 60 seconds) • After that sender sends one probe segment every 60s until the window is reopened
TCP Timers • Keepalive Timer • Used to prevent a long idle connection between two TCPs. • Each time the server hears from a client, it resets this timer • Time-out is usually 2 hours • After 2 hours, sending 10 probes to client (each 75 secs), then terminates connection • TIME-WAIT Timer • The time-wait timer is used during connection termination
12.10 Options • The TCP header can have up to 40 bytes of optional information • Options convey additional information to the destination or align other options • Two categories of options • one-byte options • multiple-byte options
12.11 TCP Package • A TCP package involving a table called Transmission Control Blocks, a set of timers, and three software modules: main module, input processing module, output processing module.
TCP Package (Cont’d) • Transmission Control Block (TCBs) • To control the connection, TCP uses a structure to hold information about each connection • TCP keeps an array of TCBs in the form of a table
TCP Package (Cont’d) • State : defining the state of the connection according to the state transition diagram • Process : defining the process using this connection at this machine as a client or a server • Local IP address : defining the IP address of the local machine used by this connection • Local port number : defining the local port number used by this connection • Remote IP address • Remote port address • Interface : defining the local interface • Local window : holding information about the window at the local TCP • Remote window
TCP Package (Cont’d) • Sending sequence number • Receiving sequence number • Sending ACK number • Time-out values : retransmission time-out, persistence time-out, keepalive time-out, and so on • Buffer size : defining the size of the buffer at the local TCP • Buffer pointer : pointer to buffer where the receiving data is kept until is read by the application
TCP Package (Cont’d) • Main Module : The main module is invoked by an arrived TCP segment, a time-out, or a message from an application program
TCP Package (Cont’d) • Main Module (cont’d)
TCP Package (Cont’d) • Main Module (cont’d)
TCP Package (Cont’d) • Main Module (cont’d)
TCP D Package (Cont’d) • Main Module (cont’d)
TCP Package (Cont’d) • Main Module (cont’d)
TCP Package (Cont’d) • Main Module (cont’d)
TCP Package (Cont’d) • Main Module (cont’d)
TCP Package (Cont’d) • Main Module (cont’d)
TCP Package (Cont’d) • Input processing module • handles all the details needed to process data or acknowledgment received when TCP is in the ESTABLISHED state • sends an ACK if needed, takes care of the window size, does error checking, and so on • Output processing module • handles all the details needed to send out data received from application program when TCP is in the ESTABLISHED state • handles retransmission time-outs, persistent time-outs, and so on