internet transport protocols - rochester institute of...

24
EECC694 - Shaaban EECC694 - Shaaban #1 lec #12 Spring2000 4-20-2000 Internet Transport Protocols Internet Transport Protocols Transmission Control Protocol (TCP): Transmission Control Protocol (TCP): TCP Socket Primitives. The TCP Segment Header. Establishing & Terminating TCP Connections: TCP Three-way Handshake. TCP Connection Management Finite State Machine. TCP Flow Control: Basic TCP Sliding Window Flow Control. The Silly Window Syndrome. Internet Congestion Control Algorithm. User Datagram Protocol (UDP).

Upload: ngothu

Post on 06-Feb-2018

219 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#1 lec #12 Spring2000 4-20-2000

Internet Transport ProtocolsInternet Transport Protocols•• Transmission Control Protocol (TCP):Transmission Control Protocol (TCP):

– TCP Socket Primitives.

– The TCP Segment Header.

– Establishing & Terminating TCP Connections:• TCP Three-way Handshake.

• TCP Connection Management Finite State Machine.

– TCP Flow Control:• Basic TCP Sliding Window Flow Control.

• The Silly Window Syndrome.

– Internet Congestion Control Algorithm.

• User Datagram Protocol (UDP).

Page 2: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#2 lec #12 Spring2000 4-20-2000

The Internet Transport Protocols (TCP, UDP)TCP (Transmission Control Protocol), RFC 1323:TCP (Transmission Control Protocol), RFC 1323:

– Connection-oriented protocol designed to provide reliable end-to-end byte streams over unreliable internetworks.

– TCP transport entity (TCP) is either implemented as a userprocess or as part of the operating system kernel.

– TCP accepts user data streams from application processes (theapplication layer interface) as segments and breaks them downinto a sequence of separate IP datagrams (of size Max TransferUnit : (MTU)= 64k, usually 1500 bytes) for transmission.

– Arriving IP datagrams containing TCP data are passed to theTCP transport entity to reorder, reassemble and reconstruct theoriginal data stream.

– TCP service and connection is provided to sender and receiverapplication processes by creating end points (sockets) with asocket address consisting of the IP address and a local 16-bit portnumber.

Page 3: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#3 lec #12 Spring2000 4-20-2000

TCP (continued) socket address = (IP address , Port number)

32 bits 16 bits

– To utilize TCP services, a connection must be establishedbetween a socket on the sending machine and a socket on thereceiving machine using a number of socket calls.

– A socket may be used by a number of open connections.

– A TCP connection is always full-duplex, point-to-point and isidentified by the socket identifiers at both end: (socket1, socket2)

– Data passed to TCP by an application may be transmittedimmediately, or buffered to collect more data.

– The lowest 256 port numbers are reserved for standard services,Examples: FTP: port 21, Telnet: port 23, SMTP: port 25,HTTP: port 80, NNTP: port 119, etc.

– Client/Server Model: A server application is one alwayslistening to serve incoming data service requests on a specificport number issued by client processes requesting the service.

Page 4: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#4 lec #12 Spring2000 4-20-2000

Of TCP Segments and IP DatagramsOf TCP Segments and IP Datagrams• TCP connections are byte streams not message streams.

• The original segment boundaries at the sender are not preserved atthe receiver.

• Example:

– The sending application sends data to the sending TCP entity asfour 512-byte TCP segments in four writes transformed into fourIP datagrams.

– The receiving application can get the data from the receiver TCPentity as four 512-byte segments, two 1024-byte segments or, asgiven below, as a single 2048-byte segment in a single read.

Four 512-byte TCPsegment writes by sending application

A single TCP 2048-byte segment read by receiving

application

Page 5: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#5 lec #12 Spring2000 4-20-2000

TCP Socket PrimitivesTCP Socket PrimitivesAvailable to applications

Page 6: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#6 lec #12 Spring2000 4-20-2000

A Client Application Using TCPA Client Application Using TCPSocket PrimitivesSocket Primitives

socket => [bind =>] connect => {write | sendto => read |

recvfrom }* => close | shutdown

– Create a socket,

– Bind it to a local port,

– Establish the address of the server,

– Communicate with it,

– Terminate.

– If bind is not used, the kernel will select a free local port.

Page 7: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#7 lec #12 Spring2000 4-20-2000

socket => bind => listen => {accept => {read | recvfrom =>write | sendto}* }* => close | shutdown

– Create a socket,

– Bind it to a local port,

– Set up service with indication of maximum number ofconcurrent services,

– Accept requests from connection oriented clients,

– receive messages and reply to them,

– Terminate.

A Server Application Using TCPA Server Application Using TCPSocket PrimitivesSocket Primitives

Page 8: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#8 lec #12 Spring2000 4-20-2000

The TCP Segment HeaderThe TCP Segment Header

Page 9: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#9 lec #12 Spring2000 4-20-2000

• 20 bytes fixed-format header:– Source and destination ports (each 16 bits)– Sequence number (32 bits): of segment.– Acknowledgment number (32 bits): Next byte expected (every byte is

numbered in the TCP byte stream).– TCP header length: Number of 32-bit words in header.– 6 bit field: Not used yet; intended for future use.– Six 1-bit flags:

• URG 1 if the urgent pointer is used.• ACK 1 acknowledgment number is valid, 0 no acknowledgment.• PSH 1 PUSHed data; deliver to application upon arrival.• RST 1 reset confused connection due to crash or malfunction.• SYN used to establish connections. (SYN=1 ACK=0) connection request (SYN=1 ACK=1) connection accpeted

• FIN used to release connections; sender has no more data.– Window Size: Specifies the size of the receiver's available buffer or window.– Checksum: of header, data, and pso-header.– Urgent pointer: Byte offset from current sequence # for urgent data.

• Header options (0 or more 32 bit words).• Optional data: up to 65535 -20 (IP header) - 20 (TCP header) = 65515 bytes

TCP Header Fields

Page 10: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#10 lec #12 Spring2000 4-20-2000

Pseudo-header IncludedPseudo-header Included In The TCP Checksum In The TCP Checksum

Page 11: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#11 lec #12 Spring2000 4-20-2000

Establishing & Terminating TCP ConnectionsEstablishing & Terminating TCP Connections• A connection is established using a three-way handshake:

– The transmitter sends ConnectionRequest(seq=x) to start aconnection with transmitter message id x.

– The receiver replies ConnectionAccepted(seq=y, ACK=x+1), toacknowledge x and establish for its messages the identity y.

– Finally the transmitter confirms the connection withConnectionAccepted(seq=x+1,ACK=y+1) to confirm its ownidentifier x and accept the receiver's identifier y.

– If the receiver wanted to reject x, it would send Reject(ACK=x).

– If the transmitter wanted to reject y it would sendReject(ACK=y).

– As part of the handshake the transmitter and receiver specifytheir MSS (Maximum Segment Size), that is the maximum size ofa segment they can accept. A typical value for MSS is 1460.

• A connection is terminated with a similar FOUR-way handshake:

[FIN->, ACK<-, FIN<-, ACK->].

Page 12: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#12 lec #12 Spring2000 4-20-2000

Establishing TCP ConnectionsEstablishing TCP Connections

Normal CaseNormal Case Call CollisionCall Collision

Page 13: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#13 lec #12 Spring2000 4-20-2000

TCPTCPConnectionConnectionManagementManagementFinite StateFinite StateMachineMachine

Page 14: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#14 lec #12 Spring2000 4-20-2000

States of TCP Connection Management State MachineStates of TCP Connection Management State Machine

Page 15: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#15 lec #12 Spring2000 4-20-2000

A Typical Sequence of StatesA Typical Sequence of StatesVisited By A Client TCPVisited By A Client TCP

Page 16: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#16 lec #12 Spring2000 4-20-2000

A Typical Sequence of StatesA Typical Sequence of StatesVisited By Server-Side TCPVisited By Server-Side TCP

Page 17: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#17 lec #12 Spring2000 4-20-2000

Basic TCP Sliding WindowBasic TCP Sliding WindowFlow ControlFlow Control

• When a sender transmits a segment it starts a timer.

• When the segment arrives and is accepted at thedestination, the receiving TCP entity sends backan acknowledgment:– With data if any exist.

– Has an acknowledgment sequence number equal to the nextbyte number of this connection it expects to receive.

