Main Content

UDP Send

Send UDP packet

  • Library:
  • Embedded Coder / Embedded Targets / Host Communication

  • UDP Send block


The UDP Send block transmits an input data vector as a UDP packet to a remote IP network port. The remote IP port number to which the block sends the UDP packets is tunable in the generated code.

Some Simulink® blocks and .exe files built from models that contain those blocks require shared libraries, such as .dll files on Windows®. The UDP Send block requires the networkdevice.dll library file. To meet this requirement, follow the example on the packNGo function page to package the code files for your model. The resulting compressed folder contains the .dll files that the model requires, including networkdevice.dll. To run this type of .exe file outside of a MATLAB® environment, place the required .dll files in the same folder as the .exe file or place them in a folder on the Windows system path. For more details, see How To Run a Generated Executable Outside MATLAB (DSP System Toolbox).



expand all

UDP packet, specified as a data vector, which is transmitted to an IP network port.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | enumerated | bus


expand all

Specify the IP address or hostname to which to send UDP packets. If you specify a hostname, specify it as a string. To broadcast a UDP packet, specify ''.

Specify the IP port number to which to send UDP packets. This parameter is tunable in the generated code but is not tunable during simulation.

On Linux®, to set the IP port number below 1024, run MATLAB with root privileges. For example, at the Linux command line, enter:

sudo matlab

Specify whether the block uses a local port number that the system assigns or that you specify by using the Local IP port parameter. To let the system assign the port number, select Automatically determine. If the receiving address expects UDP packets from a specific port number, select Specify via dialog and specify the port number by using the Local IP port parameter.

Parameter Dependencies

To enable the Local IP port parameter, select Specify via dialog.

Specify the IP port number from which the block sends UDP packets. Use this parameter when the receiving address expects messages from a specific port number.

Parameter Dependencies

To enable this parameter, set Local IP port source to Specify via dialog.

Specify the size of the buffer, in bytes, that sends the UDP packets. Make the buffer large enough to avoid data loss caused by buffer overflows.

Extended Capabilities

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

Introduced in R2011a