Teaching material: Computer Network (7th edition) xie Xiren edition

Transport layer

1. Network process communication, port number, socket, uniquely identifies a process on the network

From the perspective of communication and information processing, the transportation layer provides communication services to the application layer above it. It belongs to the highest level of communication-oriented part, and is also the lowest level of user functions.

One thing to note here: From the perspective of the transport layer, the real endpoint of communication is not the host but the process within the host, that is, end-to-end communication between application processes.

The transport layer provides logical communication between application processes. This communication seems to involve sending data directly in the horizontal direction. In fact, there is no horizontal physical connection between the two transport layers.

As you can see from the figure above, the network layer provides the logical communication between hosts, while the transportation layer provides the end-to-end logical communication between application processes. In addition, the transport layer performs error detection on the received packet.

2. The UDP and TCP

The transport layer requires two different transport protocols, connection-oriented TCP and connectionless UDP.

  • User Datagram Protocol (UDP)
  • Transmission control protocol TCP

Transport Protocol Data Unit TPDU: A unit of data transmitted by two peer transport entities during communication.

The transportation layer hides the details of the underlying network core from high-level users. It makes the application process see as if there is an end-to-end logical path between the two transportation layer entities, but the performance of this logical communication channel to the upper layer is very different depending on the different protocols used by the transportation layer. When this logical communication channel is equivalent to a full-duplex reliable channel. However, when the transport layer adopts the connectionless UDP protocol, this logical communication channel is still an unreliable channel.

  • Reuse: All application processes in the application layer can be transferred to the IP layer through the transport layer.
  • Split: After the transport layer receives the data sent to each application process from the IP layer, it must deliver the data to each application process separately.

2.1 port

  1. Port number used by the server

There are two categories, the most important of which are known port numbers or system port numbers.Value of 0-1024

  1. Port number used by the client

Port numbers ranging from 49152-65535 are dynamically selected only when the client process is running. Hence the term transient port number.

2.2 the UDP

2.2.1 overview

  1. UDP is connectionless

No connection needs to be established before data is sent, thus reducing overhead and latency before data is sent.

  1. Do your best to deliver

And do not guarantee reliable delivery, so hosts do not need to maintain complex connection state tables.

  1. For a message

The UDP packet sent by the sender to the application program adds the header and delivers the packet to the IP layer. UDP does not combine or split the packets delivered by the application layer. Instead, the boundaries of these messages are preserved.

4. UDP does not control congestion. 5. UDP supports one-to-one, one-to-many, many-to-one, and many-to-many interaction communication. 6. The header has a small overhead of 8 bytes, which is smaller than the 20 bytes of TCP.

2.2.2 Header format

  1. Source port

Source port number. Choose when you need a reply. You can use all zeroes if you don’t need them.

  1. Destination port

Destination port number. This must be used when an endpoint delivers a packet.

  1. The length of the

Datagram length of a UDP user. Its minimum value is 8(only the head).

  1. Inspection and

Check whether a UDP user datagram has an error during transmission. If anything goes wrong, throw it away.

Note: There is a special way to calculate the sum in UDP user datagram headers. When calculating the checksum, add a 12-byte pseudo-header before the UDP user datagram. Unlike IP datagram validation, where only the header of an IP datagram is checked, UDP validation validates both the header and the data portion.

2.3 the TCP

2.3.1 characteristics

  1. Connection-oriented transport layer protocol.

Before an application can use THE TCP protocol, a TCP connection must be established. After data transmission is complete, the established TCP connection must be released.

  1. Each TCP connection can only have two endpoints, and each TCP connection can only be point-to-point.

  2. TCP provides reliable delivery of services.

The data transmitted through TCP connection is error-free, lost-free, repeatable, and arrives in sequence.

  1. TCP provides full-duplex communication.

TCP allows both application processes to send data at any time.

  1. Byte stream oriented.

A TCP stream is a sequence of bytes flowing into or out of a process. Although the application interacts with TCP one block at a time, TCP treats the data handed down by the application as a series of unstructured byte streams.The TCP packet segment is transmitted to the IP layer first, and then to the data link layer after the IP layer header is added. Add the head and tail of the data link layer before leaving the host to send to the physical link.

3. TCP segment header

Although TCP is byte stream oriented, the data unit transmitted by TCP is packet segment.

  • Source port and destination port: occupy each port2 bytes, write the source port number and destination port number respectively.
  • Serial number:Of 4 bytes. The serial number ranges from 0 to 2e32-1. After the sequence is increased to 2e32-1, the next sequence returns to 0. In other words, the sequence number uses mod 2^32.

