Transport layer-UDP/TCP protocol

1. UDP 

  • Source port: the port number of the sender application layer process
  • Destination port: the port number of the recipient application layer process
  • Length: the length of the UDP user datagram, the minimum value is 8 (only the header)
  • Checksum: Detect whether there are errors in the transmission of UDP user datagrams, and discard them if there are errors.

UDP must be an even number of bytes, and 0 can be added if it is insufficient.

 

2. TCP

  • Source port: the port number of the sender
  • Destination port: the port number of the receiving end
  • Sequence number: the sequence number of the first byte of the data in this segment [receiving end receives messages that may be fragmented in order]
  • Confirmation sequence number: expect to receive the sequence number of the first byte of the next segment of the other party
  • Header length (data offset): How far is the data start of the TCP message segment from the start of the TCP message segment, that is, the length of the header. Unit: 32 bits (4 bytes)
  • Reserved: 6 digits, reserved for future use, should be set to 0 at present.
  • Urgent URG: This bit is 1, indicating that the urgent pointer field is valid. It tells the system that there is urgent data in this segment and should be transmitted as soon as possible. [ Similar to a fire truck/ambulance ]
  • Acknowledgment ACK: Only when ACK=1, the acknowledgment number field is valid. TCP stipulates that ACK must be set to 1 in all message segments transmitted after the connection is established.
  • Push PSH: When two application processes communicate interactively, sometimes the application process at one end hopes to receive the response of the other party immediately after typing a command. In this case, TCP can use the push operation. At this time, the sender TCP sets PSH to 1, and immediately creates a segment to send out, and the receiver receives the segment with PSH=1, and delivers it to the receiving application process as soon as possible (ie: "push forward") , Instead of waiting until the entire cache is full before delivery [ in fact, it will not be slow before delivery, generally TCP is delivered after receiving a certain amount of data ].
  • Reset RST: used to reset the corresponding TCP connection.
  • Synchronous SYN: Only valid when the TCP connection is established by the three-way handshake. When SYN=1 and ACK=0, it indicates that this is a connection request message. If the other party agrees to establish a connection, SYN=1 and ACK=1 should be used in the corresponding message segment. Therefore, SYN is set to 1 to indicate This is a connection request or connection reception message.
  • Terminate FIN: Used to release a connection. When FIN = 1, it indicates that the data of the sender of this message segment has been sent, and the transport connection is required to be released.
  • Window: refers to the receiving window of the party sending this segment. Flow control, sending data <min (congestion window, receiving window)
  • Checksum: The scope of the checksum field check includes two parts: the header and the data. When calculating the checksum, a 12-byte pseudo-header needs to be added [Pseudo-header function: confirm whether this message segment is sent to Machine, reference: https://baike.baidu.com/item/%E4%BC%AA%E9%A6%96%E9%83%A8?fr=aladdin ].
  • Urgent pointer: only meaningful when URG = 1, it points out the number of bytes of urgent data in this segment (common data after the end of urgent data), that is, points out that the end of the urgent data is in the segment Location, note: Urgent data can be sent even when the window is 0.
  • Option: The length is variable, up to 40 bytes. When the option is not used, the TCP header length is 20 bytes.

 

Guess you like

Origin blog.csdn.net/qq_44065088/article/details/109235582