Chapter 12 Transmission Control Protocol Kyung Hee University

  • Slides: 111
Download presentation
Chapter 12 Transmission Control Protocol Kyung Hee University 1

Chapter 12 Transmission Control Protocol Kyung Hee University 1

Introduction q Position of TCP Kyung Hee University 2

Introduction q Position of TCP Kyung Hee University 2

Introduction (cont’d) q. Responsibilities of Transport Layer to create a process-to-process communication l using

Introduction (cont’d) q. Responsibilities of Transport Layer to create a process-to-process communication l using port numbers in case of TCP to provide a flow-and-error control mechanism at the transport level l l TCP uses sliding window protocol to achieve error control. TCP uses the acknowledgment packet, time-out, and retransmission to achieve error control. to provide a connection mechanism for the application program l l Kyung Hee University sending streams of data to the transport layer by application program making a connection with the receiver, chopping the stream into transportable units, numbering them and sending them one by one 3

Introduction (cont’d) l l At the receiving end, waiting until all the different units

Introduction (cont’d) l l At the receiving end, waiting until all the different units belonging to same application program have received, checking, passing those that are error free and delivering them to the receiving application program as a stream. After the entire stream has been sent, the transport layer should close the connection. q TCP is called a connection-oriented, reliable transport protocol adding connection-oriented and reliability features to the services of IP Kyung Hee University 4

12. 1 Process-to-Process Communication q Host-to-host communication and process-to-process communication Kyung Hee University 5

12. 1 Process-to-Process Communication q Host-to-host communication and process-to-process communication Kyung Hee University 5

Process-to-Process Communication (cont’d) q Port Addresses (Numbers) process-to-process communication that achieved through the client/server

Process-to-Process Communication (cont’d) q Port Addresses (Numbers) process-to-process communication that achieved through the client/server paradigm to define the client and server programs, we need second identifiers called port numbers. integers between 0 and 65, 535 The client program running on the local computer defines itself with a port number, chosen randomly by the TCP software running on the local host l using a ephemeral port number But, the server program on the remote computer must also define itself with a port number l Kyung Hee University using a well-known port number 6

Process-to-Process Communication (cont’d) q Explanation of port numbers using TENET application Kyung Hee University

Process-to-Process Communication (cont’d) q Explanation of port numbers using TENET application Kyung Hee University 7

Process-to-Process Communication (cont’d) q Well-known ports used by TCP Kyung Hee University 8

Process-to-Process Communication (cont’d) q Well-known ports used by TCP Kyung Hee University 8

Process-to-Process Communication (cont’d) q Socket Addresses To make a connection, l l Kyung Hee

Process-to-Process Communication (cont’d) q Socket Addresses To make a connection, l l Kyung Hee University needs 2 identifier : IP address + Port number Socket address a pair of socket address – Client socket address – Server socket address 9

12. 2 TCP Services q Stream Delivery Service TCP is a stream-oriented protocol TCP

12. 2 TCP Services q Stream Delivery Service TCP is a stream-oriented protocol TCP creates an environment in which the two processes seem to be connected by an imaginary “tube” that carries their data across the Internet. Kyung Hee University 10

TCP Services (cont’d) q Sending and Receiving Buffers Because the sending and receiving processes

TCP Services (cont’d) q Sending and Receiving Buffers Because the sending and receiving processes may not produce and consume data at the same speed, TCP needs buffers for storage. One way to implement is to use a circular array Not acknowledged Kyung Hee University 11

TCP Services (cont’d) q TCP Segments Kyung Hee University 12

TCP Services (cont’d) q TCP Segments Kyung Hee University 12

TCP Services (cont’d) q Stream Data Service (stream transport layer service) The sending TCP

TCP Services (cont’d) q Stream Data Service (stream transport layer service) The sending TCP 1) accepts a stream of characters from sending application program 2) creates packets called segments, of appropriate size extracted from the stream 3) sends segments across the network The receiving TCP 1) receives segments, extracts data from segments 2) orders segments if they have arrived out of order 3) delivers segments as a stream of characters to the receiving application program Kyung Hee University 13

