adolfbasil › industrial iot gateway › Can TCP and UDP bind to the same port at the same time?

Can TCP and UDP bind to the same port at the same time?

2023年04月17日



Introduction to TCP and UDP

TCP and UDP are two independent protocols of IP (Internet Protocol), and they both work at the network layer in the OSI model. Among them, the biggest difference between TCP and UDP is connection-oriented and connectionless-oriented.

TCP
When the reliability of the data to be transmitted is very important, we generally use TCP for transmission, because the data transmitted by the TCP protocol is transmitted sequentially. If the data receiver does not receive the data transmitted by the sender, TCP will resend the packet after a certain time. This is what we often call the packet loss retransmission mechanism, as well as congestion control, flow control, etc. The reliability of TCP is precisely because of these characteristics.

UDP
UDP (User Datagram Protocol) is a connectionless service. UDP data will not be guaranteed to be transmitted in order like TCP. The receiver will not retransmit the data regardless of whether it is received or not. Therefore, UDP has a lower cost than TCP. Delay. In applications where time priority is higher than data reliability, UDP is more commonly used, such as video calls and online games that are usually used. Because for these applications, time is more important than data consistency.
picture
What is a network port? What does the port do?

There are many communication programs on our computer. When our computer receives a data packet, how is the data packet accurately distributed to different applications? We can understand that the IP address in the network is equivalent to the community name in our real life, and the port number is like a specific house number.
picture
The function of the port is to allow various application processes in the application layer to deliver their data down to the transport layer through the port, and to let the transport layer know that the data in its segment should be delivered up through the port to the process of the application layer. In order to distinguish the ports, each port is numbered, which is the port number. When we send data from one device to another, it goes to a specific TCP or UDP port, depending on the protocol we use to communicate.
picture
Can TCP and UDP Sockets be bound to the same port?

Both TCP and UDP server networks will call bind to bind ports.


TCP network programming



TCP and UDP ports are not related to each other. TCP ports are interpreted by the TCP stack, and UDP ports are interpreted by the UDP stack. Ports are a way of multiplexing connections so that multiple devices can be connected to a node. So technically higher level protocols can use the same or different TCP and UDP port numbers. On the other hand, a computer can communicate with two different services using the same TCP and UDP port numbers at the same time.


The port numbers of TCP/UDP are independent of each other. TCP has a port 80, and UDP can also have a port 80, and the two do not conflict.

Therefore, TCP and UDP can be bound to the same port at the same time.

The TCP and UDP transport protocols are implemented in the kernel by two completely independent software modules.

When the host receives the data packet, it can know whether the data packet is TCP or UDP in the "protocol number" field of the IP header, so it can determine which module (TCP/UDP) to send to the TCP/UDP module according to this information. According to the "port number", the message is sent to which application program to process.

Therefore, the respective port numbers of TCP/UDP are independent of each other and do not affect each other.


タグ :TCP and UDP

同じカテゴリー(industrial iot gateway)の記事
 What is the difference between BLE and traditional Bluetooth (2023-05-08 18:28)
 LBT wireless communication technology functions (2023-04-28 12:16)
 What is the future development potential of antenna (2023-03-20 18:43)
 Oil exploration wells are scattered and numerous in number (2023-03-13 14:46)
 The challenges posed by the current Internet of Things (2023-03-13 14:26)
 Wi-Fi 6 Advantages (2023-02-20 17:13)

上の画像に書かれている文字を入力して下さい
 
<ご注意>
書き込まれた内容は公開され、ブログの持ち主だけが削除できます。