Professional Documents
Culture Documents
asd
TCP is connection oriented The transferred bytes are numbered Lost or damaged data is requested again
The ends of the connection ( Source and Destination) are specified with the port number This number is two-byte, so its value can vary between 0 and 65535 Port numbers are expressed with a backslash and the protocol name tcp (i.e. 53/tcp) Port 53/tcp has nothing in common with port 53/udp
5
The operating system uses the target port number to recognize to which application it should deliver the TCP segment
The client begins establishing a connection by sending the first TCP segment (segment 1)
The second segment already confirms data received; it has the ACK flag set. It confirms one byte of data received the acknowledgment number of the confirmed byte expresses the number of the next byte that the source may send. Thus the source may send ISN+1
12
With the third segment, connection establishment ends. Therefore we can say that TCP requires threephase handshaking for establishing a connection
13
Terminating a Connection
the client that establishes the connection, but either side can close the connection. The first side to send a TCP segment with the FIN (end of connection) flag carries out an active close The second side has no choice but to carry out a passive close.
14
Four TCP segments are required for properly closing a connection segment 6 begins the active close of the connection with the set FIN flag. Segment 7 confirms the connection closure (passive close) if segment 8 also contained the FIN flag, it would cause the entire connection to begin closing
15
Segment 7 does not contain the FIN flag, because the right side wants to continue the connection (i.e. it wants to use a half closed connection to transmit application data) The side that closed the connection cannot send any more data When the second party has sent what it wanted to, it sets up the FIN flag in the last segment (8) and waits till the termination of connection is confirmed (9)
16
17
The Proto column contains the name of the protocol used (TCP or UDP). The Recv-Q column displays the number of bytes in the connection input queue (waiting to be processed by an application). The Send-Q column displays the number of bytes in the output queue (waiting to be sent). The Local Address column contains the address of the local network interface The Foreign Address column contains the IP address and port number of the remote side of the connection. The (state) column displays the connection state.
18
Window Technique
A problem arises when a client needs to send large amounts of data Example:
the client has established a connection with the server They agreed on a Maximum Segment Size (MSS) of 1 K (or 1024 B) And window size of 4 K (or 4096 B).
19
The server returns a confirmation (segment 4) from the server that confirms segments 1 and 2.
The client in return sends segments 5, 6, and 7, but the server has not had enough time to process the data and its buffer has been exhausted. Segment 8 therefore confirms that segments 3, 5, 6, and 7 were received, but at the same time, it closes the window for the client.
Segment 9 does not fully open the window; it only opens 2 K because not all of the data in the buffer memory has been processed and there is no 20 space for more.
21
22
Network Congestion
A window (WIN) is the amount of data that the destination is able to receive Although the window size is determined by the destination, the problem also extends to the source
If the source is fast and the destination is slow, then the source could jam up the network with data up to the window size
23
Data loss is always bad and our goal is to avoid it whenever possible The source-side window is called the congestion window (CWND) The source gradually increases the CWND The threshold after which network congestion is likely to occur is called SSTHRESH
24
Slow Start
The source sets the CWND dynamically
it sends one segment and waits for its confirmation. If it receives confirmation, it sends two segments. If it receives a confirmation again, it sends four segments and so on.
25
after a few rounds, the source reaches the window size (WIN) or will flood the network and will not receive confirmation because congestion occurs. In other words, it has to send the segments again because a segment got lost. At this point, the CWND is reduced by half
the source does not receive any confirmation at all within the defined time limit.
In this case, the CWND is set to the size of one segment (segsize) the SSTHRESH is set to twice the size of a segment (2xsegsize) the slow start is started over from the beginning.
27
Congestion Avoidance
For each connection, the source keeps the actual values of the MSS, WIN, CWND, and SSTHRESH
1. If CWND is less than or equal to SSTHRESH, then we are dealing with a slow start. It is therefore possible to try to send double the amount of data.
28
2. If CWND is already larger than SSTHRESH, then sending double the amount of data would probably cause congestion.
In this case the CWND is only increased by segsizexsegsize/CWND+segsize/8 counted in integers. This minor increase of the CWND is called the Congestion Avoidance Algorithm.
29
References
Libor Dostalek, Alena Kabelova,Understanding TCP/IP a clear and comprehensive guide to TCP/IP protocols, Packet publishing 2006
30