473,406 Members | 2,713 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,406 software developers and data experts.

UDP Multicast losing messages

Hi,

I'm trying to send a large number of messages to a UDP multicast group
with which I have one client subscribed. But I'm losing mesages, and
I'm not entirely sure why. I can't seem to find the reason, the asynch
receive on the client doesn't even get called the corect number of
times, which is 1000. I'm trying to send 1000 messages via an asynch
call to sendto.

the connect code for the send

lock (_lock)
{
if (_socketState ==
TSMultiCastEndPointState.Connected) return true;

_socket = null;
_socket = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp);
_remoteEP = new IPEndPoint(_remoteIP, _port);
_localEP = new IPEndPoint(_localIP, _port);

_socket.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.ReuseAddress, 1);

_socket.Bind(_localEP);

connectSuccessful = true;

_socketState = TSMultiCastEndPointState.Connected;
}

other then that I just call sendTo 1000 times in a for loop, and the
receive on the client only pops maybe 300 times. Anyone have any
ideas? The receiveCallback code won't really help because it doesn't
even get called 1000 times.

Jan 3 '07 #1
7 3542
"DaTurk" <mm******@hotmail.comwrote in message
news:11*********************@s34g2000cwa.googlegro ups.com...
Hi,

I'm trying to send a large number of messages to a UDP multicast group
with which I have one client subscribed. But I'm losing mesages, and
I'm not entirely sure why.
UDP is not reliable. There is no guarantee that if you send 1000 datagrams,
each recipient will receive 1000 datagrams.

There's a bunch of other stuff UDP doesn't guarantee either. You really
need to study the basic rules for UDP before you start trying to use it.
Jan 4 '07 #2

