Home AMX User Forum AMX General Discussion
Options

Wishing I could PING

Just sayin...

I wish we had a PING (ICMP) that is...

I can jury rig one by telneting into myself and sending the command there. But, that's just a janky way of doing it.

Comments

  • Options
    viningvining Posts: 4,368
    There's a half bake module for that here:
    http://www.amxforums.com/showthread.php?6488-Ping_URL_n_GET_IP
  • Options
    ericmedleyericmedley Posts: 4,177
    vining wrote: »

    Thanks Vinning. But, I already can do this in spades.

    I'm wanting to do a good ole fashioned ICMP message (Ping)

    I want to ping an IP device from the Netlinx master in code.

    We cannot do this in Netlinx. (as far as I know) attempting to do so results in nothing we can process in our sandbox.
  • Options
    viningvining Posts: 4,368
    Yeah, I guess that would be an elementary part of your Certified Cyber Solution which BTW is pretty cool.
  • Options
    ericmedleyericmedley Posts: 4,177
    vining wrote: »
    Yeah, I guess that would be an elementary part of your Certified Cyber Solution which BTW is pretty cool.
    Not much gets past you! I'm working on an AMX module for it right now.
  • Options
    viningvining Posts: 4,368
    ericmedley wrote: »
    Not much gets past you! I'm working on an AMX module for it right now.
    That's cuz I'm a trained professional. :)
  • Options
    ericmedleyericmedley Posts: 4,177
    vining wrote: »
    That's cuz I'm a trained professional. :)
    Yes you are.
  • Options
    Spire_JeffSpire_Jeff Posts: 1,917
    Have you looked at Duet? I am thinking that might be native to Duet. Maybe a Duet programmer could create a simple module for you.

    Jeff
  • Options
    ericmedleyericmedley Posts: 4,177
    Spire_Jeff wrote: »
    Have you looked at Duet? I am thinking that might be native to Duet. Maybe a Duet programmer could create a simple module for you.

    Jeff
    That's a great idea. I'm done with the Certified Cyber Solutions - HCS module for now. But, I'll look into it.
  • Options
    mpullinmpullin Posts: 949
    .. when you wish upon a ping .. you can locate any thing ..
  • Options
    ericmedleyericmedley Posts: 4,177
    mpullin wrote: »
    .. when you wish upon a ping .. you can locate any thing ..
    :D your streamssssss cooommmee truuuuuue
  • Options
    travistravis Posts: 180
    Anyone find a duet module? Does pinging from the master work well for you guys? It takes forever ( about a minute) for me to get a reply. It doesn't take that long if I use the netlinx telnet interface.
    SEND_STRING dvMaster, "'192.168.1.21',13"
    
    DATA_EVENT[dvMaster]
    {
        STRING:{
    	SEND_STRING 0, DATA.TEXT
        }
    }
    
    Line      1 (16:52:43)::  p
    Line      2 (16:52:43)::  ing 192.168.1.21$0D$0A
    Line      3 (16:53:59)::  192.168.1.21
    Line      4 (16:54:00)::   is alive.$0D$0A>
    
  • Options
    viningvining Posts: 4,368
    How are you doing that? I tried sending strings directly to the master and got nothing?

    On my office master NI-3100 (I believe) which is loaded with a bunch of unorganized code from years of testing crap so I don't know what is really running in the background or what define program code/FB there might be I still get pretty decent results using the telnet through code method.

    If I use Diagnostics "Control Device" to send to my virtual device "'PING_IP:192.168.1.33" which is my router and then 'PING_IP:yahoo.com'" to test a ping on the WAN side. From the virtual receiving the command it then opens a socket with the master's telnet port and gives it the ping command with the desired IP or name.

    Both tests took only 2 seconds from receiving the commnand to closing the socket and getting my offline event, again on a system running alot of crappy code.

    To Router (192.168.1.33)
    Line      1 (13:58:44)::  TELNET MODULE: CMD RX: PING_IP:192.168.1.33 :DEBUG<645>
    Line      2 (13:58:44)::  TELNET MODULE: RX request to PING_IP: [ 192.168.1.33 ] :DEBUG<674>
    Line      3 (13:58:44)::  TELNET MODULE: Attempting to Connect! :DEBUG<520>
    Line      4 (13:58:44)::  Accepted Telnet connection:socket=42 addr=127.0.0.1 port=1039
    Line      5 (13:58:44)::  Connected Successfully
    Line      6 (13:58:44)::  CIpEvent::OnLine 0:19:1
    Line      7 (13:58:44)::  TELNET MODULE: ONLINE
    Line      8 (13:58:44)::  TELNET MODULE: RX: [ $FF$FB$01 ] :DEBUG<626>$0D$0A
    Line      9 (13:58:44)::  TELNET MODULE: RX: [ $0D$0ALogin :  ] :DEBUG<626>$0D$0A
    Line     10 (13:58:44)::  TELNET MODULE: sending login name
    Line     11 (13:58:44)::  TELNET MODULE: RX: [ v ] :DEBUG<626>$0D$0A
    Line     12 (13:58:44)::  TELNET MODULE: RX: [ ining$0D$0APassword :  ] :DEBUG<626>$0D$0A
    Line     13 (13:58:44)::  TELNET MODULE: sending login password
    Line     14 (13:58:44)::  TELNET MODULE: RX: [ * ] :DEBUG<626>$0D$0A
    Line     15 (13:58:44)::  TELNET MODULE: RX: [ *****$0D$0AWelcome to NetLinx v3.50.430 Copyright AMX LLC 2008$0D$0A> ] :DEBUG<626>$0D$0A
    Line     16 (13:58:44)::  TELNET MODULE: RX: [ p ] :DEBUG<626>$0D$0A
    Line     17 (13:58:44)::  TELNET MODULE: RX: [ in ] :DEBUG<626>$0D$0A
    Line     18 (13:58:44)::  TELNET MODULE: RX: [ g 1 ] :DEBUG<626>$0D$0A
    Line     19 (13:58:44)::  TELNET MODULE: RX: [ 92. ] :DEBUG<626>$0D$0A
    Line     20 (13:58:44)::  TELNET MODULE: RX: [ 168 ] :DEBUG<626>$0D$0A
    Line     21 (13:58:44)::  TELNET MODULE: RX: [ .1. ] :DEBUG<626>$0D$0A
    Line     22 (13:58:44)::  TELNET MODULE: RX: [ 33$0D$0A ] :DEBUG<626>$0D$0A
    Line     23 (13:58:44)::  Memory Available = 13056688 <126256>
    Line     24 (13:58:45)::  TELNET MODULE: RX: [ 192.168.1.33 ] :DEBUG<626>$0D$0A
    Line     25 (13:58:45)::  TELNET MODULE: RX: [  is alive.$0D$0A> ] :DEBUG<626>$0D$0A
    Line     26 (13:58:45)::  TELNET MODULE: Ping 192.168.1.33 RESULT: "PASSED" <193>
    Line     27 (13:58:45)::  PING_URL RX: [ PING_IP:192.168.1.33RESULT:PASSED ] :DEBUG<692>
    Line     28 (13:58:45)::  TELNET MODULE: RX: [ e ] :DEBUG<626>$0D$0A
    Line     29 (13:58:46)::  Exiting TCP Read thread - closing this socket for local port 19
    Line     30 (13:58:46)::  TELNET MODULE: RX: [ xi ] :DEBUG<626>$0D$0A
    Line     31 (13:58:46)::  TELNET MODULE: RX: [ t$0D$0A> ] :DEBUG<626>$0D$0A
    Line     32 (13:58:46)::  CIpEvent::OffLine 0:19:1
    Line     33 (13:58:46)::  TELNET MODULE: OFFLINE, STATUS DISCO
    

    To Yahoo.com through the router above which is behind another router that acts as the gateway:
    Line      1 (14:01:54)::  TELNET MODULE: CMD RX: PING_IP:yahoo.com :DEBUG<645>
    Line      2 (14:01:54)::  TELNET MODULE: RX request to PING_IP: [ yahoo.com ] :DEBUG<674>
    Line      3 (14:01:54)::  TELNET MODULE: Attempting to Connect! :DEBUG<520>
    Line      4 (14:01:54)::  Accepted Telnet connection:socket=42 addr=127.0.0.1 port=1041
    Line      5 (14:01:54)::  Connected Successfully
    Line      6 (14:01:54)::  CIpEvent::OnLine 0:19:1
    Line      7 (14:01:54)::  TELNET MODULE: ONLINE
    Line      8 (14:01:54)::  TELNET MODULE: RX: [ $FF$FB$01 ] :DEBUG<626>$0D$0A
    Line      9 (14:01:54)::  TELNET MODULE: RX: [ $0D$0ALogin :  ] :DEBUG<626>$0D$0A
    Line     10 (14:01:54)::  TELNET MODULE: sending login name
    Line     11 (14:01:54)::  TELNET MODULE: RX: [ v ] :DEBUG<626>$0D$0A
    Line     12 (14:01:54)::  TELNET MODULE: RX: [ ining$0D$0APassword :  ] :DEBUG<626>$0D$0A
    Line     13 (14:01:54)::  TELNET MODULE: sending login password
    Line     14 (14:01:54)::  TELNET MODULE: RX: [ * ] :DEBUG<626>$0D$0A
    Line     15 (14:01:54)::  TELNET MODULE: RX: [ *****$0D$0AWelcome to NetLinx v3.50.430 Copyright AMX LLC 2008$0D$0A> ] :DEBUG<626>$0D$0A
    Line     16 (14:01:55)::  TELNET MODULE: RX: [ p ] :DEBUG<626>$0D$0A
    Line     17 (14:01:55)::  TELNET MODULE: RX: [ in ] :DEBUG<626>$0D$0A
    Line     18 (14:01:55)::  TELNET MODULE: RX: [ g y ] :DEBUG<626>$0D$0A
    Line     19 (14:01:55)::  TELNET MODULE: RX: [ aho ] :DEBUG<626>$0D$0A
    Line     20 (14:01:55)::  TELNET MODULE: RX: [ o.c ] :DEBUG<626>$0D$0A
    Line     21 (14:01:55)::  TELNET MODULE: RX: [ om$0D$0A ] :DEBUG<626>$0D$0A
    Line     22 (14:01:56)::  TELNET MODULE: RX: [ yahoo.com ] :DEBUG<626>$0D$0A
    Line     23 (14:01:56)::  TELNET MODULE: RX: [  is alive.$0D$0A> ] :DEBUG<626>$0D$0A
    Line     24 (14:01:56)::  TELNET MODULE: Ping yahoo.com RESULT: "PASSED" <193>
    Line     25 (14:01:56)::  PING_URL RX: [ PING_IP:yahoo.comRESULT:PASSED ] :DEBUG<692>
    Line     26 (14:01:56)::  TELNET MODULE: RX: [ e ] :DEBUG<626>$0D$0A
    Line     27 (14:01:56)::  TELNET MODULE: RX: [ xi ] :DEBUG<626>$0D$0A
    Line     28 (14:01:56)::  Exiting TCP Read thread - closing this socket for local port 19
    Line     29 (14:01:56)::  TELNET MODULE: RX: [ t$0D$0A> ] :DEBUG<626>$0D$0A
    Line     30 (14:01:56)::  CIpEvent::OffLine 0:19:1
    Line     31 (14:01:56)::  TELNET MODULE: OFFLINE, STATUS DISCO
    

    Here's an example of the string with the additional command to notify a device so that the ping result will be sent to a specified device's string event handler so you can use the results in the code that needs it.
    Line      2 (14:33:10)::  TELNET MODULE: CMD RX: PING_IP:192.168.1.33NOTIFY:33028:1:0 :DEBUG<645>
    Line      3 (14:33:10)::  TELNET MODULE: RX request to PING_IP: [ 192.168.1.33 ], respond to [ 33028:1:0 ] :DEBUG<669>
    Line      4 (14:33:10)::  TELNET MODULE: Attempting to Connect! :DEBUG<520>
    Line      5 (14:33:10)::  Accepted Telnet connection:socket=42 addr=127.0.0.1 port=1043
    Line      6 (14:33:10)::  Connected Successfully
    Line      7 (14:33:10)::  CIpEvent::OnLine 0:19:1
    Line      8 (14:33:10)::  TELNET MODULE: ONLINE
    Line      9 (14:33:10)::  TELNET MODULE: RX: [ $FF$FB$01 ] :DEBUG<626>$0D$0A
    Line     10 (14:33:10)::  TELNET MODULE: RX: [ $0D$0ALogin :  ] :DEBUG<626>$0D$0A
    Line     11 (14:33:10)::  TELNET MODULE: sending login name
    Line     12 (14:33:10)::  TELNET MODULE: RX: [ v ] :DEBUG<626>$0D$0A
    Line     13 (14:33:10)::  TELNET MODULE: RX: [ ining$0D$0APassword :  ] :DEBUG<626>$0D$0A
    Line     14 (14:33:10)::  TELNET MODULE: sending login password
    Line     15 (14:33:10)::  TELNET MODULE: RX: [ * ] :DEBUG<626>$0D$0A
    Line     16 (14:33:10)::  TELNET MODULE: RX: [ *****$0D$0AWelcome to NetLinx v3.50.430 Copyright AMX LLC 2008$0D$0A> ] :DEBUG<626>$0D$0A
    Line     17 (14:33:10)::  TELNET MODULE: RX: [ p ] :DEBUG<626>$0D$0A
    Line     18 (14:33:10)::  TELNET MODULE: RX: [ in ] :DEBUG<626>$0D$0A
    Line     19 (14:33:11)::  TELNET MODULE: RX: [ g 1 ] :DEBUG<626>$0D$0A
    Line     20 (14:33:11)::  TELNET MODULE: RX: [ 92. ] :DEBUG<626>$0D$0A
    Line     21 (14:33:11)::  TELNET MODULE: RX: [ 168 ] :DEBUG<626>$0D$0A
    Line     22 (14:33:11)::  TELNET MODULE: RX: [ .1. ] :DEBUG<626>$0D$0A
    Line     23 (14:33:11)::  TELNET MODULE: RX: [ 33$0D$0A ] :DEBUG<626>$0D$0A
    Line     24 (14:33:12)::  TELNET MODULE: RX: [ 192.168.1.33 ] :DEBUG<626>$0D$0A
    Line     25 (14:33:12)::  TELNET MODULE: RX: [  is alive.$0D$0A> ] :DEBUG<626>$0D$0A
    Line     26 (14:33:12)::  TELNET MODULE: Ping 192.168.1.33 RESULT: "PASSED" <193>
    Line     27 (14:33:12)::  PING_URL RX: [ PING_IP:192.168.1.33RESULT:PASSED ] :DEBUG<692>
    Line     28 (14:33:12)::  TELNET MODULE: RX: [ e ] :DEBUG<626>$0D$0A
    Line     29 (14:33:12)::  TELNET MODULE: RX: [ xi ] :DEBUG<626>$0D$0A
    Line     30 (14:33:12)::  Exiting TCP Read thread - closing this socket for local port 19
    Line     31 (14:33:12)::  TELNET MODULE: RX: [ t$0D$0A> ] :DEBUG<626>$0D$0A
    Line     32 (14:33:12)::  CIpEvent::OffLine 0:19:1
    Line     33 (14:33:12)::  TELNET MODULE: OFFLINE, STATUS DISCO
    
  • Options
    AuserAuser Posts: 506
    Spire_Jeff wrote: »
    Have you looked at Duet?

    Based on my meagre readings on the subject, Java doesn't provide access to the ICMP protocol. According to its documentation Java 5.0's InetAddress.isRecahable() function seems to use the underlying OS's ICMP implementation but we do not have access to Java 5.0 in Duet.

    Most people who need to implement this functionality in Java seem to be using another active port on the target devices (such as the echo service on port 7) to perform pseudo-pings instead of relying on the ICMP ping mechanism.
  • Options
    AuserAuser Posts: 506
    Auser wrote: »
    Based on my meagre readings on the subject, Java doesn't provide access to the ICMP protocol. According to its documentation Java 5.0's InetAddress.isRecahable() function seems to use the underlying OS's ICMP implementation but we do not have access to Java 5.0 in Duet.

    The following returns a java.lang.SecurityException: Not supported by platform
    Process ping = Runtime.getRuntime().exec("ping " + host);
    

    Which pretty much only leaves us with using JNI to run native code to access raw socket functionality (which I think requires that vxWorks on the control system is up to a certain version, which I don't believe it is).

    Telnetting into the master and pinging a device from the console seems to be the easiest and onlyiest way to go for the time being :(
  • Options
    travistravis Posts: 180
    vining wrote: »
    How are you doing that? I tried sending strings directly to the master and got nothing?

    briefly
    CHAR ip_master[] = {'192.168.1.198'}
    INTEGER port_master = 23
    test_string = "'ping 192.168.1.21'"
    
    IP_CLIENT_OPEN(dvMaster.PORT, ip_master, port_master, IP_TCP) ;
    
    SEND_STRING dvMaster, "test_string,13"
    
    DATA_EVENT[dvMaster]
    {
        STRING:{
    	SEND_STRING 0, DATA.TEXT
        }
    }
    

    I feel like I must be causing some kind of infinite loop of send_strings, but I don't get exactly how. I do see the command going twice actually:
    Line      1 (08:43:33)::  p
    Line      2 (08:43:33)::  ing 192.168.1.21$0D$0A
    Line      3 (08:44:49)::  192.168.1.21
    Line      4 (08:44:49)::   is alive.$0D$0A>ping 192.168.1.21$0D$0A
    Line      5 (08:45:05)::  192.168.1.21
    Line      6 (08:45:05)::   is alive.$0D$0A>
    
  • Options
    viningvining Posts: 4,368
    Ok, that a little clearer, now I see you're opening a telnet connection to the master 1st. I assume:
    SEND_STRING dvMaster, "test_string,13"
    
    is in the ONLINE event handler for dvMAster then. If there's no user/pass set up for the telnet session then that's pretty straigh forward and should work similar if not faster then results I got since you not having to log in so why is it so slow. Hmmm. What kind of master and how loaded is it? Put some code in the ONERROR handler and see if the connection times out during the request. How do you call your IP_CLIEN_OPEN, a button? Need more code....
  • Options
    travistravis Posts: 180
    PROGRAM_NAME='main'
    DEFINE_DEVICE
    dvMaster   = 0:5:0
    vdvMaster	= DYNAMIC_VIRTUAL_DEVICE
    
    dvTP = 5555:1:0
    
    DEFINE_VARIABLE
    VOLATILE INTEGER cCommStatus
    CHAR test_string[64]
    CHAR ip_master[] = {'192.168.1.198'}
    INTEGER port_master = 23
    CHAR ip_test[] = {'192.168.1.21'}
    DEFINE_CALL 'Master Connect'
    { 	
        ip_client_close(dvMaster.PORT)
        IP_CLIENT_OPEN(dvMaster.PORT, ip_master, port_master, IP_TCP) ;
    }
    
    DEFINE_START
    CALL 'Master Connect'
    test_string = "'ping ',ip_test"
    
    DEFINE_EVENT
    DATA_EVENT[dvMaster]
    {
        STRING:{
    	SEND_STRING 0, DATA.TEXT
        }
        ONLINE:{
    	cCommStatus = TRUE
        }
        OFFLINE:{
    	cCommStatus = FALSE
        }
        ONERROR:{
    	cCommStatus = TYPE_CAST(DATA.NUMBER)
        }
    }
    
    BUTTON_EVENT[dvTP, 1]
    {
        PUSH:{
    	SEND_STRING dvMaster, "test_string,13"
        }
    }
    
    BUTTON_EVENT[dvTP, 2]
    {
        PUSH:{
    	CALL 'Master Connect'
        }
    }
    DEFINE_PROGRAM
    
    Line     39 (12:37:52)::  CIpEvent::OnLine 0:5:1
    Line     40 (12:37:52)::  $FF$FB$01
    Line     41 (12:37:52)::  $0D$0AWelcome to NetLinx v3.50.439 Copyright AMX LLC 2008$0D$0A>
    Line     42 (12:38:21)::  p
    Line     43 (12:38:21)::  ing 192.168.1.21$0D$0A
    Line     44 (12:39:37)::  192.168.1.21
    Line     45 (12:39:37)::   is alive.$0D$0A>
    
    
  • Options
    viningvining Posts: 4,368
    The only real difference I see between my code and yours is I open the connection, send when I my "online" handler triggers, negotiate user/pass, receive what I need and then close. I also use local host 127.0.0.1 instead of the LAN IP address.
  • Options
    ericmedleyericmedley Posts: 4,177
    vining wrote: »
    The only real difference I see between my code and yours is I open the connection, send when I my "online" handler triggers, negotiate user/pass, receive what I need and then close. I also use local host 127.0.0.1 instead of the LAN IP address.

    Vining,
    Does having this connection open to 127.0.0.1 preclude anyone else opening one on the AN IP? In other words, do you lock some out by being on the internal IP?
    E
  • Options
    viningvining Posts: 4,368
    ericmedley wrote: »
    Vining,
    Does having this connection open to 127.0.0.1 preclude anyone else opening one on the AN IP? In other words, do you lock some out by being on the internal IP?
    E
    Beats the F' out of me? I could check when I get a moment.
  • Options
    ericmedleyericmedley Posts: 4,177
    vining wrote: »
    Beats the F' out of me? I could check when I get a moment.

    nah, don't do that. I'm not crippled. I can hobble over and do it myself. I was just hoping you knew it in your brain. Thanks! :D
    e
  • Options
    viningvining Posts: 4,368
    ericmedley wrote: »
    nah, don't do that. I'm not crippled. I can hobble over and do it myself. I was just hoping you knew it in your brain. Thanks! :D
    e
    It really ain't nothing but a thing to do so I connected my PC to the master via telnet, enabled "msg on". Opened up debug to enable my telnet debug var, then diagnostic's "control device" to send a ping command to my virtual and it worked fine and my debug strings printed in both diagnostics and my telent window. So , yes telnet on 127.0.0.1 and telnet from a LAN IP connection can work concurrently.
  • Options
    ericmedleyericmedley Posts: 4,177
    vining wrote: »
    It really ain't nothing but a thing to do so I connected my PC to the master via telnet, enabled "msg on". Opened up debug to enable my telnet debug var, then diagnostic's "control device" to send a ping command to my virtual and it worked fine and my debug strings printed in both diagnostics and my telent window. So , yes telnet on 127.0.0.1 and telnet from a LAN IP connection can work concurrently.

    I honestly didn't expect you to do that but truthfully I knew you would. You're too inquisitive to resist. ;)
    Thank you kind sir!
    E
Sign In or Register to comment.