TCP is byte stream oriented. Each byte in the byte stream passed in a TCP connection is numbered sequentially. The starting sequence number of the entire byte stream to be transmitted must be set when the connection is established. The ordinal field value in the header refers to the ordinal number of the first byte of the data sent in this text segment. For example, a segment with a sequence number of 301 receives 100 bytes of data. This indicates that the sequence number of the first byte of the data in this article is 301 and the sequence number of the last byte is 400. Obviously, the data ordinal for the next segment (if any) should start at 401, that is, the ordinal field value for the next segment should be 401. The sequence number of this field is also called segment number.

  • Confirmation no. :Of 4 bytes. Is the sequence number of the first data byte expected to receive the next packet segment from the peer. For example, if B correctly receives A packet segment sent by A, its sequence number field value is 501, and the data length is 200 bytes (sequence number 501-700), B correctly receives the data sent by A up to sequence number 700. Therefore, B expects the next data number from A to be 701, so B sets the acknowledgement number to 701 in the acknowledgement segment sent to A. Notice that the confirmation number is now not 501 or 700, but 701.

If the confirmation number is = N, it indicates that all data up to the number n-1 have been received correctly.

  • Data offset:Of the four, which indicates how far the start of the TCP segment data is from the start of the TCP segment. This field actually indicates the header length of the TCP segment.

The data offset field is necessary because there are also options fields of indeterminable length in the header, but note that the “data offset” is measured in 32-bit words (that is, in 4-byte words). Since the maximum decimal number that can be represented by a four-bit binary number is 15, the maximum data offset is 60 bytes, which is also the maximum byte in the TCP header (that is, the option length cannot exceed 40 bytes).

  • Keep:Of the six, reserved for future use, but should be set to 0 at present. Here are six control bits that illustrate the nature of this article.
  • emergencyURG (URGent): whenURG=1, the emergency pointer field is valid. It tells the system that there is urgent data in this segment and that it should be sent as soon as possible (equivalent to high-priority data) rather than in the original queued order.

For example, a long program has been sent to run on a remote host. However, some problems were discovered that the program needed to be cancelled, so the user issued an interrupt command from the keyboard. If emergency data is not used, these two characters are stored at the end of the cache that receives TCP. These two characters are delivered to the recipient’s application process only after all the data has been processed. Doing so wastes a lot of time.

When URG is set to 1, the sending application process tells the sender’s TCP that there is urgent data to transmit. The sender, TCP, then inserts the emergency data at the beginning of the paragraph, while the data following the emergency data remains normal data. In this case, use it with the Urgent Pointer field in the header.

  • Acknowledge ACK (ACKnowledgment) : The ACKnowledgment id field is valid only when ACK = 1, and is invalid when ACK = 0. TCP specifies that all segments sent after a connection is established must have an ACK of 1.

  • PSH (PuSH) : When two application processes are communicating interactively, sometimes one application process wants to receive a response immediately after typing a command. In this case, TCP can use push operations. At this point, the sender TCP sets PSH to 1 and immediately creates a segment to send. After receiving the packet segment with PSH=1, the TCP receiver delivers the packet to the receiving application process as soon as possible (that is, “push” forward). You don’t have to wait until the entire cache is full.

  • ReSeT RST (ReSeT) : When RST=1, a serious error has occurred in the table name TCP connection (such as due to a host crash or other reason) and the connection must be released before the transport connection is reestablished. Setting RST to 1 is also used to deny an invalid segment or to deny the opening of a connection.

  • SYN: Used to synchronize the serial number when a connection is established. When SYN=1 and ACK=0, this indicates a connection request segment. If the other party agrees to establish a connection, it should set SYN=1 and ACK=1 in the response segment. Therefore, setting SYN to 1 indicates that this is a connection request or a connection accept packet.

  • Terminating FIN (meaning “FINis”) : Used to release a connection. When FIN=1, it indicates that the sent data of this segment has been sent and the transport connection needs to be released.

  • Window: 2 bytes. The window value is an integer between 0,2 ^16-1. Window refers to the receiving window of the party sending the article (not its own sending window). The window value tells the recipient the amount of data (in bytes) that the recipient is currently allowed to send from the acknowledgment number at the beginning of this paragraph. The reason for this restriction is that the receiver has limited data cache space. In summary, the window value acts as the basis for the receiver to let the sender set its sending window.

For example, a segment is sent with the acknowledgement number 701 and the window field 1000. This is to say, “From 701, I (the sender’s segment) have space in the receive cache to accept another 1000 bytes of data (byte numbering 701 to 1700). You must take this into account when sending data to me.”

Bottom line: The window field specifies the amount of data that is now allowed to be sent. Window values often change dynamically.

  • Check and: occupy2 -. The scope of validation and field validation includes both header and data.

