Files
PrimAITE/docs/source/simulation_components/system/services/ftp_client.rst

89 lines
2.3 KiB
ReStructuredText
Raw Normal View History

.. only:: comment
2025-01-02 15:05:06 +00:00
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
2024-02-23 16:49:01 +00:00
.. _FTPClient:
FTPClient
2024-02-23 16:49:01 +00:00
#########
2024-02-23 16:49:01 +00:00
The ``FTPClient`` provides a client interface for connecting to the :ref:`FTPServer`.
Key features
2024-02-23 16:49:01 +00:00
============
2024-02-23 16:49:01 +00:00
- Connects to the :ref:`FTPServer` via the ``SoftwareManager``.
- Simulates FTP requests and FTPPacket transfer across a network
- Allows the emulation of FTP commands between an FTP client and server:
- PORT: specifies the port that server should connect to on the client (currently only uses ``PORT_LOOKUP["FTP"]``)
- STOR: stores a file from client to server
- RETR: retrieves a file from the FTP server
- QUIT: disconnect from server
- Leverages the Service base class for install/uninstall, status tracking, etc.
2024-02-28 15:08:00 +00:00
- :ref:`FTPClient` and ``FTPServer`` utilise port 21 (FTP) throughout all file transfer / request
Usage
2024-02-23 16:49:01 +00:00
=====
- Install on a Node via the ``SoftwareManager`` to start the FTP client service.
- Service runs on FTP (command) port 21 by default
- Execute sending a file to the FTP server with ``send_file``
- Execute retrieving a file from the FTP server with ``request_file``
Implementation
2024-02-23 16:49:01 +00:00
==============
- Leverages ``SoftwareManager`` for sending payloads over the network.
- Provides easy interface for Nodes to transfer files between each other.
- Extends base Service class.
2023-09-26 12:09:41 +01:00
2024-02-23 16:49:01 +00:00
Examples
========
2023-09-26 12:09:41 +01:00
2024-02-23 16:49:01 +00:00
Python
""""""
2023-09-26 12:09:41 +01:00
.. code-block:: python
2024-02-23 16:49:01 +00:00
from primaite.simulator.network.hardware.nodes.host.server import Server
2023-09-26 12:09:41 +01:00
from primaite.simulator.system.services.ftp.ftp_client import FTPClient
2024-02-23 16:49:01 +00:00
# Create Server
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,
}
2023-11-27 11:38:03 +00:00
)
2024-02-23 16:49:01 +00:00
server.power_on()
2023-09-26 12:09:41 +01:00
2024-02-23 16:49:01 +00:00
# Install FTPClient on server
server.software_manager.install(FTPClient)
ftp_client: FTPClient = server.software_manager.software.get("ftp-client")
2024-02-23 16:49:01 +00:00
ftp_client.start()
2023-09-26 12:09:41 +01:00
2023-09-26 15:14:24 +01:00
2024-02-23 16:49:01 +00:00
Via Configuration
"""""""""""""""""
2023-09-26 12:09:41 +01:00
2024-02-23 16:49:01 +00:00
.. code-block:: yaml
2023-09-26 12:09:41 +01:00
2024-02-23 16:49:01 +00:00
simulation:
2025-03-13 11:36:24 +00:00
network:
nodes:
- hostname: example_server
type: server
...
services:
- type: ftp-client
2023-09-26 12:09:41 +01:00
2024-02-23 16:49:01 +00:00
Configuration
=============
2023-09-26 12:09:41 +01:00
``Common Attributes``
^^^^^^^^^^^^^^^^^^^^^
2023-09-26 12:09:41 +01:00
See :ref:`Common Configuration`