data and computer communications

58
Data and Computer Data and Computer Communications Communications Eighth Edition Eighth Edition by William Stallings by William Stallings Lecture slides by Lawrie Lecture slides by Lawrie Brown Brown Chapter 20 – Transport Chapter 20 – Transport Protocols Protocols

Upload: lark

Post on 19-Mar-2016

22 views

Category:

Documents


0 download

DESCRIPTION

Data and Computer Communications. Chapter 20 – Transport Protocols. Eighth Edition by William Stallings Lecture slides by Lawrie Brown. Transport Protocols. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Data and Computer Communications

Data and Computer Data and Computer CommunicationsCommunications

Eighth EditionEighth Editionby William Stallingsby William Stallings

Lecture slides by Lawrie BrownLecture slides by Lawrie Brown

Chapter 20 – Transport ProtocolsChapter 20 – Transport Protocols

Page 2: Data and Computer Communications

Transport ProtocolsTransport ProtocolsThe foregoing observations should make us The foregoing observations should make us reconsider the widely held view that birds live reconsider the widely held view that birds live only in the present. In fact, birds are aware of only in the present. In fact, birds are aware of more than immediately present stimuli; they more than immediately present stimuli; they remember the past and anticipate the future.remember the past and anticipate the future.—The Minds of Birds, Alexander Skutch

Page 3: Data and Computer Communications

Transport ProtocolsTransport Protocols end-to-end data transfer serviceend-to-end data transfer service shield upper layers from network detailsshield upper layers from network details reliable, connection orientedreliable, connection oriented

has greater complexityhas greater complexity eg. TCPeg. TCP

best effort, connectionlessbest effort, connectionless datagramdatagram eg. UDPeg. UDP

Page 4: Data and Computer Communications

TCP HeaderTCP Header

Page 5: Data and Computer Communications

Connection Oriented Connection Oriented Transport ProtocolsTransport Protocols

provides establishment, maintenance & provides establishment, maintenance & termination of a logical connectiontermination of a logical connection

most common servicemost common service used for a wide variety of applicationsused for a wide variety of applications is reliableis reliable but complexbut complex first discuss evolution from reliable to first discuss evolution from reliable to

unreliable network servicesunreliable network services

Page 6: Data and Computer Communications

Reliable Sequencing Network Reliable Sequencing Network ServiceService

assume virtually 100% reliable delivery by assume virtually 100% reliable delivery by network service of arbitrary length messagesnetwork service of arbitrary length messages eg. reliable packet switched network with X.25eg. reliable packet switched network with X.25 eg. frame relay with LAPF control protocoleg. frame relay with LAPF control protocol eg. IEEE 802.3 with connection oriented LLC serviceeg. IEEE 802.3 with connection oriented LLC service

transport service is a simple, end to end protocol transport service is a simple, end to end protocol between two systems on same networkbetween two systems on same network

issues are: addressing, multiplexing, flow control, issues are: addressing, multiplexing, flow control, connection establishment and terminationconnection establishment and termination

Page 7: Data and Computer Communications

AddressingAddressing establish identity of other transport entity by:establish identity of other transport entity by:

user identification (host, port)user identification (host, port)• a socket in TCPa socket in TCP

transport entity identification (on host)transport entity identification (on host)• specify transport protocol (TCP, UDP)specify transport protocol (TCP, UDP)

host address of attached network devicehost address of attached network device• in an internet, a global internet addressin an internet, a global internet address

network numbernetwork number transport layer passes host to network layertransport layer passes host to network layer

Page 8: Data and Computer Communications

Finding AddressesFinding Addresses know address ahead of timeknow address ahead of time Well-known addressesWell-known addresses

eg. common servers like FTP, SMTP etceg. common servers like FTP, SMTP etc name servername server

does directory lookupdoes directory lookup sending request to well-known address sending request to well-known address

which spawns new process to handle itwhich spawns new process to handle it

Page 9: Data and Computer Communications

(Multiplexing)(Multiplexing) of upper layers (downward multiplexing)of upper layers (downward multiplexing)

so multiple users employ same transport so multiple users employ same transport protocolprotocol

user identified by port number or service user identified by port number or service access pointaccess point

