Jump to content
skshatri

File transfer using UDP

Recommended Posts

Hello,

 

I am using UDP to transfer files from server to client but I cannot receive the complete file. I can receive only a part of it.

 

For example if the size of the file to be sent is 25 MB, I am receiving only 60 KB at the client end.

 

Please help me with your suggestions. 

 

UDP file tranfer examples would be helpful. 

 

Thankyou,

Hima

 

 

 

Share this post


Link to post
Share on other sites

Hima,

UDP is a lossy protocol. There is no guarantee that all the data will arrive at the listener. This could be one reason you are seeing data loss. Have you considered usiing TCP/IP, a much more robust protocol?

Share this post


Link to post
Share on other sites

Hi austinman,

 

I have tried sending data through TCP and it works perfect but my project demands the UDP transmission. Simplex communication.

 

So I am working on UDP communication..  i.e., Transfer of complete file from sender to receiver.

 

 

Thanks,

Hima

Share this post


Link to post
Share on other sites
6 minutes ago, Phillip Brooks said:

Are the client and server both running LabVIEW?

Do you have tftp client or server available on either of the systems? tftp is UDP based, but takes care of the handshaking.

https://en.wikipedia.org/wiki/Trivial_File_Transfer_Protocol

 

To add to this, there is an implementation in LabVIEW at:

https://decibel.ni.com/content/docs/DOC-8301

 

Share this post


Link to post
Share on other sites
1 hour ago, Neil Pate said:

The best thing about UDP jokes is that I don't care if you get them or not.

Boo. Hiss. Cheer...

Share this post


Link to post
Share on other sites
3 hours ago, Neil Pate said:

The best thing about UDP jokes is that I don't care if you get them or not.

The best thing I like about *any* jokes is you get more likes than if you answer questions ( ͡~ ͜ʖ ͡~)

  • Like 1

Share this post


Link to post
Share on other sites
11 minutes ago, ShaunR said:

The best thing I like about *any* jokes is you get more likes than if you answer questions ( ͡~ ͜ʖ ͡~)

Is that a joke?  Cause I like that.

Share this post


Link to post
Share on other sites
10 hours ago, skshatri said:

Hello,

I am using UDP to transfer files from server to client but I cannot receive the complete file. I can receive only a part of it.

For example if the size of the file to be sent is 25 MB, I am receiving only 60 KB at the client end

Can you post your code?

How big do you make the UDP packages?


I guess you know that a one UDP package could only be 65,507 bytes


So you need to split them into multiple packages with some header data, so you can see that you have received them all and put them together in the correct order.

 

 

 

Share this post


Link to post
Share on other sites
7 hours ago, MikaelH said:

So you need to split them into multiple packages with some header data, so you can see that you have received them all and put them together in the correct order.

This would also require acks which means bidirectional communication  (vs: " my project demands the UDP transmission. Simplex communication.").

I don't think there is a way to do this with that constraint, and if you don't have that constraint then tcp or ftp will work.

Edited by smithd

Share this post


Link to post
Share on other sites

I gave quite serious thought to whether I should post or not as I did not really want to derail the thread. However, that joke is perhaps in my top two of tech jokes I know, it is too good to not share.

The other one is..

“Whenever faced with a problem, some people say `Lets use AWK.' 
  Now, they have two problems.”

Share this post


Link to post
Share on other sites
11 hours ago, hooovahh said:

Is that a joke?  Cause I like that.

Tongue in cheek..(What? No likes :P 

8 hours ago, smithd said:

This would also require acks which means bidirectional communication  (vs: " my project demands the UDP transmission. Simplex communication.").

I don't think there is a way to do this with that constraint, and if you don't have that constraint then tcp or ftp will work.

Transport.lvlib

2 hours ago, Neil Pate said:

I gave quite serious thought to whether I should post or not

You think too much :D Too many engineers have their sense of humour beaten out of them by unrealistic marketing requirements and customer demands. Post and be damned :lol:

My current favourite is:

Linux is Windows 95 without the GUI.:D

Edited by ShaunR

Share this post


Link to post
Share on other sites
10 hours ago, MikaelH said:

Can you post your code?

How big do you make the UDP packages?

I guess you know that a one UDP package could only be 65,507 bytes

So you need to split them into multiple packages with some header data, so you can see that you have received them all and put them together in the correct order.

 

Hi,. Here is my code. please go through it.

 

client.vi

server.vi

Share this post


Link to post
Share on other sites

Crosspost

Honestly not sure which thread has more discussion.

(BTW Shaun I gave you a like)

  • Like 1

Share this post


Link to post
Share on other sites
On 18-8-2016 at 0:46 AM, MikaelH said:

I guess you know that a one UDP package could only be 65,507 bytes

And that is neither guaranteed to work! Depending on gateways and other limitations on the everchanging interweb of IP, an IP packet exceeding the minimum MTU of  576 for IPv4 may be dropped for any reason that any router device on the way may feel like, including scarce internal memory or CPU resources, or just a temporary mood of the day. And a single dropped or corrupted IP fragment in a complete UDP packet will cause the entire UDP packet to be refused (dropped) by the receiving UDP endpoint. Since the IP packet also needs to contain the IP and UDP header, the actual "safe" minimum maximum UDP packet size is really more like 508 bytes (accounting for extra IP options in the header).

The maximum size of an UDP packet of 64kB is a Windows feature. Other socket implementations can use lower limits. The 64kB is also the theoretical maximum limit, since UDP only uses a 16 bit length indicator in its header, so it can't really transmit more than 64kB in a single packet. And UDP itself does not provide for a mechanisme to fragment and reassemble bigger packets. So I'm pretty sure all the socket implementations out there, simply cap any attempt of a user application to transmit more than those 64kB.

You could argue that LabVIEW as high level programming environment should produce an error if you try to send more, but that is a pretty fuzzy idea. Nothing in the UDP implementation guarantees the transmission of any packet size across the network, so why bother to create an error?

Also, if the entire route from sender to receiver is guaranteed to be IPv6, all the above changes considerably. The MTU changes to about 2000 bytes and by using IPv6 jumbograms, UDP can transmit larger packets than 64B. So above limitation doesn't apply but since the LabVIEW network nodes currently only support IPv4 anyways, this is of no concern in terms of LabVIEW programming.

Edited by rolfk

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.