Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 12 Transmission Control Protocol

Similar presentations


Presentation on theme: "Chapter 12 Transmission Control Protocol"— Presentation transcript:

1 Chapter 12 Transmission Control Protocol
Prof. Choong Seon HONG

2 Introduction Position of TCP

3 Introduction (cont’d)
Responsibilities of Transport Layer to create a process-to-process communication using port numbers in case of TCP to provide a flow-and-error control mechanism at the transport level TCP uses sliding window protocol to achieve error control. TCP uses the acknowledgment packet, time-out, and retransmission to achieve error control. to provide a connection mechanism for the application program sending streams of data to the transport layer by application program making a connection with the receiver, chopping the stream into transportable units, numbering them and sending them one by one

4 Introduction (cont’d)
At the receiving end, waiting until all the different units belonging to same application program have received, checking, passing those that are error free and delivering them to the receiving application program as a stream. After the entire stream has been sent, the transport layer should close the connection. TCP is called a connection-oriented, reliable transport protocol adding connection-oriented and reliability features to the services of IP

5 12.1 Process-to-Process Communication
Host-to-host communication and process-to-process communication

6 Process-to-Process Communication (cont’d)
Port Addresses (Numbers) process-to-process communication that achieved through the client/server paradigm to define the client and server programs, we need second identifiers called port numbers. integers between 0 and 65,535 The client program running on the local computer defines itself with a port number, chosen randomly by the TCP software running on the local host using a ephemeral port number But, the server program on the remote computer must also define itself with a port number using a well-known port number

7 Process-to-Process Communication (cont’d)
Explanation of port numbers using TENET application

8 Process-to-Process Communication (cont’d)
Well-known ports used by TCP

9 Process-to-Process Communication (cont’d)
Socket Addresses To make a connection, needs 2 identifier : IP address + Port number  Socket address a pair of socket address Client socket address Server socket address

10 12.2 TCP Services TCP is a stream-oriented protocol
Stream Delivery Service TCP is a stream-oriented protocol TCP creates an environment in which the two processes seem to be connected by an imaginary “tube” that carries their data across the Internet.

11 TCP Services (cont’d) Sending and Receiving Buffers Because the sending and receiving processes may not produce and consume data at the at the same speed, TCP needs buffers for storage. One way to implement is to use a circular array Not acknowledged

12 TCP Services (cont’d) Segments

13 TCP Services (cont’d) Stream Data Service (stream transport layer service) The sending TCP 1) accepts a stream of characters from sending application program 2) creates packets called segments, of appropriate size extracted from the stream 3) sends segments across the network The receiving TCP 1) receives segments, extracts data from segments 2) orders segments if they have arrived out of order 3) delivers segments as a stream of characters to the receiving application program

14 TCP Services (cont’d) For stream delivery,
the sending and receiving TCPs use buffers the sending TCP uses sending buffer to store the data coming from the sending application program. the sending application program writes data to the buffer of the sending TCP the receiving TCP receives the segments and stores them in a receiving buffer the receiving application program uses the read operation to read the data from the receiving buffer. Since the rate of reading can be slower than the rate of receiving, the data is kept in the buffer until the receiving application reads it completely.

15 TCP Services (cont’d) Full-Duplex Service Reliable Service
TCP offers full-duplex service After two application programs are connected to each other, they can both send and receive data. Piggybacking When a packet is going from A to B, it can also carry an acknowledgment of the packets received from B Reliable Service TCP uses the acknowledgment mechanism to check the safe and sound arrival of data

16 12.3 Segment The Unit of data transfer between two devices using TCP is a segment The format of a segment

17 Segment (cont’d) Source port address Destination port address
defining the port number of application program in the host that is sending the segment Destination port address defining the port number of application program in the host that is receiving the segment Sequence number defining the number assigned to the first byte of data contained in this segment during the connection establishment, each party uses a random number generator to create an initial sequence number (ISN)

