"Computer network Fifth Edition" read note five: Transport layer

Source: Internet
Author: User
Tags ack

Fifth Transport Layer

1. Transport Layer Functions : Provides end-to-end logical communication between application processes, providing communication services to the application layer. (The network layer provides logical communication between hosts and hosts)
2. two important protocols for transport Layer : User Packet protocol UDP and Transmission Control Protocol TCP


3. Port of Transport layer (protocol port number)
(1) Software port is the application layer of the various protocol processes and transport entities to interact between layers of an address
(2) Server port number: Known or system port number 0~1023, register port number 1024~49151
(3) Client port number: 49151~65535 Ephemeral port number that is selected dynamically only when the client process is running
4. User Datagram Protocol UDP
4.1 features

    • UDP is non-connected and can transfer data without establishing a connection
    • UDP is delivered to the maximum extent possible and does not guarantee reliable delivery
    • UDP is message-oriented, the application layer transmission of the message after the header is sent directly, not merge not split
    • UDP does not have congestion control
    • UDP support One-to-many, multi-pair, many-to-many
    • UDP header Eight bytes, low overhead

4.2 UDP Header format : Source port | Destination Port | length | checksum


4.3 Calculate the checksum: As with the IP datagram header checksum, the inverse code arithmetic operation
5. Transmission Control Protocol TCP
5.1 Features:

    • TCP is connection-oriented, a TCP connection is established before data can be transferred, the transfer is completed and a TCP connection is established
    • TCP connection two ports (sockets), point-to-point
    • TCP delivers reliable delivery
    • TCP provides full-duplex communication
    • TCP is a byte-stream-oriented, TCP based on the other side given the window value and network congestion status to determine the length of a datagram, if the cache data is too long to divide a short number of transmissions, if the data is too short, then wait to accumulate more after the transmission.

Socket socket = (IP address: port number), TCP connection:: = {Socket1,socket2} = {(Ip1:port1), (IP2:PORT2)} (refers to socket for two ports)

5.2 Reliable Transmission principle
(1) Stop waiting Protocol: (reliable transmission on unreliable transmission networks) (automatic retransmission of request ARQ)

    • Error-Free situation: A sends a packet m1,b received to a confirmation, a continues to send packet M2, go down .... until all is sent.
    • Error: B Accept packet error is directly discarded, a did not receive a confirmation message, waited until the time-out retransmission. A send a group will temporarily retain a copy of this group, for a time-out retransmission to be used; grouping and confirming groupings must be numbered to confirm which ones are not received, and the timeout timer must be longer than the average round trip time for data in a packet transfer.
    • Confirm missing and confirm late: B confirmation M1 message is missing, a timeout retransmission m1,b received after discard duplicate M1, retransmission confirmation m1;b confirmation M1 message was late, a retransmission also received confirmation, this time late confirmation M1 came, a received after discarded.
    • Channel Utilization: Total time = A's send time td+ round trip time rtt+ acknowledgment message sent time TA. Channel Utilization = The total time td/the send time of a. Round-trip time is generally much larger than the sending time, so the channel utilization is very low !

5.3 Continuous ARQ Protocol : maintains a sliding window, receives a confirmation packet and then slides the window forward, sending the next packet.

Tips: The receiver does not have to acknowledge the absence of a group, but instead takes a cumulative acknowledgement to send an acknowledgment to the last group on demand. Note that if a group M is lost in the middle, the receiver can only accept the group confirmation in front of M, the sender can only fall back to the lost M grouping position, and send again the subsequent groupings!

5.4 The header format of the TCP packet P194


5.5 implementation of TCP reliable transmission
(1) A sliding window in bytes: Maintain a Send window and accept the window, send the window according to the confirmation sequence received constantly update the sending window, its interior has three pointers, point to the window's starting sequence number, the window has sent the byte trailing sequence number, the window allows to send the trailing sequence number, these three pointers constantly updated The acceptance window receives the data sequentially and sends a confirmation of the highest ordinal number accepted by the order. P197 in the specific process reference book
(2) The choice of time-out retransmission
Records the round-trip time for each message rtt,tcp retains a weighted average round trip time of Rtts. Time-out retransmission, RTO = Rtts+4xrttd,rttd is a weighted average of the deviation of the RTT.
Karn algorithm: When calculating the weighted average Rtts, as long as the message segment retransmission, it does not use its round-trip time sample, so that the weighted average Rtts and RTO is more accurate. Then proposed the Karn correction method, as long as the message section retransmission, take the new retransmission time is twice times the old retransmission time.
(3) Select Confirm Sack
The data stream received by the TCP receiver is discontinuous, by selecting confirm, allowing the send to be sent only to retransmit the missing data, rather than retransmission all the data that did not receive the acknowledgement.
5.6 traffic control for TCP(Let the sender send the rate not too fast, to let the receiver in time to receive)
(1) Use the sliding window to control the flow: the sender's sending window cannot exceed the value of the receiving window given by the receiver.
(2) Transmission efficiency: TCP to control the sending cache timing to ensure transmission efficiency.

    • The cached data arrives at the MSS and the TCP packets are sent out
    • The sender application process indicates which segment of the message is required to send, with a push push operation supported by TCP
    • The sender's time limit is sent to the existing cache, but must be less than the maximum message segment length MS
    • Nagle algorithm: First byte is sent, and then the data in the cache is sent out as a TCP message after receiving the acknowledgement.
    • Solve the confused window syndrome: The sender does not send a small segment of the message at the same time, the receiver does not send a confirmation message to the sender when the cache is only a little bit