As with UDP user datagrams, a 12-byte pseudo header is added to the beginning of the TCP segment when the validation sum is calculated. The format of the pseudo headers is the same as that of UDP user datagrams. Change 17 in the fourth field of the false header to 6 (TCP’s protocol number is 6). Change the UDP length in field 5 to the TCP length. After receiving the segment, the receiver still adds the pseudo header to calculate the check sum. If TPv6 is used, the corresponding pseudo header should also be changed.

  • Emergency pointer: 2 bytes. The emergency pointer is only inURG=1It indicates the number of bytes of emergency data in this article (when the emergency data ends, it is normal data).

Therefore, the in – emergency pointer indicates where the end of the urgent data is in the segment. When all the emergency data has been processed, TCP tells the application to return to normal operation. It is important to note that emergency data can be sent even when the window is 0.

  • Options: variable length, up to4 bytes. When options are not used,TCPThe length of the head of is20 bytes.

Initially, TCP provided only one option: Maximum Segment Szie (MSS). Notice what the noun MSS means. MSS is the maximum length of the data field in each TCP packet segment. The data field plus the TCP header equals the entire TCP segment. Therefore, the MSS is not the maximum length of the entire TCP segment, but the length of the TCP segment minus the TCP header.

4. The TCP connection is established and released

4.1 Three-way handshake is used to establish a TCP Connection

Transfer control block TCB: Stores some important information for each connection. Such as the TCP connection table, Pointers to send and receive buffers, Pointers to retransmission queues, current send and receive sequences, and so on.

Assume that host A is A TCP client program and host B is A TCP server program. Initially, the TCP processes on both ends are CLOSED. The client A opens the link, and the server opens the link. At first, B’s TCP server process creates A transfer control block, TCB, and prepares to accept the client process’s connection request. Then the server process is in the Listening state, waiting for A’s connection request.

  1. Then process A first creates the transport control module TCB. Send a connection request segment to B with SYN=1 in the header and select an initial sequence number seq=x. According to TCP, the SYN segment (that is, the segment with SYN=1) cannot write data, but consumes an ordinal number. At this point, A enters the state that synchronization has been sent.

  2. After receiving the connection request packet, IF B agrees to set up A connection, B sends an acknowledgement packet to A. In the acknowledgement packet, B sets the SYN bit and AVK position to 1, ack+1, and selects an initial serial number y for B. Similarly, this segment cannot write data, but it consumes an ordinal number. Then B enters the synchronization receiving state.

  3. After receiving B’s confirmation, A should also give B A confirmation. ACK =y+1, and seq=x+1. An ACK packet segment can carry data, but if it does not carry data, no sequence number is consumed. In this case, the sequence number of the next data packet segment is still seq=x+1.

TCP is now established. A Indicates that the connection has been established. After receiving the confirmation, B also enters the connection state.

Why does A have to send A final confirmation? This is mainly to prevent the connection request segment that has failed to be sent to B suddenly, resulting in an error.

What is the invalid connection request segment?

  1. First, in the normal case, A sends A connection request but does not receive an acknowledgement because the connection request packet is lost. Then A retransmits the connection request. Confirmation was later received and a connection was established. When the data is transmitted, the connection is released. A sends two connection request packets. The first one is lost and the second one reaches B. No invalid connection request packet segment exists.
  2. In the bad case, the first connection request segment sent by A is not lost, but remains in some network node for A long time, so that it does not reach B until some time after the connection is released. Originally, this was an invalid packet segment. However, after receiving this invalid connection request packet segment, B mistakenly thought that A sent A new connection request. Then an acknowledgement segment is sent to A. The packet connection is agreed. However, since A has not made A connection request at the moment, B’s acknowledgement is ignored and no data is sent to B. But B thinks that A new transport connection has been established and is waiting for A to send data, so A lot of B’s resources are wasted!

The three-way handshake can prevent the occurrence of the above phenomenon. For example, in the abnormal situation just now, A will not send confirmation to B. Because B does not receive confirmation, it knows that A does not ask to establish A connection. That’s why you do it three times.

Three handshakes?? You fart! . Syn-flood attacks are the most common DDoS attacks and the most classical denial of service attacks. The attacker first makes a SYN request to the server with a forged address, and the server responds with a SYN+ACK packet, while the real IP will think, I did not send the request and will not respond. If the server does not receive a response, the server does not know whether the SYN+ACK message was sent successfully. By default, the server tries five times (tcp_syn_retries). In this case, for the server’s memory, bandwidth are very large consumption. If the attacker is on the public network and can forge an IP address, it is difficult for the server to identify the attacker based on the IP address, which brings great difficulties in defense.

How about four handshakes? You fart! . There are drawbacks to the three-way handshake, even if the handshake is guaranteed, there will also be related problems! The three-way handshake is the most reasonable use of network resources on the basis of smooth connection.