may also multiplex with respect to network may also multiplex with respect to network services used (upward multiplexing)services used (upward multiplexing) eg. multiplexing a single virtual X.25 circuit to eg. multiplexing a single virtual X.25 circuit to

a number of transport service usera number of transport service user

Page 10: Data and Computer Communications

Flow ControlFlow Control issues:issues:

longer transmission delay between transport entities longer transmission delay between transport entities compared with actual transmission time delays compared with actual transmission time delays communication of flow control infocommunication of flow control info

variable transmission delay so difficult to use timeoutsvariable transmission delay so difficult to use timeouts want TS flow control because:want TS flow control because:

receiving user can not keep upreceiving user can not keep up receiving transport entity can not keep upreceiving transport entity can not keep up

which can result in buffer overflowingwhich can result in buffer overflowing managing flow difficult because of gap between managing flow difficult because of gap between

sender and receiversender and receiver

Page 11: Data and Computer Communications

Coping with Flow Control Coping with Flow Control RequirementsRequirements

do nothingdo nothing segments that overflow are discardedsegments that overflow are discarded sender fail to get ACK and will retransmitsender fail to get ACK and will retransmit

refuse further segmentsrefuse further segments triggers network flow control but clumsytriggers network flow control but clumsy

use fixed sliding window protocoluse fixed sliding window protocol works well on reliable networkworks well on reliable network does not work well on unreliable networkdoes not work well on unreliable network

use credit schemeuse credit scheme

Page 12: Data and Computer Communications

Credit SchemeCredit Scheme decouples flow control from ACKdecouples flow control from ACK each octet has sequence numbereach octet has sequence number each transport segment has seq number (SN), each transport segment has seq number (SN),

ack number (AN) and window size (W) in headerack number (AN) and window size (W) in header sends seq number of first octet in segmentsends seq number of first octet in segment ACK includes (AN=i, W=j) which meansACK includes (AN=i, W=j) which means

all octets through SN=i-1 acknowledged, want i nextall octets through SN=i-1 acknowledged, want i next permission to send additional window of W=j octetspermission to send additional window of W=j octets

Page 13: Data and Computer Communications

Credit AllocationCredit Allocation

Page 14: Data and Computer Communications

Sending and Receiving Sending and Receiving PerspectivesPerspectives

Page 15: Data and Computer Communications

Establishment and Establishment and TerminationTermination

need connection establishment and need connection establishment and termination procedures to allow: termination procedures to allow: each end to know the other existseach end to know the other exists negotiation of optional parametersnegotiation of optional parameters triggers allocation of transport entity triggers allocation of transport entity

resourcesresources

Page 16: Data and Computer Communications

Connection State DiagramConnection State Diagram

Page 17: Data and Computer Communications

Connection EstablishmentConnection Establishment

Page 18: Data and Computer Communications

Connection TerminationConnection Termination either or both sides by mutual agreementeither or both sides by mutual agreement graceful or abrupt terminationgraceful or abrupt termination if graceful, initiator must:if graceful, initiator must:

send FIN to other end, requesting terminationsend FIN to other end, requesting termination place connection in FIN WAIT stateplace connection in FIN WAIT state when FIN received, inform user and close connectionwhen FIN received, inform user and close connection

other end must:other end must: when receives FIN must inform TS user and place when receives FIN must inform TS user and place

connection in CLOSE WAIT stateconnection in CLOSE WAIT state when TS user issues CLOSE primitive, send FIN & when TS user issues CLOSE primitive, send FIN &

close connectionclose connection

Page 19: Data and Computer Communications

Unreliable Network ServiceUnreliable Network Service more difficult case for transport protocol sincemore difficult case for transport protocol since

segments may get lostsegments may get lost segments may arrive out of ordersegments may arrive out of order

examples includeexamples include IP internet, frame relay using LAPF, IEEE 802.3 with IP internet, frame relay using LAPF, IEEE 802.3 with

unacknowledge connectionless LLCunacknowledge connectionless LLC issues:issues:

ordered delivery, retransmission strategy, duplication ordered delivery, retransmission strategy, duplication detection, flow control, connection establishment & detection, flow control, connection establishment & termination, crash recoverytermination, crash recovery

Page 20: Data and Computer Communications

Ordered DeliveryOrdered Delivery segments may arrive out of ordersegments may arrive out of order hence number segments sequentiallyhence number segments sequentially TCP numbers each octet sequentiallyTCP numbers each octet sequentially and segments are numbered by the first and segments are numbered by the first

