24
Transport Layer: TCP and UDP

Transport Layer: TCP and UDP. Overview of TCP/IP protocols Comparing TCP and UDP TCP connection: establishment, data transfer, and termination Allocation

Embed Size (px)

Citation preview

Transport Layer: TCP and UDP

Transport Layer: TCP and UDP Overview of TCP/IP protocols Comparing TCP and UDP TCP connection: establishment, data

transfer, and termination Allocation of port numbers Size matters: MTU, datagram, MSS, buffer Standard Internet services and

applications Debugging techniques and tools

Overview of TCP/IP Protocols

Comparing TCP and UDP

TCP Connection: Establishment

Three-way handshake

TCP Options Three common TCP options (sent in SYN) :

MSS option: The maximum segment size that can be received

65,535 (16 bits for the widow size field in the TCP header) is the upper limit

Window scale option: To allow the advertised widow size to be scaled (left-shift) 0-14 bits.

MSS can thus reach up to 65,355 x 214 bytes Timestamp option: May be used for high-speed

connections to prevent possible data corruption caused by old, delayed, or duplicated segments

TCP Connection: Data Transfer

TCP Connection: Termination

Four-way handshake

TCP State Transition Diagram

TIME_WAIT State Its duration is twice the MSL (maximum segment l

ifetime), sometimes called 2MSL MSL may be 30 seconds, 1 minute, or 2 minutes

Two reasons for the TIME_WAIT state : To implement TCP’s full duplex connection terminatio

n reliably To give TCP enough time to handle the loss of any of the last four

segments To allow old duplicate segments to expire in the networ

k To prevent old duplicates being misinterpreted as belonging to a

new incarnation of the same connection

10

Illustrating the First Reason

Allocation of Port Numbers

Socket Pair

4-tuple that defines the two endpoints of a connection The local IP address, local TCP port,

foreign IP address, and foreign TCP port

Uniquely identifies every TCP connection on the Internet

A Concurrent Server

Server’s socket pair

Connect Request from Client toSever

Connect Request from Client toSever

TCP must look at all four elements in the socket pair to determine whichendpoint receives anarriving segment

TCP Output and UDP Output

17

Size Matters Maximum IP datagrams :

IPv4: 65,535; IPv6: 65,575 (without jumbo payload option) Link MTU (maximum transmission unit) :

Ethernet: 1,500; FDDI: 4,325; PPP: configurable Path MTU: The smallest MTU in the path between two h

osts 1,500 is the popular one today Path MTU may be asymmetric between two hosts, due to possib

ly different route in each direction TCP MSS (maximum segment size)

It is subject to the reassembly buffer size at two hosts However, it is often the link MTU minus IP & TCP headers

18

Buffer Sizes and Limitations Link MTU (maximum transmission unit):

Ethernet MTU: 1500 bytes, PPP MTU: configurable

Path MTU: the smallest link MTU in the path, can be discovered by IPv4 DF (don’t fragment) bit

TCP Output and UDP Output

TCP Output The write blocks if no room in the socket

send buffer The kernel will not return from the write

until the final byte in the application buffer has been copied into the socket send buffer

Successful return from a write only tells us that we can reuse our application buffer

TCP must keep a copy of our data until it is acknowledged by the peer

UDP Outputs UDP socket has a send buffer size but no

real buffer If application’s datagram > send buffer

size, an error message is returned UDP need not keep a copy of our data A successful return from a write to a UDP

socket tells us the datagram has been added to the data link output queue

An error message will be generated if there is no room in the data link output queue

Standard Internet Services andApplications

Protocol Usage of Various Common Applications