Re: Multiple PDUs in UDP Packet?
From: Michael B Allen (mba2000_at_ioplex.com)
Date: 05/20/05
- Next message: Sean Burke: "Re: Do the people I see in the movies use Unix?"
- Previous message: Casper H.S. Dik: "Re: Do the people I see in the movies use Unix?"
- In reply to: Måns Rullgård: "Re: Multiple PDUs in UDP Packet?"
- Next in thread: David Schwartz: "Re: Multiple PDUs in UDP Packet?"
- Reply: David Schwartz: "Re: Multiple PDUs in UDP Packet?"
- Reply: Måns Rullgård: "Re: Multiple PDUs in UDP Packet?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 20 May 2005 16:52:30 -0400
On Fri, 20 May 2005 13:08:18 +0200, Måns Rullgård wrote:
> Michael B Allen <mba2000@ioplex.com> writes:
>
>> Is it ok to send multiple Protocol Data Units in one UDP packet?
>>
>> For example, would it be normal (or wise) to encode 3 DNS requests into
>> a buffer and then send the entire buffer with one call to sendto(2)?
>>
>> I'm writing some generic message multiplexing code and want to know if
>> I need to treat UDP (sendto) different from TCP (write).
>
> It all depends on what the receiving end is expecting. Are you
> dealing with a standard protocol, or something of your own invention?
I'm trying to be generic so it could be a standard protocol or it could
be custom. As it is I have buffers into which I encode messages. These
buffers are then "written" to sockets. The question is - if I encode
multiple messages into a single buffer can they all be sent with a single
call to write(2)/sendto(2)?
For TCP the answer is absolutely yes because any good protocol decoder
will have to deal with the scenario where some packets are coalesced due
to congestion, client/server speed differential, etc. Thus the decoder
must know how to determine the PDU boundry.
But with UDP this will not work (I don't think - this is what I'm asking)
because the packet *is* the PDU so a call to sendto(2) corresponds
directly to one recvfrom(2) at the other end (minus lost packets). Thus
if I try to sendto(2) a buffer containting 3 PDUs, the other end will
think it's one PDU and probably choke.
So, my message multiplexing code must behave differently depending on
wheather or not the socket is UDP or TCP. If it's TCP I can just write
whatevers in the buffer. For UDP I must either keep track of the PDU
boundies so I can ensure only one PDU is used with each call to sendto(2)
or ensure that the buffer is flushed with sendto(2) before encoding
another message.
Mike
- Next message: Sean Burke: "Re: Do the people I see in the movies use Unix?"
- Previous message: Casper H.S. Dik: "Re: Do the people I see in the movies use Unix?"
- In reply to: Måns Rullgård: "Re: Multiple PDUs in UDP Packet?"
- Next in thread: David Schwartz: "Re: Multiple PDUs in UDP Packet?"
- Reply: David Schwartz: "Re: Multiple PDUs in UDP Packet?"
- Reply: Måns Rullgård: "Re: Multiple PDUs in UDP Packet?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|