380 likes | 574 Views
TCP. Reliable Transport in TCP TCP flow and Congestion Control. Learning objectives. TCP. Application. Application. byte stream. byte stream. segments. Transmitter. Receiver. Send buffer. Receive buffer. ACKs. TCP: Overview.
E N D
Reliable Transport in TCP TCP flow and Congestion Control Learning objectives
Application Application byte stream byte stream segments Transmitter Receiver Send buffer Receive buffer ACKs TCP: Overview - TCP passed block of data to IP, consisting of the TCP header and application layer data, called segment - Stream of octets passed between sender/ receiver Deliver in same octate sequence - Connection-oriented service - Full duplex - Reliable service
0 4 10 16 24 31 Source Port Destination Port Sequence Number Acknowledgement Number U A P R S F Header R C S S Y I Reserved Window Size Length G K H T N N Checksum Urgent Pointer Options Padding Data TCP Segment
TCP header fields • Source, Destination port: 16 bits - identify applications at ends of the • connection • Client Program allocates a port (usually above 1023) • Servers are known by ports number • - FTP 20, TELNET 23, SMTP 25, HTTP 80 • Port numbers are generally allocated by • -- 0 -- not used • -- 1- 255 -- Reserved ports for well- known services • -- 256- 1023 -- Other reserved ports • -- 1024- 65535 -- user- defined server ports • Unix store general used ports in /etc/ services
Socket • Connection identification by 5 tuple • --- 2 IP address, 2 port, protocol number (TCP=6) -- Socket • IP address is unique to a node, the port is unique on a node • A connection is identified by the socket address at its to ends: • - client socket: 158. 108.33. 3, 3000; 158.108.2.71,21 • - server socket: 158.108.2.71,21; 158.108.33.3,3000;
Socket: Multiple connection • Server’s unique socket address can be accessed simultaneously by clients
TCP: Reliable Transport • Send and wait for acknowledgment with sequence number • ---sender reset timer • when receives ACK • No ACK within a certain time, • retransmit the packet • ---Error Recovery
TCP: Reliable Transport • Use for flow control : • - Prevent sender from overloading receiver with data, e. g. • high- performance server to slow PC • - Congestion inside network, e. g. router performance, slow link speed • How to provide flow control? Set the appropriate size of sliding window size adaptively
Sliding window/ Transmission window • Receiver “ advertises” it’s windows size in acknowledgments • - Window size specifies how many bytes the receiver is willing to accept • - Limited by congestion window • Sender will adjusts buffer pointer as receiver’s advertisement • A larger window size allows more data to be transmitted with pending • acknowledgment • Need not to wait for acknowledgment every segment
Connection Concept • Before data could be transferred, a connection must be opened • ---servers do passive open (listen) • ---clients do active open (connect) • When it finished, the connection is closed • TCP has general 3 phases • -- connection setup phase • -- data phase • -- connection close phase • Socket is stored in „TCP control block“ TCB • - with sequence number and timer values
Host A Host B SYN, Seq_no = x SYN, Seq_no = y, ACK, Ack_no = x+1 Seq_no = x+1, ACK, Ack_no = y+1 3-way Handshake for connection establishment Closed Active open Listen Established Established
t0 Seq_no = 1, Ack_no = 2000, Win = 2048, No Data t1 Seq_no = 2000, Ack_no = 1, Win = 1024, Data = 2000-3023 t2 Seq_no = 3024, Ack_no = 1, Win = 1024, Data = 3024-4047 t3 Seq_no = 1, Ack_no = 4048, Win = 512, Data = 1-128 t4 Seq_no = 4048, Ack_no = 129, Win = 1024, Data = 4048-4559 TCP Window control
Host B FIN, seq = 5086 ACK = 5087 Data, seq. = 303, ACK = 5087 Deliver 150 bytes ACK = 453 FIN, seq. =453, ACK = 5087 ACK = 454 Connection Termination Host A
Retransmission Timer • With RTT, Timeout increase