Receive UDP packets from network
The UDPReceiver object receives UDP packets from the network.
To receive UDP packets from the network:
H = dsp.UDPReceiver returns a UDP receiver System object™, H, that receives UDP packets from a specified port.
H = dsp.UDPReceiver('PropertyName',PropertyValue, ...) returns a window object, H, with each property set to the specified value.
Local port on which to receive data
Specify the port on which to receive data. The default is 25000.
Address from which data was sent
Specify the remote IP address from which to receive data. The default is '0.0.0.0', which indicates that data is accepted from any remote IP address.
Maximum size of internal buffer
Specify the size of the buffer that receives UDP packets, in bytes. The default is 8192.
Maximum size of output message
Specify the size of the output message. If received packets exceed the specified value, their contents are truncated. The default is 255.
Data type of the message
Specify the data type of the message as | double | single | int8 | uint8 | int16 | uint16 | int32 | uint32 | logical |. The default is uint8.
|clone||Create UDP receiver object with same property values|
|getNumInputs||Number of expected inputs to step method|
|getNumOutputs||Number of outputs of step method|
|isLocked||Locked status for input attributes and nontunable properties|
|release||Allow property value and input characteristics changes|
|step||Multiply input by window|
Send some UDP packets, and calculate the number of successfully transmitted bytes:
hudpr = dsp.UDPReceiver; hudps = dsp.UDPSender; bytesSent = 0; bytesReceived = 0; dataLength = 128; for k = 1:20 dataSent = uint8(255*rand(1,dataLength)); bytesSent = bytesSent + dataLength; step(hudps, dataSent); dataReceived = step(hudpr); bytesReceived = bytesReceived + length(dataReceived); end release(hudps); release(hudpr); fprintf('Bytes sent: %d\n', bytesSent); fprintf('Bytes received: %d\n', bytesReceived);
This object implements the algorithm, inputs, and outputs described on the UDP Receive block reference page. The object properties correspond to the block parameters, except:
The Output variable-size signal parameter is not included in the System object.
The Sample time parameter is not included in the System object.