4.2 Releasing a TCP Connection, wave four times

After the data transmission is complete, both parties can release the connection. Now BOTH A and B are in the ESTABLISHED state.

  1. The application process of A sends A TCP connection to release the packet segment, stops sending data, and closes the TCP connection. A Releases the link from the end control bit at the beginning of the segmentFINSet to1, its serial number isseq=u, which is equal to the ordinal number of the last byte of the previously transmitted data plus1At this time A entersFin-wait-1Status, waiting for B’s confirmation.

Note: TCP specifies that the FIN segment consumes a sequence number even if it does not carry data!

  1. B Sends an acknowledgement after receiving the link release segment. The acknowledgment number isack = u + 1, and the sequence number of the segment itself isvIs equal to the data that B has previously transmittedThe sequence number of the last byte is increased by 1.Then B entersCLOSE-WAITState. In this case, the TCP server process should notify the high-level application process, so that the connection from A to B is released. In this case, the TCP connection is in the semi-closed state, that is, A has no data to send, but B still needs to receive data. In other words, the connection from B to A is not closed. This may be the case for some time.
  2. After receiving confirmation from B, A entersFin-wait-2The connection release segment is waiting to be sent by B. If B has no data to send to A, the application process notifies TCP to release the connection. In this case, the connection release segment sent by B must be enabledFIN = 1Now assume that the serial number of B isw(B may have sent some more data in the semi-closed state). B must also repeat the confirmation number that was last sentack = u + 1. Then B entersLast-ack (final confirmation)Status, waiting for A’s confirmation.
  3. After receiving the link release segment from B, A must confirm the link release segment. In the acknowledgement segmentACK to oneAnd confirm,ack=w+1, and his serial number isseq=u+1(According to the TCP standard, the previously sent FIN packet segment consumes a sequence number.) And then it goes intoTIME-WAIT(time waiting) state.Note:Now TCP connectionIt hasn't been released yet. Must pass the time waiting for the timer to set2MSLThen A can enter the CLOSED state.

The time MSL is called the maximum segment lifetime, and two minutes is recommended for RFC793. But two minutes is too long in current engineering, so TCP allows different implementations to use smaller MSL values depending on the situation.

Why 2MSL time?? Here’s why

  1. To ensure that the last ACK packet segment sent by A can reach B. This ACK segment may be lost, so that B in the last-ask state cannot receive acknowledgement of the sent FIN-ACK segment. B retransmits the FIN+ACK segment upon timeout, and A receives the FIN+ACK segment within 2MSL. A can receive the retransmitted FIN+ACK segment within 2MSL. Then A retransmits A confirmation and restarts the 2MSL timer. A and B are CLOSED. If A does not WAIT for A period of TIME in the TIME-wait state but releases the connection immediately after sending the ACK packet segment, A cannot receive the FIN+ACK packet segment retransmitted by B, and therefore does not send the acknowledgement packet segment again.
  2. Invalid connection request segment is prevented. After sending the last ACK packet segment, A can make all the packet segments generated during the duration of the connection disappear from the network after 2MSL. In this way, the old connection request packet segment will not appear in the next connection. As soon as B receives the confirmation from A, it enters the CLOSED state. Similarly, B terminates the TCP connection after canceling the corresponding transport control block TCB.

Therefore, the end time of THE TCP connection of USER B is earlier than that of user A.

5. Reliable transmission

CRC Error detection, frame numbering, acknowledgement and retransmission mechanism ARQ, continuous ARQ

5.1 Working Principle

The segment sent by TCP is sent to the IP layer for transmission. But the IP layer can only provide best effort service. In other words, the networks below TCP provide unreliable transport. Therefore, TCP must take appropriate measures to make the communication between the two transport layers reliable.

Ideal transmission conditions have the following two characteristics

  1. The transmission channel does not generate errors
  2. No matter how fast the sender sends the data, the receiver always has time to process the data it receives.

5.1.1 Stopping the waiting protocol

This protocol is the simplest in reliable transport, but the transport layer does not use it. This is just to bring up the issue of reliable transmission. The following assumes that data is transmitted in only one direction.

  • Error free situation

A sends group M1, and stops sending after sending, waiting for B’s confirmation. Send acknowledgement to A upon receipt of M1. After receiving acknowledgement for M1, A sends the next packet, M2.

  • Any errors

