UDP server socket

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ajay

    #1

    UDP server socket

    hi!

    whats the maximum number of datagrams that can queue up on a UDP server
    socket? or is that system dependent?
    i have some code that iteratively handles datagrams, and while testing it,
    i noticed that it responds to at most 3 datagrams (i tried sending 4, 6, 8
    and 10 datagrams / second)
    is that a system dependent feature or can i change that (i didn't see
    anything in the manual)

    thanks

    cheers






    ----------------------------------------------------------------
    This message was sent using IMP, the Internet Messaging Program.
  • Peter L Hansen

    #2
    Re: UDP server socket

    Ajay wrote:[color=blue]
    > whats the maximum number of datagrams that can queue up on a UDP server
    > socket? or is that system dependent?
    > i have some code that iteratively handles datagrams, and while testing it,
    > i noticed that it responds to at most 3 datagrams (i tried sending 4, 6, 8
    > and 10 datagrams / second)
    > is that a system dependent feature or can i change that (i didn't see
    > anything in the manual)[/color]

    I don't believe (though I'm not an expert in UDP) that you can
    "queue up" UDP packets at all. At least, there are explicitly
    NO guarantees as to whether any given packet will even make it
    through the network, and I doubt any system provides explicit
    guarantees as to how many UDP packets can be handled if there
    is a backlog. If you are looking for reliable communications,
    that's what TCP is for... otherwise you have to handle missed
    or duplicated packets yourself.

    -Peter

    Comment

    • Ajay

      #3
      Re: UDP server socket

      Quoting Peter L Hansen <peter@engcorp. com>:
      [color=blue]
      > Ajay wrote:[color=green]
      > > whats the maximum number of datagrams that can queue up on a UDP[/color]
      > server[color=green]
      > > socket? or is that system dependent?
      > > i have some code that iteratively handles datagrams, and while testing[/color]
      > it,[color=green]
      > > i noticed that it responds to at most 3 datagrams (i tried sending 4,[/color]
      > 6, 8[color=green]
      > > and 10 datagrams / second)
      > > is that a system dependent feature or can i change that (i didn't see
      > > anything in the manual)[/color]
      >
      > I don't believe (though I'm not an expert in UDP) that you can
      > "queue up" UDP packets at all. At least, there are explicitly
      > NO guarantees as to whether any given packet will even make it
      > through the network, and I doubt any system provides explicit
      > guarantees as to how many UDP packets can be handled if there
      > is a backlog. If you are looking for reliable communications,
      > that's what TCP is for... otherwise you have to handle missed
      > or duplicated packets yourself.
      >
      > -Peter
      > --
      > http://mail.python.org/mailman/listinfo/python-list
      >[/color]

      i am afraid i have to stick with UDP and reliability is no issue. i used
      the word queue but what i really meant was buffer and what i really want
      to know is how many packets get buffered (the ones that make through).
      i dont believe that when i send 10 packets, 7 get lost and 3 make it
      through. Since when i send 3, i always get all 3 (well except perhaps once
      or twice) but i can never get any more than 3. i want to confirm if this is
      a buffering issue
      in my code i do something like
      while 1:
      data, address = self.UDPservers ocket.recvfrom( 1024)
      #do a lot of processing which usually takes between 4-8 seconds

      my question is whether the socket buffers incoming packets, what is the
      size of the buffer and is there any way of increasing it.
      If not, a solution may be to carry the processing in another thread, but
      thats going to increase the overhead (the app. is for a PDA).



      ----------------------------------------------------------------
      This message was sent using IMP, the Internet Messaging Program.

      Comment

      • Richard Brodie

        #4
        Re: UDP server socket


        "Ajay" <abra9823@mail. usyd.edu.au> wrote in message
        news:mailman.49 34.1097757424.5 135.python-list@python.org ...
        [color=blue]
        > whats the maximum number of datagrams that can queue up on a UDP server
        > socket? or is that system dependent?[/color]

        It's system dependent; depends how much buffer space the kernel wants to
        give away. Pulling numbers out of the air I would have thought that some value
        between 8kB and 64kB would be typical.

        getsockopt(sock et.SOL_SOCKET, socket.SO_RCVBU F) and the
        corresponding setsockopt call appear to be what you want, though I've never
        had cause to use them.


        Comment

        • Donn Cave

          #5
          Re: UDP server socket

          In article <mailman.4942.1 097760523.5135. python-list@python.org >,
          Ajay <abra9823@mail. usyd.edu.au> wrote:
          ....[color=blue]
          > my question is whether the socket buffers incoming packets, what is the
          > size of the buffer and is there any way of increasing it.
          > If not, a solution may be to carry the processing in another thread, but
          > thats going to increase the overhead (the app. is for a PDA).[/color]

          I assume you're testing and encountering this result on a PDA, too.
          I have never worked with one myself, but I assume that a platform
          with more limited resources like that will naturally make more
          conservative assumptions about the necessary size of buffers and
          so forth.

          In a simple test on MacOS X, I find that a stopped server can
          wake up and process 100 or so datagrams that had been previously
          sent to it, of sort of random length between 1 and 74 bytes.
          I expect it could handle a lot more than that, and the same
          would be true of any PC or server class Berkeley UNIX or similar.
          Of course you would think the datagrams' size would have something
          to do with it.

          Donn Cave, donn@u.washingt on.edu

          Comment

          Working...