Transport Layer - TCP
-
Upload
phoebe-sykes -
Category
Documents
-
view
29 -
download
0
description
Transcript of Transport Layer - TCP
TCP: A Closer Look Browser does not send HTTP-Request-PDUs
directly to the webserver application– The application layer programs are not
physically connected– Browser sends HTTP-Request-PDU to the user
PC’s transport layer process for delivery
Browser
TransportProcess
HTTP-Request-PDU
TCP: A Closer Look
Transport layer process stores the HTTP-Request-PDU Temporarily
Browser
TransportProcess
TransportProcess
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-PDUs to handle a single HTTP request-response cycle in HTTP 1.0
Browser
TransportProcess
TransportProcess
TCP/IP: A Closer Look
The TCP header has a flags field with 1-bit SYN, ACK, and FIN fields.– SYN bit set to 1 to request connection– ACK bit set to 1 to acknowledge a received
TCP-PDU– FIN bit set to 1 to inform of closure
Flags Field
TCP-Header
TCP: A Closer Look Opening a connection takes 3 TCP-PDUs
– Second message asks to open a connection and also acknowledges the first SYN message
User PCTransportProcess
WebserverTransportProcess
SYN
SYN, ACK
ACK
TCP: A Closer Look Sending the HTTP-Request-PDU requires 2 TCP-PDUs
– Sends HTTP-Request-PDU in data field of a TCP-PDU– Receives an ACK TCP-PDU
User PCTransportProcess
WebserverTransportProcess
TCP-PDU containingHTTP-Request-PDU
ACK
Delivering the HTTP-Response-PDU Transport layer process on the webserver
receives the TCP-PDU delivering the HTTP-Request-PDU– The transport process on the webserver
passes the HTTP-Request-PDU in the TCP-PDU data field to the webserver application program Webserver
Application
TransportProcess
HTTP-Request-PDU
Delivering the HTTP-Response-PDU Webserver application creates the HTTP-
Response-PDU– Webserver application passes the
HTTP-Response-PDU to the webserver transport layer process for delivery to the user PC transport layer process
WebserverApplication
TransportProcess
HTTP-Response-PDU
TCP: A Closer Look Fragmentation of HTTP-Response-PDU
– HTTP-Response-PDUs usually are large files
– TCP-PDUs are limited to a certain maximum segment size (MSS)
• Often only 512 bytes
– Typical HTTP-Response-PDU must be fragmented into multiple TCP-PDUs containing parts of the HTTP-response-PDU
HTTP-Response-PDU
TCP-PDU-3TCP-PDU-2TCP-PDU-1
A Closer Look at TCP Sample Fragmentation Calculation
– 20 KB Size of HTTP-Response-PDU.Varies. 20KB is only an example
– 20,480 octets 1,024 bytes per KB– 550 octets Maximum segment size (MSS).
Varies. 550 is only an example.– 530 octets Maximum data per TCP-PDU
(Header has 20 octets)– 38.6 Size of HTTP-Response PDU
divided by maximum data/PDU– 39 Number of TCP-PDUs needed.
(round up)
TCP: A Closer Look Sending the HTTP-Response-PDU takes many
TCP-PDUs– Each is acknowledged
User PCTransportProcess
WebserverTransportProcess
Response TCP-PDU 1
ACK for 1
ACK for 2
Response TCP-PDU 2
TCP: A Closer Look Closing the Connection takes 4 TCP-PDUs
– Initiated by the webserver transport process when it finishes sending the last HTTP-Response-PDU fragment.
User PCTransportProcess
WebserverTransportProcess
FIN
FIN
ACK
ACK
TCP Connections: Recap
For EACH HTTP request-response cycle…
– 3 TCP-PDUs to open the connection
– 2 TCP-PDU to send the HTTP request and get an acknowledgement
– N data TCP-PDUs to send the HTTP-Response-PDU and get acknowledgements
– 4 TCP-PDUs to close the connection
– For EACH HTTP request-response cycle at the application layer
TCP: Error Handling
TCP is reliable--it does error correction
– Each TCP-PDU has a sequence number that increases with each TCP-PDU a transport process sends
– ACKs acknowledge a specific TCP-PDU in the sequence
– If a TCP-PDU is not acknowledged, the other side retransmits it after awhile
– This adds TCP-PDUs beyond the ones we have seen
TCP: Why Connections? Opens, closes, and ACKs create overhead, so
undesirable Why do it?
– Allows sequence numbers, so that errors can be handled easily
– Creates sequence numbers, so that fragmentation 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
TCP-Header Fields in TCP Header
– Shows 32 bits on each row (0 to 31)– Note: start with zero
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-Header Port number designates and application program
– E.g, well-known port number for HTTP is 80– Other applications also have well-known port numbers
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-Header Sequence and Acknowledgement Numbers
– To be sure each TCP-PDU has arrived– To place arriving TCP-PDUs in order– To allow a specific TCP-PDU to be acknowledged
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-Header Flags
– 1 bit each– SYN, FIN, ACK are three of the 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-Header Window Size
– Number of bytes other side can send beyond the TCP-PDU being acknowledged
– Initially set to allow one TCP-PDU (slow start)
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-Header
TCP Checksum– To check for an error anywhere in the whole TCP-
PDU, including the data field
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-Header Options
– Rarely used– PAD set to bring options to 32-bit boundary
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)
New: Notin Book