congestion control of 5.7 TCP
(1) The concept of congestion control: prevent excessive data from being injected into the network so that routers or links in the network are not overloaded
(2) Several states of congestion:

    • Mild congestion: When the throughput of the network is significantly less than the ideal throughput, it enters light congestion
    • Congestion state: When the supplied load reaches a certain value, the network throughput decreases as the supplied load increases and goes into a congested state
    • Deadlock: When the supplied load continues to increase to a certain value, the network throughput drops to 0, the network is no longer working, then the deadlock

(3) Open-loop and closed-loop control

    • open-loop control : In the design of the network current affairs will be concerned about congestion factors, and strive to network in the work without congestion
    • closed-loop control : Monitor network systems to monitor when congestion occurs, transmit information about congestion to actionable locations, and adjust network system operations to address emerging issues

(4) Methods of controlling congestion:

    • slow start and congestion avoidance
      Slow start: Increase the sending window and congestion window from small to large (CWnd is less than or equal to the sending window), multiply by 2 each time; congestion avoidance: When the congestion window exceeds the slow start threshold Ssthresh, the congestion window increases slowly, that is, each RTT is incremented by 1 (that is, the addition increases). If the network times out, it is possible that congestion will occur, reducing ssthresh to half of CWnd (multiplication is reduced).

    • fast retransmission and fast recovery
      Fast retransmission: Each received an out-of-sequence message section immediately issued a duplicate confirmation, so that the sender early know that there is a message segment did not reach the other side, two do not wait for themselves to send data when the piggyback; fast recovery: When the multiplication is reduced, the Ssthresh is reduced by half, and the CWnd is set to 1. Instead, the CWnd is set to the value after the slow start threshold ssthresh halved, and then the congestion avoidance algorithm is started.

(5) Upper value of sender window = Min[rwnd,cwnd]
5.8 Random early detection red (packet discard policy)
(1) Tail drop policy: After the router's queue is full, the packets that arrive later are discarded directly
(2) Maintain two parameters: Thmax and thmin, using weighted average average queue length lav, when the lav is less than thmin join to the queue, if greater than Thmax is directly discarded, if greater than thmin is less than thmax with probability p discarded.
(3) Benefits: When lav more than thmin, only a small number of packets are discarded, so that a small amount of TCP to reduce its window value, so that the packet arrives at the router less, so lav reduce, thus avoiding network congestion

5.9 Transport Connection management for TCP
(1) Client and server: actively initiates the connection called the customer, passively waits for the connection called the server
(2) TCP connection is established:

    • The client's TCP sends a connection request message to the server, its first synchronization bit syn=1, the ordinal seq = J,client enters the syn-sent state
    • When the server receives the connection request message, it sends a confirmation message if it consents to the connection. Its first SYN and ACK are set to 1, while selecting an ordinal seq = K, confirming that the number is ACK = J+1,server enters the SYN-REVD state,
    • After the client receives the confirmation message from the server, it also sends a confirmation message to the server, its first ack=1, the confirmation number is k+1, the serial number is j+1, and then the client enters the established state, that is, the connection is established.
    • When the server receives a confirmation message from the client, it enters the established state immediately and both parties can begin transmitting the data


(2) TCP connection release:

    • The client first sends a connection release request to its TCP and stops sending the data. The first fin=1 of its TCP message, the ordinal seq=u (the ordinal of the previous sending data + 1), which is the client entering the FIN_WAIT1 state
    • Immediately after the server receives a connection release request from the client, the ACK ack = u+1, the sequence number seq=v, and 1,server into the close-wait state.
    • After the client receives the acknowledgement message, it enters the fin_wait2 state and waits for the server to make a connection release request
    • After the server waits for its data to be sent, its application notifies TCP to release the connection, its header fin=1,ack=1,seq=w,ack=u+1, and enters the Last-ack final confirmation state
    • After the client receives the server's connection release request, it must confirm that its message header ack=1,ack=w+1,seq=u+1 and then enter the Time-wait state,
    • After receiving the confirmation message from the client, the server enters the closed state, and the client waits until 2MSL to enter the closed state.

Tips: Why wait until 2MSL?
Answer: First, in order to ensure that the final confirmation message can reach the server, to avoid the server does not receive the Fin+ack message timeout after the client can receive and resend the acknowledgement message, and the other is to avoid the sent connection request message segment appears in this connection, After 2MSL, all the messages generated during the duration of the connection are removed from the network, and the old connection request messages do not appear in the next connection.

"Computer network Fifth Edition" read note five: Transport layer

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.