Programmatic usage of ping - VxWorks

This is a discussion on Programmatic usage of ping - VxWorks ; Hi, I wanted to do ping from a vxWorks target with an interval of 10ms and see the output on the console: The units for _pingTxInterval are in units of 1 second. So, I wrote some code like this - ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Programmatic usage of ping

  1. Programmatic usage of ping

    Hi,

    I wanted to do ping from a vxWorks target with an interval of
    10ms and see the output on
    the console:


    The units for _pingTxInterval are in units of 1 second. So, I wrote
    some code like this -

    void testPing(char *s)
    {
    ping(s, 1, PING_OPT_DEBUG );
    }

    The output I get is somewhat like this -

    -> testPing("172.30.10.99")
    value = 87099380 = 0x53107f4
    -> 172.30.10.99 is alive

    I want an output which prints the RTT, like what we get when we use the
    shell

    -> p ping "172.30.10.99"

    PING 172.30.10.99: 56 data bytes
    64 bytes from 172.30.10.99: icmp_seq=0. time=0. ms

    Is there a way, I can print the RTT programmatically or on the console
    ?

    (2) I would like to ping every 10 ms. Because pingTxInterval is
    declared as int and is in units of
    seconds, I cannot do it simply by giving a fractional parameter.

    So, I did this -

    void testPing(char *s)
    {
    for (int i=0;i {
    ping(s, 1, PING_OPT_DEBUG);
    taskDelay(sysClkRateGet()/10);
    }
    }

    This still does not seem to speed up ping rate. I guess this is because
    each ping call blocks until
    it gets the ping response. The alternative seems to be to create about
    10 threads and let each of them call testPing continuously.

    Is there a better way for this ? If so, please let me know.

    Thanks
    Phani


  2. Re: Programmatic usage of ping

    Hi:

    I would bypass the ping function, and just create a raw socket and
    create the ICMP message directly and send it out on your own intervals,
    varying the TTL as needed.

    10ms is pretty short. You'll have to balance that with the TTL you use
    and the RTT to the host you are pinging.

    Lot of source code for "ping" around, or try one of the IP books for
    examples.

    Good luck,
    LArry
    phanindra.ganti@gmail.com wrote:
    > Hi,
    >
    > I wanted to do ping from a vxWorks target with an interval of
    > 10ms and see the output on
    > the console:
    >
    >
    > The units for _pingTxInterval are in units of 1 second. So, I wrote
    > some code like this -
    >
    > void testPing(char *s)
    > {
    > ping(s, 1, PING_OPT_DEBUG );
    > }
    >
    > The output I get is somewhat like this -
    >
    > -> testPing("172.30.10.99")
    > value = 87099380 = 0x53107f4
    > -> 172.30.10.99 is alive
    >
    > I want an output which prints the RTT, like what we get when we use the
    > shell
    >
    > -> p ping "172.30.10.99"
    >
    > PING 172.30.10.99: 56 data bytes
    > 64 bytes from 172.30.10.99: icmp_seq=0. time=0. ms
    >
    > Is there a way, I can print the RTT programmatically or on the console
    > ?
    >
    > (2) I would like to ping every 10 ms. Because pingTxInterval is
    > declared as int and is in units of
    > seconds, I cannot do it simply by giving a fractional parameter.
    >
    > So, I did this -
    >
    > void testPing(char *s)
    > {
    > for (int i=0;i > {
    > ping(s, 1, PING_OPT_DEBUG);
    > taskDelay(sysClkRateGet()/10);
    > }
    > }
    >
    > This still does not seem to speed up ping rate. I guess this is because
    > each ping call blocks until
    > it gets the ping response. The alternative seems to be to create about
    > 10 threads and let each of them call testPing continuously.
    >
    > Is there a better way for this ? If so, please let me know.
    >
    > Thanks
    > Phani



+ Reply to Thread