User Datagram Protocol UDP and Transmission Control Protocol TCP

Table of contents

UDP

Function of UDP

Features of UDP

UDP header format

TCP

Function of TCP

Characteristics of TCP

TCP stream-oriented concept

socket

Comparison of Connectionless Workflow and Connection-Oriented Workflow


UDP

Function of UDP

UDP adds very little functionality over IP's datagram service:

1. Multiplexing and demultiplexing functions

2. Error detection function

Features of UDP

UDP is connectionless, that is, there is no need to establish a connection before sending data, thus reducing overhead and delay before sending data

UDP uses best-effort delivery and does not guarantee reliable delivery, so the host does not need to maintain a complex connection state table

UDP is message-oriented , that is, UDP neither merges nor splits the messages delivered by the application layer, but reserves the boundaries of these messages and delivers a complete message at a time

UDP has no congestion control, so network congestion will not reduce the sending rate of the source host, which is very suitable for real-time application requirements

UDP supports one-to-one, one-to-many, many-to-one, many-to-many interactive communication

UDP header overhead is small, only 8 bytes, much shorter than TCP's 20 bytes

UDP header format

 The pseudo-header is only for calculating the checksum

  

 

TCP

Function of TCP

On the basis of connectionless and unreliable IP network services, a series of measures to ensure reliability are added to provide reliable delivery services

Characteristics of TCP

Connection-Oriented Transport Layer Protocol

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

TCP provides reliably delivered services

TCP provides full-duplex communication

Byte stream-oriented: The stream in TCP refers to the sequence of bytes flowing into or out of the process. The meaning of byte stream-oriented is that although the interaction between the application program and TCP is one data block at a time, TCP hands over the application program data as just a series of unstructured byte streams

TCP stream-oriented concept

 

  • A TCP connection is a virtual connection rather than a real physical connection
  • TCP does not care how long the application process sends the message to the TCP cache at a time
  • TCP decides how many bytes a message segment should contain according to the window value given by the other party and the degree of current network congestion (the length of the message sent by UDP is given by the application process)
  • TCP can divide too long data blocks into shorter ones before sending them
  • TCP can wait for enough bytes to be accumulated before forming a segment and sending it out

  • TCP regards connection as the most basic abstraction. Each TCP connection has two endpoints
  • The endpoint of the TCP connection is not the host, not the IP address of the host, not the application process, nor the protocol port of the transport layer. The endpoint of a TCP connection is called a socket or socket
  • The port number is concatenated with the IP address to form a socket
     

 

socket

  • A TCP connection is an abstraction provided by the protocol software
  • The endpoint of the TCP connection is a very abstract socket, namely (IP address: port number)
  • The same IP address can have multiple different TCP connections
  • The same port number can also appear in multiple different TCP connections

Different Meanings of Sockey

  • The application programming interface API is called socket API, or socket for short. A function name used in the socket API is also called socket. The endpoint that calls the socket function is called the socket
  • When the socket function is called, its return value is called socket descriptor, which can be referred to as socket
  • The Berkeley implementation of the networking protocol in the operating system kernel, called the socket implementation

Comparison of Connectionless Workflow and Connection-Oriented Workflow

 The difference is that the server waits for a connection after it is turned on, the client requests a connection, and the corresponding request and response are made after the connection is established.

Guess you like

Origin blog.csdn.net/zy1183747231/article/details/124230822