LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

UDP Help

First off 2 questions about UDP in labview.

1. I have my data that is a 1-D array of string, and i am trying to connect it to the UDP write block, and its sink is a string, what is the best way to convert the data to make the block work, and then subsequently what would be the best way to unpack the string on the other end.

2. On the read side of the udp, how do I know what to set the max bytes read to?

 

Any help would be appreciated,

 

Thanks,

David

0 Kudos
Message 1 of 6
(3,467 Views)

1. Loop?

2. What is the max size of the strings in your array? I believe the limit of UDP might be 65,507 bytes

Message Edited by FMonkey on 10-03-2007 12:29 PM

Message Edited by FMonkey on 10-03-2007 12:31 PM

0 Kudos
Message 2 of 6
(3,450 Views)
Umm it is already in a loop, i need to know how to convert my data is in a 1-d aray of strings to just a string inorder for it to work on the udp block. And i need to know how to set the max size, i know what the default max size could be, but i have no idea about the size of each data packet that i am trying to read, if that is what the block wants.
0 Kudos
Message 3 of 6
(3,431 Views)

1. Is there are reason you want to send it in one huge packet instead of one packet per array entry? If you prefer the former (a long is it fits under 65,507 bytes):

2. You don't need to specify exact byte size of each packet. It will read in one packet at a time.

Message Edited by FMonkey on 10-03-2007 01:01 PM

0 Kudos
Message 4 of 6
(3,427 Views)

For your first question, you may be able to use the Array to Spreadsheet String function to convert your array to a single string. You'll have to work with it; I tried to get the delimiter as nothing, but it defaults to tab delimiters in that case. If you don't mind spaces in between array elements, it would work.

As to your second question, I don't have a good answer, but I did notice this is the LabVIEW Help:

"If you wire a value other than 548 to this input, Windows might return an error because the function cannot read fewer bytes than are in a packet. "

Michael

0 Kudos
Message 5 of 6
(3,414 Views)


@dstafford wrote:

First off 2 questions about UDP in labview.

1. I have my data that is a 1-D array of string, and i am trying to connect it to the UDP write block, and its sink is a string, what is the best way to convert the data to make the block work, and then subsequently what would be the best way to unpack the string on the other end.

2. On the read side of the udp, how do I know what to set the max bytes read to?

 

Any help would be appreciated,

 

Thanks,

David



1) The best would be to use Flatten To String for the sender side (select some endianess here but the network byte order (big endian) is the prefered one for any network protocol and make sure to set the "prepend array or string size" input to true. The problem is that you can not use a single node on the receiver side since you need to know the number of array elements and the length of each string individually before you can read the data. So the receiver gets a bit more complicated where you will first read 4 bytes and unflatten them with the Unflatten from String function to an int32 (use the same endianess type as for the Flatten To String). This integer is the number of array elements that follow. Now in a loop that executes as many times as the first integer indicated read another int32 in the same way and then read the number of characters this second int32 indicated. At the loop boundary you will now get your nice array of strings then.

2) UDP is maybe not the best network layer to use but that depends on your requirements. UDP does not gurantee that you will receive every single byte that was sent nor does it provide for functionality for the sender nor receiver to detect this. The integrity of the data has to be controlled by you in some way if that is important. TCP/IP however will guarantee that the data is either completely transfered or flag an error on the sender and/or receiver side if it isn't. Also aside from some strange router limitations in your network, the maximum size of TCP/IP messages is not really limited but in some network setups trying to stay below 1500 bytes per individual write operation can have a positive influence on the transfer speed. UDP definitely is limited to a maximal size but I'm not sure if that is 64kB or less.

Rolf Kalbermatter

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 6 of 6
(3,404 Views)