octet number in the segmentoctet number in the segment

Page 21: Data and Computer Communications

Retransmission StrategyRetransmission Strategy retransmission of segment needed because retransmission of segment needed because

segment damaged in transitsegment damaged in transit segment fails to arrivesegment fails to arrive

transmitter does not know of failuretransmitter does not know of failure receiver must acknowledge successful receiptreceiver must acknowledge successful receipt

can use cumulative acknowledgement for efficiencycan use cumulative acknowledgement for efficiency sender times out waiting for ACK triggers sender times out waiting for ACK triggers

re-transmissionre-transmission

Page 22: Data and Computer Communications

Timer ValueTimer Value fixed timerfixed timer

based on understanding of network behaviorbased on understanding of network behavior can not adapt to changing network conditionscan not adapt to changing network conditions too small leads to unnecessary re-transmissionstoo small leads to unnecessary re-transmissions too large and response to lost segments is slowtoo large and response to lost segments is slow should be a bit longer than round trip timeshould be a bit longer than round trip time

adaptive schemeadaptive scheme may not ACK immediatelymay not ACK immediately can not distinguish between ACK of original segment can not distinguish between ACK of original segment

and re-transmitted segmentand re-transmitted segment conditions may change suddenlyconditions may change suddenly

Page 23: Data and Computer Communications

Duplication DetectionDuplication Detection if ACK lost, segment duplicated & re-transmittedif ACK lost, segment duplicated & re-transmitted receiver must recognize duplicatesreceiver must recognize duplicates if duplicate received prior to closing connectionif duplicate received prior to closing connection

receiver assumes ACK lost and ACKs duplicatereceiver assumes ACK lost and ACKs duplicate sender must not get confused with multiple ACKssender must not get confused with multiple ACKs need a sequence number space large enough to not need a sequence number space large enough to not

cycle within maximum life of segmentcycle within maximum life of segment

Page 24: Data and Computer Communications

Incorrect Incorrect Duplicate Duplicate DetectionDetection

Page 25: Data and Computer Communications

Flow ControlFlow Control credit allocation quite robust with unreliable netcredit allocation quite robust with unreliable net

can ack data & grant creditcan ack data & grant credit or just one or otheror just one or other lost ACK recovers on next receivedlost ACK recovers on next received

have problem if AN=i, W=0 closing windowhave problem if AN=i, W=0 closing window then send AN=i, W=j to reopen, but if this is lost then send AN=i, W=j to reopen, but if this is lost

sender thinks window closed, receiver thinks it opensender thinks window closed, receiver thinks it open solution is to use persist timersolution is to use persist timer if timer expires, send somethingif timer expires, send something

could be re-transmission of previous segmentcould be re-transmission of previous segment

Page 26: Data and Computer Communications

Connection EstablishmentConnection Establishment Two-way handshakeTwo-way handshake

A send SYN, B replies with SYNA send SYN, B replies with SYN lost SYN handled by re-transmissionlost SYN handled by re-transmission ignore duplicate SYNs once connectedignore duplicate SYNs once connected

lost or delayed data segments can cause lost or delayed data segments can cause connection problemsconnection problems eg. segment from old connectioneg. segment from old connection

Page 27: Data and Computer Communications

Two-Way Two-Way Handshake:Handshake:

Obsolete Obsolete Data Data

SegmentSegment

Page 28: Data and Computer Communications

Two-Way Handshake:Two-Way Handshake:Obsolete SYN SegmentObsolete SYN Segment

Page 29: Data and Computer Communications

Three-Way Three-Way Handshake:Handshake:

State State DiagramDiagram

Page 30: Data and Computer Communications

Three WayThree WayHandshake:Handshake:ExamplesExamples

Page 31: Data and Computer Communications

Connection TerminationConnection Termination like connection, need 3-way handshakelike connection, need 3-way handshake misordered segments could cause:misordered segments could cause:

entity in CLOSE WAIT state sends last data segment, entity in CLOSE WAIT state sends last data segment, followed by FINfollowed by FIN

FIN arrives before last data segmentFIN arrives before last data segment receiver accepts FIN, closes connection, loses datareceiver accepts FIN, closes connection, loses data