18 Segment (cont’d) Acknowledgment number Header length Reserved
If the source of the segment has successfully received byte number x from the other party, it defines x+1 as the acknowledgment number Header length Indicating the number of 4-byte words in the TCP header the value between 5 and 15 (20 and 60 bytes) Reserved For future use

19 Segment (cont’d) Control
Enabling flow control, connection establishment and termination, and mode of data transfer in TCP

20 Segment (cont’d) Description of flags in the control field

21 Segment (cont’d) Window size Checksum : see section 12.5
defining the size of the window, in bytes, that the other party must maintain. maximum size of window : 65,535 bytes Checksum : see section 12.5 Urgent pointer used when the segment contains urgent data defining the number that must be added to the sequence number to obtain the number of the last urgent byte in the data section of the segment Options : 40 bytes

22 12.4 Options Two categories of options
Used to convey additional information to the destination or to align other options Two categories of options one-byte options multiple-byte options

23 Options (cont’d) End of option
After this option, the receiver looks for the payload data End of options imparting 3 pieces of information to the destination No more options in the header The remainder of the 32-bit word is garbage Data from the application program starts at the beginning of the next 32-bit word

24 Options (cont’d)

25 Options (cont’d) No operation
One-byte option used as a filler between options

26 Options (cont’d) Maximum segment size (MSS)
defining the size of the biggest chunk of data that can be received by the destination of the TCP segment in spite of its name, defining the maximum size of the data, not the maximum size of the segment value of 0 to 65,535 bytes : default is 536 to be determined during the connection establishment phase by the destination of the segment used only in the segments that make the connections. Not used in the segments during data transfer

27 Options (cont’d) Window scale factor
defining the size of the sliding window new window size = window size defined in the header x 2 window scale factor Determined in phase of the connection setup The largest value of scale factor allowed by TCP/IP is 16.

28 Options (cont’d) Timestamp 10-byte option
The timestamp field is filled by the source when the segment leaves. When the destination sends an acknowledgment for the bytes in that segment, the destination enters the previously stored value in the echo reply field. The source, when it receives the acknowledgment, checks the current time versus this value The difference is the round-trip time.

29 12.5 Checksum The inclusion of the checksum in TCP is mandatory.

30 12.6 Flow Control Defining the amount of data that a source can send before receiving an acknowledgement from the destination. Sliding window For flow control, TCP uses a sliding window protocol The window covers a portion of the buffer that a host can send before worrying about an acknowledgment from other host

31 Flow Control (Cont’d) Sliding window
Before receiving any acknowledgment from the destination the source can send up to 10 bytes

32 Flow Control (Cont’d) Sliding window with pointer

33 Flow Control (Cont’d) Window size in TCP is variable
the size of the window can be increased or decreased depending on the advertisement by the destination Increasing the Window Size (depending on the advertisement by the destination)

34 Flow Control (Cont’d) Decreasing the Window Size (depending on the advertisement by the destination)

35 Flow Control (Cont’d) Window management
TCP uses two buffers and one window to control the flow of data. The size of the window in the sending TCP is determined by the receiver and is announced in the ACK segments. usually the space left over in the receiving TCP buffer

36 Flow Control (Cont’d)

37 12.7 Error Control Including mechanisms for detecting corrupted segments, lost segments, out-of-order segments, and duplicated segments. Also, including a mechanism for correcting errors after they are detected. Error Detection and Correction Checksum Acknowledgment : TCP does not use negative acknowledgment Time-out

38 Error Control (Cont’d)
Corrupted Segment

39 Error Control (Cont’d)
Lost Segment

40 Error Control (Cont’d)
Duplicate Segment can be created by a source TCP when the acknowledgment does not arrive before the time-out. Out-of-Order Segment Because of IP datagrams

41 Error Control (Cont’d)
Lost Acknowledgment

42 12.8 TCP Timers To perform its operation smoothly, TCP uses the 4 timers