TCP Services (cont’d) q For stream delivery, the sending and receiving TCPs use buffers

TCP Services (cont’d) q For stream delivery, the sending and receiving TCPs use buffers l the sending TCP uses sending buffer to store the data coming from the sending application program. – l the receiving TCP receives the segments and stores them in a receiving buffer – – Kyung Hee University the sending application program writes data to the buffer of the sending TCP the receiving application program uses the read operation to read the data from the receiving buffer. Since the rate of reading can be slower than the rate of receiving, the data is kept in the buffer until the receiving application reads it completely. 14

TCP Services (cont’d) q Full-Duplex Service TCP offers full-duplex service l After two application

TCP Services (cont’d) q Full-Duplex Service TCP offers full-duplex service l After two application programs are connected to each other, they can both send and receive data. Piggybacking l Kyung Hee University When a packet is going from A to B, it can also carry an acknowledgment of the packets received from B 15

TCP Services (cont’d) q Connection-Oriented Services 1. A’s TCP informs B’s TCP and gets

TCP Services (cont’d) q Connection-Oriented Services 1. A’s TCP informs B’s TCP and gets approval from B’s TCP 2. A’s TCP and B’s TCP exchange data in both directions 3. After both processes have no data left to send and the buffers are empty, two TCPs destroy their buffers q Reliable Service TCP uses the acknowledgment mechanism to check the safe and sound arrival of data Kyung Hee University 16

12. 3 TCP Features q. Byte numbers All data bytes being transferred in each

12. 3 TCP Features q. Byte numbers All data bytes being transferred in each connection are numbered by TCP. The numbering starts with a randomly generated number. Number range for first byte : 0 ~ 2 32 -1 l If random number is 1, 057 and total number 6, 000 bytes, the bytes are numbered from 1, 057 to 7, 056 Byte numbering is used for flow and error control. Kyung Hee University 17

Numbering Bytes (cont’d) q Sequence number After the bytes have been numbered, TCP assigns

Numbering Bytes (cont’d) q Sequence number After the bytes have been numbered, TCP assigns a sequence number to each segment that is being sent. Segment number for each segment is number of the first byte carried in that segment. Kyung Hee University 18

Numbering Bytes (cont’d) q. Example 2 Imagine a TCP connection is transferring a file

Numbering Bytes (cont’d) q. Example 2 Imagine a TCP connection is transferring a file of 5000 bytes. The first byte is numbered 10001. What are the sequence numbers for each segment if data is sent in five segments with the each segment carrying 1, 000 bytes? Kyung Hee University 19

Numbering Bytes (cont’d) Solution The following shows the sequence number for each segment: Segment

Numbering Bytes (cont’d) Solution The following shows the sequence number for each segment: Segment 1 10, 001 Segment 2 11, 001 (10, 001 to 11, 001) (11, 001 to 12, 001) Segment 3 12, 001 Segment 4 13, 001 (13, 001 to 14, 001) Segment 5 14, 001 Kyung Hee University (12, 001 to 13, 001) (14, 001 to 15, 001) 20

Numbering Bytes (cont’d) q Acknowledgment Number The value of the acknowledgment field in a

Numbering Bytes (cont’d) q Acknowledgment Number The value of the acknowledgment field in a segment defines the number of the next byte a party expects to receives. The acknowledgment number is cumulative. Kyung Hee University 21

12. 3 Segment q A packet in TCP is called segment Kyung Hee University

12. 3 Segment q A packet in TCP is called segment Kyung Hee University 22

Segment (cont’d) q Source port address defining the port number of application program in

Segment (cont’d) q Source port address defining the port number of application program in the host that is sending the segment q Destination port address defining the port number of application program in the host that is receiving the segment q Sequence number defining the number assigned to the first byte of data contained in this segment during the connection establishment, each party uses a random number generator to create an initial sequence number (ISN) Kyung Hee University 23

Segment (cont’d) q Acknowledgment number If the source of the segment has successfully received

