473,382 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to make UDP reliable

72
Hi,

I have implemented client server communication, I have used UDP as transport layer protocol. I am sending a file from client to server. Each time am sending 1024bytes. At receiver side am receiving those bytes and writing to a file. But as we know that UDP is unreliable, packets may arrive out of order. So how can I make all packets in order at receiver side? Is there any way to implement it? My target is to make sending file and receiving file to be identical. Please show me the way how can i implement?

Thanks,
Manjunath
Feb 13 '08 #1
7 10261
gpraghuram
1,275 Expert 1GB
Hi,

I have implemented client server communication, I have used UDP as transport layer protocol. I am sending a file from client to server. Each time am sending 1024bytes. At receiver side am receiving those bytes and writing to a file. But as we know that UDP is unreliable, packets may arrive out of order. So how can I make all packets in order at receiver side? Is there any way to implement it? My target is to make sending file and receiving file to be identical. Please show me the way how can i implement?

Thanks,
Manjunath

What you can do is with every chunk of data you send add a chunk count to it and in the receiving end you can read the data and store it in memory for some time till u get the all the chunks.
Then you can order the chunks based on the count and flush it to the file

Raghuram
Feb 13 '08 #2
sicarie
4,677 Expert Mod 4TB
My big question is why are you trying to do this? If you want a reliable protocol, use TCP. UDP is for streaming data, TCP is where you want to make sure you have everything being sent.

Easy fix: use TCP.
Feb 13 '08 #3
manjuks
72
My big question is why are you trying to do this? If you want a reliable protocol, use TCP. UDP is for streaming data, TCP is where you want to make sure you have everything being sent.

Easy fix: use TCP.
Ok thanks, But am intrusted to implemented using UDP, Its just for my curiosity to know how can we make UDP as reliable.

Thanks,
Manju
Feb 14 '08 #4
sicarie
4,677 Expert Mod 4TB
Ok thanks, But am intrusted to implemented using UDP, Its just for my curiosity to know how can we make UDP as reliable.

Thanks,
Manju
Make it like UDP? I don't understand the question. Why would you want to turn it into something that's already out there? Why not just use what's already out there?
Feb 16 '08 #5
Ok thanks, But am intrusted to implemented using UDP, Its just for my curiosity to know how can we make UDP as reliable.

Thanks,
Manju
UDP is designed for unreliable, connection less purpose, it is not like you can not make it as reliable, when you make it completely, then it becomes TCP. And also your are violating RFC. if you are violating RFC you many live in networking world.

TCP is one the more powerfull protocol in transport, so learn it , work on it, then i think you will become more curiosity on TCP.

If you have any design/technical problem by using TCP, please tell to me, we could innovate something else....

-Regards
Arul
Feb 16 '08 #6
Hi,

I have implemented client server communication, I have used UDP as transport layer protocol. I am sending a file from client to server. Each time am sending 1024bytes. At receiver side am receiving those bytes and writing to a file. But as we know that UDP is unreliable, packets may arrive out of order. So how can I make all packets in order at receiver side? Is there any way to implement it? My target is to make sending file and receiving file to be identical. Please show me the way how can i implement?

Thanks,
Manjunath
Why not add a header for every chunk of data? Normally, network protocols that can be implemented over UDP uses sequence numbers to keep track of its order.
Feb 17 '08 #7
chump
1
There's not much point in making UDP as reliable as TCP (just use TCP). However, it is frequently desireable to use UDP and assume some lost packets but still require that packets be processed in order.

An easy way to ensure packets are receive in order is to add a sequence number to your message. If the receiver has received and processed sequence # n and gets a packet with secquence # n-1, it drops it. If the receiver receives n+1, it processes it (sends it to the application).

f it receives n+2, it sticks it in a queue and then starts an interval timer. If the timer expires without getting any other messages, it assumes n+1 never made it and processes the queued packet. If n+1 arrives, it processes it and then pulls n+2 out of the queue and processes it.

The implementation details are a little more complicated, but you get the gist.

TCP has all sorts of stuff in the protocol, including ACKs, retries, flow control, etc, that would be very difficult to (re)implement with UDP. However, you could probably devise a light-weight retry mechanism (without the rest of TCP) on UDP with not much effort if your application can't handle dropped packets. You can do this by manuall sending ACKs for each packet, but then you will need to deal with duplicate packets, more timers, etc.
Feb 17 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

82
by: Peter Diedrich | last post by:
The site design is pretty simple: ============================================ | Head | ============================================ | | ...
0
by: relisoft | last post by:
Seattle, WA -- Seattle-based Reliable Software® announces the release their Windows Library into the public domain. Reliable Software Windows Library, RSWL, is the foundation for their compact,...
0
by: melledge | last post by:
The Reliable Source for Everything XML - XML 2005 Update XML 2005 - November 14-18 - Atlanta Hilton Hotel - Atlanta, GA www.xmlconference.org Register today and participate in IDEAlliance's...
2
by: Buddy Ackerman | last post by:
I seem to have a lot of complaints from users about file upload problems to my site (developed in ASP.NET). The issue is not related to setting the maxRequestLength or any security issues. Most of...
5
by: splodge | last post by:
This may seem like a stupid question but I want to check before I go ahead and build this... I am working on a portal, part of which allows users to upload files. Part of the array within...
11
by: OlafMeding | last post by:
Because of multithreading semantics, this is not reliable. This sentence is found in the Python documentation for "7.8.1 Queue Objects". This scares me! Why would Queue.qsize(), Queue.empty(...
4
by: John Grant | last post by:
If I build a web services today with VS 2005 does it support reliable messaging? If I use WSE 3.0 will it support reliable messaging? If I don’t have reliable messaging can I make a web method...
1
by: relisoft | last post by:
SEATTLE, Washington. - July 12, 2006: Reliable Software® announces the upcoming release of Code Co-op® version 5.0. Code Co-op is an affordable peer-to-peer version control system for distributed...
2
by: bshumsky06 | last post by:
Hi, I am trying to create stored procedures in MySQL. Does anyone have a suggestion on a good IDE to use. I have been working with the MySQL Query Browser but it generates errors very often and...
1
by: =?Utf-8?B?S2F1c2hhbCBNZWh0YQ==?= | last post by:
Hi, I am facing the ServerTooBusyException when using reliable session and net.tcp binding. I have single server and single client application. The client registers for the event at the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.