What's the fastest way to send a file over UDP?
A) Create a large datagram for each chunk of the file, send that, and wait for a acknowledgement from the client before continuing
B) Create a large datagram for each chunk of the file, send multiple (numbered) datagrams, and wait for an acknowledgement that all sections were received, then continue the transfer. If some were not received with 5 seconds, re-transmit those parts
C) Some other method I'm not yet aware of
Asked
Active
Viewed 1,871 times
0

bbosak
- 5,353
- 7
- 42
- 60
-
4If you want reliable file transfer, use TCP. I'd only use UDP for cases where you can tolerate some loss and simply send the packets without checking, include some timestamp so you can discard out of order packets on the client. – tvanfosson May 15 '11 at 22:58
-
@tvanfosson: NFS uses UDP because it's more lightweight than TCP. You get some pretty awesome speeds with it. http://stackoverflow.com/questions/584112/why-does-nfs-use-udp-by-default – Chris Eberle May 15 '11 at 23:52
-
2@Chris but NFS doesn't transfer files. It transfers individual blocks. – user207421 May 16 '11 at 00:28
-
I can't use TCP because I need to be able to traverse firewalls. I'm writing a P2P transfer program (for use in streaming maps for a game), and I need to be able to traverse firewalls, as my users will (typically) have no clue how to forward ports on their router. – bbosak May 16 '11 at 00:35
2 Answers
2
Practically anything I can think of in (C) will be miles faster than either of them. Neither of them uses windowing, so they can't use all the available bandwidth-delay product. (B) is in fact a very poor piece of protocol design.
By the time you have added all the required features to UDP you have TCP. Use TCP.

user207421
- 305,947
- 44
- 307
- 483
2
Solution B is faster than A, but solution C is even more fast (and safe): try using TCP instead of UDP

Mikant
- 299
- 3
- 18