Segment (cont’d) q Acknowledgment number If the source of the segment has successfully received byte number x from the other party, it defines x+1 as the acknowledgment number q Header length Indicating the number of 4 -byte words in the TCP header l the value between 5 and 15 (20 and 60 bytes) q Reserved For future use Kyung Hee University 24

Segment (cont’d) q Control Enabling flow control, connection establishment and termination, and mode of

Segment (cont’d) q Control Enabling flow control, connection establishment and termination, and mode of data transfer in TCP Kyung Hee University 25

Segment (cont’d) q Description of flags in the control field Kyung Hee University 26

Segment (cont’d) q Description of flags in the control field Kyung Hee University 26

Segment (cont’d) q Window size defining the size of the window, in bytes, that

Segment (cont’d) q Window size defining the size of the window, in bytes, that the other party must maintain. maximum size of window : 65, 535 bytes q Checksum : picture in next page q Urgent pointer used when the segment contains urgent data defining the number that must be added to the sequence number to obtain the number of the last urgent byte in the data section of the segment q Options : 40 bytes Kyung Hee University 27

Segment (cont’d) Kyung Hee University 28

Segment (cont’d) Kyung Hee University 28

Segment (cont’d) q A TCP segments is encapsulated in an IP datagram Kyung Hee

Segment (cont’d) q A TCP segments is encapsulated in an IP datagram Kyung Hee University 29

12. 4 TCP Connection q The server program tells its TCP to make a

12. 4 TCP Connection q The server program tells its TCP to make a passive open q The Client program issues a request for an active open. + Kyung Hee University 30

TCP Connection – three-way handshaking q A SYN segment cannot carry data, but it

TCP Connection – three-way handshaking q A SYN segment cannot carry data, but it consumes one sequence number. q A SYN + ACK segment cannot carry data, but does consume one sequence number. q An ACK segment, if carrying no data, consumes no sequence number. Kyung Hee University 31

TCP Connection (Cont’d) q Data transfer Kyung Hee University 32

TCP Connection (Cont’d) q Data transfer Kyung Hee University 32

TCP Connection (Cont’d) q Urgent data To send urgent data Use of URG bit

TCP Connection (Cont’d) q Urgent data To send urgent data Use of URG bit set by sending TCP Receiving TCP extracts the urgent data from the segment using urgent pointer Kyung Hee University 33

TCP Connection (Cont’d) q Connection Termination The FIN segment consumes one sequence number if

TCP Connection (Cont’d) q Connection Termination 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. + Kyung Hee University 34

TCP Connection (Cont’d) q Half-close + + + Kyung Hee University 35

TCP Connection (Cont’d) q Half-close + + + Kyung Hee University 35

12. 5 State Transition Diagram q To keep track of all the different events

12. 5 State Transition Diagram q To keep track of all the different events happening during connection establishment, connection termination, and data transfer, the TCP software is implemented as a finite state machine. Kyung Hee University 36

State Transition Diagram (cont’d) Kyung Hee University 37

State Transition Diagram (cont’d) Kyung Hee University 37

State Transition Diagram (Cont’d) q A state transition diagram Server or RST/- Client Special

State Transition Diagram (Cont’d) q A state transition diagram Server or RST/- Client Special Input / Output MSL : Maximum Segment Lifetime (30 sec ~ 1 min) Kyung Hee University Simultaneous Close Three-way Handshake (2 MSL) Now connection is closed in one direction. 38

Connection Establishment and Termination Kyung Hee University 39

Connection Establishment and Termination Kyung Hee University 39

Connection Termination Using Three-way Handshake Kyung Hee University 40

Connection Termination Using Three-way Handshake Kyung Hee University 40

Simultaneous Open Kyung Hee University 41

Simultaneous Open Kyung Hee University 41

Simultaneous Close Kyung Hee University 42

Simultaneous Close Kyung Hee University 42

Denying a Connection Kyung Hee University 43

Denying a Connection Kyung Hee University 43

Aborting a Connection Kyung Hee University 44

Aborting a Connection Kyung Hee University 44

12. 6 Flow Control q Defining the amount of data that a source can

12. 6 Flow Control q Defining the amount of data that a source can send before receiving an acknowledgement from the destination. q Sliding window For flow control, TCP uses a sliding window protocol The window covers a portion of the buffer that a host can send before worrying about an acknowledgment from other host A sliding window is used to make transmission more efficient as well as to control the flow of data so that the destination does not become overwhelmed with data. TCP sliding windows are byte oriented. Kyung Hee University 45

Sliding Window Protocol Kyung Hee University 46

Sliding Window Protocol Kyung Hee University 46

Sliding Window Protocol q an Example Kyung Hee University 47

Sliding Window Protocol q an Example Kyung Hee University 47

Flow Control (cont’d) q In TCP, the sender window size is totally controlled by

Flow Control (cont’d) q In TCP, the sender window size is totally controlled by the receiver window value. However, the actual window size can be smaller if there is congestion in the network. q Some Points about TCP’s Sliding Windows: 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 one byte after the window is shut down. l Kyung Hee University To prevent deadlock by proving 48

12. 7 Error Control q Including mechanisms for detecting corrupted segments, lost segments, out-of-order

12. 7 Error Control q Including mechanisms for detecting corrupted segments, lost segments, out-of-order segments, and duplicated segments. q Also, including a mechanism for correcting errors after they are detected. q Error Detection and Correction Checksum Acknowledgment : TCP does not use negative acknowledgment Time-out Kyung Hee University 49

Normal Operation Kyung Hee University 50

Normal Operation Kyung Hee University 50

Lost Segment Kyung Hee University 51

Lost Segment Kyung Hee University 51

Fast Retransmission Kyung Hee University 52

Fast Retransmission Kyung Hee University 52

Lost Ack Kyung Hee University 53

Lost Ack Kyung Hee University 53

Lost ACK Corrected by Resending a Segment Kyung Hee University 54

Lost ACK Corrected by Resending a Segment Kyung Hee University 54

12. 8 Congestion Control q Congestion in a network may occur if the load

12. 8 Congestion Control q Congestion in a network may occur if the load on the network is greater than the capacity of the network q Congestion control refers to the mechanism and techniques to control the congestion and keep the load below the capacity q Congestion in a network or internetwork occurs because routers and switches have queues. Kyung Hee University 55

Congestion Control (cont’d) Kyung Hee University 56

Congestion Control (cont’d) Kyung Hee University 56

Congestion Control (cont’d) q Network performance Delay versus Load Kyung Hee University 57

Congestion Control (cont’d) q Network performance Delay versus Load Kyung Hee University 57

Congestion Control (cont’d) Throughput versus Load – Kyung Hee University –the reason is the

Congestion Control (cont’d) Throughput versus Load – Kyung Hee University –the reason is the discarding of packets by the routers 58

Congestion Control (cont’d) q Congestion control mechanisms refers to techniques and mechanisms that can

Congestion Control (cont’d) q Congestion control mechanisms refers to techniques and mechanisms that can either prevent congestion, before it happens, or remove congestion, after it has happened. l Kyung Hee University open-loop congestion control (prevention) and closed loop congestion control (removal) 59

Congestion Control (cont’d) Open-loop congestion control l Retransmission policy – l Acknowledgment policy –

Congestion Control (cont’d) Open-loop congestion control l Retransmission policy – l Acknowledgment policy – l If the receiver does not acknowledge every packet it receives, it may slow down the sender and help prevent congestion Discard policy – Kyung Hee University the retransmission policy and the retransmission timers must be designed to optimize efficiency and at the same time prevent congestion 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 60

Congestion Control (cont’d) Closed-loop congestion control l Back pressure – l Choke point –

Congestion Control (cont’d) Closed-loop congestion control l Back pressure – l Choke point – – l Detecting an implicit signal warning of congestion and slow down its sending rate. Ex) receiving delayed ACK Explicit signaling – Kyung Hee University 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 – l informing the previous upstream router to reduce the rate of outgoing packets Router experiencing congestion can send an explicit signal by setting a bit in a packet to the sender or the receiver. 61

Congestion Control in TCP q Congestion window Today, TCP protocols include that the sender’s

Congestion Control in TCP q 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) Kyung Hee University 62

Congestion Control in TCP (cont’d) q Slow start: exponential increase MSS(max. segment size) Kyung

Congestion Control in TCP (cont’d) q Slow start: exponential increase MSS(max. segment size) Kyung Hee University 63

Congestion Control in TCP (cont’d) q In the slow start algorithm, the size of

Congestion Control in TCP (cont’d) q 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 Kyung Hee University 64

Congestion Control in TCP (cont’d) q Congestion avoidance: additive increase When the size of

Congestion Control in TCP (cont’d) q 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 Kyung Hee University 65

Congestion Control in TCP (cont’d) q Congestion detection: Multiplicative Decrease Most implementations react differently

Congestion Control in TCP (cont’d) q Congestion detection: Multiplicative Decrease Most implementations react differently to congestion detection: l l Kyung Hee University If detection is by time-out, a new slow start phase starts. If detection is by three ACKs, a new congestion avoidance phase starts. 66

Congestion Control in TCP (cont’d) q TCP congestion policy summary Kyung Hee University 67

Congestion Control in TCP (cont’d) q TCP congestion policy summary Kyung Hee University 67

Congestion Control in TCP (cont’d) q Congestion example Kyung Hee University 68

Congestion Control in TCP (cont’d) q Congestion example Kyung Hee University 68

12. 9 TCP Timers q. To perform its operation smoothly, most TCP implementations use

12. 9 TCP Timers q. To perform its operation smoothly, most TCP implementations use at least four timers. Kyung Hee University 69

TCP Timers q Round Trip Time(RTT) To calculate the retransmission(RTO), we first need to

TCP Timers q 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. Kyung Hee University 70

TCP Timers q Smothed RTT (RTTS) : Weighed average of RTTM and previous RTTS

TCP Timers q Smothed 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 Kyung Hee University 71

TCP Timers q RTT Deviation (RTTD) Original No Value After first measurement RTTD =

TCP Timers q 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 ¼. Kyung Hee University 72

TCP Timers q Retransmission Timeout (RTO) Original Initial Value After any measurement RTO =

TCP Timers q Retransmission Timeout (RTO) Original Initial Value After any measurement RTO = RTTS + 4 RTTD Kyung Hee University 73

Example 10 Let us give a hypothetical example. Figure 12. 38 shows part of

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 RTTD = 1. 5 / 2 = 0. 75 Kyung Hee University RTTS = 1. 5 RTO = 1. 5 + 4. 0. 75 = 4. 5 74

Example 10 3. When the first data segment is sent, a new RTT measurement

Example 10 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. 625 RTTD = 3/4 (7. 5) + 1/4 |1. 625 − 2. 5| = 0. 78 RTO = 1. 625 + 4 (0. 78) = 4. 74 Kyung Hee University 75

Example 10 Kyung Hee University 76

Example 10 Kyung Hee University 76

TCP Timers q Persistence Timer When acknowledgment with non-zero window size after zero window

TCP Timers q 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 60 s until the window is reopened. Kyung Hee University 77

TCP Timers q. Keepalive. Timer Used to prevent a long idle connection between two

TCP Timers q. 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. q TIME-WAIT Timer The time-wait timer is used during connection termination. Kyung Hee University 78

12. 10 Options q The TCP header can have up to 40 bytes of

12. 10 Options q The TCP header can have up to 40 bytes of optional information. q Options convey additional information to the destination or align other options. q. Two categories of options one-byte options multiple-byte options Kyung Hee University 79

Options q Kyung Hee University 80

Options q Kyung Hee University 80

Options q. End of option (EOP) After this option, the receiver looks for the

Options q. End of option (EOP) After this option, the receiver looks for the payload data EOP option imparts 2 pieces of information to the destination 1) 2) Kyung Hee University No more options in the header Data from the application program starts at the beginning of the next 32 -bit word *EOP can be used only once. 81

Options q No Operation Is One-byte option used as a filler. *NOP can be

Options q No Operation Is One-byte option used as a filler. *NOP can be used more than once. Kyung Hee University 82

Options q Maximum segment size (MSS) defining the size of the biggest unit of

Options q Maximum segment size (MSS) defining the size of the biggest unit of data that can be received by the destination of the TCP segment l l Kyung Hee University in spite of its name, defining the maximum size of the data, not the maximum size of the segment value of 0 to 65, 535 bytes : default is 536 to be determined during the connection establishment phase by the destination of the segment used only in the segments that make the connections. Not used in the segments during data transfer 83

Options q Window Scale Factor defining the size of the sliding window l new

Options q Window Scale Factor defining the size of the sliding window l new window size = window size defined in the header x 2 window scale factor l Determined in phase of the connection setup l The largest value of scale factor allowed by TCP/IP is 14. The value of the window scale factor can be determined only during connection establishment; it does not change during the connection Kyung Hee University 84

Options q Timestamp 10 -byte option The end with the active open announces a

Options q Timestamp 10 -byte option The end with the active open announces a timestamps in the connection request segment (SYN Segment) If it receives a timestamp in the next segment (SYN + SCK) from the other end, it is allowed to use the timestamp. Kyung Hee University 85

Example 12 Kyung Hee University 86

Example 12 Kyung Hee University 86

Options q SACK-permitted and SACK Options SACK-permitted option is used only during connection established

Options q SACK-permitted and SACK Options SACK-permitted option is used only during connection established with SYN segment and SYN + ACK segment. SACK-permitted option is not allowed during the data transfer phase. SACK Option is used during data transfer only if both ends agree l Kyung Hee University The option includes a list for blocks arriving out-of-order. 87

Options q SACK Kyung Hee University 88

Options q SACK Kyung Hee University 88

Example 13 q Kyung Hee University 89

Example 13 q Kyung Hee University 89

Example 14 q For duplicate segment Kyung Hee University 90

Example 14 q For duplicate segment Kyung Hee University 90

Example 15 q Duplicate and out-of-order block Kyung Hee University 91

Example 15 q Duplicate and out-of-order block Kyung Hee University 91

12. 11 TCP Package q A TCP package involving a table called Transmission Control

12. 11 TCP Package q 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. Kyung Hee University 92

TCP Package (Cont’d) q Transmission Control Block (TCBs) To control the connection, TCP uses

TCP Package (Cont’d) q 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 Kyung Hee University 93

TCP Package (Cont’d) State : defining the state of the connection according to the

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 Kyung Hee University 94

TCP Package (Cont’d) Sending sequence number Receiving sequence number Sending ACK number Time-out values

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 Round-trip time 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 Kyung Hee University 95

TCP Package (Cont’d) q Main Module : The main module is invoked by an

TCP Package (Cont’d) q Main Module : The main module is invoked by an arrived TCP segment, a time-out, or a message from an application program Kyung Hee University 96

TCP Package (Cont’d) q. Main Module (cont’d) Kyung Hee University 97

TCP Package (Cont’d) q. Main Module (cont’d) Kyung Hee University 97

TCP Package (Cont’d) q Main Module (cont’d) Kyung Hee University 98

TCP Package (Cont’d) q Main Module (cont’d) Kyung Hee University 98

TCP Package (Cont’d) q Main Module (cont’d) Kyung Hee University 99

TCP Package (Cont’d) q Main Module (cont’d) Kyung Hee University 99

TCP D Package (Cont’d) q Main Module (cont’d) Kyung Hee University 100

TCP D Package (Cont’d) q Main Module (cont’d) Kyung Hee University 100

TCP Package (Cont’d) q Main Module (cont’d) Kyung Hee University 101

TCP Package (Cont’d) q Main Module (cont’d) Kyung Hee University 101

TCP Package (Cont’d) q Main Module (cont’d) Kyung Hee University 102

