Summary of computer network transport layer knowledge

Transport layer: a layer only available on the host, communication between processes

Services provided by the transport layer

Transport layer functions

  •     The transport layer provides logical communication between processes, that is, end-to-end communication (the network layer is communication between hosts)
  •     Reuse and deuse
  •     Error detection (header and data part)
  •     Connection-oriented TCP and connectionless UDP

Multiplexing: All application processes in the application layer can be transmitted to the network layer through the transport layer.
Decentralization: The transport layer receives the data from the network layer and delivers it to the specified application process

[2018 Unified Examination Real Questions] The header field based on the implementation of UDP protocol and split use is (A).

A. Destination port number

C. Length

D. Checksum

A. Source port number

port

The role of ports

  •     The port identifies the process in the host
  •     Hardware ports are interfaces for different hardware devices to interact (available on routers and switches)
  •     Software port is an address for inter-layer interaction between various protocol processes and transmission entities in the application layer

The port number

  •    Well-known port numbers are 0-1023
  •    The registration port number is 1024-49151
  •    The short-term port number is 49152-65535 

socket

  •     Socket = (IP address: port number)
  •     It uniquely identifies a host in the network and an application (process) on it

summary

    1. The network layer only provides header error control
    2. The SAP of the data link layer is the MAC address, the SAP of the network layer is the IP address, and the SAP of the transport layer is the port .
    3. The transport layer uses software ports
    4. The user application uses UDP for data transmission, so it must provide reliable support at the upper layer of the transport layer, the application layer. All work on gender
    5. The header length of a TCP message is 20B, and the header length of an IP datagram is also 20B
 

UDP

There is no need to establish a connection before transmitting data, and no confirmation is required after receiving the UDP message.

For network applications that use UDP, the reliability of their transmission is responsible for the application layer.

UDP only adds two basic services to IP's datagram services: multiplexing and demultiplexing, and error detection.

UDP datagram

Features of UDP:

  • UDP does not require establishing a connection
  • No connection status
  • Packet header overhead is small (8B)
  • The application layer has better control over what data is sent and when it is sent.
  • UDP supports one-to-one, one-to-many, many-to-one and many-to-many interactive communications.
  • Suitable for small files
  • Send an entire message at once
  • UDP is message-oriented

UDP header format
    ●Source port
    ●Destination port
    ●Length
    ●Checksum

UDP checksum

18bf53b8c62d4dac896e07776eac0531.jpeg

  •  During verification, if the length of the UDP datagram part is not an even number of bytes, you need to fill in an all-0 byte
  •  If the UDP checksum verifies that the UDP datagram is wrong, it can be discarded or delivered to the upper layer, but an error report needs to be attached, that is, the upper layer should be told that this is a wrong datagram.
  • Through the pseudo header, you can not only check the source port number, destination port number and data part of the UDP user datagram, but also check the source IP address and destination address of the IP datagram.
  • When there is no error, the result is all 1, otherwise it is an error and the receiver discards the UDP datagram.
  • This field is optional, set to all zeros if not used

summary

   1. The format of UDP datagram includes UDP source port number, UDP destination port number, UDP message length and checksum, but does not include UDP datagram header length. Because the UDP datagram header length is fixed at 8B, there is no need to set the header length field.
    2. The checksum function of UDP is not necessary and can not be used.
    3. If the UDP checksum calculation result is 0, then in the checksum The field is set to all 1
    4. The calculation of UDP checksum field includes a pseudo header, UDP header and carried user data 
    5.UDP checksum The calculation method is binary complement operation, sum and then negation

TCP

A connection must be established before data is transmitted, and the connection must be released after data transmission is completed. No broadcast or multicast services are provided. Since TCP needs to provide reliable connection-oriented transmission services, it inevitably adds a lot of overhead: confirmation, flow control, timers and connection management, etc.

Characteristics of TCP:

  • Connection-oriented, logical connection
  • Each TCP connection is one-to-one
  • Full duplex communication
  • reliable
  • byte stream oriented
  • Suitable for large files


TCP segment
    ●Header (the first 20B of the header is fixed. The minimum length of the TCP header is 20B, followed by 4N bytes, which are options that can be added as needed. The length Is an integer multiple of 4B.)
    ●Data