43 TCP Timers (Cont’d) Retransmission Timer
To control a lost or discarded segment, when TCP sends a segment, it creates a retransmission timer for that particular segment. Calculation of Retransmission Time TCP uses the dynamic retransmission time-out that is different for each connection and which may be changed during the same connection Retransmission time = 2 x RTT Calculation of RTT : use of Timestamp option and Timer in sending TCP

44 TCP Timers (Cont’d) The value of RTT used in the calculation of the retransmission time of the next segment RTT =  x previous RTT + (1 -  ) current RTT where,  is usually 90 % Persistence Timer When acknowledgment with non-zero window size after zero window size is lost, to correct deadlock, TCP uses a persistence timer for each connection When the sending TCP receives an acknowledgment with a window size of zero, the persistence timer is started When persistence timer goes off, the sending TCP sends a special segment called a probe

45 TCP Timers (Cont’d) Persistence Timer (cont’d) KeepaliveTimer
The probe alerts the receiving TCP that the acknowledgment was lost and should be resent. If a response is not received, the sender continues sending the probe segments and doubling, and resetting the value of the persistence timer until the value reaches a threshold (usually 60 seconds). KeepaliveTimer Used to prevent a long idle connection between two TCPs. Each time the server hears from a client, it resets this timer. Time-out is usually 2 hours. After 2 hours, sending 10 probes to client (each 75 secs), then terminates connection.

46 12.9 Connection connection establishment connection termination
A connection-oriented protocol establishes a virtual path between the source and destination using two procedures : connection establishment connection termination Connection Establishment TCP transmits data in full-duplex mode. 4 functions between host A and host B Host A sends segment to announce its wish for connection and includes its initialization information about the traffic from A to B Host B sends a segment to acknowledge (confirm) the request of A Host B sends a segment that includes its initialization information about the traffic from B to A Host A sends a segment to acknowledge (confirm) the request of B can be combined into one step

47 Connection (cont’d) Three-way Handshaking Passive Open Active Open
The sever program tells its TCP that it is ready to accept a connection It means that although its TCP is ready to accept any connection from any machine in the world it cannot make the connection itself. Active Open A client that wishes to connect to a server tells its TCP that it needs to be connected to a particular server.

48 Connection (cont’d) Three-way Handshaking Procedures

49 Connection (cont’d) 1. The client sends the first segment, a SYN segment. Including the source and destination port numbers, and client initialization sequence number (ISN) used for numbering the bytes of data sent from the client to the server Defining the wish of the client to make a connection with certain parameters. 2. The server sends the second segment, a SYN and ACK segment Including the ACK of receipt of the first segment The server must define also the client window size Used as the initialization segment for the server Containing the window scale factor option (if needed) to be used by the server and the MSS defined by the server

50 Connection (cont’d) 3. ACK segment
Acknowledging the receipt of the second segment using the ACK flag and acknowledgment number field. Client must also define the server window size.

51 Connection (cont’d) Connection Termination (Four-way handshaking)
4 actions needed for closing the connection Host A sends a segment announcing its wish for connection termination Host B sends a segment acknowledging (confirming) the request of A. After this, the connection is closed in one direction. When host B has finished sending its own data, it sends a segment to indicate that it wants to close the connection. Host A acknowledges (confirms) the request of B

52 Connection (cont’d) Four-Way Handshaking

53 Connection (cont’d) Connection Resetting
Resetting here means that the current connection is destroyed. When the TCP on one side has requested a connection to a nonexistent port, the TCP on the other side may send a segment with its RST bit set to annul the request. When one TCP wants to abort the connection due to an abnormal situation. It can send an RST segment to close the connection. 3. When the TCP on one side may discover that the TCP on the other side is idle for a long time. It may send an RST segment to destroy the connection.

54 12.10 State Transition Diagram
To keep track of all the different events happening during connection establishment, connection termination,and data transfer, TCP software is implemented as a finite state machine A finite state machine is in a one of the states at any moment.

55 State Transition Diagram (Cont’d)
States for TCP e

56 State Transition Diagram (Cont’d)
A state transition diagram Server Client Unusual Input / Output Now connection is closed in one direction.