TCP Package (Cont’d) q Main Module (cont’d) Kyung Hee University 102

TCP Package (Cont’d) q Main Module (cont’d) Kyung Hee University 103

TCP Package (Cont’d) q Main Module (cont’d) Kyung Hee University 103

TCP Package (Cont’d) q Main Module (cont’d) Kyung Hee University 104

TCP Package (Cont’d) q Main Module (cont’d) Kyung Hee University 104

TCP Package (Cont’d) q Input processing module handles all the details needed to process

TCP Package (Cont’d) q 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 q 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 Kyung Hee University 105

Summary(1) q Transmission Control Protocol (TCP) is one of the transport layer protocols in

Summary(1) q Transmission Control Protocol (TCP) is one of the transport layer protocols in the TCP/IP protocol suite. q TCP provides process-to-process, full-duplex, and connection-oriented service. q The unit of data transfer between two devices using TCP software is called a segment; it has 20 to 60 bytes of header, followed by data from the application program. q A TCP connection normally consists of three phases: connection establishment, data transfer, and connection termination. q Connection establishment requires three-way handshaking; connection termination requires three- or four-way handshaking. q TCP software is implemented as a finite state machine. q TCP uses flow control, implement as a sliding window mechanism, to avoid overwhelming a receiver with data. Kyung Hee University 106

Summary(2) q The TCP window size is determined by the receiver-advertised window size(rwnd) or

Summary(2) q The TCP window size is determined by the receiver-advertised window size(rwnd) or the congestion window size(cwnd), whichever is smaller. The window can be opened or closed by the receiver, but should not be shrunk. q The bytes of data being transferred in each connection are numbered by TCP. The numbering starts with a randomly generated number. q TCP uses error control to provide a reliable service. Error control is handled by the checksum, acknowledgement, and time-out. Corrupted and lost segments are retransmitted and duplicate segments are discarded. Data may arrive out of order and temporarily stored by the receiving TCP, but TCP guarantees that no out-of-order segment is delivered to the process. q In modern implementations, a retransmission occurs if the retransmission timer expires or three duplicate ACK segments have arrived. q TCP uses congestion control to avoid and detect congestion in the network. Kyung Hee University 107

Summary(3) q The slow start (exponential increase), congestion avoidance (additive increase), and congestion detection

Summary(3) q The slow start (exponential increase), congestion avoidance (additive increase), and congestion detection (multiplicative decrease) strategies are used for congestion control. q In the slow start algorithm the size of the congestion window increases exponentially until it reaches a threshold. q In the congestion avoidance algorithm the size of the congestion window increases additively until congestion is detected. q 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. q TCP uses four timers (retransmission, persistence, keepalive, and time-waited) in its operation. q In TCP, there can be only be one RTT measurement in progress at any time. Kyung Hee University 108

Summary(4) q TCP does not consider the RTT of a retransmitted segment in its

Summary(4) q TCP does not consider the RTT of a retransmitted segment in its calculation of a new RTO. q TCP uses several options to provide more services. q The end-of-option (EOP) option is used for alignment and indicates there are no more options in the header. EOP can be used only once. q The no-operation (NOP) option is used for filler and alignment purposes. NOP can be used more than once. q The maximum segment size option is used in connection setup to define the largest allowable data segment. The value of MSS is determined during connection establishment and does not change during the connection. q The window scale factor is a multiplier that increases the window size. Kyung Hee University 109

Summary(5) q The timestamp option shows how much time it takes for data to

Summary(5) q The timestamp option shows how much time it takes for data to travel from sender to receiver. One application of timestamp option is in the calculation of round trip time (RTT). Another application is for PAWS. q Recent implementations of TCP use two more options, SACKpermitted option and SACK option. These two options allow the selective acknowledgment of the received segments by the receiver. q Transmission control blocks (TCBs) hold information about each TCP connection. q A TCP package can contain TCBs, timers, a main module, an input processing module, and an output processing module. Kyung Hee University 110

Q and A Kyung Hee University 111

Q and A Kyung Hee University 111