TCP Reliablility

mmiers

Newcomer
Joined
Apr 3, 2003
Messages
7
My sincere apologies if this is a repeat post but the search limitations on < 4 char words makes it difficult. Also, forgive the length, I want to make sure I ask the question correctly the first time.

Anyway, my questions is this. I know a lot about networking as I've taken many cisco classes and have made several net apps. I know it is designed to be very reliable and efficient. It uses windows and confirmations to make sure every thing has been received.

However, I've heard many times from many resources that TCP isn't 100% guaranteed. Packets are not always received in order, are often strung together or are not received at all. Now that's only what I've heard. I've made a few networking apps back in VB6 using winsock and never had these problems, however, that was on a very stable connection and sending very small packages.

Now I want to move onto something a bit better. I'm trying to develop a low-level socket class that offers very efficient and near perfect transfers of data, no matter the size. I want to be sure that all packets are received if it's a file of several gigabytes, but also act very fast if there are many small packets coming from different connections.

To sum up all of that into a simple question. Should I take the time to implement a more guaranteed transfer using packet ids, lengths, crc, all of that (basically that's a whole different protocol!), or should I trust that tcp will get me all of the information? If the former is the case and to be sure i'd have to make my own custom protocol, couldn't i just use UDP and put that protocol over top of it?

I know there is probably no way to guarantee 100% of the time all data will make it perfectly, but > 95% is good to me.


Thanks
- Mark
 
The hole idea of TCP is there is a constant conection between the server and the client so packet loss cannot happen

e.g.

Start
1. Server sends data
2. Client recieves data
3. Client sends reponse
4. Server reads response
5. Server send next chunk of data
End (Repeat until all data sent)

As long as the connect between the server and the client using TCP exists 99.99% will be sucessfull.

NOTE : If there is an error within the data sent your client will re request the packet same happens if packet is never received.


UTP is the unreliable one (Like your example) no guarantee the data will get to the client and the client doen't bother checking.

Andy
 
I wouldn't bother writing that class. .NET already provides a (optionally) very low level socket class that should be ample for your needs.

TCP/IP _does_ guarantee that your packets will arrive, and in the right order too. The only thing it doesn't guarantee is that they won't be broken up or stuck together, but the data will arrive correctly. Of course, it's up to the programmer to use delimiters if it's necessary to distinguish from one packet to the next.
 
Thank you for your replies.

I'm well aware of the TcpClient class. But working directly with the sockets offers me more control in thinks such as encryption, security and all that. It's nice to know exactly how my data is being handled.

Again thanks a lot.

- Mark
 
Back
Top