Ping : Network ping probe

更新时间:
2024-05-13
下载文档

Ping : Network ping probe

This module provides a network ping function, typically used to diagnose network connection status. This module is supported in EdgerOS 1.8.8 and later.

User can use the following code to import the ping module.

var ping = require("ping");

Support

The following shows ping module APIs available for each permissions.

 User ModePrivilege Mode
ping.ping

Ping Functions

ping.ping(ipaddr[, opt], callback)

  • ipaddr {String} IPv4 or IPv6 address.
  • opt {Object} Ping option.
  • callback {Function} Return ping results.
    • error {Error} Indicate failure information when ping fails.

Ping the specified remote host. The parameters that opt can contain are as follows:

ParameterTypeDescriptionDefaultsAllowable
ttlIntegerSend packet IP TTL641~255
sizeIntegerPayload size320~65500
timeoutIntegerWait time for echo (ms)30000~60000
devStringDevice to bindingundefined-

Example

var { ping } = require("ping");
// Ping IPv4
ping("127.0.0.1", function(error) {
  if (error) {
    console.error("ping 127.0.0.1 error:", error);
  } else {
    console.log("ping 127.0.0.1 ok!");
  }
});
// Ping IPv6
ping("::1", function(error) {
  if (error) {
    console.error("ping ::1 error:", error);
  } else {
    console.log("ping ::1 ok!");
  }
});

JSRE limit: only ping up to 32 targets at the same time.

文档内容是否对您有所帮助?
有帮助
没帮助