2023-11-22 08:54:39 +00:00
|
|
|
.. only:: comment
|
|
|
|
|
|
2025-01-02 15:05:06 +00:00
|
|
|
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
|
2023-11-22 08:54:39 +00:00
|
|
|
|
2024-02-23 16:49:01 +00:00
|
|
|
.. _NTPServer:
|
|
|
|
|
|
2024-02-23 08:55:32 +00:00
|
|
|
NTPServer
|
2024-02-23 16:49:01 +00:00
|
|
|
#########
|
|
|
|
|
|
2023-11-22 08:54:39 +00:00
|
|
|
The ``NTPServer`` provides a NTP Server simulation by extending the base Service class.
|
|
|
|
|
|
|
|
|
|
NTP Client
|
2024-02-23 16:49:01 +00:00
|
|
|
==========
|
|
|
|
|
|
2023-11-22 08:54:39 +00:00
|
|
|
The ``NTPClient`` provides a NTP Client simulation by extending the base Service class.
|
|
|
|
|
|
|
|
|
|
Key capabilities
|
2024-02-23 16:49:01 +00:00
|
|
|
================
|
2023-11-22 08:54:39 +00:00
|
|
|
|
|
|
|
|
- Simulates NTP requests and NTPPacket transfer across a network
|
|
|
|
|
- Leverages the Service base class for install/uninstall, status tracking, etc.
|
|
|
|
|
|
|
|
|
|
Usage
|
2024-02-23 16:49:01 +00:00
|
|
|
=====
|
2023-11-22 08:54:39 +00:00
|
|
|
- Install on a Node via the ``SoftwareManager`` to start the database service.
|
2024-02-12 17:24:28 +00:00
|
|
|
- Service runs on UDP port 123 by default.
|
2023-11-22 08:54:39 +00:00
|
|
|
|
|
|
|
|
Implementation
|
2024-02-23 16:49:01 +00:00
|
|
|
==============
|
2023-11-22 08:54:39 +00:00
|
|
|
|
|
|
|
|
- NTP request and responses use a ``NTPPacket`` object
|
|
|
|
|
- Extends Service class for integration with ``SoftwareManager``.
|
2024-02-23 16:49:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
Examples
|
|
|
|
|
========
|
|
|
|
|
|
|
|
|
|
Python
|
|
|
|
|
""""""
|
|
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
|
|
from primaite.simulator.network.hardware.nodes.host.server import Server
|
|
|
|
|
from primaite.simulator.system.services.ntp.ntp_server import NTPServer
|
|
|
|
|
|
|
|
|
|
# Create Server
|
2025-02-27 18:16:45 +00:00
|
|
|
server = Server(config = {
|
|
|
|
|
"hostname":"server",
|
|
|
|
|
"ip_address":"192.168.2.2",
|
|
|
|
|
"subnet_mask":"255.255.255.0",
|
|
|
|
|
"default_gateway":"192.168.1.10",
|
|
|
|
|
"start_up_duration":0,
|
|
|
|
|
}
|
2024-02-23 16:49:01 +00:00
|
|
|
)
|
|
|
|
|
server.power_on()
|
|
|
|
|
|
|
|
|
|
# Install NTPServer on server
|
|
|
|
|
server.software_manager.install(NTPServer)
|
2025-02-10 14:39:28 +00:00
|
|
|
ntp_server: NTPServer = server.software_manager.software.get("ntp-server")
|
2024-02-23 16:49:01 +00:00
|
|
|
ntp_server.start()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Via Configuration
|
|
|
|
|
"""""""""""""""""
|
|
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
|
|
simulation:
|
2025-03-13 11:36:24 +00:00
|
|
|
network:
|
|
|
|
|
nodes:
|
|
|
|
|
- hostname: example_server
|
|
|
|
|
type: server
|
|
|
|
|
...
|
|
|
|
|
services:
|
|
|
|
|
- type: ntp-server
|
2024-09-05 08:41:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
``Common Attributes``
|
2024-09-05 11:23:52 +01:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^
|
2024-09-05 08:41:04 +01:00
|
|
|
|
|
|
|
|
See :ref:`Common Configuration`
|