implement basic CFDP handler
This commit is contained in:
parent
87c7542015
commit
6f9a866e9c
|
@ -92,9 +92,10 @@ ReturnValue_t CfdpHandler::handleCfdpPacket(TmTcMessage& msg) {
|
||||||
PacketInfo info(type, msg.getStorageId());
|
PacketInfo info(type, msg.getStorageId());
|
||||||
result = destHandler.passPacket(info);
|
result = destHandler.passPacket(info);
|
||||||
} else {
|
} else {
|
||||||
// Route depending on directive type. Retrieve directive type from raw stream for better
|
// Route depending on PDU type and directive type if applicable. It retrieves directive type
|
||||||
// performance (with sanity and directive code check). The routing is based on section 4.5 of
|
// from the raw stream for better performance (with sanity and directive code check).
|
||||||
// the CFDP standard which specifies the PDU forwarding procedure.
|
// The routing is based on section 4.5 of the CFDP standard which specifies the PDU forwarding
|
||||||
|
// procedure.
|
||||||
|
|
||||||
// PDU header only. Invalid supplied data. A directive packet should have a valid data field
|
// PDU header only. Invalid supplied data. A directive packet should have a valid data field
|
||||||
// with at least one byte being the directive code
|
// with at least one byte being the directive code
|
||||||
|
|
|
@ -5,7 +5,8 @@ import time
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
|
|
||||||
from spacepackets.cfdp import ConditionCode, TransmissionModes
|
from spacepackets.cfdp import ConditionCode, TransmissionModes, PduType, DirectiveType
|
||||||
|
from spacepackets.cfdp.pdu import AbstractFileDirectiveBase, PduHolder
|
||||||
from spacepackets.ecss import PusVerificator
|
from spacepackets.ecss import PusVerificator
|
||||||
|
|
||||||
import tmtccmd
|
import tmtccmd
|
||||||
|
@ -80,6 +81,43 @@ class CfdpHandler(CfdpUserBase):
|
||||||
put_request, self.remote_cfg_table.get_remote_entity(self.dest_id)
|
put_request, self.remote_cfg_table.get_remote_entity(self.dest_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def pass_packet(self, packet: AbstractFileDirectiveBase):
|
||||||
|
"""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 whcih specifies the PDU forwarding
|
||||||
|
procedure.
|
||||||
|
"""
|
||||||
|
if packet.pdu_type == PduType.FILE_DATA:
|
||||||
|
self.dest_handler.pass_packet(packet)
|
||||||
|
else:
|
||||||
|
if packet.directive_type in [
|
||||||
|
DirectiveType.METADATA_PDU,
|
||||||
|
DirectiveType.EOF_PDU,
|
||||||
|
DirectiveType.PROMPT_PDU,
|
||||||
|
]:
|
||||||
|
# Section b) of 4.5.3: These PDUs should always be targeted towards the file
|
||||||
|
# receiver a.k.a. the destination handler
|
||||||
|
self.dest_handler.pass_packet(packet)
|
||||||
|
elif packet.directive_type in [
|
||||||
|
DirectiveType.FINISHED_PDU,
|
||||||
|
DirectiveType.NAK_PDU,
|
||||||
|
DirectiveType.KEEP_ALIVE_PDU,
|
||||||
|
]:
|
||||||
|
# Section c) of 4.5.3: These PDUs should always be targeted towards the file sender
|
||||||
|
# a.k.a. the source handler
|
||||||
|
self.source_handler.pass_packet(packet)
|
||||||
|
elif packet.directive_type == DirectiveType.ACK_PDU:
|
||||||
|
# Section a): Recipient depends on the type of PDU that is being acknowledged.
|
||||||
|
# We can simply extract the PDU type from the raw stream. If it is an EOF PDU,
|
||||||
|
# this packet is passed to the source handler. For a finished PDU, it is
|
||||||
|
# passed to the destination handler
|
||||||
|
pdu_holder = PduHolder(packet)
|
||||||
|
ack_pdu = pdu_holder.to_ack_pdu()
|
||||||
|
if ack_pdu.directive_code_of_acked_pdu == DirectiveType.EOF_PDU:
|
||||||
|
self.source_handler.pass_packet(packet)
|
||||||
|
elif ack_pdu.directive_code_of_acked_pdu == DirectiveType.FINISHED_PDU:
|
||||||
|
self.dest_handler.pass_packet(packet)
|
||||||
|
|
||||||
def transaction_indication(self, transaction_id: TransactionId):
|
def transaction_indication(self, transaction_id: TransactionId):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue