Transmission Control Protocol (TCP)

Slides:



Advertisements
Similar presentations
Flow control Connection management TCP, UDP
Advertisements

TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
CSCI 4550/8556 Computer Networks
Transmission Control Protocol (TCP)
1 TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
1 CS 4396 Computer Networks Lab Transmission Control Protocol (TCP) Part I.
TCP: Transmission Control Protocol Overview Connection set-up and termination Interactive Bulk transfer Timers Improvements.
Provides a reliable unicast end-to-end byte stream over an unreliable internetwork.
School of Information Technologies TCP Congestion Control NETS3303/3603 Week 9.
UNIT 07 Process – to – Process Delivery: UDP,TCP and SCTP
Chapter 15 Transmission Control Protocol (TCP)
Ch 23 Ameera Almasoud Based on Data Communications and Networking, 4th Edition. by Behrouz A. Forouzan, McGraw-Hill Companies, Inc., 2007.
Process-to-Process Delivery:
Copyright © Lopamudra Roychoudhuri
TCP : Transmission Control Protocol Computer Network System Sirak Kaewjamnong.
TCP Lecture 13 November 13, TCP Background Transmission Control Protocol (TCP) TCP provides much of the functionality that IP lacks: reliable service.
26-TCP Dr. John P. Abraham Professor UTPA. TCP  Transmission control protocol, another transport layer protocol.  Reliable delivery  Tcp must compensate.
TCP1 Transmission Control Protocol (TCP). TCP2 Outline Transmission Control Protocol.
Chapter 12 Transmission Control Protocol (TCP)
1 TCP: Reliable Transport Service. 2 Transmission Control Protocol (TCP) Major transport protocol used in Internet Heavily used Completely reliable transfer.
23.1 Chapter 23 Process-to-Process Delivery: UDP, TCP, and SCTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Copyright © Lopamudra Roychoudhuri
TCP: Transmission Control Protocol Part II : Protocol Mechanisms Computer Network System Sirak Kaewjamnong Semester 1st, 2004.
1 CS 4396 Computer Networks Lab TCP – Part II. 2 Flow Control Congestion Control Retransmission Timeout TCP:
Computer Networks23-1 PART 5 Transport Layer. Computer Networks23-2 Position of Transport Layer Responsible for the delivery of a message from one process.
NET 221D:COMPUTER NETWORKS FUNDAMENTALS Lecture : Transport Layer: Behrouz A. Forouzan” Data communications and Networking 1.
ECE 4110 – Internetwork Programming
Fall 2004FSU CIS 5930 Internet Protocols1 TCP – Data Exchange Reading: Section 24.4.
TCP Transmission Control Protocol Part 2 CH 23 Aseel Alturki.
TCP/IP1 Address Resolution Protocol Internet uses IP address to recognize a computer. But IP address needs to be translated to physical address (NIC).
Transmission Control Protocol (TCP) TCP Flow Control and Congestion Control CS 60008: Internet Architecture and Protocols Department of CSE, IIT Kharagpur.
CSEN 404 Transport Layer II Amr El Mougy Lamia AlBadrawy.
1 TCP ProtocolsLayer name DNSApplication TCP, UDPTransport IPInternet (Network ) WiFi, Ethernet Link (Physical)
TCP/IP Protocol Suite 1 Chapter 12 Upon completion you will be able to: Transmission Control Protocol Be able to name and understand the services offered.
Chapter 3 Transport Layer
TCP - Part II.
DMET 602: Networks and Media Lab
Fast Retransmit For sliding windows flow control we waited for a timer to expire before beginning retransmission of a packet TCP uses an additional mechanism.
Topics discussed in this section:
Chapter 15 Transmission Control Protocol (TCP)
Introduction to Networks
Introduction to Networks
Chapter 15 Transmission Control Protocol (TCP)
5. End-to-end protocols (part 1)
Chapter 17 and 18: TCP is connection oriented
Process-to-Process Delivery, TCP and UDP protocols
Process-to-Process Delivery
TCP.
PART 5 Transport Layer Computer Networks.
6 Transport Layer Computer Networks Tutun Juhana
TCP - Part I Karim El Defrawy
TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 15 Transmission Control Protocol.
TCP - Part II Relates to Lab 5. This is an extended module that covers TCP flow control, congestion control, and error control in TCP.
Introduction to the Transport Layer
TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
Chapter 23 Introduction To Transport Layer
PUSH Flag A notification from the sender to the receiver to pass all the data the receiver has to the receiving application. Some implementations of TCP.
CS4470 Computer Networking Protocols
Chapter 12 Transmission Control Protocol
Dr. John P. Abraham Professor UTPA
Dr. John P. Abraham Professor UTPA
Chapter 15 Transmission Control Protocol (TCP)
Chapter 12 Transmission Control Protocol
PART 5 Transport Layer.
CS4470 Computer Networking Protocols
TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
The Transmission Control Protocol (TCP)
TCP: Transmission Control Protocol Part II : Protocol Mechanisms
Transport Layer 9/22/2019.
Presentation transcript:

Transmission Control Protocol (TCP) Reference: TCP/IP Protocol Suite, Fourth Edition by Behrouz A. Forouzan

TCP Services Process-to-Process Communication Stream Delivery Service using port numbers Stream Delivery Service Sending and Receiving Buffers necessary for flow- and error-control mechanisms

Full-Duplex Communication Segments A number of bytes together into a packet called a segment Full-Duplex Communication Each TCP endpoint then has its own sending and receiving buffer, and segments move in both directions. Multiplexing and Demultiplexing Like UDP, TCP performs multiplexing at the sender and demultiplexing at the receiver Connection-Oriented Service TCP, unlike UDP, is a connection-oriented protocol a virtual connection, not a physical connection

Reliable Service Flow Control Error Control Congestion Control It uses an acknowledgment mechanism to check the safe and sound arrival of data Flow Control Error Control Congestion Control

TCP Features Numbering System Byte Number Sequence Number When TCP receives bytes of data from a process, it stores them in the sending buffer and numbers them. The numbering does not necessarily start from 0. TCP chooses an arbitrary number between 0 and 232 − 1 for the number of the first byte. Sequence Number The sequence number for each segment is the number of the first byte of data carried in that segment.

When a segment carries a combination of data and control information (piggybacking), it uses a sequence number. However, some segments, when carrying only control information, need a sequence number to allow an acknowledgment from the receiver. These segments are used for connection establishment, termination, or abortion

Example Suppose a TCP connection is transferring a file of 5,000 bytes. The first byte is numbered 10,001. What are the sequence numbers for each segment if data are sent in five segments, each carrying 1,000 bytes?

Solution

Acknowledgment Number Acknowledgment number defines the number of the next byte that the party expects to receive The acknowledgment number is cumulative which means that the party takes the number of the last byte that it has received, safe and sound, adds 1 to it, and announces this sum as the acknowledgment number if receiver uses 5,643 as an acknowledgment number, it has received all bytes from the beginning up to 5,642. Note that this does not mean that the receiver has received 5,642 bytes, because the first byte number does not have to start from 0.

TCP Segment

Acknowledgment number This 32-bit field defines the byte number that the receiver of the segment is expecting to receive from the other party Header length The length of the header can be between 20 and 60 bytes (value in this field is to be multiplied by 4 to get Hlen) Window size is determined by the receive

PSH In general, transport layer sends data when window becomes full, When application have some data to be sent immediately, PSH is set and sent without waiting to get the window fills fully May be used in case on instant messaging application.

Urgent pointer TCP is a stream-oriented protocol When application requires some data to be treated in special way, it is treated as urgent data The sending TCP creates a segment and inserts the urgent data at the beginning of the segment. The rest of the segment can contain normal data from the buffer The urgent pointer field in the header defines the end of the urgent data (the last byte of urgent data). When the receiving TCP receives a segment with the URG bit set, it informs the receiving application of the situation

