CFDP Package
Module contents
Please note that this module does not contain configuration helpers, for example
to convert CLI or GUI parameters into the internalized CFDP classes. You can find all those
helpers inside the tmtccmd.config.cfdp module.
- class cfdppy.CfdpIndication(value)
Bases:
EnumAn enumeration.
- ABANDONED = 9
- EOF = 1
- EOF_RECV = 10
- FAULT = 8
- FILE_SEGMENT_RECV = 4
- FINISHED = 2
- METADATA = 3
- REPORT = 5
- RESUMED = 7
- SUSPENDED = 6
- TRANSACTION = 0
- class cfdppy.CfdpState(value)
Bases:
EnumAn enumeration.
- BUSY = 1
- IDLE = 0
- SUSPENDED = 2
- class cfdppy.CfdpUserBase(vfs: VirtualFilestore | None = None)
Bases:
ABCThis user base class provides the primary user interface to interact with CFDP handlers. It is also used to pass the Virtual Filestore (VFS) implementation to the CFDP handlers so the filestore operations can be mapped to the underlying filestore.
This class is used by implementing it in a child class and then passing it to the CFDP handler objects. The base class provides default implementation for the user indication primitives specified in the CFDP standard. The user can override these implementations to provide custom indication handlers.
- abstract abandoned_indication(transaction_id: TransactionId, cond_code: ConditionCode, progress: int) None
This is the
Fault.Indicationas specified in chapter 3.4.15 of the standard.The user implementation of this function could be used to keep a (failed) transaction history, which might be useful for the positive ACK procedures expected from a receiving CFDP entity.
- abstract eof_recv_indication(transaction_id: TransactionId) None
- abstract eof_sent_indication(transaction_id: TransactionId) None
- abstract fault_indication(transaction_id: TransactionId, cond_code: ConditionCode, progress: int) None
This is the
Fault.Indicationas specified in chapter 3.4.14 of the standard.The user implementation of this function could be used to keep a (failed) transaction history, which might be useful for the positive ACK procedures expected from a receiving CFDP entity.
- abstract file_segment_recv_indication(params: FileSegmentRecvdParams) None
- abstract metadata_recv_indication(params: MetadataRecvParams) None
- abstract report_indication(transaction_id: TransactionId, status_report: Any) None
- abstract suspended_indication(transaction_id: TransactionId, cond_code: ConditionCode) None
- abstract transaction_finished_indication(params: TransactionFinishedParams) None
This is the
Transaction-Finished.Indicationas specified in chapter 3.4.8 of the standard.The user implementation of this function could be used to keep a (failed) transaction history, which might be useful for the positive ACK procedures expected from a receiving CFDP entity.
- abstract transaction_indication(transaction_indication_params: TransactionParams) None
This indication is used to report the transaction ID to the CFDP user
- cfdppy.HostFilestore
alias of
NativeFilestore
- class cfdppy.IndicationConfig(eof_sent_indication_required: 'bool' = True, eof_recv_indication_required: 'bool' = True, file_segment_recvd_indication_required: 'bool' = True, transaction_finished_indication_required: 'bool' = True, suspended_indication_required: 'bool' = True, resumed_indication_required: 'bool' = True)
Bases:
object- eof_recv_indication_required: bool = True
- eof_sent_indication_required: bool = True
- file_segment_recvd_indication_required: bool = True
- resumed_indication_required: bool = True
- suspended_indication_required: bool = True
- transaction_finished_indication_required: bool = True
- class cfdppy.LocalEntityConfig(local_entity_id: UnsignedByteField, indication_cfg: IndicationConfig, default_fault_handlers: DefaultFaultHandlerBase)
Bases:
objectThis models the remote entity configuration information as specified in chapter 8.2 of the CFDP standard.
- default_fault_handlers: DefaultFaultHandlerBase
- indication_cfg: IndicationConfig
- local_entity_id: UnsignedByteField
- class cfdppy.PacketDestination(value)
Bases:
EnumAn enumeration.
- DEST_HANDLER = 1
- SOURCE_HANDLER = 0
- class cfdppy.PutRequest(destination_id: UnsignedByteField, source_file: Path | None, dest_file: Path | None, trans_mode: TransmissionMode | None, closure_requested: bool | None, seg_ctrl: SegmentationControl | None = SegmentationControl.NO_RECORD_BOUNDARIES_PRESERVATION, fault_handler_overrides: list[FaultHandlerOverrideTlv] | None = None, flow_label_tlv: FlowLabelTlv | None = None, msgs_to_user: list[MessageToUserTlv] | None = None, fs_requests: list[FileStoreRequestTlv] | None = None)
Bases:
objectThis is the base class modelling the CFDP put request.
You can create this class from the simplified
tmtccmd.config.defs.CfdpParamsclass with the generictmtccmd.config.cfdp.generic_cfdp_params_to_put_request()API and/or all related specific APIs.- dest_file: Path | None
- destination_id: UnsignedByteField
- flow_label_tlv: FlowLabelTlv | None = None
- property metadata_only: bool
- seg_ctrl: SegmentationControl | None = 0
- source_file: Path | None
- trans_mode: TransmissionMode | None
- class cfdppy.RemoteEntityConfig(entity_id: UnsignedByteField, max_file_segment_len: int | None, max_packet_len: int, closure_requested: bool, crc_on_transmission: bool, default_transmission_mode: TransmissionMode, crc_type: ChecksumType, positive_ack_timer_interval_seconds: float = 10.0, positive_ack_timer_expiration_limit: int = 2, check_limit: int = 2, disposition_on_cancellation: bool = False, immediate_nak_mode: bool = True, nak_timer_interval_seconds: float = 10.0, nak_timer_expiration_limit: int = 2, cfdp_version: int = 1)
Bases:
objectThis models the remote entity configuration information as specified in chapter 8.3 of the CFDP standard.
Some of the fields which were not considered necessary for the Python implementation were omitted. Some other fields which are not contained inside the standard but are considered necessary for the Python implementation are included.
Notes on Positive Acknowledgment Procedures
The
positive_ack_timer_interval_secondsandpositive_ack_timer_expiration_limitwill be used for positive acknowledgment procedures as specified in CFDP chapter 4.7. The sending entity will start the timer for any PDUs where an acknowledgment is required (e.g. EOF PDU). Once the expected ACK response has not been received for that interval, as counter will be incremented and the timer will be reset. Once the counter exceeds thepositive_ack_timer_expiration_limit, a Positive ACK Limit Reached fault will be declared.Notes on Deferred Lost Segment Procedures
This procedure will be active if an EOF (No Error) PDU is received in acknowledged mode. After issuing the NAK sequence which has the whole file scope, a timer will be started. The timer is reset when missing segments or missing metadata is received. The timer will be deactivated if all missing data is received. If the timer expires, a new NAK sequence will be issued and a counter will be incremented, which can lead to a NAK Limit Reached fault being declared.
- Parameters:
entity_id (UnsignedByteField) – The ID of the remote entity.
max_packet_len (int) – This determines of all PDUs generated for that remote entity in addition to the max_file_segment_len attribute which also determines the size of file data PDUs.
max_file_segment_len (int | None) – The maximum file segment length which determines the maximum size of file data PDUs in addition to the max_packet_len attribute. If this field is set to None, the maximum file segment length will be derived from the maximum packet length. If this has some value which is smaller than the segment value derived from max_packet_len, this value will be picked.
closure_requested (bool) – If the closure requested field is not supplied as part of the Put Request, it will be determined from this field in the remote configuration.
crc_on_transmission (bool) – If the CRC option is not supplied as part of the Put Request, it will be determined from this field in the remote configuration.
default_transmission_mode (TransmissionMode) – If the transmission mode is not supplied as part of the Put Request, it will be determined from this field in the remote configuration.
disposition_on_cancellation (bool) – Determines whether an incomplete received file is discard on transaction cancellation. Defaults to False.
crc_type (ChecksumType) – Default checksum type used to calculate for all file transmissions to this remote entity.
check_limit (int) – this timer determines the expiry period for incrementing a check counter after an EOF PDU is received for an incomplete file transfer. This allows out-of-order reception of file data PDUs and EOF PDUs. Also see 4.6.3.3 of the CFDP standard. Defaults to 2, so the check limit timer may expire twice.
positive_ack_timer_interval_seconds (float) – See the notes on the Positive Acknowledgment Procedures inside the class documentation. Expected as floating point seconds. Defaults to 10 seconds.
positive_ack_timer_expiration_limit (int) – See the notes on the Positive Acknowledgment Procedures inside the class documentation. Defaults to 2, so the timer may expire twice.
immediate_nak_mode (bool) – Specifies whether a NAK sequence should be issued immediately when a file data gap or lost metadata is detected in the acknowledged mode. Defaults to True.
nak_timer_interval_seconds (float) – See the notes on the Deferred Lost Segment Procedure inside the class documentation. Expected as floating point seconds. Defaults to 10 seconds.
nak_timer_expiration_limit (int) – See the notes on the Deferred Lost Segment Procedure inside the class documentation. Defaults to 2, so the timer may expire two times.
- cfdp_version: int = 1
- check_limit: int = 2
- closure_requested: bool
- crc_on_transmission: bool
- crc_type: ChecksumType
- default_transmission_mode: TransmissionMode
- disposition_on_cancellation: bool = False
- entity_id: UnsignedByteField
- immediate_nak_mode: bool = True
- max_packet_len: int
- nak_timer_expiration_limit: int = 2
- nak_timer_interval_seconds: float = 10.0
- positive_ack_timer_expiration_limit: int = 2
- positive_ack_timer_interval_seconds: float = 10.0
- class cfdppy.RemoteEntityConfigTable(init_cfgs: Sequence[RemoteEntityConfig] | None = None)
Bases:
objectThin abstraction for a dictionary containing remote configurations with the remote entity ID being used as a key.
- add_config(cfg: RemoteEntityConfig) bool
- add_configs(cfgs: Sequence[RemoteEntityConfig]) None
- get_cfg(remote_entity_id: UnsignedByteField) RemoteEntityConfig | None
- class cfdppy.RestrictedFilestore(restricted_path: Path)
Bases:
NativeFilestoreWrapper to restrict filestore access to a specific directory.
- calculate_checksum(checksum_type: ChecksumType, file_path: Path, size_to_verify: int, segment_len: int = 4096) bytes
Calculate checksum of file.
- Parameters:
checksum_type – Type of checksum
file_path – Path to file
size_to_verify – Size to check in bytes
segment_len – Length of segments to calculate checksum for
- Returns:
checksum as bytes
- create_directory(_dir_name: Path) FilestoreResponseStatusCode
Create directory.
- create_file(file: Path) FilestoreResponseStatusCode
Create file.
- delete_file(file: Path) FilestoreResponseStatusCode
Delete file.
- file_exists(path: Path) bool
Check if file exists.
- file_size(file: Path) int
Get file size.
- is_directory(path: Path) bool
Check if path is a directory.
- list_directory(_dir_name: Path, _file_name: Path, _recursive: bool = False) FilestoreResponseStatusCode
List directory contents.
- remove_directory(dir_name: Path, recursive: bool = False) FilestoreResponseStatusCode
Remove directory.
- rename_file(_old_file: Path, _new_file: Path) FilestoreResponseStatusCode
Rename file.
- replace_file(_replaced_file: Path, _source_file: Path) FilestoreResponseStatusCode
Replace file.
- truncate_file(file: Path) None
Truncate file.
- class cfdppy.TransactionId(source_entity_id: UnsignedByteField, transaction_seq_num: UnsignedByteField)
Bases:
object
- class cfdppy.VirtualFilestore
Bases:
ABCInterface for a virtual filestore implementation.
- abstract calculate_checksum(checksum_type: ChecksumType, file_path: Path, size_to_verify: int, segment_len: int = 4096) bytes
Calculate the checksum for a given file.
- Raises:
ValueError – Invalid input parameters
FileNotFoundError – File for checksum calculation does not exist
- abstract create_directory(_dir_name: Path) FilestoreResponseStatusCode
- abstract create_file(file: Path) FilestoreResponseStatusCode
- abstract delete_file(file: Path) FilestoreResponseStatusCode
- abstract file_exists(path: Path) bool
Check if a file exists at the given path.
- Parameters:
path – Path to check
- Returns:
True if the file exists
- abstract file_size(file: Path) int
Get the size of a file.
- Parameters:
file – File to get the size of as number of bytes
- Returns:
Size of the file in bytes
- Raises:
FileNotFoundError – In case the file does not exist
- abstract filename_from_full_path(path: Path) str | None
Get the filename from a full path.
- Parameters:
path – Full path
- Returns:
Filename
- abstract is_directory(path: Path) bool
Check if a given path is a directory.
- Parameters:
path – Path to check
- Returns:
True if the path is a directory
- abstract list_directory(_dir_name: Path, _file_name: Path, _recursive: bool = False) FilestoreResponseStatusCode
- abstract read_data(file: Path, offset: int | None, read_len: int) bytes
Read data from a provided Path at a specific offset.
This is not used as part of a filestore request. It is used to read a file, for example to send it.
- Parameters:
file – File to read
offset – Offset to read from
read_len – Number of bytes to read
- Returns:
The read data
- Raises:
PermissionError – In case the file is not readable
FileNotFoundError – In case the file does not exist.
- abstract read_from_opened_file(bytes_io: BinaryIO, offset: int, read_len: int) bytes
Read data from an already opened file object.
- Parameters:
bytes_io – File object
offset – Offset to read from
read_len – Number of bytes to read
- Returns:
The read data
- abstract remove_directory(_dir_name: Path, recursive: bool) FilestoreResponseStatusCode
- abstract rename_file(_old_file: Path, _new_file: Path) FilestoreResponseStatusCode
- abstract replace_file(_replaced_file: Path, _source_file: Path) FilestoreResponseStatusCode
- abstract truncate_file(file: Path) None
Truncate a file to zero bytes.
- Parameters:
file – File to truncate
- Raises:
FileNotFoundError – In case the file does not exist
- verify_checksum(checksum: bytes, checksum_type: ChecksumType, file_path: Path, size_to_verify: int, segment_len: int = 4096) bool
- abstract write_data(file: Path, data: bytes, offset: int | None) None
This is not used as part of a filestore request, it is used to build up the received file.
The file needs to exist before writing to it.
- Parameters:
file – File to write to
data – Data to write
offset – Offset to write, may be None for no offset
- Raises:
PermissionError – In case the file is not writable
FileNotFoundError – In case the file does not exist
- cfdppy.get_packet_destination(packet: AbstractFileDirectiveBase | AbstractPduBase) PacketDestination
This function routes the packets based on PDU type and directive type if applicable.
The routing is based on section 4.5 of the CFDP standard which specifies the PDU forwarding procedure.
NOTE: The standard also specifies a direction flag, which could be used for that purpose as well. However, I prefer the approach here to explicitly check the PDU types and event the ACK PDU content. I think this is more reliable than relying on that bit.
Filestore Module
Contains the Filestore Interface and a Native Filestore implementation.
- cfdppy.filestore.HostFilestore
alias of
NativeFilestore
- class cfdppy.filestore.NativeFilestore
Bases:
VirtualFilestore- calculate_checksum(checksum_type: ChecksumType, file_path: Path, size_to_verify: int, segment_len: int = 4096) bytes
Calculate the checksum for a given file.
- Raises:
ValueError – Invalid input parameters
FileNotFoundError – File for checksum calculation does not exist
- checksum_type_to_crcmod_str(checksum_type: ChecksumType) str | None
- create_directory(dir_name: Path) FilestoreResponseStatusCode
- create_file(file: Path) FilestoreResponseStatusCode
Returns CREATE_NOT_ALLOWED if the file already exists
- delete_file(file: Path) FilestoreResponseStatusCode
- file_exists(path: Path) bool
Check if a file exists at the given path.
- Parameters:
path – Path to check
- Returns:
True if the file exists
- file_size(file: Path) int
Get the size of a file.
- Parameters:
file – File to get the size of as number of bytes
- Returns:
Size of the file in bytes
- Raises:
FileNotFoundError – In case the file does not exist
- filename_from_full_path(path: Path) str | None
Get the filename from a full path.
- Parameters:
path – Full path
- Returns:
Filename
- is_directory(path: Path) bool
Check if a given path is a directory.
- Parameters:
path – Path to check
- Returns:
True if the path is a directory
- list_directory(dir_name: Path, target_file: Path, recursive: bool = False) FilestoreResponseStatusCode
List a directory
- Parameters:
dir_name – Name of directory to list
target_file – The list will be written into this target file
recursive
- Returns:
- read_data(file: Path, offset: int | None, read_len: int | None = None) bytes
Read data from a provided Path at a specific offset.
This is not used as part of a filestore request. It is used to read a file, for example to send it.
- Parameters:
file – File to read
offset – Offset to read from
read_len – Number of bytes to read
- Returns:
The read data
- Raises:
PermissionError – In case the file is not readable
FileNotFoundError – In case the file does not exist.
- read_from_opened_file(bytes_io: BinaryIO, offset: int, read_len: int) bytes
Read data from an already opened file object.
- Parameters:
bytes_io – File object
offset – Offset to read from
read_len – Number of bytes to read
- Returns:
The read data
- rename_file(old_file: Path, new_file: Path) FilestoreResponseStatusCode
- replace_file(replaced_file: Path, source_file: Path) FilestoreResponseStatusCode
- truncate_file(file: Path) None
Truncate a file to zero bytes.
- Parameters:
file – File to truncate
- Raises:
FileNotFoundError – In case the file does not exist
- class cfdppy.filestore.VirtualFilestore
Bases:
ABCInterface for a virtual filestore implementation.
- abstract calculate_checksum(checksum_type: ChecksumType, file_path: Path, size_to_verify: int, segment_len: int = 4096) bytes
Calculate the checksum for a given file.
- Raises:
ValueError – Invalid input parameters
FileNotFoundError – File for checksum calculation does not exist
- abstract create_directory(_dir_name: Path) FilestoreResponseStatusCode
- abstract create_file(file: Path) FilestoreResponseStatusCode
- abstract delete_file(file: Path) FilestoreResponseStatusCode
- abstract file_exists(path: Path) bool
Check if a file exists at the given path.
- Parameters:
path – Path to check
- Returns:
True if the file exists
- abstract file_size(file: Path) int
Get the size of a file.
- Parameters:
file – File to get the size of as number of bytes
- Returns:
Size of the file in bytes
- Raises:
FileNotFoundError – In case the file does not exist
- abstract filename_from_full_path(path: Path) str | None
Get the filename from a full path.
- Parameters:
path – Full path
- Returns:
Filename
- abstract is_directory(path: Path) bool
Check if a given path is a directory.
- Parameters:
path – Path to check
- Returns:
True if the path is a directory
- abstract list_directory(_dir_name: Path, _file_name: Path, _recursive: bool = False) FilestoreResponseStatusCode
- abstract read_data(file: Path, offset: int | None, read_len: int) bytes
Read data from a provided Path at a specific offset.
This is not used as part of a filestore request. It is used to read a file, for example to send it.
- Parameters:
file – File to read
offset – Offset to read from
read_len – Number of bytes to read
- Returns:
The read data
- Raises:
PermissionError – In case the file is not readable
FileNotFoundError – In case the file does not exist.
- abstract read_from_opened_file(bytes_io: BinaryIO, offset: int, read_len: int) bytes
Read data from an already opened file object.
- Parameters:
bytes_io – File object
offset – Offset to read from
read_len – Number of bytes to read
- Returns:
The read data
- abstract rename_file(_old_file: Path, _new_file: Path) FilestoreResponseStatusCode
- abstract replace_file(_replaced_file: Path, _source_file: Path) FilestoreResponseStatusCode
- abstract truncate_file(file: Path) None
Truncate a file to zero bytes.
- Parameters:
file – File to truncate
- Raises:
FileNotFoundError – In case the file does not exist
- verify_checksum(checksum: bytes, checksum_type: ChecksumType, file_path: Path, size_to_verify: int, segment_len: int = 4096) bool
- abstract write_data(file: Path, data: bytes, offset: int | None) None
This is not used as part of a filestore request, it is used to build up the received file.
The file needs to exist before writing to it.
- Parameters:
file – File to write to
data – Data to write
offset – Offset to write, may be None for no offset
- Raises:
PermissionError – In case the file is not writable
FileNotFoundError – In case the file does not exist
Management Information Base (MIB) Module
- class cfdppy.mib.CheckTimerProvider
Bases:
ABC- abstract provide_check_timer(local_entity_id: UnsignedByteField, remote_entity_id: UnsignedByteField, entity_type: EntityType) Countdown
- class cfdppy.mib.DefaultFaultHandlerBase
Bases:
ABCThis base class provides a way to implement the fault handling procedures as specified in chapter 4.8 of the CFDP standard.
It is passed into the CFDP handlers as part of the local entity configuration and provides a way to specify custom user error handlers.
It does so by mapping each applicable CFDP
ConditionCodeto a fault handler which is denoted by the fourspacepackets.cfdp.defs.FaultHandlerCodes. This code is used to dispatch to a user-provided callback function:IGNORE_ERROR->ignore_cb()NOTICE_OF_CANCELLATION->notice_of_cancellation_cb()NOTICE_OF_SUSPENSION->notice_of_suspension_cb()ABANDON_TRANSACTION->abandon_transaction_cb()
For each error reported by
report_fault(), the appropriate fault handler callback will be called. The user provides the callbacks by providing a custom class which implements this base class and all abstract fault handler callbacks. This allows logging of the errors as specified in chapter 4.8.3.Some note on the provided default settings:
Checksum failures will be ignored by default. This is because for unacknowledged transfers, cancelling the transfer immediately would interfere with the check limit mechanism specified in chapter 4.6.3.3.
Unsupported checksum types will also be ignored by default. Even if the checksum type is not supported the file transfer might still have worked properly.
- abstract abandoned_cb(transaction_id: TransactionId, cond: ConditionCode, progress: int) None
- get_fault_handler(condition: ConditionCode) FaultHandlerCode
- abstract ignore_cb(transaction_id: TransactionId, cond: ConditionCode, progress: int) None
- abstract notice_of_cancellation_cb(transaction_id: TransactionId, cond: ConditionCode, progress: int) None
- abstract notice_of_suspension_cb(transaction_id: TransactionId, cond: ConditionCode, progress: int) None
- report_fault(transaction_id: TransactionId, condition: ConditionCode, progress: int) None
- Raises:
ValueError – Invalid condition code which is not applicable for fault handling procedures.
- set_handler(condition: ConditionCode, handler: FaultHandlerCode) None
- Raises:
ValueError – Invalid condition code which is not applicable for fault handling procedures.
- class cfdppy.mib.IndicationConfig(eof_sent_indication_required: 'bool' = True, eof_recv_indication_required: 'bool' = True, file_segment_recvd_indication_required: 'bool' = True, transaction_finished_indication_required: 'bool' = True, suspended_indication_required: 'bool' = True, resumed_indication_required: 'bool' = True)
Bases:
object
- class cfdppy.mib.LocalEntityConfig(local_entity_id: UnsignedByteField, indication_cfg: IndicationConfig, default_fault_handlers: DefaultFaultHandlerBase)
Bases:
objectThis models the remote entity configuration information as specified in chapter 8.2 of the CFDP standard.
- default_fault_handlers: DefaultFaultHandlerBase
- indication_cfg: IndicationConfig
- local_entity_id: UnsignedByteField
- class cfdppy.mib.RemoteEntityConfig(entity_id: UnsignedByteField, max_file_segment_len: int | None, max_packet_len: int, closure_requested: bool, crc_on_transmission: bool, default_transmission_mode: TransmissionMode, crc_type: ChecksumType, positive_ack_timer_interval_seconds: float = 10.0, positive_ack_timer_expiration_limit: int = 2, check_limit: int = 2, disposition_on_cancellation: bool = False, immediate_nak_mode: bool = True, nak_timer_interval_seconds: float = 10.0, nak_timer_expiration_limit: int = 2, cfdp_version: int = 1)
Bases:
objectThis models the remote entity configuration information as specified in chapter 8.3 of the CFDP standard.
Some of the fields which were not considered necessary for the Python implementation were omitted. Some other fields which are not contained inside the standard but are considered necessary for the Python implementation are included.
Notes on Positive Acknowledgment Procedures
The
positive_ack_timer_interval_secondsandpositive_ack_timer_expiration_limitwill be used for positive acknowledgment procedures as specified in CFDP chapter 4.7. The sending entity will start the timer for any PDUs where an acknowledgment is required (e.g. EOF PDU). Once the expected ACK response has not been received for that interval, as counter will be incremented and the timer will be reset. Once the counter exceeds thepositive_ack_timer_expiration_limit, a Positive ACK Limit Reached fault will be declared.Notes on Deferred Lost Segment Procedures
This procedure will be active if an EOF (No Error) PDU is received in acknowledged mode. After issuing the NAK sequence which has the whole file scope, a timer will be started. The timer is reset when missing segments or missing metadata is received. The timer will be deactivated if all missing data is received. If the timer expires, a new NAK sequence will be issued and a counter will be incremented, which can lead to a NAK Limit Reached fault being declared.
- Parameters:
entity_id (UnsignedByteField) – The ID of the remote entity.
max_packet_len (int) – This determines of all PDUs generated for that remote entity in addition to the max_file_segment_len attribute which also determines the size of file data PDUs.
max_file_segment_len (int | None) – The maximum file segment length which determines the maximum size of file data PDUs in addition to the max_packet_len attribute. If this field is set to None, the maximum file segment length will be derived from the maximum packet length. If this has some value which is smaller than the segment value derived from max_packet_len, this value will be picked.
closure_requested (bool) – If the closure requested field is not supplied as part of the Put Request, it will be determined from this field in the remote configuration.
crc_on_transmission (bool) – If the CRC option is not supplied as part of the Put Request, it will be determined from this field in the remote configuration.
default_transmission_mode (TransmissionMode) – If the transmission mode is not supplied as part of the Put Request, it will be determined from this field in the remote configuration.
disposition_on_cancellation (bool) – Determines whether an incomplete received file is discard on transaction cancellation. Defaults to False.
crc_type (ChecksumType) – Default checksum type used to calculate for all file transmissions to this remote entity.
check_limit (int) – this timer determines the expiry period for incrementing a check counter after an EOF PDU is received for an incomplete file transfer. This allows out-of-order reception of file data PDUs and EOF PDUs. Also see 4.6.3.3 of the CFDP standard. Defaults to 2, so the check limit timer may expire twice.
positive_ack_timer_interval_seconds (float) – See the notes on the Positive Acknowledgment Procedures inside the class documentation. Expected as floating point seconds. Defaults to 10 seconds.
positive_ack_timer_expiration_limit (int) – See the notes on the Positive Acknowledgment Procedures inside the class documentation. Defaults to 2, so the timer may expire twice.
immediate_nak_mode (bool) – Specifies whether a NAK sequence should be issued immediately when a file data gap or lost metadata is detected in the acknowledged mode. Defaults to True.
nak_timer_interval_seconds (float) – See the notes on the Deferred Lost Segment Procedure inside the class documentation. Expected as floating point seconds. Defaults to 10 seconds.
nak_timer_expiration_limit (int) – See the notes on the Deferred Lost Segment Procedure inside the class documentation. Defaults to 2, so the timer may expire two times.
- crc_type: ChecksumType
- default_transmission_mode: TransmissionMode
- entity_id: UnsignedByteField
- class cfdppy.mib.RemoteEntityConfigTable(init_cfgs: Sequence[RemoteEntityConfig] | None = None)
Bases:
objectThin abstraction for a dictionary containing remote configurations with the remote entity ID being used as a key.
- add_config(cfg: RemoteEntityConfig) bool
- add_configs(cfgs: Sequence[RemoteEntityConfig]) None
- get_cfg(remote_entity_id: UnsignedByteField) RemoteEntityConfig | None
Request Module
- class cfdppy.request.PutRequest(destination_id: UnsignedByteField, source_file: Path | None, dest_file: Path | None, trans_mode: TransmissionMode | None, closure_requested: bool | None, seg_ctrl: SegmentationControl | None = SegmentationControl.NO_RECORD_BOUNDARIES_PRESERVATION, fault_handler_overrides: list[FaultHandlerOverrideTlv] | None = None, flow_label_tlv: FlowLabelTlv | None = None, msgs_to_user: list[MessageToUserTlv] | None = None, fs_requests: list[FileStoreRequestTlv] | None = None)
Bases:
objectThis is the base class modelling the CFDP put request.
You can create this class from the simplified
tmtccmd.config.defs.CfdpParamsclass with the generictmtccmd.config.cfdp.generic_cfdp_params_to_put_request()API and/or all related specific APIs.- destination_id: UnsignedByteField
User Module
- class cfdppy.user.CfdpUserBase(vfs: VirtualFilestore | None = None)
Bases:
ABCThis user base class provides the primary user interface to interact with CFDP handlers. It is also used to pass the Virtual Filestore (VFS) implementation to the CFDP handlers so the filestore operations can be mapped to the underlying filestore.
This class is used by implementing it in a child class and then passing it to the CFDP handler objects. The base class provides default implementation for the user indication primitives specified in the CFDP standard. The user can override these implementations to provide custom indication handlers.
- abstract abandoned_indication(transaction_id: TransactionId, cond_code: ConditionCode, progress: int) None
This is the
Fault.Indicationas specified in chapter 3.4.15 of the standard.The user implementation of this function could be used to keep a (failed) transaction history, which might be useful for the positive ACK procedures expected from a receiving CFDP entity.
- abstract fault_indication(transaction_id: TransactionId, cond_code: ConditionCode, progress: int) None
This is the
Fault.Indicationas specified in chapter 3.4.14 of the standard.The user implementation of this function could be used to keep a (failed) transaction history, which might be useful for the positive ACK procedures expected from a receiving CFDP entity.
- abstract file_segment_recv_indication(params: FileSegmentRecvdParams) None
- abstract metadata_recv_indication(params: MetadataRecvParams) None
- abstract transaction_finished_indication(params: TransactionFinishedParams) None
This is the
Transaction-Finished.Indicationas specified in chapter 3.4.8 of the standard.The user implementation of this function could be used to keep a (failed) transaction history, which might be useful for the positive ACK procedures expected from a receiving CFDP entity.
- abstract transaction_indication(transaction_indication_params: TransactionParams) None
This indication is used to report the transaction ID to the CFDP user
- class cfdppy.user.FileSegmentRecvdParams(transaction_id: TransactionId, offset: int, length: int, segment_metadata: SegmentMetadata | None)
Bases:
objectThe length of the segment metadata is not supplied as an extra parameter as it can be simply queried with len(segment_metadata)
- transaction_id: TransactionId
- class cfdppy.user.MetadataRecvParams(transaction_id: 'TransactionId', source_id: 'UnsignedByteField', file_size: 'int | None', source_file_name: 'str | None', dest_file_name: 'str | None', msgs_to_user: 'list[MessageToUserTlv] | None' = None)
Bases:
object- source_id: UnsignedByteField
- transaction_id: TransactionId
- class cfdppy.user.TransactionFinishedParams(transaction_id: 'TransactionId', finished_params: 'FinishedParams', status_report: 'Any | None' = None)
Bases:
object- finished_params: FinishedParams
- transaction_id: TransactionId
- class cfdppy.user.TransactionParams(transaction_id: TransactionId, originating_transaction_id: TransactionId | None = None)
Bases:
objectNot wholly standard conformant here, but supplying the originating transaction ID makes the implementation of handling with proxy put requests easier.
- transaction_id: TransactionId
Exceptions Module
- exception cfdppy.exceptions.ChecksumNotImplemented(checksum_type: ChecksumType)
Bases:
Exception
- exception cfdppy.exceptions.InvalidDestinationId(expected_dest_id: UnsignedByteField, found_dest_id: UnsignedByteField)
Bases:
ExceptionInvalid destination entity ID. This is not necessarily the receiver of a packet but actually the recipient of a file, or the entity receiving file data and metadata PDUs
- exception cfdppy.exceptions.InvalidPduDirection(expected_dir: Direction, found_dir: Direction)
Bases:
Exception
- exception cfdppy.exceptions.InvalidPduForDestHandler(packet: AbstractFileDirectiveBase | AbstractPduBase)
Bases:
Exception
- exception cfdppy.exceptions.InvalidPduForSourceHandler(packet: AbstractFileDirectiveBase)
Bases:
Exception
- exception cfdppy.exceptions.InvalidSourceId(expected_src_id: UnsignedByteField, found_src_id: UnsignedByteField)
Bases:
ExceptionInvalid source entity ID. This is not necessarily the sender of a packet but actually the entity that started a transaction, or the entity which is transferring a file
- exception cfdppy.exceptions.InvalidTransactionSeqNum(expected: UnsignedByteField, received: UnsignedByteField)
Bases:
Exception
- exception cfdppy.exceptions.NoRemoteEntityConfigFound(entity_id: UnsignedByteField)
Bases:
Exception
- exception cfdppy.exceptions.PduIgnoredForDest(reason: PduIgnoredForDestReason, ignored_packet: AbstractFileDirectiveBase | AbstractPduBase)
Bases:
Exception
- class cfdppy.exceptions.PduIgnoredForDestReason(value)
Bases:
IntEnumAn enumeration.
- FIRST_PACKET_IN_ACKED_MODE_NOT_METADATA_NOT_EOF_NOT_FD = 2
For the acknowledged mode, the first packet that was received with no metadata received previously was not a File Data PDU or EOF PDU.
- FIRST_PACKET_NOT_METADATA_PDU = 0
First packet received was not a metadata PDU for the unacknowledged mode.
- INVALID_MODE_FOR_ACKED_MODE_PACKET = 1
The received PDU can only be handled in acknowledged mode.
- exception cfdppy.exceptions.PduIgnoredForSource(reason: PduIgnoredForSourceReason, ignored_packet: AbstractFileDirectiveBase)
Bases:
Exception
CRC Module
Definitions Module
- class cfdppy.defs.CfdpIndication(value)
Bases:
EnumAn enumeration.
- ABANDONED = 9
- EOF = 1
- EOF_RECV = 10
- FAULT = 8
- FILE_SEGMENT_RECV = 4
- FINISHED = 2
- METADATA = 3
- REPORT = 5
- RESUMED = 7
- SUSPENDED = 6
- TRANSACTION = 0