– Includes the Receive window, RWIN size it can handledepending on available buffer space.

• If the sender’s timer goes off before the acknowledgmentis received the segment is re-transmitted.

Page 18: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#18 lec #12 Spring2000 4-20-2000

TCP Segment Sequence Numbers, Timeout SelectionTCP Segment Sequence Numbers, Timeout Selection• TCP segment sequence numbers are needed to make sure stale and

delayed duplicate TCP segments do not create confusion and to insurecorrect sliding window protocol operation.

• Both the transmitter and receiver must identify their segments andthese identifiers are usually different.

• The lower k =32 bits from the local time-of-day timer or clock are usedto generate initial TCP segment sequence numbers.

• It’s assumed that no segment remains alive longer than the interveningtime of 2k = 232 cycles.– For the Internet, Maximum Segment Life, MSL = 120 seconds.

• To generate timeout periods, round trip times, RTTs, are maintainedfor each distinct destination and a timeout is calculated from the mostrecent RTTs.– An estimated RTT may be computed that is the exponential average of

the RTTs and then the timeout is chosen as 2 times that estimate.– Exponential averaging assumes a number a, 0<=a<=1, and computes a

sequence of estimated RTTs according to the formula: ERTT(i+1) = a * ERTT(i) + (1-a) * RTT(i)

Page 19: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#19 lec #12 Spring2000 4-20-2000

Sliding Window Flow Control In TCPSliding Window Flow Control In TCP

Page 20: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#20 lec #12 Spring2000 4-20-2000

TypicalTypicalClient/ServerClient/ServerInteractionInteractionUsingUsing TCPTCP

Page 21: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#21 lec #12 Spring2000 4-20-2000

The Silly Window SyndromeThe Silly Window SyndromeTo Avoid It:To Avoid It:Senders and receiversmay refrain from sending data or acknowledgmentsuntil:

• A minimum amount of data has been received/removed, or• A timer expires (usually 500 msec).

Page 22: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#22 lec #12 Spring2000 4-20-2000

An Internet Congestion Control Algorithm:An Internet Congestion Control Algorithm:Slow StartSlow Start

• In addition to the receiver's window size from the Sliding Window Protocol,a transmitter using Slow Start maintains a Congestion Window, anda Threshold, initially set at 64KB.

• The amount of data that can be transmitted at once in a burst of TCPsegments is the minimum of the sliding window size and the congestionwindow size.

• The congestion window starts at the maximum size of a segment.• If the message is acknowledged, the congestion window is doubled, and so

on until the threshold is reached or a message is lost or times out.

• When the threshold is reached, the congestion window can still grow, butnow it is incremented by a single maximal segment per successfultransmission.

• If no more timeouts occur, the congestion window will continue to grow upto the size of of the receiver's window.

• When a message is lost or timed-out , the threshold is set to 1/2 of thecongestion window and the congestion window is restarted at the size of themaximum segment.

Page 23: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#23 lec #12 Spring2000 4-20-2000

Internet Congestion Control:Internet Congestion Control:

Threshold Initially = 64KAfter an initial timeout before transmission #0: Threshold set to = 64K / 2 = 32KCongestion Window = TCP segment size = 1K

Maximum Segment size = 1K

Minimum time between consecutive transmissions = Round Trip Time (RTT)

Assuming a timeout has occurred just before transmission number 0 shown.

Slow Start Slow Start Example Example

64K / 2 = 32K

40K / 2 = 20K

40K

New

Page 24: Internet Transport Protocols - Rochester Institute of ...meseec.ce.rit.edu/eecc694-spring2000/694-4-20-2000.pdf · Internet Transport Protocols ... – Internet Congestion Control

EECC694 - ShaabanEECC694 - Shaaban#24 lec #12 Spring2000 4-20-2000

User Datagram Protocol (UDP)User Datagram Protocol (UDP)• A connectionless Internet transport protocol that delivers

independent messages, called datagrams between applicationsor processes on host computers.

• Unreliable: Datagrams may be lost, delivered out of order.• Each datagram must fit into the payload of an IP packet.• Used by a number of server-client applications with only one

request and one response.• Checksum is optional; may be turned off for digital speech and

video transmissions where data quality is less important.• The UDP header: