Send UDP message
DSP System Toolbox / Sinks
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 (Simulink Coder) function page to package the code
files for your model. The resulting compressed folder contains the
files that the model requires, including
networkdevice.dll. To run this
.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.
Input — Input data vector
Specify the input data vector that the block transmits as a UDP packet.
Complex Number Support: Yes
Remote IP address ('255.255.255.255' for broadcast) — IP address from which to accept UDP packets
'127.0.0.1' (default) | IP address | string
Specify the IP address or host name to which to send UDP packets. If you specify a
host name, specify it as a string. To broadcast a UDP packet, specify
Remote IP port — Number of remote IP port
25000 (default) | scalar in the range [1, 65535]
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
Local IP port source — Source of local IP port
Automatically determine (default) |
Specify via dialog
Specify whether the block uses a local port number that the system assigns or that
you specify by using the Local IP port parameter. For the system to
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.
Local IP port — Number of local IP port
-1 (default) | scalar in the range [1, 65535]
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.
To enable this parameter, set Local IP port source to
Specify via dialog.
Send buffer size (bytes) — Size of buffer that sends UDP packets
8192 (default) | scalar in the range [1, 67108864]
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.
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Usage notes and limitations:
The executable generated from this block relies on prebuilt dynamic library files (
.dllfiles) included with MATLAB. Use the
packNGofunction to package the code generated from this block and all the relevant files in a compressed ZIP file. Using this ZIP file, you can relocate, unpack, and rebuild your project in another development environment where MATLAB is not installed. For more details, see How To Run a Generated Executable Outside MATLAB.
The Remote IP port parameter is tunable in the generated code, but not tunable during simulation. You can control the parameter tunability in the generated code through several ways. One of the ways is to configure the parameter as a tunable field of a global structure in the generated code. Other ways include applying a built-in storage class or custom storage class to a
Simulink.Parameterobject and using this object to set the value of the block parameter. For details, see Create Tunable Calibration Parameter in the Generated Code (Simulink Coder).