Connect Reset (RST) TCP at one end may deny a connection request, requested a connection to a nonexistent port may abort an existing connection, or want to abort an existing connection due to an abnormal situation may terminate an idle connection. the other side has been idle for a long time All of these are done with the RST (reset) flag.

Checksum

TCP Connection Connection Establishment Three-Way Handshaking SYN segment (from client to server): only the SYN flag is set for synchronization of sequence numbers (called initial sequence number) does not contain an acknowledgment number. It does not define the window size either No data it consumes one sequence number

SYN + ACK (from server to client): two flag bits set: SYN and ACK SYN segment for communication in the other direction (S-> R), to initialize a sequence number for numbering the bytes sent from the server to the client ACK to acknowledge received segment (SYN), displaying the next sequence number it expects to receive from the client As its ACK is set, need to defines the receive window size SYN + ACK segment cannot carry data, does consume one sequence number

ACK Segment (Client to Server): Ack for SYN segment (received (SYN+ACK) Ack of ACK segment is not sent ACK segment does not consume any sequence numbers Some implementations allow this third segment in the connection phase to carry the first chunk of data from the client. In this case, the third segment must have a new sequence number showing the byte number of the first byte in the data. In general, the third segment usually does not carry data and consumes no sequence numbers.

3 way handshaking (connection establishment)

Data Transfer

Connection Termination 3-way handshaking

Half-Close

Flow Control We will be considering unidirectional communication (bidirectional communication can be considered, having two unidirectional)

Windows in TCP Send Window The send window size is dictated by the receiver (flow control) and the congestion in the underlying network (congestion control).

SR vs TCP send windows The window in SR numbers pockets, but the window in the TCP numbers bytes. Although actual transmission in TCP occurs segment by segment, the variables that control the window are expressed in bytes. TCP can store data received from the process and send them later, but we assume that the sending TCP is capable of sending segments of data as soon as it receives them from its process. The theoretical Selective Repeat protocol may use several timers for each packet sent, but the TCP protocol uses only one timer

Receive Window

SR vs TCP receive windows TCP allows the receiving process to pull data at its own pace. This means that part of the allocated buffer at the receiver may be occupied by bytes that have been received and acknowledged, but are waiting to be pulled by the receiving process. The receive window size is then always smaller or equal to the buffer size rwnd = buffer size − number of waiting bytes to be pulled ACK in TCP is a cumulative acknowledgment announcing the next expected byte to receive

Cont… Opening and Closing Windows Size of buffer of both parties are fixed The receive window closes (moves its left wall to the right) when more bytes arrive from the sender; it opens (moves its right wall to the right) when more bytes are pulled by the process. We assume that it does not shrink (the right wall does not move to the left).

Cont… The opening, closing, and shrinking of the send window is controlled by the receiver The send window closes (moves its left wall to the right) when a new acknowledgement allows it to do so. The send window opens (its right wall moves to the right) when the receive window size (rwnd) advertised by the receiver allows it to do so. The send window shrinks on occasion.

A scenario

Shrinking of Windows Window Shutdown the receive window cannot shrink. Send window can shrink Window Shutdown the receiver can temporarily shut down the window by sending a rwnd of 0. the sender does not actually shrink the size of the window, but stops sending data until a new advertisement has arrived. the sender can always send a segment with 1 byte of data. This is called probing and is used to prevent a deadlock

Silly Window Syndrome A serious problem can arise in the sliding window operation when either the sending application program creates data slowly or the receiving application program consumes data slowly, or both. results in the sending of data in very small segments, which reduces the efficiency of the operation This problem is called the silly window syndrome

Syndrome Created by the Sender When an application program that creates data slowly, small segments are created and sent Solution Prevent the sending TCP from sending the data byte by byte It must wait and collect data to send in a larger block. How long should the sending TCP wait? If it waits too long, it may delay the process. If it does not wait long enough, it may end up sending small segments. Nagle found an elegant solution

Nagle’s Algorithm Immediately send 1st piece of data (even if it is only 1 byte) Then, wait until (keep on storing received data) either the receiving TCP sends an acknowledgment or until enough data has accumulated to fill a maximum-size segment. At this time, the sending TCP can send the segment. Step 2 is repeated for the rest of the transmission. Segment 3 is sent immediately if an acknowledgment is received for segment 2, or if enough data have accumulated to fill a maximum-size segment.

Syndrome Created by the Receiver If receiving application consumes data slowly Receiving buffer will be full very soon Shutdowns sender window In worst case consumes 1 byte at a time Sender sends 1 byte segments Solution to it Clark’s Solution send an acknowledgment as soon as the data arrive, Close the window until either there is enough space to accommodate a segment of maximum size or at least half of the receive buffer is empty. Delayed Acknowledgment A segment is not acknowledged immediately The receiver waits until there is a decent amount of space in its incoming buffer before acknowledging the arrived segments.

prevents the sender (sending TCP) from sliding its window. After the sender (sending TCP) has sent the data in the window, it stops. it reduces traffic (each segment is not acknowledged) The delayed acknowledgment may result in the sender unnecessarily retransmitting the unacknowledged segments. In TCP the acknowledgment should not be delayed by more than 500 ms.

Error Control TCP provides reliability using error control. Error control includes mechanisms for detecting and resending corrupted segments, resending lost segments, storing out-of-order segments and detecting and discarding duplicated segments. Error control in TCP is achieved through the use of: checksum, acknowledgment, and time-out.

Acknowledgement ACK segments do not consume sequence numbers and are not acknowledged. Acknowledgment Type Cumulative Acknowledgment (ACK) The receiver advertises the next byte it expects, ignoring all segments received and stored out of order no feedback is provided for discarded, lost, or duplicate segments The 32-bit ACK field in the TCP header is used for cumulative acknowledgments and its value is valid only when the ACK flag bit is set to 1.

Selective Acknowledgment (SACK) A SACK does not replace ACK, but reports additional information to the sender A SACK reports a block of data that is out of order, and also a block of segments that is duplicated SACK is implemented as an option at the end of the TCP header

Generating Acknowledgments the most common rules Piggybacked ACKs, if possible If there is only one outstanding in-order segment, ACK is delayed When an expected segment arrives, and previous in-order is not ACKed, send ACK Out of order segment no. received (higher than expected), send ACK for expected. When a missing segment arrives, the receiver sends an ACK segment to announce the next sequence number expected. If a duplicate segment arrives, the receiver discards the segment, but immediately sends an acknowledgment indicating the next in-order segment expected

Retransmission Error control is handled using retransmission When a segment is sent, it is stored in a queue until it is acknowledged. When the retransmission timer expires or when the sender receives three duplicate ACKs for the first segment in the queue, that segment is retransmitted.

Retransmission after RTO The sending TCP maintains one retransmission time-out (RTO) RTO expires TCP sends the segment in the front of the queue (the segment with the smallest sequence number) and restarts the timer. Sf< Sn This version of TCP is sometimes referred to as Tahoe.

Retransmission after Three Duplicate ACK Segments Usually RTO value is large To increase throughput , 3-dulicate ACKs (an original ACK plus three exactly identical copies) are used to retransmit the segment before RTO matures This feature is called fast retransmission This version of TCP is sometimes referred to as Reno

Out-of-Order Segments TCP does not discard out-of-order segments. Those are stored temporarily and flag them as out-of-order segments until the missing segments arrive. however, that out-of-order segments are never delivered to the process.

Normal Operation of TCP

Some Segment Lost

Fast Retransmission

Automatically Corrected Lost ACK Corrected by next ACK RTO does not expires

Corrected by RTO Duplicate segments will be received and discarded

Congestion Control The load on the network (the number of packets sent to the network) is greater than the capacity of the network (the number of packets a network can handle) Due to waiting in a system Buffers at routers and switches. Congestion Prevention Congestion Removal

TCP Congestion Control TCP uses a congestion window and a congestion policy

3 Steps to control the congestion First, how does a TCP sender limit the rate at which it sends traffic into its connection? Second, how does a TCP sender perceive that there is congestion on the path between itself and the destination? And third, What algorithm should the sender use to change its send rate as a function of perceived end-to-end congestion?

Limiting Sender rate: Congestion Window Sender window size is determined by the available buffer space in the receiver (rwnd). What if network cannot deliver at the rate data is created at sender Now Sender decides window size according to Actual window size = minimum (rwnd, cwnd)

Congestion Detection Loss of segments Due to Timeout Due to 3 Duplicate ACKs

Congestion Policy Based on three phases: slow start, congestion avoidance, and congestion detection

Slow Start: Exponential Increase cwnd starts with 1 MSS cwnd increases with 1 MSS when an ACK received We assume rwnd >> cwnd we ignore delayed-ACK policy and assume that each segment is acknowledged individually

When to stop slow-start? When the size of window in bytes reaches a threshold, slow start stops and the next phase starts.

Congestion Avoidance: Additive Increase Congestion avoidance, increases the cwnd additively instead of exponentially When the size of the cwnd reaches the slow start threshold in the case where cwnd = i, the slow start phase stops and the additive phase begins.

The increase in cwnd is based on RTT, not on the number of arrived ACKs. In the congestion avoidance algorithm the size of the cwnd increases additively until congestion is detected.

Congestion Detection: Multiplicative Decrease If congestion occurs, the congestion window size must be decreased TCP assumes that, when there is a need of retransmission it is due to congestion Retransmission can occur in one of two cases: when the RTO timer times out or when three duplicate ACKs are received. In both cases, the size of the threshold is dropped to half (multiplicative decrease).

Most TCP implementations have two reactions: If a time-out occurs, there is a stronger possibility of congestion (a segment has probably been dropped in the network). In this case TCP reacts strongly: Threshold = ½(current window size). cwnd = one segment. It starts the slow start phase again. Also known as TCP Tahoe

If three duplicate ACKs are received, there is a weaker possibility of congestion. TCP has a weaker reaction as shown below: Threshold = ½(current window size). cwnd = threshold (some implementations add three segment sizes to the threshold). It starts the congestion avoidance phase. Also Known as TCP Reno

TCP Tahoe v/s TCP Reno TCP Tahoe is old method: Always enters to Slow-Start phase (Reacts in same manner for both: Tiome-out and 3 duplicate ACKs) TCP Reno: Reacts differently on both events of a segment loss.

Exercise In a network assume rwnd >>cwnd Initially threshold value is 16. At time 40 sec. sender retransmits a segment due to RTO expiry. At time 70 sec. sender receives 2 duplicate ACKs. Draw a graph between cwnd and RTT Note: RTT = 5 sec.

TCP TIMERS Retransmission Timer Round-Trip Time (RTT) retransmission time-out (RTO), the waiting time for an ack of a segment Round-Trip Time (RTT) To calculate the RTO, we first need to calculate the RTT

RTT Calculation MeasuredRTT (RTTm) SmoothedRTT (RTTS) Time it takes to send a segment and receive an ack for it. Only 1 RTT can be measured at a time. TCP never computes Measured RTT for retransmitted segments. SmoothedRTT (RTTS) The RTTM, is likely to change for each round trip α =1/8

Retransmission Time-out (RTO) RTT Deviation Retransmission Time-out (RTO) Whenever a timeout occurs, TCP sets timeout interval to twice the previous value. β =1/4 D

Doubling the Timeout interval Whenever a timeout occurs, TCP sets timeout interval to twice the previous value. Fast Retransmission Timeout-triggered retransmission lead to slow retransmission. If sender receives 3 duplicate ACKs for the same data, retransmit segment before timeout occurs.

The window in SR numbers packets, but the window in the TCP numbers bytes. The variables that control the window are expressed in bytes.