tcp: a closer look

24
TCP: A Closer Look Transmission Control Protocol

Upload: reese-walter

Post on 02-Jan-2016

67 views

Category:

Documents


3 download

DESCRIPTION

TCP: A Closer Look. Transmission Control Protocol. TCP: A Closer Look. Browser does not send HTTP Requests directly to the webserver application The application layer programs are not physically connected Browser sends HTTP Request to the user PC’s transport layer process for delivery. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: TCP: A Closer Look

TCP: A Closer Look

Transmission Control Protocol

Page 2: TCP: A Closer Look

TCP: A Closer Look• Browser does not send HTTP Requests

directly to the webserver application– The application layer programs are not

physically connected– Browser sends HTTP Request to the user

PC’s transport layer process for delivery

Browser

TransportProcess

HTTP Request

Page 3: TCP: A Closer Look

TCP: A Closer Look

• Transport layer process stores the HTTP Request Temporarily

Browser

TransportProcess

TransportProcess

Page 4: TCP: A Closer Look

TCP: A Closer Look• User PC transport process opens a

connection to the webserver transport layer process– This connection can be used to send several

TCP segments to handle a each HTTP request-response cycle

Browser

TransportProcess

TransportProcess

Page 5: TCP: A Closer Look

TCP: A Closer Look• TCP has a Flags Field

– Six one-bit flags

Source Port # (16) Destination Port # (16)

Sequence Number (32 bits)

Acknowledgement Number (32 bits)

Hdr Len(4) Flags (6) Window Size (16)

Options (if any) PAD

Bit 0 Bit 31

Reserved (6)

TCP Checksum (16) Urgent Pointer (16)

TCP Segment

Data Field

Page 6: TCP: A Closer Look

TCP/IP: A Closer Look

• Three Flags are Widely Used– SYN bit set to 1 in a TCP segment to request a

connection– ACK bit set to 1 in a segment to acknowledge a

received TCP segment– FIN bit set to 1 in a segment to inform of a connection

closure

Hdr Len(4) Flags (6) Window Size (16)Reserved (6)

Page 7: TCP: A Closer Look

TCP: A Closer Look• Opening a connection takes 3 Segments

– Second TCP segment asks to open a connection and also acknowledges the first SYN message

User PCTransportProcess

WebserverTransportProcess

SYN

SYN, ACK

ACK

Page 8: TCP: A Closer Look

TCP: A Closer Look• Next, user PC sends the HTTP Request

– Sends HTTP Request in data field of a TCP segment– Receives an ACK TCP segment to acknowledge

receipt

User PCTransportProcess

WebserverTransportProcess

TCP segment containingHTTP Request

ACK

Page 9: TCP: A Closer Look

Delivering the HTTP Response• Transport layer process on the webserver

receives the TCP segment delivering the HTTP Request– The transport process on the webserver

passes the HTTP Request in the TCP segment data field to the webserver application program Webserver

Application

TransportProcess

HTTP Request

Page 10: TCP: A Closer Look

Delivering the HTTP Response• Webserver application creates the HTTP

Response message– Webserver application passes the HTTP

Response message to the webserver transport layer process for delivery to the user PC transport layer process

WebserverApplication

TransportProcess

HTTP Response

Page 11: TCP: A Closer Look

Delivering the HTTP Response• Webserver Transport Process Delivers

the Response– User PC transport process sends an

acknowledgement

User PCTransportProcess

WebserverTransportProcess

TCP segment containingHTTP Response

ACK

Page 12: TCP: A Closer Look

TCP: A Closer Look• Multiple HTTP Request-Response

Cycles can be Handled with a Single TCP Connection in HTTP/1.1 and later versions

• Each will have the following:– TCP segment carrying the request– Acknowledgement of this segment– TCP segment carrying the response– Acknowledgement of response segment

Page 13: TCP: A Closer Look

TCP: A Closer Look

• Closing the Connection takes 4 TCP Segments– Initiated by the browser when it downloads

the last file

User PCTransportProcess

WebserverTransportProcess

FIN

FIN

ACK

ACK

Page 14: TCP: A Closer Look

TCP: A Closer Look

• Refinement– ACKs have to be delivered quickly

– Can be sent in TCP segments that carry only ACKs

– However, if a data TCP segment is returned quickly, the ACK will be included with this segment

– This segment will contain both new data and an acknowledgement of a previously received TCP segment

– Reduces TCP segment transmissions

Page 15: TCP: A Closer Look

TCP Connections: Recap• For EACH HTTP request-response cycle…

– 3 TCP segments to open the connection

– 2 TCP segments to send the HTTP request and get an acknowledgement for EACH request-response cycle

– 2 TCP segments to send the HTTP response and get an acknowledgement for EACH request-response cycle

– 4 TCP segments to close the connection

– A very chatty protocol

Page 16: TCP: A Closer Look

TCP: Error Handling• TCP is reliable--it does error correction

– Each TCP segment has a sequence number that increases with each TCP segment a transport process sends

Source Port # (16) Destination Port # (16)

Sequence Number (32 bits)

Bit 0 Bit 31TCP Segment

Page 17: TCP: A Closer Look

TCP: Error Handling• TCP is reliable--it does error correction

– ACKs acknowledge a specific TCP segment in the sequence

– If a TCP segment is not acknowledged, the other side retransmits it after awhile

– This adds TCP segments beyond the ones we have seen

Page 18: TCP: A Closer Look

TCP: Error Handling• TCP is reliable--it Places TCP Segments

in Order

– TCP segments are encapsulated in IP packets

– IP does not guarantee that packets will arrive in order

– TCP can place TCP segments in order based on their sequence numbers

Page 19: TCP: A Closer Look

TCP: Error Handling• TCP Reliability in Perspective

– Provides clean application data to application program

– If data link layer frame or IP packet is lost at lower layers, receiving transport process will not acknowledge a segment

– The sending transport process will resend automatically

– So TCP protects against errors at lower layers as well as transport layer errors

Page 20: TCP: A Closer Look

TCP: Why Connections?• Opens, closes, and ACKs create overhead, so

undesirable• Why do it?

– Allows sequence numbers, so that errors can be handled easily

• Overall, TCP is a high-overhead, highly reliable transport layer protocol that catches any errors at lower layers, giving “clean” service to the application programs

Page 21: TCP: A Closer Look

TCP: Refinements• Fragmentation

– Transport process must fragments long application messages (break them into several pieces) and transmits them in several TCP segments

– Each of these segments must be acknowledged separately

– So when long files are downloaded in webservice, many more TCP segments will be generated than we discussed above

Mod A

Page 22: TCP: A Closer Look

TCP: Refinements

• Flow Control– TCP implements flow control, so that one

transport process will not overload its peer by transmitting too quickly

Mod A

Page 23: TCP: A Closer Look

User Datagram Protocol (UDP)• UDP

– User Datagram Protocol– Alternative to TCP at the transport layer– Lightweight

• No connections

• No error correction

• Reduces work source and destination host must do

Page 24: TCP: A Closer Look

User Datagram Protocol (UDP)• UDP

– Good for voice, for which the delay of error correction would be unacceptable

– Good for applications for which the cost of an occasional message is small compared to the cost of connection-oriented service