The library for PTP management client uses IEEE 1558 management messages
to communicate with PTP entities over the network.
We support get, set and command of all management TLVs that are described in IEEE 1588-2019.
In addition, we support LinuxPTP specific implementation management TLVs.
The library supports the three PTP network layers:
In addition, we support using the Unix network and communicate with LinuxPTP ptp4l.
We also support parsing incoming signalling messages.
Users can use Linux VLAN with all sockets.
Project home page https://libptpmgmt.nwtime.org/
Reporting bugs and issues at
https://github.com/erezgeva/libptpmgmt/issues
The library is written in C++ using a data-oriented model.
It uses the namespace 'ptpmgmt'.
Each class represents a data object with methods acting on the data.
The socket classes are the exception, as they represent a system object.
Management TLVs that have data, have a structure and a process function that
builds and parses from structure to message and via versa.
The caller needs to fill the structure and use it with a message object.
When receiving a reply message, the user can parse the message and
get a pointer to a structure from the message object.
The configuration file uses the ptp4l parameters that are relevant to the pmc tool.
The library is written in C++ and provides a C wrapper.
A notice regarding memory:
The classes wrappers, provide a free
callback which free any memory allocated by the wrapper itself.
With one exception: the functions ptpmgmt_json_msg2json
and ptpmgmt_json_tlv2json
allocate string,
which you need to free, in your application!
You need to release any memory allocated on your application,
as the library and the wrappers do not free them!
As C do not provides namespaces, all global functions and global structures
are prefix with ptpmgmt_
or PTPMGMT_
.
The libptpmgmt Library uses C++11
with POSIX,
GNU extensions
and Linux kernel headers.
The C wrapper use C11
.
We try our best to avoid conflicts with newer versions of C++ and C.
But if you find a conflict, please notify us.
This project uses SWIG to generate wrapper to script languages.
For now, we support:
Though the C++ library uses the namespace 'ptpmgmt'.
SWIG for PHP does not support namespace.
Ruby uses 'Ptpmgmt' as namespace, following Ruby convention.
Perl uses the name 'PtpMgmtLib', following Perl convention.
Tcl, Lua, Go, and Python use the namespace 'ptpmgmt'.
Some C++ syntax is ignored or renamed in various scripts.
For example in PHP: Binary::empty is renamed to Binary::c_empty.
See comments in libptpmgmt.i and warn.i of each language for the relevant changes.
Some C++ structure and functions use C++ standard vector "std::vector<>
"
SWIG maps C++ standard vector to a class.
See libptpmgmt.i for the full list of the mapping classes.
All languages create the vector as a class object.
In Python, Ruby, and Tcl the vector has the properties of a native list.
Lua uses subset of C++ standard vector methods.
Perl, PHP, and Go use class methods. See PtpMgmtLib.pm for Perl, ptpmgmt.php for php,
and ptpmgmt.go for Go, for these methods.
C++ std::vector<> map in Scripts Languages provides more information on vectors mapping and the Doxygen documentation provides information per class.
Since Go is a compile language,
and not a "pure" script, the wrapper is used a bit differently.
The wrapper is only required during development,
as the resulting application is a binary that does not require the Go wrapper, only the C++ library.
During development, you need the Go wrapper and the C++ library development headers,
as the Go build compiles the Go wrapper.
In addition add the '-lm -lptpmgmt' flags to the linking using the CGO_LDFLAGS
environment,
so Go will link your application with the C++ library.
Pay attention that although Go uses static typing and checks the types in compilation,
some C++ methods uses variable arguments or share name for different methods.
In this case, swig will use the ... interface{}
parameter
and perform the type check in runtime; if types are wrong, the Go swig wrapper
will issue an exception to your application in run-time.
For example, Binary.SetBin(position, value)
requires position
to be int64
and value
to be byte
.
Go uses methods for interface which use Pascal notation,
so all class functions in the C++ library are converted to use first letter capital.
Go does not use constructors and destructors.
You need to use the New'Class' functions and release with Delete'Class'.
You can use the defer
statment for the releasing, if the release is due in the same function.
Note: as Go syntax is stricter, you may need to update your code with small fixes,
when you build with a newer version of the Go wrapper of the library.
We do our best to retain backward compatible with the C++ library,
but NOT with the Go wrapper, which may break!
Leveraging the libptpmgmt Library, the clock Manager is a framework for monitoring network time synchronization on the local platform. The Clock Manager exposes an API to enable reporting time synchronization status to any application executing on the system. It is planned that Clock Manager will not only be able to report timing telemetry information, but also configure the platform. For further information, see the Clock Manager introduction.
The project provides a clone of LinuxPTP
pmc tool using the libptpmgmt library
and phc_ctl using the libptpmgmt library and python wrapper.
The library provides functionality that is provided by the pmc tool of the LinuxPTP project.
We wish to thank Richard Cochran and the LinuxPTP contributors for their excellent work.
The project comes with packaging:
The project more documents
The Licence of this project is
This project is under development. All source code and features on the main branch are for the purpose of testing or evaluation and not production ready.