Losing 70% of packets is a huge number, especially within a local lan
(I'm assuming OP is in a development environment within a local lan).

Sam
------------------------------------------------------------
We're hiring! B-Line Medical is seeking Mid/Sr. .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.

On Wed, 3 Jan 2007 17:39:50 -0800, "Peter Duniho"
<Np*********@NnOwSlPiAnMk.comwrote:
>"DaTurk" <mm******@hotmail.comwrote in message
news:11*********************@s34g2000cwa.googlegr oups.com...
>Hi,

I'm trying to send a large number of messages to a UDP multicast group
with which I have one client subscribed. But I'm losing mesages, and
I'm not entirely sure why.

UDP is not reliable. There is no guarantee that if you send 1000 datagrams,
each recipient will receive 1000 datagrams.

There's a bunch of other stuff UDP doesn't guarantee either. You really
need to study the basic rules for UDP before you start trying to use it.
Jan 4 '07 #3

Peter Duniho wrote:
"DaTurk" <mm******@hotmail.comwrote in message
news:11*********************@s34g2000cwa.googlegro ups.com...
Hi,

I'm trying to send a large number of messages to a UDP multicast group
with which I have one client subscribed. But I'm losing mesages, and
I'm not entirely sure why.

UDP is not reliable. There is no guarantee that if you send 1000 datagrams,
each recipient will receive 1000 datagrams.

There's a bunch of other stuff UDP doesn't guarantee either. You really
need to study the basic rules for UDP before you start trying to use it.
I do understand UDP. Been using it for years, but like Mr. Neff said
losing 70% is a very large percentage. THere has to be something else
going on.

I've tried running the sender / receiver on the same box, and on
different boxs, but with the same results. It seems that it can do 100
messages fine, but anything larger, say 125 encounters some loss. What
really worried me is that the Asynch receive callback is not even
receiving anything.

That's why I think it has something to do with the way the sockets have
been set up. I tried sending the messages synch, and asynch with the
only change being that using asynch, more message were received.

Does anyone have any other ideas besides condescending to me about UDP

Jan 4 '07 #4
"DaTurk" <mm******@hotmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
Does anyone have any other ideas besides condescending to me about UDP
It's not condescension. It's simply being realistic. Too many people show
up here asking about sockets without really having made any effort to learn
the fundamentals to assume you are different when you're not clear about
your problem. You said "But I'm losing mesages, and
I'm not entirely sure why". Nothing in that statement suggests that you
have any idea that it's natural to lose messages while using UDP, and in
fact it strongly suggests otherwise.

I agree that 70% is a large number to lose, but it's not impossible. That
said, sure...you might have a bug in your own code. Since you're so
experienced with UDP, you're obviously aware of the diagnostic tools that
you can use to narrow down where the data is being lost. That would be the
first thing I'd do...until you know where the problem is, you can't hope to
fix it.

In addition to ruling out actual network problems, you are also mistaken to
assume that the receive code itself isn't faulty. Failing to keep up with
the inbound data is one easy way to lose lots of UDP datagrams. At this
point, you have not posted any information that narrows the problem down one
bit.

You either need to post *all* of the code involved and hope someone is
generous enough to read through it all and see if there's a bug, or you need
to do enough diagnostics to narrow the problem down enough so that you can
post the exact subset of the code that you *know* is causing the problem.

Pete
Jan 4 '07 #5
Wow, touchy touchy. Look, I have analyzed my traffic, and do see that
everything is getting sent across. Stating that "I'm not entirely sure
why" doesn't suggest I don't know how to use UDP. It suggests that I
don't know why I'm losing messages, and that's all. If you want to
assume that I'm daft, that's your choice. At any rate, I've found my
problem, but I do appreciate your help. In the very least you've
helped me to become a better person.

Peter Duniho wrote:
"DaTurk" <mm******@hotmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
Does anyone have any other ideas besides condescending to me about UDP

It's not condescension. It's simply being realistic. Too many people show
up here asking about sockets without really having made any effort to learn
the fundamentals to assume you are different when you're not clear about
your problem. You said "But I'm losing mesages, and
I'm not entirely sure why". Nothing in that statement suggests that you
have any idea that it's natural to lose messages while using UDP, and in
fact it strongly suggests otherwise.

I agree that 70% is a large number to lose, but it's not impossible. That
said, sure...you might have a bug in your own code. Since you're so
experienced with UDP, you're obviously aware of the diagnostic tools that
you can use to narrow down where the data is being lost. That would be the
first thing I'd do...until you know where the problem is, you can't hope to
fix it.

In addition to ruling out actual network problems, you are also mistaken to
assume that the receive code itself isn't faulty. Failing to keep up with
the inbound data is one easy way to lose lots of UDP datagrams. At this
point, you have not posted any information that narrows the problem down one
bit.

You either need to post *all* of the code involved and hope someone is
generous enough to read through it all and see if there's a bug, or you need
to do enough diagnostics to narrow the problem down enough so that you can
post the exact subset of the code that you *know* is causing the problem.

Pete
Jan 4 '07 #6
"DaTurk" <mm******@hotmail.comwrote in message
news:11**********************@42g2000cwt.googlegro ups.com...
Wow, touchy touchy.
I'm not touchy. I'm simply trying to explain why YOU shouldn't be touchy.
Who told you to assume I was being condescending? I didn't (and even if I
did, why should you listen to me?).
Look, I have analyzed my traffic, and do see that
everything is getting sent across.
So it *is* a problem with your receiving code, even though you said you knew
it wasn't.
Stating that "I'm not entirely sure
why" doesn't suggest I don't know how to use UDP. It suggests that I
don't know why I'm losing messages, and that's all.
The most common reason for someone to not know why they are losing UDP
datagrams is that they don't understand UDP. You didn't write anything to
suggest otherwise, so the safe assumption was that you don't understand UDP.
If you do, that's great. But you didn't write anything to start with to
suggest you do, and you *did* write something that suggested you don't.

Again, I had no control over what you wrote in your initial post (or any
subsequent one for that matter). I can't help that your post was ambiguous
and led to incorrect assumptions. When you provide incomplete information,
we are forced to either make assumptions or simply not answer. I suppose
not answering is a valid option, but it doesn't make for much forward
progress. Personally, I prefer to make assumptions and try to get a problem
solved in the process.
If you want to
assume that I'm daft, that's your choice.
I prefer the word "inexperienced". Many people fail to understand UDP
without being "daft". But again, if you want to be touchy about it, I
suppose that's your right. Just remember, it's *you* being touchy, not me.
At any rate, I've found my
problem, but I do appreciate your help. In the very least you've
helped me to become a better person.
If you found your problem, why did you not post the resolution here?
There's more to having a newsgroup than just getting people to tell you what
your problems are. By sharing your solution, you may help someone with the
same problem in the future.

Pete
Jan 4 '07 #7
Your right, my apologies. I was wrong in assuming the problem was not
in the receive method. I assumed that because the method wasn't being
hit there was an issue ealier on.

