473,385 Members | 1,356 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,385 software developers and data experts.

Udp Multicasting and buffers...

I have a question concerning developing a generic multicast subscriber. How
do you go about determining a decent buffer size? Why does the
Socket.(Begin)ReceiveFrom method require an instanciated buffer instead of
requiring a stream or returning a correctly sized buffer? Aside from DOS
attack conciderations, I guess, it seems to be a major limitation.
Nov 15 '05 #1
3 2744
"Ryan Cromwell" <cr**********@hotmail.com> wrote in message news:<O#*************@tk2msftngp13.phx.gbl>...
I have a question concerning developing a generic multicast subscriber. How
do you go about determining a decent buffer size? Why does the
Socket.(Begin)ReceiveFrom method require an instanciated buffer instead of
requiring a stream or returning a correctly sized buffer? Aside from DOS
attack conciderations, I guess, it seems to be a major limitation.


Ryan -

There are two different buffers involved in the socket
communication that you should worry about. The low-level socket buffer
will accept incoming multicast packets until it is full. You can
change the socket buffer size using the SetSocketOption() method. Your
application should try to read data at least as fast as it is coming
in, or the socket buffer will eventually fill and drop packets. Since
this is UDP, those packets will not be retransmitted.

Each call to the ReceiveFrom() method will extract one datagram
from the socket buffer. You should ensure that the data buffer you are
using in the ReceiveFrom() method is large enough to hold each UDP
datagram you are expecting to receive. The ReceiveFrom() method will
throw a SocketException if the buffer specified is smaller than the
amount of data in the next datagram in the socket buffer. The left
over data (the data in the datagram that did not fit in the data
buffer) will be lost.

If you are worried about not specifying a large enough buffer, you
might notice that the UdpClient Receive() method does not need a
specific buffer to be set. It returns a correctly sized buffer after
reading the datagram (of course if you still try squeezing it into too
small of a data buffer a SocketException will be thrown as well).
Maybe that would work better for you.

Hope this helps shed some light on the topic for you. Good luck
with your network programming.

Rich Blum - Author
"C# Network Programming" (Sybex)
http://www.sybex.com/sybexbooks.nsf/Booklist/4176
"Network Performance Open Source Toolkit" (Wiley)
http://www.wiley.com/WileyCDA/WileyT...471433012.html
Nov 15 '05 #2
Thanks for the help Rich. Is it accurate to say that client/server
communication in an unreliable protocol require a common agreement on
datagram size such that the client knows when a particular tranmission set
is complete? I've asked this question on the framework group, but have not
yet received an answer.
"Rich Blum" <ri*******@juno.com> wrote in message
news:cc**************************@posting.google.c om...
"Ryan Cromwell" <cr**********@hotmail.com> wrote in message

news:<O#*************@tk2msftngp13.phx.gbl>...
I have a question concerning developing a generic multicast subscriber. How do you go about determining a decent buffer size? Why does the
Socket.(Begin)ReceiveFrom method require an instanciated buffer instead of requiring a stream or returning a correctly sized buffer? Aside from DOS attack conciderations, I guess, it seems to be a major limitation.


Ryan -

There are two different buffers involved in the socket
communication that you should worry about. The low-level socket buffer
will accept incoming multicast packets until it is full. You can
change the socket buffer size using the SetSocketOption() method. Your
application should try to read data at least as fast as it is coming
in, or the socket buffer will eventually fill and drop packets. Since
this is UDP, those packets will not be retransmitted.

Each call to the ReceiveFrom() method will extract one datagram
from the socket buffer. You should ensure that the data buffer you are
using in the ReceiveFrom() method is large enough to hold each UDP
datagram you are expecting to receive. The ReceiveFrom() method will
throw a SocketException if the buffer specified is smaller than the
amount of data in the next datagram in the socket buffer. The left
over data (the data in the datagram that did not fit in the data
buffer) will be lost.

If you are worried about not specifying a large enough buffer, you
might notice that the UdpClient Receive() method does not need a
specific buffer to be set. It returns a correctly sized buffer after
reading the datagram (of course if you still try squeezing it into too
small of a data buffer a SocketException will be thrown as well).
Maybe that would work better for you.

Hope this helps shed some light on the topic for you. Good luck
with your network programming.

Rich Blum - Author
"C# Network Programming" (Sybex)
http://www.sybex.com/sybexbooks.nsf/Booklist/4176
"Network Performance Open Source Toolkit" (Wiley)
http://www.wiley.com/WileyCDA/WileyT...471433012.html

Nov 15 '05 #3
"Ryan Cromwell" <cr**********@hotmail.com> wrote in message news:<uQ**************@tk2msftngp13.phx.gbl>...
Thanks for the help Rich. Is it accurate to say that client/server
communication in an unreliable protocol require a common agreement on
datagram size such that the client knows when a particular tranmission set
is complete? I've asked this question on the framework group, but have not
yet received an answer.

Ryan -

I guess the answer is "it depends". If reliable communication is a
necessity between the client and server, then I would recommend
choosing TCP as the transmission protocol. However, in some
client/server applications dropping a packet or two along the way does
not produce catastrophic results. Such as with an audio stream - going
back and retransmitting a dropped packet in the middle of a data
stream is much worse than just living with the missing data (which may
only produce a small glitch in the audio signal).

That said, in my book I cover a couple of different scenarios of
how to compensate for problems with UDP communications, such as when
data is lost by not reading the entire packet in the ReceiveFrom()
method, or when UDP packets are dropped. Hope this explanation helps
out some.

Rich Blum - Author
"C# Network Programming" (Sybex)
http://www.sybex.com/sybexbooks.nsf/Booklist/4176
"Network Performance Open Source Toolkit" (Wiley)
http://www.wiley.com/WileyCDA/WileyT...471433012.html
Nov 15 '05 #4

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

Similar topics

18
by: JG | last post by:
Does anyone know a standard (or supported on Linux, Mac, Win32) way to clear a read stream buffer (standard ANSI C file stream)? I would even settle for a platform specific way of doing it. ...
0
by: Nicholas Beenham | last post by:
Hi all, I'm having problems with a udpclient with multicasting and then waiting for a response and if none arrives closes after a few seconds. I have the client multicasting fine but am having...
0
by: gregory_may | last post by:
I posted this in the dotnet.framework group with no responce yet, maybe someone in these groups can point me in the right direction? Or maybe I need to use something already in .Net to get an IGMP...
3
by: Sally Sally | last post by:
I have a very basic question on the two parameters shared buffers and effective cache size. I have read articles on what each is about etc. But I still think I don't quite grasp what these settings...
2
by: | last post by:
Hi, we are planning to rewrite an extisting C++ image processing application/library in C#. Now several question arouse where I hope you can help me: So far we allocated a block of memory as...
0
by: POgletree | last post by:
I need to set up a small client/server or, best solution, a peer-to-peer system to swap data strings between wide spread users. I've looked at IP multicasting and it seems like a reasonable...
0
by: Sam Durai | last post by:
Hello, A particular select query took unusually long time to execute hence I took an app.snap to find out what happens internally and I found out that tablequeue buffers are overflowing on a...
9
by: Sayudh27 | last post by:
Hi all, I am a relatively new programmer in C++...I need to write a code that performs multicasting as well as returns the data-packets in a decompressed form.Data-receipt seems to work...
1
by: Nick | last post by:
Does any one have a simple wcf of udp multicating other than the one posted here http://wcf.netfx3.com/files/folders/transport_channels/entry5235.aspx I would like a program with just the basics...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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.