Re: Linux Sockets UDP and fragmentation



"toobee84@xxxxxxxxxxxxxx" <toobee84@xxxxxxxxxxxxxx> writes:

i try to write a c-program that sends udp-packages. works so far, but
if i try to send packages that are bigger for example 10.000 Byte i
receive "Message too long" error from my sendto()-call.

i expected that the socket api would automatic fragment my too-large
package in smaller pieces so that things would fit but i obviously
don't. does that mean i have to ask the network for its MTU and the
split my package into pieces ?

No, you can't get round the upper limit of one IP datagram.
Fragmentation may occur, but that will affect things like
performance -- it will not affect how large a packet you can send.
Even then, since UDP gives you no delivery guarantees, the network is
permitted to drop even small packets.

For practical purposes, you would not want to even approach this
theoretical limit. In the days when I knew about such things, it was
considered unwise to use a payload bigger than about 1200 bytes for a
UDP datagram and I'd be surprised if this has changed much.

Or am i doing something wrong, i wrote a program that used tcp instead
of udp and there it was not necessary to split the packages (i suppose
it happend automatically).

TCP is designed to do this (and more). UDP does not do this. In
fact, UDP is about the simplest transport-layer protocol that you can
imagine over running IP. If you need reliable transfer or have large
amounts of data you should probably not use UDP.

There used to some proposals around for reliable, uni-directional,
large datagram protocols, but I don't think any became widely used.

--
Ben.
.



Relevant Pages

  • Re: UDP networking with Ada
    ... most of GNAT's add-on packages like Florist uses TCP. ... GNAT.Sockets does supports both TCP and UDP protocols. ... bind a ipv6 socket will generate an exception error. ...
    (comp.lang.ada)
  • Re: about UDP
    ... > when I use UDP instead of TCP/IP, will I only have to fear about ... > packages, where the first few bytes might have been dropped) ...
    (microsoft.public.win32.programmer.networks)
  • UDP sendto buffering problem
    ... I have a Fujitsu Siemens Loox and use WLAN to send UDP ... packages to a Windows XP computer. ... that the UDP packages are buffered somewhere. ... The buffering time is not limited - so ...
    (microsoft.public.pocketpc.developer.networking)
  • Re: Simple UDP server
    ... applications like video and audio streaming. ... UDP does neither guarantee ... Can your protocol handle missing packages and out of order packages? ...
    (comp.lang.python)
  • Re: Mozilla/Firefox "PostScript/default" security problems
    ... Will you put those packages somewhere where others can reach them as ... build bigger and better idiot-proof programs, ... to build bigger and better idiots. ... So far, the Universe is winning... ...
    (Debian-User)