NAME
Net::SNTP::Server - Perl Module SNTP Server based on RFC4330
VERSION
Version 0.02
SYNOPSIS
The Net::SNTP::Server - Perl module has the ability to retrieve the time from the local internal clock of the OS. The module has been tested on LinuxOS but it should be compatible with MacOS and WindowsOS. When the server is activated, it will enter while state mode and wait for client requests. The SNTP server uses the local time in seconds and nano seconds accuracy based on the OS accuracy ability. The server will encode a message format based on RFC4330 that will be send to the client in-order to calculate the round-trip delay d and system clock offset.
use Net::SNTP::Server;
my ( $error , $hashRefOutput ) = basicSNTPSetup( %hashInput );
...
ABSTRACT
The module receives and sends a UDP packet formated according to RFC4330 message format. The server expects an SNTP packet from the client which will reply back to him. The received packet, gets decoded into a human readable form. As a second step the server extracts and adds the needed data to create the packet. Before the message to be sent to the client it gets encoded and transmitted back to the recipient.
DESCRIPTION
This module exports a single method (basicSNTPSetup) and returns an associative hash based on the user input and a string in case of an error. The response from the SNTP server is been encoded to a human readable format. The obtained information received from the server on the client side can be used into further processing or manipulation according to the user needs. Maximum accuracy down to nano seconds can only be achieved based on different OS.
EXPORT
my %hashInput = (
-ip => $ip, # IP
-port => $port, # default NTP port 123
);
my ( $error , $hashRefOutput ) = basicSNTPSetup( %hashInput );
IP
-ip: Is not a mandatory for the method key to operate correctly. By default the module will assign the localhost IP ("127.0.0.1"), but this will restrict the server to localhost communications (only internally it can receive and transmit data).
PORT
-port: Is a mandatory key, that the user must define. By default the port is not set. The user has to specify the port. We can not use the default 123 NTP due to permission. The user has to choose a port number identical to port that the client will use client to communicate with the server (e.g. -port => 123456).
SUBROUTINES/METHODS
my ( $error , $hashRefOutput ) = basicSNTPSetup( %hashInput );
EXAMPLE
This example starts a remote NTP server based on RFC4330 message format. The IP and Port that the user will provide based on his criteria.
We use the Data::Dumper module to print the output if needed. The module does not require to printout the output. It should be used only for initialization purposes to assist the user with debugging in case of an error. The $error string it is also optional that will assist the user to identify the root that can cause a faulty initialization.
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use Net::SNTP::Server qw(basicSNTPSetup);
my %hashInput = (
-ip => "127.0.0.1",
-port => 12345,
);
my ( $error , $hashRefOutput ) = basicSNTPSetup( %hashInput );
print Dumper $hashRefOutput;
print "Error: $error\n" if ($error);
AUTHOR
Athanasios Garyfalos, <garyfalos at cpan.org>
BUGS
Please report any bugs or feature requests to bug-net-sntp-server at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-SNTP-Server. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Net::SNTP::Server
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
I want to say thank you to Perl Monks The Monastery Gates for their guidance and assistance when ever I had a problem with the implementation process of module.
LICENSE AND COPYRIGHT
Copyright 2015 Athanasios Garyfalos.
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
http://www.perlfoundation.org/artistic_license_2_0
Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.
If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.
This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.
This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
CHANGE LOG
$Log: Server.pm,v $ Revision 2.0 2015/07/21 16:32:31 Thanos