need to associate sequence number with FINneed to associate sequence number with FIN receiver waits for all segments before FIN receiver waits for all segments before FIN

sequence numbersequence number

Page 32: Data and Computer Communications

Connection Termination Connection Termination Graceful CloseGraceful Close

also have problems with loss of segments also have problems with loss of segments and obsolete segmentsand obsolete segments

need graceful close which will:need graceful close which will: send FIN i and receive AN i+1send FIN i and receive AN i+1 receive FIN j and send AN j+1receive FIN j and send AN j+1 wait twice maximum expected segment wait twice maximum expected segment

lifetimelifetime

Page 33: Data and Computer Communications

Failure RecoveryFailure Recovery after restart all state info is lostafter restart all state info is lost may have half open connectionmay have half open connection

as side that did not crash still thinks it is connectedas side that did not crash still thinks it is connected close connection using keepalive timerclose connection using keepalive timer

wait for ACK for (time out) * (number of retries)wait for ACK for (time out) * (number of retries) when expired, close connection and inform userwhen expired, close connection and inform user

send RST i in response to any i segment arrivingsend RST i in response to any i segment arriving user must decide whether to reconnectuser must decide whether to reconnect

have problems with lost or duplicate datahave problems with lost or duplicate data

Page 34: Data and Computer Communications

TCPTCP Transmission Control Protocol (RFC 793)Transmission Control Protocol (RFC 793) connection oriented, reliable communicationconnection oriented, reliable communication over reliable and unreliable (inter)networksover reliable and unreliable (inter)networks two ways of labeling data:two ways of labeling data:

data stream pushdata stream push• user requires transmission of all data up to push flaguser requires transmission of all data up to push flag• receiver will deliver in same mannerreceiver will deliver in same manner• avoids waiting for full buffersavoids waiting for full buffers

urgent data signalurgent data signal• indicates urgent data is upcoming in streamindicates urgent data is upcoming in stream• user decides how to handle ituser decides how to handle it

Page 35: Data and Computer Communications

TCP ServicesTCP Services a complex set of primitives:a complex set of primitives:

incl. passive & active open, active open with incl. passive & active open, active open with data, send, allocate, close, abort, statusdata, send, allocate, close, abort, status

passive open indicates will accept connectionspassive open indicates will accept connections active open with data sends data with openactive open with data sends data with open

and parameters:and parameters: incl. source port, destination port & address, incl. source port, destination port & address,

timeout, security, data, data length, PUSH & timeout, security, data, data length, PUSH & URGENT flags, send & receive windows, URGENT flags, send & receive windows, connection state, amount awaiting ACKconnection state, amount awaiting ACK

Page 36: Data and Computer Communications

TCP HeaderTCP Header

Page 37: Data and Computer Communications

TCP and IPTCP and IP not all parameters used by TCP are in its not all parameters used by TCP are in its

headerheader TCP passes some parameters down to IPTCP passes some parameters down to IP

precedenceprecedence normal delay/low delaynormal delay/low delay normal throughput/high throughputnormal throughput/high throughput normal reliability/high reliabilitynormal reliability/high reliability securitysecurity

min overhead for each PDU is 40 octetsmin overhead for each PDU is 40 octets

Page 38: Data and Computer Communications

TCP MechanismsTCP Mechanisms Connection Establishment Connection Establishment

Three-way handshakeThree-way handshake SYN, SYN-ACK, ACKSYN, SYN-ACK, ACK

connection determined by source and connection determined by source and destination sockets (host, port)destination sockets (host, port)

can only have a single connection can only have a single connection between any unique pairs of portsbetween any unique pairs of ports

but one port can connect to multiple but one port can connect to multiple different destinations (different ports)different destinations (different ports)

Page 39: Data and Computer Communications

TCP MechanismsTCP Mechanisms Data Transfer Data Transfer

data transfer a logical stream of octetsdata transfer a logical stream of octets octets numbered modulo 2octets numbered modulo 22323

flow control uses credit allocation of number of flow control uses credit allocation of number of octetsoctets

data buffered at transmitter and receiverdata buffered at transmitter and receiver sent when transport entity readysent when transport entity ready unless PUSH flag used to force sendunless PUSH flag used to force send

