CSCE 515 : Computer Network Programming
E N D
Presentation Transcript
CSCE 515:Computer Network Programming Chin-Tser Huang huangct@cse.sc.edu University of South Carolina
Transmission Control Protocol (TCP) • A connection-oriented transport layer protocol • Transmit byte streams between both ends of connection • Full-duplex service • Provide reliable service
Reliability of TCP • Application data is broken into best sized chunks to send, called TCP segment • TCP sends acknowledgment for data received from other end of connection • TCP maintains a timer for each segment • Segment retransmitted if no acknowledgment in time • TCP maintains an end-to-end checksum on its header and data • If checksum of received segment is invalid, discard the segment
Reliability of TCP (cont’d) • TCP resequences out-of-order data before passing them to the application • TCP discards duplicate data • TCP provides flow control • TCP only allows other end to send as much data as it has buffer for
TCP Header 0 15 16 31 source port number destination port number sequence number acknowledgment number 20 bytes header length reserved U R G A C K P S H R S T S Y N F I N window size TCP checksum urgent pointer option (if any) data (if any)
TCP Connection Establishment • Three-way handshake • Client sends a SYN segment specifying server’s port number and client’s initial sequence number (ISN) • Server responds with a SYNACK segment containing server’s ISN and acknowledging client’s SYN (client’s ISN+1) • Client responds with an ACK segment acknowledging server’s SYN (server’s ISN+1)
TCP Connection Termination • Need four segments to terminate a connection because of TCP’s half-close • Either end can send a FIN when it finishes sending data • The end sending first FIN performs active close and the other end performs passive close • A TCP can still send data after receiving FIN • When receiving a FIN, respond with an ACK of received sequence number plus 1
Next Class • TCP data flow • Read TI Ch. 19, 20