When B detects an error when receiving M1, M1 is discarded and A is not notified of receiving the errant group. Or it could be that M1 was lost in transit, and A wouldn’t know about it. Therefore, in reliable transmission, as long as A does not receive acknowledgement after A certain period of time, the packet sent just now is considered lost, so the packet sent before is retransmitted, which is called timeout retransmission. So there will be a timeout timer. If an acknowledgement is received before the timeout timer expires, the timeout timer is revoked. Note the following: 1. After sending A group, user A must temporarily keep A copy of the sent group. The temporary retention of group copies will be made clear only after the appropriate acknowledgement has been received. 2. Both groups and confirmation groups must be numbered. This makes it clear which of the sent groups received the acknowledgement and which did not. 3. The timeout timer should be set to a retransmission time that is longer than the average round trip time of data in packet transmission. If the length is too long, the transmission efficiency is low. If the length is too short, unnecessary retransmission may occur. The retransmission time for the transport layer is complex because of the uncertainty of which networks the packets have been sent over and how much delay will be generated by those networks.

  • Confirm loss and confirm lateness
    1. Left a

The acknowledgement of M1 sent by B is lost. If A does not receive acknowledgement within the set timeout retransmission time, it cannot know whether the packet sent by it is wrong or lost, or whether the acknowledgement sent by B is lost. So A has to retransmit M1 when the timeout timer expires. Now note the action of B, assuming that B has received a retransmission of group M1. Two actions should be taken. – Discard the duplicate frame and do not deliver it to the upper layer. – Send confirmation to A. It cannot be considered that the acknowledgement has been sent and no longer sent. Therefore, the reason why A retransmits M1 indicates that A has not received the acknowledgement for M1. 2. No error occurred in the transmission process of Figure B on the right, when B was late for the confirmation of group M1. A will receive duplicate confirmation. The handling of duplicate acknowledgements is simple: receive and discard. B will still receive the duplicate M1, and will again discard the duplicate M1, and confirm the group again.

Confirmation and retransmission mechanisms like the above allow reliable communication over unreliable transmission networks.Copy the code

So reliable transport protocols like the one above are often called automatic retransmission request ARQ.

This means that the request for retransmission is automatic. The receiver does not need to ask the sender to retransmit an errant packet.

  • Channel utilization

TD: A Time required for sending packets RTT: round trip delay TA: time required for sending acknowledgement packets TA

But this is inefficient! So we have pipelining!

5.1.2 Continuous ARQ protocol

The sender maintains the sending window, and the five groups in the sending window can be sent consecutively without waiting for the other party’s confirmation. So you have a higher channel utilization. Each time the sender receives an acknowledgement, it slides the sending window forward one grouping position. The receiver is generally a cumulative acknowledgment method, which means that the receiver does not have to send acknowledgments for each received packet. Instead, after receiving several groups, it sends an acknowledgement to the last one that arrives on demand,

If the sender sends the first five packets, but the middle third packet is lost. The receiver can only acknowledge the first two packets. The sender had no way of knowing where the next three groups were and had to retransmit all three. This is called go-back-n, which means you need to Go back and retransmit N groups that have been sent. It can be seen that when the communication line signal is bad, continuous ARQ protocol will bring negative effects.

5.2 Implementation

5.2.1 Sliding Windows in bytes

I suggest you see this blogger’s introduction, which is very detailed in terms of sliding Windows in bytes

Now assume that A has received the acknowledgement segment from B, where the window is 20 bytes and the acknowledgement number is 31(this indicates that the next sequence number B expects to receive is 31, and the data up to 30 has been received). From these two data points, A constructs its own sending window.

The sending window indicates that A can continuously send all the data in the window without receiving the confirmation from B. All reservations must be displayed before the acknowledgement is received so that retransmission is used in a timeout.

You know from the above

  • A window:

Anything less than P1 is the part that has been sent and received an acknowledgement, while anything greater than P3 is the part that is not allowed to be sent. P3-p1 = The sending window of A P2-P1 = The number of bytes sent but not yet acknowledged P3-P2 = The number of bytes allowed to be sent that are currently unsent (also known as the number of available or valid Windows)

  • B window:

The size of the receiving window of B is 20. Outside the receiving window, the data until 30th has been sent for confirmation and delivered to the host. So you can no longer keep this data in B.After xu sends the data of serial numbers 42-53, the pointer P2 moves forward and coincides with P3. All the serial numbers in the sending window have been used up, but no confirmation has been received yet. Because A’s send window is full, the available window has been reduced to zero, so the send must be stopped. If all the data in the sending window have arrived at B correctly and B has already sent the confirmation, but these confirmations are stuck in the network, if there is no confirmation, A can only think that B has not received the confirmed data. So after the time controlled by the timeout calculator, A will retransmit this part of data. Reset the timeout timer until B’s confirmation.

Here is the relationship between the receiving cache and the receiving window.The send cache is used to temporarily store:

  1. The sending application sends data to the sender TCP to be sent.
  2. TCP sends data that has not yet received an acknowledgement.

The send window is usually only part of the send cache. Confirmed data should be deleted from the send cache, so the back edge of the send cache and the send window overlap. The number of bytes that were last written to the send cache by the sending application minus the last acknowledged byte is the number of bytes that are still written in the send cache. The sending application must control the rate at which data is written to the cache, or there will be no space in the sending cache.

The receive cache is used to temporarily store:

  1. Data that arrives in sequence but has not yet been read by the receiving application.
  2. Data that did not arrive in order.

5.2.2 Selecting the timeout retransmission time

For details about how to set the TCP timeout retransmission time, see blogger timeout retransmission time. If the timeout retransmission time is set too short, unnecessary retransmission of many packet segments will occur, which increases the network load. However, if the timeout retransmission time is set too long, the idle time of the network increases and the transmission efficiency is reduced.

TCP uses an adaptive algorithm that records the time when a segment is sent and the time when the corresponding acknowledgement is received. The difference between these two times isRTT round trip time of the packet segment. Weighted average round trip Time TCP retains a weighted average round trip time (RTTS) of RTT (also known as smooth round trip time). When the RTT sample is measured for the first time, the RTTS value is taken as the measured RTT sample value. After measuring a new RTT sample, press the formula to recalculate RTTS:

RTO Retransmission time-out (RTO) should be slightly greater than the weighted average round trip Time (RTTS). RFC 2988 recommends the following formula to calculate RTO.RTTD is the weighted average of the deviations of RTT. RFC 2988 recommends calculating RTTD in this way. For the first measurement, the RTTD value was taken as half of the measured RTT sample value. In subsequent measurements, the RTTD of the weighted average is calculated using the following formula:Is a coefficient less than 1, and the recommended value is 1/4, or 0.25.

Description No acknowledgement was received for TCP segment 1. After retransmission (segment 2), an ACK of the acknowledgment segment was received. Procedure How do I determine whether this acknowledgment segment is the acknowledgment of the original segment 1 or the retransmitted segment 2? Karn algorithm

When calculating RTT, the RTT sample is not used as long as the segment is retransmitted. The weighted average round trip time (RTTS) and timeout retransmission time (RTO) obtained in this way are more accurate. But this raises new questions. When the delay of a packet segment suddenly increases greatly, no acknowledgement packet segment is received within the original retransmission time. The segment is then retransmitted.

However, according to the Karn algorithm, the round trip time sample of the retransmitted packet segment is not considered. In this way, the timeout retransmission time cannot be updated. Each time the segment is retransmitted, the RTO is increased:The typical value of the coefficient γ is 2. When no segment retransmission occurs, the RTT and RTO are updated according to the round trip delay of the segment.

5.2.3 Confirming the SACK

Refer to the bloggerSelect confirm SACKThe serial number of the byte stream sent by the receiver of TCP is discontinuous. The serial number of the byte stream 1001 to 1500 is not received. The next byte stream was received again, but it lacked 3001-3500. And then no receipt from serial number 4501. That is, the receiver receives two byte blocks that are not contiguous with the preceding one. But send the information accurately and quickly, so that the sender does not send the data that has already been received.

6. TCP window mechanism

In general, we want data to move faster. But if the sender sends the data too fast, the receiver may not receive it in time, and the data will be lost. The so-called flow control is to let the sender send speed is not too fast, to let the receiver and receive. The following is flow control using the sliding window mechanism.

Let A send data to B. When the connection is established, B tells the receiving window A RWND = 400. Therefore, the sending window of the sender cannot exceed the value of the receiving window given by the receiver. Note that TCP Windows are in bytes, not segments.

Suppose that the packet segment is 100 bytes long, and the initial value of seq is set to 1. The uppercase ACK indicates the acknowledgment bit in the header, and the lowercase ACK indicates the value of the acknowledgment field.

We should note that host B on the receiving end performed three flow controls.

  1. The first time, reduce the window to RWND =300.
  2. The second time it was reduced to RWND =100.
  3. Finally, it is reduced to zero, which means the sender is not allowed to send any more data.

To prevent A from waiting for A non-zero window sent by B (the segment is lost during transmission!) TCP sets A duration timer for each connection as long as the TCP side receives A zero window notification from the other side. Starts the duration timer. If the duration timer expires, a probe segment with a zero window is sent, and the peer party gives the current window value when confirming the probe segment. So there are two outcomes

  1. If the window is still 0, then the party that received the segment resets the duration timer.
  2. If the window is not zero, then the wait is broken.

7. Calculates the TCP timeout retransmission time

See the sample!

8. The TCP selection confirms the SACK

See above! 5.2.3 requires

9. TCP flow control (zero window problem, confused window syndrome)

9.1 Zero Window problem

There is! 6 points

Confused window syndrome

