|
||||||||
NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Sntp
Makes SNTP requests and parses/validates the response.
For simple requests Net.verifySntp(String, int, int, int)
can be used.
The Ntp module should be used when more control over the request is needed and/or
for accessing to the response structure.
var ntp = require('sntp'); // optionally set a custom timeout ntp.setTimeout(3000); ntp.setNtpVersion(4); // optionally set the ntp version test.beginTransaction(); test.beginStep("Step 1"); var ntpHosts = [ "3.amazon.pool.ntp.org", "time3.google.com", "ntp.nasa.gov"]; // Uncomment to perform IP address lookups using only IPv6 only, // by default IPv4 only is used. // var dns = require('dns'); // dns.setLookupMode("ipv6"); // For each host issue an NTP request for (var i = 0; i < ntpHosts.length; i++) { var host = ntpHosts[i]; test.log("===== " + host + " ====="); ntp.setHost(host); // Do the request, if the request fails or times out an exception will be thrown // and the script will report the failure test.log(ntp.execute()); } test.endStep(); test.endTransaction();
Nested Class Summary | |
---|---|
static interface |
Sntp.SntpResult
SNTP V4 message according to RFC 4330 (backward compatible with V3) |
Method Summary | |
---|---|
Sntp.SntpResult |
execute()
Connect, send SNTP request and get response. |
int |
getBytesReceived()
Number of bytes received. |
int |
getBytesSent()
Number of bytes sent. |
java.lang.String |
getHost()
Get NTP host URL. |
int |
getNtpVersion()
Get NTP version, 3 or 4, default is 4. |
int |
getPort()
Get NTP port, default is 123. |
int |
getTimeout()
Get timeout, default is 3000 ms. |
void |
setHost(java.lang.String host)
Set NTP host to test. |
void |
setNtpVersion(int version)
Set NTP version, 3 or 4, default is 4. |
void |
setPort(int port)
Set NTP port, default is 123. |
void |
setTimeout(int timeout)
Set timeout, default is 3000 ms. |
Method Detail |
---|
java.lang.String getHost()
void setHost(java.lang.String host)
host
- the host name to contactint getPort()
void setPort(int port)
port
- the port to contactint getTimeout()
void setTimeout(int timeout)
timeout
- the timeout in millisecondsint getNtpVersion()
void setNtpVersion(int version)
version
- the version to useSntp.SntpResult execute()
If there is no response from the NTP server or the hostname does not resolve to an IP an exception will be thrown.
int getBytesSent()
int getBytesReceived()
|
© 2023 Vercara, LLC. All Rights Reserved. | |||||||
NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |