I'm reading about TCP and UDP from a article. In the end what I understood is that UDP is faster than TCP but it is unreliable. So if I'm going to a send a file, If use UDP, would it be faster than TCP? Can someone explain how would it deliver faster than TCP?
|
feedback
|
|
It can be faster because it requires no handshaking to start sending packets with payload (there is no concept of a connection with UDP - you just send packets and hope the other end receives stuff) and the packet headers are slightly smaller (though for bulk traffic that results in large packets being sent this probably isn't all that significant). You would not want to send data that way though - you would have to implement the missing packet detection, packet resending, packet reordering (they don't always arrive in the same order they are sent), congestion detection, and so forth that TCP does for you. Once you add all that in you'll almost certainly find you've ended up no faster (perhaps much slower) than TCP would have been and you've done a lot of work to get there. TCP is good for when the information in lost packets don't need to be resent, you want to implement your own flow control, or you are wrapping TCP streams and similar in your own stream (i.e. you are implementing a VPN - TCP through TCP can have significant performance problems when there is intermittent congestion), it is not good for transferring bulk data like when trying to reliably transmit a file (except in the VPN case, of course, but you still use TCP within the VPN's wrapper). | |||||||
feedback
|
