• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Implementing UDP client/server application with some reliablity by adding sequence number

 
sopranos mamo
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was trying to implement a Client Server Udp socket application with some reliability by adding a sequence number to each sent byte, The sequence number shall have 2 bytes from the sent datagram packet so
Could you help me out how to implement this case!!!
 
Jelle Klap
Bartender
Posts: 1951
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is TCP not an option? Making UDP reliable while maintaining its benefits over TCP in terms of simplicity and real-time delivery isn't exactly trivial.
 
sopranos mamo
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Jelle Klap,

Yes you are right!!! But I had to implement a lot of reliability stuffs over UDP for the sake of mini project.
So i would appreciate if you give me a hint because last time i was able to develop a client server application using UDP sockets which calculates InternetChecksum , and it was fun.

Thanks
 
Henry Wong
author
Marshal
Pie
Posts: 20881
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jelle Klap wrote:Is TCP not an option? Making UDP reliable while maintaining its benefits over TCP in terms of simplicity and real-time delivery isn't exactly trivial.


IMO, the main advantage of putting a reliable protocol on top of UDP, is that UDP is capable of running on a multicast group. This means that you get the advantages of TCP, with the network hardware support for fan out.

This is also why many messaging systems implement a reliable multicast transport.


sopranos mamo wrote:
Yes you are right!!! But I had to implement a lot of reliability stuffs over UDP for the sake of mini project.
So i would appreciate if you give me a hint because last time i was able to develop a client server application using UDP sockets which calculates InternetChecksum , and it was fun.


First, with UDP, it is only non-reliable at the packet level -- meaning whole packets can be lost. So, this means that you only need to put a sequence number on the packet.


The two functionality that you need to implement are gap detection and gap fill. Gap detection is easy. if you get a packet whose sequence number is higher than the one you expected, then you have a gap that you need to fill. Gap fill is a bit harder, you need to have your source keep old packets, and you need your target to request retransmission to fill the gap. This means that your sender is really a service -- as it needs to service request for retransmission.

Other things to note. It is possible for UDP to transmit out of order, so a gap that is detected may fill automatically without a request. It is possible, assuming you are over multicast, for one target to get the packet, but another to lose it, so you need to write your target to toss duplicate packets.

There are likely a few other concerns, but this should be enough to get you started.

Henry


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic