Inquiry about IP address and port number for UDP Send and UDP Receive block

조회 수: 9 (최근 30일)
준호
준호 2024년 9월 19일
편집: Malay Agarwal 2024년 9월 20일
Hello all,
I have a question about the IP addresses and port numbers for the UDP Send and UDP Receive blocks. When sending and receiving data on the same PC, and using port 5002 to send data from MATLAB and port 5001 to receive data from external sources into MATLAB, how should I fill in fields 1 through 4?

답변 (1개)

Malay Agarwal
Malay Agarwal 2024년 9월 19일
When working on a local computer, you only need to worry about the "Remote address" and "Remote port" parameters in both the blocks.
In the "UDP Send" block, the "Remote address" specifies the IP address you want to send data to and the "Remote port" specifies the port on which the receiver is listening or expecting data on. In the "UDP Receive" block, the "Remote address" specifies the IP address you want to receive data from and the "Remote port" specifies the port on which the sender will be sending data.
In your case, assuming you want the "UDP Send" block to send data to the "UDP Receive" block, the configuration should be as follows:
  • "UDP Send" block: Set the "Remote address" to "127.0.0.1" and the "Remote port" to the "Local port" of the "UDP Receive" block. This is because the "UDP Receive" block is expecting to receive data on its local port (the UDP receiver is listening on port 5002).
  • "UDP Receive" block: Set the "Remote address" to "127.0.0.1" and the "Remote port" to the "Local port" of the "UDP Send" block. This is because the "UDP Send" block is sending data over its local port and to receive data from the "UDP Send" block, the receiver must connect to that port.
I have attached an example model to the answer which shows this configuration.
If you'd like to learn more about networking including IP addresses and port numbers, refer to the following resource: https://www.iitk.ac.in/esc101/05Aug/tutorial/networking/overview/networking.html
Refer to the following resources for more information:
Hope this helps!
  댓글 수: 2
준호
준호 2024년 9월 20일
Hi Malay,
Thank you for a kind reply.
I tried as you commanded, but there is an error below.
It says that each socket address (protocol/network address/port) can only be used by one instance.
Malay Agarwal
Malay Agarwal 2024년 9월 20일
편집: Malay Agarwal 2024년 9월 20일
Please make sure that the ports that you are using are not being used by any other services.
On Windows, launch an Administrator Command Window and use the following command:
netstat -anob
This will list all the ports that are being used on your system. Make sure your ports for the blocks are not in the list. If they are, use port numbers that are not in the list.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Direct Interface Communication in Simulink에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by