Receive UDP packets (Solaris 10 and C) - TCP-IP

This is a discussion on Receive UDP packets (Solaris 10 and C) - TCP-IP ; Hello, Does anyone know of a web page that will have code fragments to show how to receive UDP packets like the ones shown below, captured with tcpdump? 55.255.9016: UDP, length 81 02:31:10.067404 IP (tos 0x0, ttl 64, id 42012, ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: Receive UDP packets (Solaris 10 and C)

  1. Receive UDP packets (Solaris 10 and C)

    Hello,

    Does anyone know of a web page that will have code fragments to show how
    to receive UDP packets like the ones shown below, captured with tcpdump?

    55.255.9016: UDP, length 81
    02:31:10.067404 IP (tos 0x0, ttl 64, id 42012, offset 0, flags [DF],
    proto UDP (17), length 109) jc-logger1.cook.local.33167 >
    255.255.255.255.9016: UDP, length 81
    02:31:10.868608 IP (tos 0x0, ttl 64, id 42013, offset 0, flags [DF],
    proto UDP (17), length 109) jc-logger1.cook.local.33167 >
    255.255.255.255.9016: UDP, length 81

    Thanks,

    Paul.

  2. Re: Receive UDP packets (Solaris 10 and C)

    In article ,
    Paul Duncan wrote:

    > Hello,
    >
    > Does anyone know of a web page that will have code fragments to show how
    > to receive UDP packets like the ones shown below, captured with tcpdump?
    >
    > 55.255.9016: UDP, length 81
    > 02:31:10.067404 IP (tos 0x0, ttl 64, id 42012, offset 0, flags [DF],
    > proto UDP (17), length 109) jc-logger1.cook.local.33167 >
    > 255.255.255.255.9016: UDP, length 81
    > 02:31:10.868608 IP (tos 0x0, ttl 64, id 42013, offset 0, flags [DF],
    > proto UDP (17), length 109) jc-logger1.cook.local.33167 >
    > 255.255.255.255.9016: UDP, length 81


    You receive UDP packets with the recv() or recvfrom() system calls. Any
    book or web site on socket programming should explain this. I recommend
    the book "Unix Network Programming", by W. Richard Stevens.

    --
    Barry Margolin, barmar@alum.mit.edu
    Arlington, MA
    *** PLEASE don't copy me on replies, I'll read them in the group ***

  3. Re: Receive UDP packets (Solaris 10 and C)

    Hi Barry,

    Barry Margolin wrote:
    > You receive UDP packets with the recv() or recvfrom() system calls. Any
    > book or web site on socket programming should explain this. I recommend
    > the book "Unix Network Programming", by W. Richard Stevens.


    Thanks for the recomendation, but I'm on a ship in the Pacific right
    now, so unfortunately I can't just hit a book shop :-(

    Regards,

    Paul
    ~~~~~

  4. Re: Receive UDP packets (Solaris 10 and C)


    "Paul Duncan" wrote in message
    news:fu3hk8$e31$1$8300dec7@news.demon.co.uk...
    > Hello,
    >
    > Does anyone know of a web page that will have code fragments to show how
    > to receive UDP packets like the ones shown below, captured with tcpdump?
    >
    > 55.255.9016: UDP, length 81
    > 02:31:10.067404 IP (tos 0x0, ttl 64, id 42012, offset 0, flags [DF], proto
    > UDP (17), length 109) jc-logger1.cook.local.33167 > 255.255.255.255.9016:
    > UDP, length 81
    > 02:31:10.868608 IP (tos 0x0, ttl 64, id 42013, offset 0, flags [DF], proto
    > UDP (17), length 109) jc-logger1.cook.local.33167 > 255.255.255.255.9016:
    > UDP, length 81
    >
    > Thanks,
    >
    > Paul.


    Which language should the code fragments be in? Also, do you want to capture
    just the data payload of the packets or the entire packet including the
    low-level header?

    Andrew




  5. Re: Receive UDP packets (Solaris 10 and C)

    andrew queisser wrote:
    > "Paul Duncan" wrote in message
    > news:fu3hk8$e31$1$8300dec7@news.demon.co.uk...
    >> Hello,
    >>
    >> Does anyone know of a web page that will have code fragments to show how
    >> to receive UDP packets like the ones shown below, captured with tcpdump?
    >>
    >> 55.255.9016: UDP, length 81
    >> 02:31:10.067404 IP (tos 0x0, ttl 64, id 42012, offset 0, flags [DF], proto
    >> UDP (17), length 109) jc-logger1.cook.local.33167 > 255.255.255.255.9016:
    >> UDP, length 81
    >> 02:31:10.868608 IP (tos 0x0, ttl 64, id 42013, offset 0, flags [DF], proto
    >> UDP (17), length 109) jc-logger1.cook.local.33167 > 255.255.255.255.9016:
    >> UDP, length 81
    >>
    >> Thanks,
    >>
    >> Paul.

    >
    > Which language should the code fragments be in? Also, do you want to capture
    > just the data payload of the packets or the entire packet including the
    > low-level header?


    Hi, thanks for getting back to me. Yup, I should have specified C. I
    should be back in the UK in a few days now - been incredibly busy on the
    ship and didn't have as much development time as I'd hoped, so I may go
    with the book recomendation in about a week.

    Basically I want to retrieve the data in the packet - in this case NMEA
    data from navigational instruments. Its pretty much all in ASCII.

    Thanks again for getting back to me, and my appologies for the length of
    time its taken me to reply!

    Paul
    ~~~~~

  6. Re: Receive UDP packets (Solaris 10 and C)


    "Paul Duncan" wrote in message
    news:fvbah6$hlr$1$8300dec7@news.demon.co.uk...
    > andrew queisser wrote:
    >> "Paul Duncan" wrote in message
    >> news:fu3hk8$e31$1$8300dec7@news.demon.co.uk...
    >>> Hello,
    >>>
    >>> Does anyone know of a web page that will have code fragments to show how
    >>> to receive UDP packets like the ones shown below, captured with tcpdump?
    >>>
    >>> 55.255.9016: UDP, length 81
    >>> 02:31:10.067404 IP (tos 0x0, ttl 64, id 42012, offset 0, flags [DF],
    >>> proto UDP (17), length 109) jc-logger1.cook.local.33167 >
    >>> 255.255.255.255.9016: UDP, length 81
    >>> 02:31:10.868608 IP (tos 0x0, ttl 64, id 42013, offset 0, flags [DF],
    >>> proto UDP (17), length 109) jc-logger1.cook.local.33167 >
    >>> 255.255.255.255.9016: UDP, length 81
    >>>
    >>> Thanks,
    >>>
    >>> Paul.

    >>
    >> Which language should the code fragments be in? Also, do you want to
    >> capture just the data payload of the packets or the entire packet
    >> including the low-level header?

    >
    > Hi, thanks for getting back to me. Yup, I should have specified C. I
    > should be back in the UK in a few days now - been incredibly busy on the
    > ship and didn't have as much development time as I'd hoped, so I may go
    > with the book recomendation in about a week.
    >
    > Basically I want to retrieve the data in the packet - in this case NMEA
    > data from navigational instruments. Its pretty much all in ASCII.
    >
    > Thanks again for getting back to me, and my appologies for the length of
    > time its taken me to reply!
    >
    > Paul
    > ~~~~~


    Here's a really simple example, there are lots of files called "udpserver.c"
    out there. Receiving UDP packets on a socket is really extremely easy. Since
    UDP is connectionless you don't have to worry about opening several
    instances of the socket, just keep looping and reading packets from the one
    socket you create and bind. recvfrom tells you where the packet came from.


    http://www.cs.albany.edu/~xluo/csi516/04f/udpServer.c

    Andrew



+ Reply to Thread