Main Content

UDP Receive

Receive UDP data from remote host

  • UDP Receive block

Embedded Coder Support Package for ARM Cortex-A Processors


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.



expand all

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.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean


expand all

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:

sudo matlab

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 ''.

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.

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.

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.

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.

Specify the duration of wait time for a UDP packet at each sample before returning control to the scheduler.

Specify how often the scheduler runs this block. Setting this parameter to a large value reduces the likelihood of dropped UDP messages.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2014b

See Also