can flag data as URGENT, sent immediatelycan flag data as URGENT, sent immediately if receive data not for current connection, RST if receive data not for current connection, RST

flag is set on next segment to reset connectionflag is set on next segment to reset connection

Page 40: Data and Computer Communications

TCP MechanismsTCP Mechanisms Connection Termination Connection Termination

graceful closegraceful close TCP user issues CLOSE primitiveTCP user issues CLOSE primitive transport entity sets FIN flag on last segment sent transport entity sets FIN flag on last segment sent

with last of datawith last of data abrupt termination by ABORT primitiveabrupt termination by ABORT primitive

entity abandons all attempts to send or receive dataentity abandons all attempts to send or receive data RST segment transmitted to other endRST segment transmitted to other end

Page 41: Data and Computer Communications

(TCP Implementation Options)(TCP Implementation Options) TCP standard precisely specifies protocolTCP standard precisely specifies protocol have some implementation policy options:have some implementation policy options:

sendsend deliverdeliver acceptaccept retransmitretransmit acknowledgeacknowledge

implementations may choose alternative implementations may choose alternative options which may impact performanceoptions which may impact performance

Page 42: Data and Computer Communications

(Send Policy)(Send Policy) if no push or close TCP entity transmits at if no push or close TCP entity transmits at

its own convenience in credit allocationits own convenience in credit allocation data buffered in transmit bufferdata buffered in transmit buffer may construct segment per batch of data may construct segment per batch of data

from userfrom user quick response but higher overheadsquick response but higher overheads

may wait for certain amount of datamay wait for certain amount of data slower response but lower overheadsslower response but lower overheads

Page 43: Data and Computer Communications

(Deliver Policy )(Deliver Policy ) in absence of push, can deliver data at in absence of push, can deliver data at

own convenienceown convenience may deliver from each segment receivedmay deliver from each segment received

higher O/S overheads but more responsivehigher O/S overheads but more responsive may buffer data from multiple segmentsmay buffer data from multiple segments

less O/S overheads but slowerless O/S overheads but slower

Page 44: Data and Computer Communications

(Accept Policy)(Accept Policy) segments may arrive out of ordersegments may arrive out of order in orderin order

only accept segments in orderonly accept segments in order discard out of order segmentsdiscard out of order segments simple implementation, but burdens networksimple implementation, but burdens network

in windowsin windows accept all segments within receive windowaccept all segments within receive window reduce transmissionsreduce transmissions more complex implementation with bufferingmore complex implementation with buffering

Page 45: Data and Computer Communications

(Retransmit Policy)(Retransmit Policy) TCP has a queue of segments transmitted TCP has a queue of segments transmitted

but not acknowledgedbut not acknowledged will retransmit if not ACKed in given timewill retransmit if not ACKed in given time

first only - single timer, send one segment only first only - single timer, send one segment only when timer expires, efficient, has delayswhen timer expires, efficient, has delays

batch - single timer, send all segments when batch - single timer, send all segments when timer expires, has unnecessary transmissionstimer expires, has unnecessary transmissions

individual - timer for each segment, complexindividual - timer for each segment, complex effectivenesseffectiveness depends in part on receiver’s depends in part on receiver’s

accept policyaccept policy

Page 46: Data and Computer Communications

(Acknowledgement Policy)(Acknowledgement Policy) immediateimmediate

send empty ACK for each accepted segmentsend empty ACK for each accepted segment simple at cost of extra transmissionssimple at cost of extra transmissions

cumulativecumulative piggyback ACK on suitable outbound data piggyback ACK on suitable outbound data

segments unless persist timer expiressegments unless persist timer expires when send empty ACKwhen send empty ACK more complex but efficientmore complex but efficient

Page 47: Data and Computer Communications

(Congestion Control)(Congestion Control) flow control also used for congestion flow control also used for congestion

controlcontrol recognize increased transit times & dropped recognize increased transit times & dropped

packetspackets react by reducing flow of datareact by reducing flow of data

RFC’s 1122 & 2581 detail extensionsRFC’s 1122 & 2581 detail extensions Tahoe, Reno & NewReno implementationsTahoe, Reno & NewReno implementations

two categories of extensions:two categories of extensions: retransmission timer management retransmission timer management window managementwindow management

Page 48: Data and Computer Communications

Retransmission Timer Retransmission Timer ManagementManagement