Assuming that TCP receiver buffer is full, and the application of interactive process at a time from the receive buffer read 1 byte, then sends a confirmation to the sender and the window is set to 1 byte (40 bytes long) but to send the data of the time, and then the sender sent 1 byte of data (please note that the sender sends the IP datagram is 41 bytes long). The receiver sends back an acknowledgement, still 1 byte. This will make the network very inefficient.

To solve this problem, you can make the receiver wait for a period of time, either to receive mixed villages so that there is enough space for the longest segment, or to wait for a certain amount of free space in the receive cache.

10. TCP congestion control

The water is so deep that I can’t keep track of it. Check out this blogger on TCP congestion control

11. Exercises after class

The data field of a UDP user datagram is 8192 bytes. Ethernet is used for transmission at the link layer. How many IP datagram should be divided into? Specifies the length of the data field and the value of the chip offset field for each IP datagram.

The hex representation of the header of a UDP user datagram is 06 32 00 45 00 1C E2 17. Obtain the source port, destination port, total length of user datagram, and partial length of data. Is this user datagram sent from the client to the server or from the server to the client? What is this server program that uses UDP?

The third question (5-21) assumes that the continuous ARQ protocol is used, the sending window size is 3, and the sequence range is [0,15], and the transmission media guarantees to receive the packets in order at the receiver. At some point, on the receiving end, the next expected receiving sequence number is 5. Ask: ① What kinds of sequence number combinations may appear in the sending window of the sender? ② What are the possible acknowledgement packets that have been sent by the receiver but are in the network (i.e. have not reached the sender)? Indicates that these confirmation groups are used to confirm which sequence groups.

Host A sends two TCP packet segments with serial numbers 70 and 100 to host B. (1) How many bytes of data does the first segment carry? (2) What is the acknowledgement number in the acknowledgement sent back by host B after receiving the first segment? (3) If the acknowledgement number sent by host B after receiving the second packet segment is 180, how many bytes does the data in the second packet segment sent by host A contain? (4) If the first segment sent by A is lost, but the second segment reaches B. B sends an acknowledgement to A after the second segment arrives. What should the confirmation number be?

Question 5 (5-27) What is the maximum number of bytes in the data part of a TCP packet segment? Why is that? If the length of the data to be transmitted exceeds the maximum number that can be encoded in the serial number field of the TCP packet field, can TCP be used to transmit the data?Question 6 (5-31) If the communication channel bandwidth is 1Gbit/s, the end-to-end delay is 10ms, and the TCP transmission window is 65535B, what is the maximum throughput that can be achieved? What’s the channel utilization?

It is known that the round-trip time RTT of the first measured TCP is 30 ms. Then three acknowledgement segments are received, and the RTT measured by them are 26 ms, 32 ms and 24 ms respectively. Let α= 0.1. Try to calculate a new weighted average round trip time (RTT) for each trip. The result of the discussion.Problem 8 (5-38) Set the initial value of Tcp ssthresh as 8 (unit is packet segment). When the congestion window goes up to 12, the network times out. Tcp uses slow start and congestion avoidance, and try to figure out the size of each congestion window from the first transmission to the 15th transmission.

rounds Congestion window Reasons for congestion window changes
1 1 The network timed out. TCP uses the slow start algorithm
2 2 Double the congestion window value
3 4 Double the congestion window value
4 8 Double the congestion window value, which is the initial value of SSthresh
5 9 TCP uses the congestion avoidance algorithm. The value of the congestion window is increased by 1
6 10 TCP uses the congestion avoidance algorithm. The value of the congestion window is increased by 1
7 11 TCP uses the congestion avoidance algorithm. The value of the congestion window is increased by 1
8 12 TCP uses the congestion avoidance algorithm. The value of the congestion window is increased by 1
9 1 The network timed out and TCP used the full-start algorithm
10 2 Double the congestion window value
11 4 Double the congestion window value
12 6 The congestion window value is doubled, but when it reaches half of 12, it is changed to the congestion avoidance algorithm
13 7 TCP uses the congestion avoidance algorithm. The value of the congestion window is increased by 1
14 8 TCP uses the congestion avoidance algorithm. The value of the congestion window is increased by 1
15 9 TCP uses the congestion avoidance algorithm. The value of the congestion window is increased by 1

9 (5-39)

The relationship between the size of the TCP congestion window CWND and the number of transmission rounds N is as follows:

(1) Try to draw the relationship curve between congestion window and transmission rounds as shown in Figure 5-25. (2) Indicates the time interval at which TCP works in the slow start phase. (3) Specify the time interval at which TCP operates in the congestion avoidance phase. (4) After round 16 and round 22, does the sender detect the loss of the segment by receiving three repeated acknowledgments or by the supermarket? (5) What is the threshold ssthresh set for the first, 18th and 24th rounds of sending? (6) In which round is the 70th message segment sent? (7) Assuming that three repeated acknowledgmentsare received after the 26th round and the packet segment loss is detected, then how big should the congestion window CWND and threshold SSthresh be set?

