Re: What is the minimum-size UDP packet?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Trevor (trevor_at_nospam.com)
Date: 02/10/04


Date: Tue, 10 Feb 2004 16:03:55 -0500


"David Sworder" <GilGrissom@CSILasVegas.com> wrote in message
news:uzbPm0A8DHA.1052@TK2MSFTNGP12.phx.gbl...
> Hi,
>
> I'm writing an application in which a client (C#/WinForms) and server
> (C#/service) interact with one another. The client establishes a "session"
> with the server but for scalability reasons there is not a one to one map
> between a session and a physical TCP connection. A client may disconnect
the
> TCP connection if it is idle for more than 60 seconds... yet a conceptual
> "session" may last for days at a time.
>
> It's necessary that the server keep track of all open sessions. The
way
> I'm planning to handle this is to have the client send it's session ID
> [which is 4 bytes long] to the server every 2 minutes via UDP. The server
> will respond via UDP with a one bit (datatype='bit') reply of either yes
or
> no. If the server hasn't received a valid session ID via UDP from the
client
> in over 10 minutes, the server will assume that the client is gone and
will
> close out the "session."
>
> With that as the background, here are my questions:
>
> 1) I understand that UDP is a best-effort protocol and delivery of the
> packets is not guaranteed. My system can tolerate that. What it *can't*
> tolerate is only "part" of the client's UDP notification making it across
> the wire. Recall that the client's UDP notification is 4 bytes long. I
can't
> tolerate a situation in which only 2 bytes get through [without the server
> being made aware that some sort of error has occurred via a Winsock
> exception]. It should be 4 bytes or none at all. Is UDP suitable for my
> needs?
>
> 2) Is there a "minimum packet size" for UDP? In other words, when my
> client sends a payload of 4 bytes to the server, are there actually more
> bytes going across the wire due to a minimum packet size? I'm not too
> up-to-speed on TCP/IP, but I know that there is something called a minimum
> transmission unit (MTU) which can be set as high as 1,500 bytes or so.
Will
> my 4-byte notification be "padded" with 1,496 extra bytes? It's very
> important that I get an answer to this question because my app needs to
> conserve bandwidth [I may have 1000's of simultaneous "sessions" at any
> given time].
>
> Thanks in advance for any help you can provide!
>
> --
> Sincerely,
>
> David Sworder
> http://www.CodeFanatic.com
>
>
David,

1) You will get either all or none of the datagram. Is UDP for you? I will
list some pro/cons of each TCP & UDP and let you decide.

UDP:
Connectionless - there is no connection. "sessions" are frequently used to
simulate a connection. Since there is no connection, you don't know when it
is broken (other end disconnects). The host typically removes a client when
it hasn't received some sort of pulse (in your case, session ID) datagram.
This can happen some time after the other device actually shuts off, which
may be good or bad for you.

Less overhead than TCP - datagrams are sent once, either they make it or
they don't make it.

Packet based - you are dealing with datagrams (packets).

TCP:
Connection based - both ends know when the peer has broken the connection

More overhead than UDP - frames (packets for TCP) will be resent if the
other side does not acknowledge them. This is less efficient than UDP, but
when you build ACK/retries/order into UDP they end up at about the same
efficiency level.

Stream based - you are dealing with a continious stream of data. You can
treat the stream like packets but it is not really the idea.

Those are the strong points. There are tons of arguments favoring each
protocol on the internet if you are looking for more information.

2) The minimum datagram size is 1 byte. MTU means MAXIMUM transmit unit,
not minimum. For a UDP packet, the Winsock stack will send across another
20 bytes (12 for IP header, 8 for UDP header) over the wire. These 20 bytes
are the UDP/IP headers which are required, they are not pad bytes. 1500 is
the "standard" MTU for UDP datagrams. I get best results when I set my MTU
to 512. YMMV.

Of course, this is all just my 0.02.



Relevant Pages

  • Re: .Net Scalability problem
    ... LoadRunner will peak out a server with a few virtual users. ... To get an idea of load, ... Fire off the test client and watch the number of ... > So I think that the MTC generate concurrent connection and per ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Connection lost at same time every hour (sometimes)
    ... After making the two following alterations on the server the problem seems ... After analyze your ipconfig on SBS and client, ... Then, other connection is good, ...
    (microsoft.public.windows.server.sbs)
  • Re: server disconnection - very often
    ... Reason of permanent popups is VMware server aplication on clients. ... Run CEICW to configure the network of SBS: ... Two network adapters - manual router connection to broadband ... Uninstall VMware on client. ...
    (microsoft.public.windows.server.sbs)
  • Re: Lan setup 2 nic
    ... The external nic only has TCP/IP enabled. ... Ipconfig of the server is looking good, but the client is still missing the ... > connection so we have a 2 nic with router setup now. ...
    (microsoft.public.windows.server.sbs)
  • Re: Regular disconnections from remote web workplace
    ... I can connect to office server and all office clients from home at all times ... be physically working right up until the connection is lost. ... If I enter http://companyip from a client I receive the login screen for the ... Click Services tab and select Hide All Microsoft Services and Disable ...
    (microsoft.public.windows.server.sbs)