Main Content

UDP Send

Send data over UDP network to a remote device

  • Library:
  • Simulink Real-Time / IP

  • UDP Send block

Description

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.

Ports

Input

expand all

Vector of uint8 containing data to transmit over the UDP network. To determine how many bytes of data to transmit, use the Length input port.

Data Types: uint8

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.

Parameters

expand all

Dependency

When you select this parameter, it deactivates the Local IP address parameter and excludes the ports 1 through 1023 and 5500 through 5560 from use by UDP.

Programmatic Use

Block Parameter: useHostTargetConn

Specifies IP address of target device. To broadcast to all devices on the local subnetwork, send to 255.255.255.255.

Programmatic Use

Block Parameter: toAddress

Specify the UDP port of target device. With To IP address, this parameter defines the destination of the data transmission.

Programmatic Use

Block Parameter: toPort

Enter the base sample time or a multiple of the base sample time.

Programmatic Use

Block Parameter: sampleTime

Advanced Parameters

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.

Programmatic Use

Block Parameter: ipAddress

Specifies local UDP port to transmit data.

Ports 1 through 1023 and 5500 through 5560 are reserved for Simulink Real-Time communications.

The value 0, −1, or no value mean that the block transmits data by using any available port.

Programmatic Use

Block Parameter: localPort
Introduced in R2020b