(1) (2)

Slow start time intervals: [1, 6] and [23, 26]

(3)

Time interval of congestion avoidance phase: [6, 16] and [17, 22]

(4) After round 16 and round 22, does the sender detect the loss of the segment by receiving three repeated acknowledgments or by timeout?

After the 16th round, the sender detects that the segment is lost by receiving three repeated acknowledgments, and the next round’s congestion window is halved.

After 22 rounds, the sender detects that the packet segment is lost through timeout, and the congestion window of the next round drops to 1.

(5) What is the threshold ssthresh set for the first, 18th and 24th rounds of sending?

When the first round is sent, the threshold SSthresh is set to 32 because the congestion avoidance state has been entered since the sixth round, and the congestion window increases by 1 per round. On the 18th round send, the threshold SSthresh is set to half of the congestion window 42 when congestion occurs, i.e. 21. On the 24th round send, the threshold Sshresh is set to 13, half of the congestion window 26 in congestion.

(6) In which round is the 70th message segment sent?

If you add it up on the table, you know that it’s only greater than 70 in the seventh round. So it’s the seventh round.

(7) Assuming that three repeated acknowledgmentsare received after the 26th round and the packet segment loss is detected, then how big should the congestion window CWND and threshold SSthresh be set?

The CWND of the congestion window is 8 when the loss of the packet segment is detected, so the value of CWND of the congestion window should be halved to 4, and the threshold SSthRESH should be set to half of the congestion window 8 when the loss of the packet segment is detected, that is, 4.

The window is 100 bytes, and the TCP segment also transmits 100 bytes of data each time. Then set the start serial numbers of the sender and receiver to 100 and 200 respectively. Try to draw a working diagram similar to the one shown in Figure 5-31 in the book. Using TCP to transmit 512 bytes of data, set the window to 100 bytes, and TCP segment each time also transmit 100 bytes of data. Then set the start serial numbers of the sender and receiver to 100 and 200 respectively. Try to draw a working diagram similar to figure 5-31 in the book, from the connection establishment stage to the release of the connection.

Question 11 (5-61) Draw the change of the departure window in the eight cases listed in the question. And indicate the location of available Windows. Host A is known to send 3KB of data to host B. After A TCP connection is established, the size of A’s send window is 2KB. The initial number of A is 0. (1) At first, A sends 1 KB of data. (2) Then A keeps sending data until the sending window is used up. (3) Sender A receives the acknowledgement packet segment for byte no. 1000. (4) Sender A then sends the data of 850 B. (5) Sender A receives the acknowledgement packet segment with ACK = 900. (6) Sender A receives the acknowledgement segment for byte No. 2047. (7) Sender A sends all the remaining data. (8) Sender A receives the acknowledgement packet segment ack= 3072.

  1. We should note that the send window = 2KB is 2*1024=2048 bytes. So the send window is 0 to 2047 bytes, and the length is 2048 bytes. A started with 1024 bytes, so the left 1024 bytes in the sending window are used up (the left side of the window), while the blue ones on the right are available, from 1024 bytes to 2047 bytes.
  2. Sender A keeps sending data until it runs out of Windows to send. The whole window is now used up. The size of the available window is zero, not a byte can be sent.
  3. When sender A receives the acknowledgement packet segment for byte no. 1000, it indicates that A has received the acknowledgement packet with ACK =1001. At this time, the back edge of the sending serial port moves forward, the sending serial port is from byte 1001 to byte 3048, and the available window is from byte 2048 to 3018.
  4. Sender A sends another 850 bytes, moving the back edge of the available window forward by 850 bytes, to 2898 bytes. Currently available serial ports range from 2898 bytes to 3048 bytes.
  5. Sender A receives an ACK =900 acknowledgment segment without any effect on the state of its window. This is A lateness determination.
  6. Sender A receives the acknowledgement segment for byte no. 2047. A’s send window moves forward again. The send window now starts at byte 2014 through byte 4095. The available window has grown, from 2898 bytes to 4094 bytes.
  7. Sender A sends all the remaining data. Sender A has 3KB of data numbered from 0 to 3071. As a result, the available window is now smaller, so the new send window position moves forward again, from 3072 to 5119.
  8. Sender A receives an ACKNOWLEDGEMENT packet with ACK =3072, indicating that the packet segment numbered 3071 and previous packets have been received, and the expected packet segment numbers start from 3072. As a result, the position of the new send window moves forward again, from 3072 to 5119. The entire send window is also the available window.

The last

Xiao Sheng Fan Yi, looking forward to your attention.