Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS4470 Computer Networking Protocols

Similar presentations


Presentation on theme: "CS4470 Computer Networking Protocols"— Presentation transcript:

1 CS4470 Computer Networking Protocols
11/30/2018 CS Computer Networking Protocols 14. TCP Huiping Guo Department of Computer Science California State University, Los Angeles

2 Outline TCP services TCP segment format
11/30/2018 Outline TCP services TCP segment format TCP connection establishment and termination TCP state diagram 14. TCP CS4470

3 TCP services Process-to-Process communication
11/30/2018 TCP services Process-to-Process communication Using port number Full-duplex communication Data can flow in both directions at the same time Stream delivery service Connection-oriented service 14. TCP CS4470

4 Stream delivery service
TCP is a stream oriented protocol It allows the sending process to deliver data as a stream of bytes and the receiving process to obtain data as stream of bytes The two processes seem to be connected by an imaginary tube that carries their data across the Internet Note: most of the following diagrams are from chap12 , “TCP/IP Protocol Suite, 3rded” 14. TCP CS4470

5 Stream delivery service
Both the sender and the receiver keep two buffers: sending buffer and receiving buffer They may not write or read data at the same speed TCP need buffers for storage 14. TCP CS4470

6 Stream delivery service
At the sending site The buffer has 3 types of chambers The white area empty chambers that can be filled by the sending process The blue area holds bytes that have been sent but not yet acknowledged. TCP keeps these bytes in the buffer until it receives an ACK After the bytes are acked, the chambers are recycled and available for use by the the sender The pink area contains bytes to be sent by the sending TCP At the receiver site The white area contains empty chambers to be filled by bytes received from the network The colored sections contain received bytes that can be read by the receiving process When a byte is read by the receiving process, the chamber is recycled and added to the pool of empty chambers 14. TCP CS4470

7 Stream delivery service
The IP layter needs to send data in packets, not as a stream of bytes TCP groups a number of bytes together into a packet called a segment The segments are not necessarily the same size TCP adds a header to each segment and delivers the segment to the IP layer for transmission The segments are encapsulated in an IP datagram and transmitted The entire operation is transparent to the receiving process 14. TCP CS4470

8 TCP segment structure 14. TCP CS4470

9 Seq. Num. and Ack. Num. Byte number Sequence number
TCP numbers all data bytes that that are transmitted in a connection Numbering is independent in each direction The numbering does not necessarily start from 0 TCP generates a random number for the first byte Sequence number After bytes are numbered, TCP assigns a sequence number to each segment that is being sent. The sequence number for each segment is the byte number of the first byte carried in that segment 14. TCP CS4470

10 Example Suppose a TCP connection is transferring a file of 5000 bytes. The first byte is numbered What are the sequence numbers for each segment if data is sent in five segments, each carrying 1000 bytes? Segment 1 ➡ Sequence Number: 10,001 (range: 10,001 to 11,000) Segment 2 ➡ Sequence Number: 11,001 (range: 11,001 to 12,000) Segment 3 ➡ Sequence Number: 12,001 (range: 12,001 to 13,000) Segment 4 ➡ Sequence Number: 13,001 (range: 13,001 to 14,000) Segment 5 ➡ Sequence Number: 14,001 (range: 14,001 to 15,000) 14. TCP CS4470

11 Seq. Num. and Ack. Num. Acknowledge number for a segment
The sequence number of the next byte the receiver is expecting from the other party Ex. A receives a segment (byes ) from B A puts 536 in the ack. Num. field of the segment it sends to B TCP provides cumulative acknowledgments Ex. A receives a segment(0-535) and another segment (900-1,000) from B A’s next segment to B will contain 536 in the ack. Num. field 14. TCP CS4470

12 Example: Telnet A popular application-layer protocol used for remote login It runs over TCP It’s an interactive application The user at the client side typed a character The character is sent to the server The server sends the same character back to the client The “echo back” ensures that the characters seen by the telnet user have already been received and processed at the remote site Each character traverses the network twice 14. TCP CS4470

