Receive UDP data from remote host
The UDP Receive block receives UDP (User Datagram Protocol) data from a remote host. The block reads available UDP data from the socket buffer and outputs the data as a vector.
Port_1— UDP data received
UDP data received from remote host, returned as a numeric vector. Set the data type of this output by using the Data type for Message parameter.
Local IP port— IP Port on remote host
25000(default) | integer from 1 to 65,535
Specify the local IP port number of the application on the hardware board on which you want to receive UDP packets. The port number must be an integer from 1 to 65,535.
On Linux®, to set the local IP port number below 1024, run MATLAB® with root privileges. For example, at the Linux command line, enter:
Remote IP address ('0.0.0.0' to accept all)— Remote IP address to listen
'0.0.0.0'(default) | valid IP address
Specify the IP address from which the block accepts UDP packets. Entering a specific
IP address blocks, UDP packets from other addresses. To accept packets from all IP
addresses,use default value
Receive buffer size (bytes)— Maximum number of data bytes in received data
8192(default) | positive integer
Specify the size of the buffer size in which you want to store the received UDP packets. Specify the receive buffer size to be large enough to avoid data loss caused by buffer overflows.
Maximum length for Message— Maximum length of output UDP data
255(default) | positive integer
Specify the maximum length of the output UDP data. This value must be greater than or equal to the data size of a UDP packet. The system truncates any data that exceeds this length.
Data type for Message— Data type of output data
Select the data type of the output UDP data. This data type must be the same as the data type of UDP message sent by the remote host.
Output variable-size signal— Enable or disable variable output signal size
Select the Output variable-size signal if your model supports signals for varying length. In this case:
The output vector varies in length, depending on the amount of data in the UDP data received.
The block emits the data vector from a single unlabeled output.
Clear the Output variable-size signal if your model does not support signals of varying length. In this case:
The block emits a fixed-length output of the same length as the Maximum length for Message.
If the UDP packet contains less data than the fixed-length output, the difference contains invalid data.
The Data type for length parameter is enabled.
In both cases, the block truncates data that exceeds the Maximum length for Message.
Blocking time (seconds)— Time to wait for UDP packet
inf(default) | nonnegative scalar
Specify the duration of wait time for a UDP packet at each sample before returning control to the scheduler.
Sample time (seconds)— Sample time
1(default) | positive scalar
Specify how often the scheduler runs this block. Setting this parameter to a large value reduces the likelihood of dropped UDP messages.