TCP connection management
    ●Connection establishment
    ●Data transmission
    ●Connection release

TCP connection establishment:
    ●Three-way handshake
    ●The server-side resources are allocated when the second handshake is completed
    ●The client-side resources are allocated when the third handshake is completed

Contact erected. Part 3:
①SYN=1, seq=x.
②SYN=1, ACK=1, seq=y, ack=x+ 1.
③ACK=l, seq=x+ 1, ack=y+ 1.
 

[2011统考真题]主机甲向主机乙发送一个(SYN=1, seq=11220)的TCP段,期望与
主机乙建立TCP连接,若主机乙接受该连接请求,则主机乙向主机甲发送的正确的TCP
段可能是( )。
A. (SYN=0,ACK=0, seq=11221, ack= 11221 )
B. (SYN=1, ACK=1,seq= 11220, ack= 11220)
C. (SYN=1, ACK=1,seq=11221, ack=11221 )
D. (SYN=0, ACK=0,seq= 11220, ack= 11220)
在确认报文段中,同步位SYN和确认位ACK必须都是1;

返回的确认号ack是甲发送的初始序号seq=11220加1,即ack= 11221;

同时乙也要选择并消耗-一个初始序号seq, seq 值由乙的TCP进程任意给出,它与确认号、请求报文段的序号没有任何关系。

Release of TCP connection:
    ●Four-way handshake

Continuous connection. Minute 4 steps:
①FIN=1, seq=u.
②ACK=l, seq=v, ack=u+ 1.
③FIN=1, ACK=1, seq=w, ack=u+ 1.
④ACK=1, seq=u+ 1, ack=w+ 1.
 

Reliable transmission of TCP
    ●Verification (consistent with UDP)
    ●Serial number (to ensure that data is submitted to the application layer in order) a>     ●Congestion window cwnd     ●Receive window rwnd TCP congestion control     ●TCP Provide flow control services to eliminate the possibility of the sender (sending rate too fast) overflowing the receiver's buffer TCP flow control     ●Retransmission (timeout and redundant ACK)
    ●Confirmation







慢恢复例题:

[2009统考真题]一个TCP连接总以1KB的最大段长发送TCP段,发送方有足够多的
数据要发送,当拥塞窗口为16KB时发生了超时,如果接下来的4个RTT时间内的TCP
段的传输都是成功的,那么当第4个RTT时间内发送的所有TCP段都得到肯定应答时,
拥塞窗口大小是( C)。
A.7KB
B. 8KB
C. 9KB
D. 16KB
 发生超时后,慢开始门]限ssthresh变为16KB/2=8KB, 拥塞窗口变为1KB。在接下来的3个
RTT内,执行慢开始算法,拥塞窗口大小依次为2KB、4KB、8KB,由于慢开始门限ssthresh为
8KB,因此之后转而执行拥塞避免算法,即拥塞窗口开始“加法增大”。因此第4个RTT结束后,
拥塞窗口的大小为9KB。

 

快重传例题:

在一个TCP连接中,MSS为1KB,当拥塞窗口为34KB时收到了3个冗余ACK报文。.
如果在接下来的4个RTT内报文段传输都是成功的,那么当这些报文段均得到确认后,
拥塞窗口的大小是( )。
A.8KB
B. 16KB 
C.20KB
D. 21KB
条件“收到了3个冗余ACK报文”说明此时应执行快恢复算法,因此慢开始门限值设为17KB,
并在接下来的第一个RTT中cwnd也被设为17KB, 第二个RTT中cwnd=18,第三个RTT中cwnd= 19KB,
第四个RTT中cwnd = 20KB,第四个RTT中发出的报文全部得到确认后,cwnd再增加1KB,变为21KB。
注意cwnd的增加都发生在收到确认报文后。
17->18->19->20->21

summary

  1.TCP pseudo-header is the same as UDP pseudo-header, including part of the IP packet header. There is a protocol field in the IP header to indicate whether the upper layer protocol is TCP or UDP. 17 represents UDP, 6 represents TCP
  2. The header length is 20~60B. Since the unit of the data offset field is 4B, that is to say, when the offset is the maximum, the TCP header length is 15x4= 60B
  3.TCP uses variable-sized sliding windows for flow control
 

Guess you like

Origin blog.csdn.net/weixin_53197693/article/details/133783402