13 simple telnet scenario
Seq. Num. and Ack. Num. Host A Host B User types ‘C’ Seq=42, ACK=79, data = ‘C’ host ACKs receipt of ‘C’, echoes back ‘C’ Seq=79, ACK=43, data = ‘C’ host ACKs receipt of echoed ‘C’ Seq=43, ACK=80 time simple telnet scenario 14. TCP CS4470

14 Exercise Host A Host B Seq=42, ACK=79 100 bytes
14. TCP CS4470

15 TCP segment structure 14. TCP CS4470

16 Control field The field defines 6 different control bits
These bits enable flow control, connection establishment and termination, connection abortion, and the mode of data transfer 14. TCP CS4470

17 TCP is connected-oriented
When a process A at site A wants to send and receive data from another process at B The two TCP establish a connection between them Data are exchanged in both direction The connection is terminated The connection is a virtual connection Both parties keep buffers and some state information (variables) The connection information is invisible to the intermediate routers 14. TCP CS4470

18 Connection establishment
TCP transmits data in full-duplex mode Each party must initialize communication and get approval from the other party before any data is transferred Server and client The connection establishment is TCP is called three-way handshaking Server request for a passive open The server tells its TCP that it’s ready to accept a connection Client issues a request for an active open TCP can now starts a three-way handshake process 14. TCP CS4470

19 Three-way handshake 1. The client sends the first segment, a SYN segment SYN is set to 1 specifies initial seq. number: client_isn (8000) no data 2. Server receives SYN server allocates buffers and variables replies with SYNACK segment Both ACK and SYN are set to 1 specifies server initial seq. number: server_isn (15000) ack = client_isn+1 No data 14. TCP CS4470

20 Three-way handshake 3. client receives SYNACK
allocate buffers and variables replies with ACK segment ACK is set to 1 SYN is set to 0 ack =server_isn+1 The segment may contain data 14. TCP CS4470

21 Three-way handshake 14. TCP CS4470

22 Connection terminate Any of the two parties can close the connection
Two options for connection termination Three-way handshake Normal situation Four-way handshake with a half-close option One end can stop sending data while still receiving data Either the server or the client can issue a half-close requestion. 14. TCP CS4470

23 Connection termination using three-way handshake
14. TCP CS4470

24 Connection termination using four-way handshake (half close)
Seg: y-1 The 2nd seg consumes no sequence number Though the client has received sequence number y-1 and is expecting y, the server sequence number is still y-1 Then the connection finally closes, the sequence number of the last ACK is still x, because no sequence number are consumed during data transfer in that direction 14. TCP CS4470

25 TCP State diagram To keep track of all the different events happening during connection establishment, connection termination, and data transfer, the TCP software is implemented as a finite state machine A finite state machine is a machine that goes through a limited number of states At any moment, the machine is in one of the states It remains in that state until an event happens The event can take the machine to a new state and can also make the machine perform some actions 14. TCP CS4470

26 TCP State diagram 14. TCP CS4470

27 TCP state transition diagram
14. TCP CS4470

28 TCP state transition diagram
The ovals represent the states The directed lines represent the transition from one state to another Each line has two strings separated by a slash The first string is the input, what TCP receives The second string is the output, what TCP sends The diagram is for both client and server The dotted black lines represent the transition that a server normally goes through The solid black lines shows the transitions that a client normally goes through In some situations, a server transitions through a solid line or a client transitions through a dotted line The colored lines show special situations 14. TCP CS4470

29 Common scenario 1 Connection termination using 4-way handshake
The common value for MSL is between 30 seconds and 1 minute 14. TCP CS4470

30 Common scenario 2 Connection termination using 3-way handshake
14. TCP CS4470

31 Common scenario 3:Simultaneous close
14. TCP CS4470

32 Common scenario 4: Denying a connection
14. TCP CS4470


Download ppt "CS4470 Computer Networking Protocols"

Similar presentations


Ads by Google