Outline: Transmission Control Protocol (TCP)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Outline

•Transmission Control Protocol

Transmission Control Protocol (TCP)

Transport Layer 1/2 Transport Layer 2/2

Process-to-process delivery

Transport Layer Addressing Port Numbers


Addresses •Port numbers are 16-bit integers (0  65,535)
•Data link layer  MAC address Servers use well know ports, 0-1023 are privileged
•Network layer  IP address Clients use ephemeral (short-lived) ports
•Transport layer  Port number (choose among multiple
processes running on destination host) •Internet Assigned Numbers Authority (IANA) maintains a list of
port number assignment
Well-known ports (0-1023)  controlled and assigned by
IANA
Registered ports (1024-49151)  IANA registers and lists
use of ports as a convenience (49151 is ¾ of 65536)
Dynamic ports (49152-65535)  ephemeral ports
For well-known port numbers, see /etc/services on a UNIX or
Linux machine
Socket Addressing Multiplexing and Demultiplexing
•Process-to-process delivery needs two identifiers Multiplexing
IP address and Port number Sender side may have
Combination of IP address and port number is called a several processes that
socket address (a socket is a communication endpoint) need to send packets
Client socket address uniquely identifies client process (albeit only 1 transport-
layer protocol)
Server socket address uniquely identifies server process
Demultiplexing
•Transport-layer protocol needs a pair of socket addresses
At receiver side, after
Client socket address error checking and
Server socket address header dropping,
For example, socket pair for a TCP connection is a 4-tuple transport-layer delivers
Local IP address, local port, and each message to
foreign IP address, foreign port appropriate process

Transmission Control Protocol 1/10 Transmission Control Protocol 2/10


•TCP must perform typical transport layer functions:
•Reliable
Segmentation  breaks message into packets
End-to-end error control since IP is an unreliable Service requires ACK and performs retransmission
End-to-end flow control  to avoid buffer overflow If ACK not received, retransmit and wait a longer time for
Multiplexing and demultiplexing sessions ACK. After a number of retransmissions, will give up
•TCP is [originally described in RFC 793, 1981] How long to wait for ACK? (dynamically compute RTT for
Reliable estimating how long to wait for ACKs, might be ms for LANs or
seconds for WANs)
Connection-oriented  virtual circuit
Stream-oriented  users exchange streams of data RTT =  * old RTT + (1- )* new RTT where  usually 90%
Full duplex  concurrent transfers can take place in both Most common, Retransmission time = 2* RTT
directions Acknowledgments can be “piggy-backed” on reverse direction
Buffered  TCP accepts data and transmits when appropriate data packets or sent as separate packets
(can be overridden with “push”)

Transmission Control Protocol 3/10 Transmission Control Protocol 4/10


•Sequence Numbers •Sending and Receiving buffers
Associated with every byte that it sends Senders and receivers may not produce and consume data at
To detect packet loss, reordering and duplicate removal same speed
2 buffers for each direction (sending and receiving buffer)
Two fields are used sequence number and acknowledgment
number. Both refer to byte number and not segment number
Sequence number for each segment is the number of the first
byte carried in that segment
The ACK number denotes the number of the next byte that
this party expects to receive (cumulative)
If an ACK number is 5643  received all bytes from beginning up to
5642
This acknowledges all previous bytes as received error-free
Transmission Control Protocol 5/10 Transmission Control Protocol 6/10
•Flow Control
•TCP uses a sliding window mechanism for flow control
Tell peer exactly how many bytes it is willing to accept
•Sender maintains 3 pointers for each connection (advertised window  sender can not overflow receiver buffer)
Pointer to bytes sent and acknowledged Sender window includes bytes sent but not acknowledged
Pointer to bytes sent, but not yet acknowledged Receiver window (number of empty locations in receiver buffer)
Receiver advertises window size in ACKs
Sender window includes bytes sent but not acknowledged
Sender window <= receiver window (flow control)
Pointer to bytes that cannot yet be sent
Sliding sender window (without a change in receiver’s advertised
window)
Expanding sender window (receiving process consumes data faster than
it receives  receiver window size increases)
Shrinking sender window (receiving process consumes data more
slowly than it receives  receiver window size reduces)
Closing sender window (receiver advertises a window of zero)

Transmission Control Protocol 7/10 Transmission Control Protocol 8/10


•Error Control •Congestion Control
Mechanisms for detecting corrupted segments, lost segments, TCP assumes the cause of a lost segment is due to congestion
out-of-order segments, and duplicated segments in the network
Tools: checksum (corruption), ACK, and time-out (one time- If the cause of the lost segment is congestion, retransmission of
out counter per segment) the segment does not remove the problem, it actually aggravates
Lost segment or corrupted segment are the same situation: it
segment will be retransmitted after time-out (no NACK in
The network needs to tell the sender to slow down (affects the
TCP)
sender window size in TCP)
Duplicate segment (destination discards)
Out-of-order segment (destination does not acknowledge, Actual window size = Min (receiver window size, congestion
until it receives all segments that precede it) window size)
Lost ACK (loss of an ACK is irrelevant, since ACK The congestion window is flow control imposed by the sender
mechanism is cumulative) The advertised window is flow control imposed by the receiver

Transmission Control Protocol 9/10 Transmission Control Protocol 10/10


•Congestion Control
•Full-Duplex
send and receive data in both directions.
Keep sequence numbers and window sizes for each direction
of data flow
TCP Connection Establishment TCP Options
Each SYN can contain TCP options
•MSS Option
maximum segment  the maximum amount of data it is
Passive open willing to accept in each TCP segment
Sending TCP uses receiver’s MSS as its MSS
•Window Scale Option
maximum window is 65,535 bytes (corresponding field in TCP
header occupies 16 bits)
it can be scaled (left-shifted) by 0-14 bits providing a
maximum of 65,535 * 214 bytes (one gigabyte)
Option needed for high-speed connections or long delay paths
SYN: Synchronize
In this case, the other side must send the option with its
ACK: Acknowledge
SYN

TCP MSS and output TCP Connection Termination


•TCP MSS is = (interface MTU – fixed sizes of IP and TCP headers (20 bytes))
MSS on an Ethernet (IPv4)= 1460 bytes (1500 (why?) - 40)
•Successful return from write implies you can reuse application buffer

•FIN: Finish
•Step 1 can be sent with data
•Steps 2 and 3 can be combined into 1 segment

You might also like