Send data over UDP network to a remote device
Simulink Real-Time / IP
The UDP Send block sends data over a UDP network to a remote device. The block can send data by using the connection between the development and target computers or by using a dedicated Ethernet card. If you use a dedicated Ethernet card, use the Speedgoat configuration utility to configure the dedicated Ethernet board. One of the settings provided by this utility is the Default Gateway setting. When using the UDP Send block to broadcast to 255.255.255.255, the IP interface for broadcast is based on this Default Gateway setting.
To broadcast to all devices on the
local subnetwork, set To IP address to
255.255.255.255. Otherwise, set To IP
address to a valid IP address.
For unicasting, broadcasting and multicasting, the parameters Local IP address and Local port are optional. The Local IP address applies when the block executes in a real-time application on a target computer or in a model simulation on a development computer. If your model is running in Simulink® on the development computer, you can use this block to transmit data to a remote device. In this case, the Windows® operating system determines the network connection.
Data — Data to transmit
uint8 containing data to transmit over
the UDP network. To determine how many bytes of data to transmit, use
the Length input port. If you enable the
Enable Simulink messages parameter, the data
UDP_Packet. Use the
slrealtime.createUDPPacketBusObj function to create the
Ethernet_Packet. This data type consists
IP_Address: DataType: uint8, Complexity: real, Dimensions: [4 1]
IP_Port: DataType: uint16, Complexity: real, Dimensions: 1
Length: DataType: uint16, Complexity: real, Dimensions: 1
Data: DataType: uint8, Complexity: real, Dimensions: [75 1]
Length — Number of bytes of data to transmit
This port is available when you disable the Enable Simulink
messages parameter. The Length determines the number of
bytes of data to transmit. Specify the width of the
Data vector as the maximum number of bytes that
you expect to transmit.
Use host-target connection — Use Ethernet connection between development and target computers
'off' (default) |
When you select this parameter, it deactivates the Local IP
address parameter and excludes the ports
5560 from use by
To IP address — IP address of target device
10.10.10.10 (default) |
Specifies IP address of target
device. To broadcast
to all devices on the local subnetwork, send to
To port — UDP port of target device
34 (default) |
Specify the UDP port of target device. With To IP address, this parameter defines the destination of the data transmission.
Enable Simulink messages — Data as messages
off (default) |
The Enable Simulink messages directs the block to treat data as messages. When enabled, the Length port is removed.
Local IP address — Source IP address for sending data
no value (default) |
When Local IP address is set to Use host-target connection, the block uses the connection between the development and target computers. When To IP address is specified as a multicast address, the local IP address is used to determine the outbound interface over which multicast datagrams are sent. The default value for the Local IP address field is no value. This empty field means that the operating system chooses the Local IP address for UDP transmission.
Local port — Source UDP port to transmit data
no value (default) |
Specifies local UDP port to transmit data.
5560 are reserved for Simulink Real-Time
−1, or no value
mean that the block transmits data by using
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Version HistoryIntroduced in R2020b
R2021b: Changed Parameters Local IP Address and Local Port
The parameters for the UDP Send block have changed. For unicasting, broadcasting, and multicasting, the parameters Local IP address and Local port are optional.
R2021a: Added Multicast Support
The UDP Multicast Receive block was added, and the UDP Send block has multicast support. These blocks provide multicast message support for the UDP communications protocol.