TCP: Transmission Control Protocol, Slides of Computer Science

An overview of the transmission control protocol (tcp), explaining why it is necessary to build a reliable layer on top of the internet protocol (ip), the problems that can occur when sending messages between hosts, and how tcp addresses these issues through features like guaranteed delivery, message ordering, and flow control. The document also covers the tcp usage model, segment format, and state transition diagram.

Typology: Slides

2012/2013

Uploaded on 03/27/2013

ekana
ekana 🇮🇳

4

(44)

370 documents

1 / 29

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Transmission Control Protocol (TCP),
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d

Partial preview of the text

Download TCP: Transmission Control Protocol and more Slides Computer Science in PDF only on Docsity!

Transmission Control Protocol (TCP),

The Need for TCP

 Network Layer (IP) provides a best-effort service

 Need to build a reliable layer on top of IP

 Possible problems sending messages from one host

to another:

 May be lost  May be reordered  May be delivered multiple times  May be delivered after a long delay  May be broken into smaller messages  May be corrupted

Can this be done hop-by-hop

instead of end-to-end?

 Think of this like the postal service

 One major problem: Nodes would not know what

happened two or more hops ahead of them  Routing tables incorrect, packets dropped, machine crashed, link failed…  Only ends can be sure of receipt/non-receipt of a message

 For others: read “End-to-end arguments for

System Design”… Classic, must-read paper, could be on exam

TCP Usage Model

 Connection setup

 􀁻􀁻 3-way handshake

 Data transport

 Sender writes data

 TCP

 Breaks data into segments

  • Sends each segment over IP
  • Retransmits, reorders and removes duplicates as necessary
  • Receiver reads some data

 Teardown

 4 step exchange

TCP is connection-oriented

Connection Setup

3-way handshake

(Active)

Client

(Passive)

Server

Syn (ISNA)

Syn (ISNB) + Ack (ISNA+1)

Ack (ISNB+1)

Connection Close/Teardown

2 x 2-way handshake

(Active)

Client

(Passive)

Server

Fin (SNA)

(Data +) Ack (SN (^) A+1)

Fin (SNB)

Ack (SNB+1)

TCP supports a “stream of

bytes” service

Host A

Host B

The TCP Segment Format

IP Hdr

IP Data TCP Data TCP Hdr

Src port Dst port

Sequence #

Ack Sequence # HLEN 4 RSVD 6 URG ACK PSH RST SYN FIN

Flags Window Size

Checksum Urg Pointer

(TCP Options)

0 15 31

TCP Data

TCP Segment Header

 16-bit source and destination ports

 32-bit send and ACK sequence numbers

 4-bit header length in 4-byte words

 􀁻􀁻 Minimum value of 5  􀁻􀁻 Offset to first data byte

 6 1-bit flags

 􀁻􀁻 URG: Segment contains urgent data  􀁻􀁻 ACK: ACK sequence number is valid  􀁻􀁻 PSH: Do not delay delivery of data  􀁻􀁻 RST: Reset connection (reject or abn. termination)  􀁻􀁻 SYN: Synchronize segment for setup  􀁻􀁻 FIN: Final segment for teardown

TCP Options

 Negotiate maximum segment size (MSS)

 Each host suggests a value  Minimum of two values is chosen  Prevents IP fragmentation over first and last hops

 Packet timestamp

 Allows RTT calculation for retransmitted packets  Extends sequence number space for identification of stray packets

 Negotiate advertised window granularity

 Allows windows to be scaled to larger sizes  Good for routes with large bandwidth-delay products

Sequence Numbers

Host A

Host B

TCP Data

TCP Data

TCP HDR

TCP HDR

ISN (initial sequence number)

Sequence number = 1st byte Ack sequence number = next expected byte

TCP State Descriptions

CLOSED Disconnected

LISTEN Waiting for incoming connection

SYN_RCVD Connection request received

SYN_SENT Connection request sent

ESTABLISHED Connection ready for data transport

CLOSE_WAIT Connection closed by peer

LAST_ACK Connection closed by peer, closed locally, await ACK

FIN_WAIT_1 Connection closed locally

FIN_WAIT_2 Connection closed locally and ACK’d

CLOSING Connection closed by both sides simultaneously

TIME_WAIT Wait for network to discard related packets

TCP State Transition Diagram

TCP Sliding Window

 How much data can a TCP sender have

outstanding in the network?

 How much data should TCP retransmit

when an error occurs? Just selectively

repeat the missing data?

 How does the TCP sender avoid over-

running the receiver’s buffers?

TCP Sliding Window

Window Size

Outstanding Un-ack’d data

Data OK to send

Data not OK to send yet

Data ACK’d

 Window is meaningful to the sender.

 Current window size is “advertised” by receiver

(usually 4k – 8k Bytes when connection set-up).

 TCP’s Retransmission policy is “Go Back N”.