Documente Academic
Documente Profesional
Documente Cultură
TCP © Dr. Ayman Abdel-Hamid, CS4254 Spring 2006 1 TCP © Dr. Ayman Abdel-Hamid, CS4254 Spring 2006 2
Process-to-process delivery
TCP © Dr. Ayman Abdel-Hamid, CS4254 Spring 2006 3 TCP © Dr. Ayman Abdel-Hamid, CS4254 Spring 2006 4
1
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
9Local IP address, local port, and each message to
9foreign IP address, foreign port appropriate process
TCP © Dr. Ayman Abdel-Hamid, CS4254 Spring 2006 7 TCP © Dr. Ayman Abdel-Hamid, CS4254 Spring 2006 8
2
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 9Sender window includes bytes sent but not acknowledged
¾Pointer to bytes sent, but not yet acknowledged 9Receiver window (number of empty locations in receiver buffer)
9Receiver advertises window size in ACKs
9Sender window includes bytes sent but not acknowledged
¾Sender window <= receiver window (flow control)
¾Pointer to bytes that cannot yet be sent
9Sliding sender window (without a change in receiver’s advertised
window)
9Expanding sender window (receiving process consumes data faster than
it receives Æ receiver window size increases)
9Shrinking sender window (receiving process consumes data more
slowly than it receives Æ receiver window size reduces)
9Closing sender window (receiver advertises a window of zero)
TCP © Dr. Ayman Abdel-Hamid, CS4254 Spring 2006 13 TCP © Dr. Ayman Abdel-Hamid, CS4254 Spring 2006 14
40
36 ¾Keep sequence numbers and window sizes for each direction
32
28
of data flow
24
Series1
20
16
12
8
4
0
0 2 4 6 8 10 12 14 16 18 20 22 24 26
Transmission number
TCP © Dr. Ayman Abdel-Hamid, CS4254 Spring 2006 17 TCP © Dr. Ayman Abdel-Hamid, CS4254 Spring 2006 18
3
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 © Dr. Ayman Abdel-Hamid, CS4254 Spring 2006 19 TCP © Dr. Ayman Abdel-Hamid, CS4254 Spring 2006 20
•FIN: Finish
•Step 1 can be sent with data
•Steps 2 and 3 can be combined into 1 segment
TCP © Dr. Ayman Abdel-Hamid, CS4254 Spring 2006 21 TCP © Dr. Ayman Abdel-Hamid, CS4254 Spring 2006 22
TCP © Dr. Ayman Abdel-Hamid, CS4254 Spring 2006 23 TCP © Dr. Ayman Abdel-Hamid, CS4254 Spring 2006 24
4
State Transition Diagram 3/4 State Transition Diagram 4/4
State Description
TCP © Dr. Ayman Abdel-Hamid, CS4254 Spring 2006 29 TCP © Dr. Ayman Abdel-Hamid, CS4254 Spring 2006 30
5
TCP Header Fields 2/2
•Sequence Number: position of the data in the sender’s byte stream
•Acknowledgment Number: position of the byte that the source
expects to receive next (valid if ACK bit set)
•Header Length: header size in 32-bit units. Value ranges from [5-15]
•Window: advertised window size in bytes
•Urgent
9defines end of urgent data (or “out-of-band”) data and start of normal data
9Added to sequence number (valid only if URG bit is set)
•Checksum: 16-bit CRC (Cyclic Redundancy Check) over header
and data
•Options: up to 40 bytes of options
TCP © Dr. Ayman Abdel-Hamid, CS4254 Spring 2006 31