LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can i attach a user-specified header to each UDP packet?

Hello,
 
i have here a question about UDP:
 
i want to stream live-videos using UDP. To avoid/observe some possible problems that could occur (e.g. wrong packet-order, packet loss etc.) i am planning to add a header to each UDP packet with e.g. frame-nr. , frame-size, packet-nr...
 
Question:
 
1. (How) Can i control the UDP packet size in LabVIEW?
2. If possible, how can i add a user specified header to each/certain (e.g. the first or the last packet of the frame) packet?
 
Thanks!
 
WLAN
 
 

Message Edited by wlan on 01-26-2007 03:02 AM

0 Kudos
Message 1 of 4
(3,145 Views)
WLAN,

first of all, you cannot change anything of TCP or UDP headers in LV. The same is true for IP headers.
Regarding your first question: You CAN influence the packetsize on your own by chopping your data into appropriate peaces. You CAN add a kind of header on your own to each of these chunks. You CAN check this selfbuilt header at your receiver and request packages which are missing or erroneous.
BUT:
THIS mechanics are already included in TCP and you will have MORE OVERHEAD when doing this errorhandling on your own then by TCP.
The only disadvantage of TCP for you might be, that TCP is P2P, not multi- or broadcast.....

hope this helps,
Norbert B.

[EDIT]: Please note that UDP was esp. designed to include NO errorhandling to increase speed. Therefore, many applications like video-streams, VoIP and games use udp since lost/misordered packages does not have a great impact. A wrong colored pixel of line in a single video-picture doesnt have too much negative effekt for the viewer, so there is no need for errorhandling here. Instead, esp. VoIP, a much larger delay between talking/receiving is very disturbing.

Message Edited by Norbert B on 01-26-2007 04:21 AM

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 4
(3,136 Views)
Thanks for your answer! Norbert!
 
i have now another question:
 
what does the option "max size (548)" in the UDP-Read-VI mean? Has it with package size to do? Or it means something else?
 
btw.:
 
How can i guarantee that the client receives data stream from the first data package of a frame? In TCP i always send a header (12bytes) with frame informations (data size, height, width), and if the connection schon exists, the client reads the first 12Bytes and then the rest bytes (size known from header) in a loop. How should i do it in UDP (UPD doesn´t need a connection between server and client)?
 
I hope you understand me... Smiley Tongue Thanks!
 
WLAN

Message Edited by wlan on 01-31-2007 09:00 AM

0 Kudos
Message 3 of 4
(3,116 Views)
WLAN,

i just copied the help regarding the max size-terminal from the LV-help:
"max size is the maximum number of bytes to read. The default is 548. Windows 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"
So, please do not change this value....

UDP creates packets from the data you transmitt. Each packet in Windows should have a size of 548 bytes or less. So this should read one whole packet at a time.... Decreasing this could lead to problems if the packet is larger.... Increasing this value changes nothing since the packets themselfs do not get larger only by trying to read more bytes..... Since you cannot alter the packetsize from LV, you shouldnt bother about that anymore.

And to add (again): UDP does not garantuee ANY correct transission. So you will never get any note if the first packet of a frame was lost. If you need some kind of garantuee for this, you have to use TCP (btw. infact, the TCP header uses 192 bytes, containing the infos like seen in the attached gif).

regards,
Norbert

Message Edited by Norbert B on 01-31-2007 11:12 AM

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 4
(3,105 Views)