57 12.11 Congestion Control If a router receives packets faster than it can process them, congestion might occur, and some packets could be dropped. When a packet does not reach the destination, no acknowledgment is sent for it. The sender has no choice but to retransmit the lost packet. This may create more congestion and more dropping of packets, which means more retransmission and more congestion. Today, TCP protocols include that the sender’s window size is not only determined by the receiver but also by congestion window size Actual window size = minimum (receiver-advertised window size, congestion window size)

58 Congestion Control (cont’d)
Window size increase strategy At the beginning of the connection, set the congestion window size to the maximum segment size

59 Congestion Control (cont’d)
Window size increasing strategy If congestion occurs, the congestion window size must be decreased. The only way the sender can guess that congestion has occurred is through a lost segment The threshold must be set to half of the last congestion window size, and the congestion window size should start from one again.

60 12.12 TCP Operation Encapsulation and Decapsulation

61 TCP Operation (Cont’d)
Queuing

62 TCP Operation (Cont’d)
Multiplexing and Demultiplexing

63 TCP Operation (Cont’d)
Pushing Data The application program on the sending site can request a push operation. Meaning that the sending TCP should not wait for the window to be filled TCP should create a segment and send it immediately. Sending TCP should also set psuh bit (PSH) to tell the receiving TCP that the segment includes data that must be delivered to the receiving application program as soon as possible and not to wait for more data to come.

64 TCP Operation (Cont’d)
Urgent Data Sometimes, an application needs to send urgent bytes. Meaning that the sending application program wants a piece of data to be read out of order by the receiving application program The sending application program tells the sending TCP that the piece of data is urgent. Then, the sending TCP creates a segment and inserts the urgent data at the beginning of the segment. The urgent pointer field in the header defines the end of the urgent data and the start of normal data. When the receiving TCP receives a segment with the URG bit set, it extract the urgent data from the segment, using the value of the urgent pointer, and deliver it, out of order, to the receiving application program

65 12.13 TCP Design A TCP package involving a table called Transmission Control Blocks, a set of timers, and three software modules: main module, input processing module, output processing module.

66 TCP Design (Cont’d) Transmission Control Block (TCBs)
To control the connection, TCP uses a structure to hold information about each connection. TCP keeps an array of TCBs in the form of a table

67 TCP Design (Cont’d) State : defining the state of the connection according to the state transition diagram Process : defining the process using this connection at this machine as a client or a server Local IP address : defining the IP address of the local machine used by this connection Local port number : defining the local port number used by this connection Remote IP address Remote port address Interface : defining the local interface Local window : holding information about the window at the local TCP Remote window

68 TCP Design (Cont’d) Sending sequence number Receiving sequence number
Sending ACK number Time-out values : transmission time-out, persistence time-out, keepalive time-out, and so on Buffer size : defining the size of the buffer at the local TCP Buffer pointer : pointer to buffer where the receiving data is kept until is read by the application

69 TCP Design (Cont’d) Main Module : The main module is invoked by an arrived TCP segment, a time-out, or a message from an application program

70 TCP Design (Cont’d) Main Module (cont’d)

71 TCP Design (Cont’d) Main Module (cont’d)

72 TCP Design (Cont’d) Main Module (cont’d)

73 TCP Design (Cont’d) Main Module (cont’d)

74 TCP Design (Cont’d) Main Module (cont’d)

75 TCP Design (Cont’d) Main Module (cont’d)

76 TCP Design (Cont’d) Main Module (cont’d)

77 TCP Design (Cont’d) Main Module (cont’d)

78 TCP Design (Cont’d) Input processing module Output processing module
handles all the details needed to process data or acknowledgment received when TCP is in the ESTABLISHED state sends an ACK if needed, takes care of the window size, does error checking, and so on Output processing module handles all the details needed to send out data received from application program when TCP is in the ESTABLISHED state handles retransmission time-outs, persistent time-outs, and so on


Download ppt "Chapter 12 Transmission Control Protocol"

Similar presentations


Ads by Google