static timer likely too long or too shortstatic timer likely too long or too short estimate round trip delay by observing pattern of delay estimate round trip delay by observing pattern of delay

for recent segmentsfor recent segments set time to value a bit greater than estimateset time to value a bit greater than estimate simple average over a number of segmentssimple average over a number of segments exponential average using time series (RFC793)exponential average using time series (RFC793) RTT Variance Estimation (Jacobson’s algorithm)RTT Variance Estimation (Jacobson’s algorithm)

Definitions:Definitions: RTT: round trip timeRTT: round trip time RTO: retransmission timeoutRTO: retransmission timeout

Page 49: Data and Computer Communications

Use of Use of Exponential Exponential

AveragingAveraging

Page 50: Data and Computer Communications

Jacobson’s Jacobson’s RTO RTO

CalculationCalculation

Page 51: Data and Computer Communications

Exponential RTO BackoffExponential RTO Backoff timeout probably due to congestiontimeout probably due to congestion

dropped packet or long round trip timedropped packet or long round trip time hence maintaining RTO is not good ideahence maintaining RTO is not good idea better to increase RTO each time a better to increase RTO each time a

segment is segment is re-transmittedre-transmitted RTO = q*RTORTO = q*RTO commonly q=2 (binary exponential backoff)commonly q=2 (binary exponential backoff) as in ethernet CSMA/CDas in ethernet CSMA/CD

Page 52: Data and Computer Communications

Karn’s AlgorithmKarn’s Algorithm if segment is re-transmitted, ACK may be for:if segment is re-transmitted, ACK may be for:

first copy of the segment (longer RTT than expected)first copy of the segment (longer RTT than expected) second copysecond copy

no way to tellno way to tell don’t measure RTT for re-transmitted segmentsdon’t measure RTT for re-transmitted segments calculate backoff when re-transmission occurscalculate backoff when re-transmission occurs use backoff RTO until ACK arrives for segment use backoff RTO until ACK arrives for segment

that has not been re-transmittedthat has not been re-transmitted

Page 53: Data and Computer Communications

Window ManagementWindow Management slow startslow start

larger windows cause problem on connection createdlarger windows cause problem on connection created at start limit TCP to 1 segmentat start limit TCP to 1 segment increase when data ACK, exponential growthincrease when data ACK, exponential growth

dynamic windows sizing on congestiondynamic windows sizing on congestion when a timeout occurs perhaps due to congestionwhen a timeout occurs perhaps due to congestion set slow start threshold to half current congestion set slow start threshold to half current congestion

windowwindow set window to 1 and slow start until thresholdset window to 1 and slow start until threshold beyond threshold, increase window by 1 for each RTTbeyond threshold, increase window by 1 for each RTT

Page 54: Data and Computer Communications

Window ManagementWindow Management

Page 55: Data and Computer Communications

(Fast Retransmit (Fast Retransmit Fast Recovery) Fast Recovery)

retransmit timer rather longer than RTTretransmit timer rather longer than RTT if segment lost, TCP slow to retransmitif segment lost, TCP slow to retransmit fast retransmitfast retransmit

if receive 4 ACKs for same segment then if receive 4 ACKs for same segment then immediately retransmit since likely lostimmediately retransmit since likely lost

fast recoveryfast recovery lost segment means some congestionlost segment means some congestion halve window then increase linearlyhalve window then increase linearly avoids slow-startavoids slow-start

Page 56: Data and Computer Communications

User Datagram ProtocolUser Datagram Protocol(UDP)(UDP)

connectionless service for application level connectionless service for application level procedures specified in RFC 768procedures specified in RFC 768 unreliableunreliable delivery & duplication control not guaranteeddelivery & duplication control not guaranteed

reduced overheadreduced overhead least common denominator serviceleast common denominator service uses:uses:

inward data collectioninward data collection outward data disseminationoutward data dissemination request-responserequest-response Real-time applicationReal-time application

Page 57: Data and Computer Communications

UDP HeaderUDP Header

Page 58: Data and Computer Communications

SummarySummary connection-oriented network and transport connection-oriented network and transport

mechanisms and servicesmechanisms and services TCP services, mechanisms, policiesTCP services, mechanisms, policies TCP congestion controlTCP congestion control UDPUDP