SO the problem was that the Receive method wasn't reacting quick enough
I was using several libraries that I built previously to deal with TCP.
They would have worked fine, but they needed to be stream lined a bit
more to be viable in a UDP world. SO I'm in the process of optimizing
them now. Specifically, my method to detach my header from the front
of the byte array was a bit more cumbersome then it needed to be. I
was truncating the front of the received byte array, and manually
deserializing it to get the info in the header.

WHich is quick, but the truncating of the original byte array had alot
of overhead as it created new memory twice, once for the header byte
array, and a second time for the newly truncated original message. Now
it passes the original byte array to the Header struct to be
deserialized, but isn't truncated. The header struct just bitConverts
what it needs.

And Peter, even though you may not mean too, you come off
condescending.

Peter Duniho wrote:
"DaTurk" <mm******@hotmail.comwrote in message
news:11**********************@42g2000cwt.googlegro ups.com...
Wow, touchy touchy.

I'm not touchy. I'm simply trying to explain why YOU shouldn't be touchy.
Who told you to assume I was being condescending? I didn't (and even if I
did, why should you listen to me?).
Look, I have analyzed my traffic, and do see that
everything is getting sent across.

So it *is* a problem with your receiving code, even though you said you knew
it wasn't.
Stating that "I'm not entirely sure
why" doesn't suggest I don't know how to use UDP. It suggests that I
don't know why I'm losing messages, and that's all.

The most common reason for someone to not know why they are losing UDP
datagrams is that they don't understand UDP. You didn't write anything to
suggest otherwise, so the safe assumption was that you don't understand UDP.
If you do, that's great. But you didn't write anything to start with to
suggest you do, and you *did* write something that suggested you don't.

Again, I had no control over what you wrote in your initial post (or any
subsequent one for that matter). I can't help that your post was ambiguous
and led to incorrect assumptions. When you provide incomplete information,
we are forced to either make assumptions or simply not answer. I suppose
not answering is a valid option, but it doesn't make for much forward
progress. Personally, I prefer to make assumptions and try to get a problem
solved in the process.
If you want to
assume that I'm daft, that's your choice.

I prefer the word "inexperienced". Many people fail to understand UDP
without being "daft". But again, if you want to be touchy about it, I
suppose that's your right. Just remember, it's *you* being touchy, not me.
At any rate, I've found my
problem, but I do appreciate your help. In the very least you've
helped me to become a better person.

If you found your problem, why did you not post the resolution here?
There's more to having a newsgroup than just getting people to tell you what
your problems are. By sharing your solution, you may help someone with the
same problem in the future.

Pete
Jan 4 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: T.C.McQueen | last post by:
Does anyone know how to receive an ICMP-Router Advertisement Message using Raw/ICMP - Sockets in Multicast -Mode with .NET I tried it several times differently but it does not work I think it's...
1
by: Alfred B. Thordarson | last post by:
Hi All. I have this weird problem that on my devlepment machine (Windows XP) I don't receive MultiCast messages that I send from my machine. This means that my two processes can't communicate...
6
by: PHLICS_Admin | last post by:
Hi All, There are two network cards in one computer (named A) , and there is one network card in another computer(named B). On computer A: one network card is used to connect to internet, and...
7
by: Jim H | last post by:
Is there something special I need to do to send data to a multicast IP and have it go across a router? Router is a Win2000 Server connecting 2 networks via RRAS PPTP. The routing appears to be...
2
by: Naveen Mukkelli | last post by:
Hi, I'm sending multicast messages UDP socket and C#. But the receiving clients are not receiving all the messages. Receiving clients are missing out some messages. When I debug the server...
1
by: Naveen Mukkelli | last post by:
Hi, When I run 2 or more clients on the same machine, the first client application is receiving multicast messages but not the subsequent clients. I'm using the same, multicast address and...
1
by: Eric St-Onge | last post by:
Hi, I have eleven C# applications running on eleven different computers sending packets to a MSMQ MultiCast configured queue (same address for all). Those eleven senders also act as receivers. ...
7
by: pietro.cerutti | last post by:
Hi guys, I have a daemon running on Debian and listening for multicast packets sent to 224.0.0.251:5353 (ZeroConf Multicast DNS queries). The server is plugged into a VLAN trunk with eth0 and...
2
by: rodrigofsilva | last post by:
Dear, by chance somebody already got to send and to receive files for protocol Multicast in C #. I am to send messages and to receive messages but files are not getting. ...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.