This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

UDP Receive

Receive UDP packets from another UDP host on an Internet network.


Receive UDP packets from another UDP host on an Internet network.

The block outputs a UDP data packet, Data, as a one-dimensional vector of length Size.

The data type of the block output, Data, is set by the parameter Data type parameter and supports the following data types: uint8, int8, uint16, int16, uint32, int32, single, and double.

The data type of the block output, Size, is uint16.

While UDP Receive waits for new data to arrive, Size outputs a zero. When new data arrives, Size changes to a non-zero value.

If you simulate a model that contains the UDP Receive block on your host computer, Simulation > Normal, then Data outputs a zero for each step of the simulation when no UDP packets are available. As a free-running application with a shorter period than the real-time application running on the Apple iOS device, a large number of zeros can be produced from the output port Data. In other words, the free-running simulation outputs zeros while waiting for the "slower" real-time application on the Apple iOS device to send data.

During simulations, this block does nothing. See Block Produces Zeros or Does Nothing in Simulation (Simulink).


If you are having trouble using UDP to communicate between your host computer and your Apple iOS device, investigate whether antivirus or firewall software might be blocking UDP traffic. If so, try to reconfigure the software to allow UDP traffic for a specific IP port number.


Local IP port

The number of the IP port on the local device, which can range from 1 to 65535. This value defaults to 25000. The “local device” is the board running the model.

Data type

Set the data type of the vector elements in the Message output. Match the data type with the data input used to create the UDP packets. This option defaults to uint8.

Data size (N)

Set the number of data elements in each UDP packet. Match the data size used to create the UDP packets. This value defaults to 255 elements.

Sample time

Specify how often this block reads the port buffer. Enter a value greater than zero. This value defaults to a sample time of 0.01 seconds.

Smaller values require the processor to complete the same number of instructions in less time, which can cause task overruns.

Extended Capabilities

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

See Also

Introduced in R2015a