PDU processing when crc_flag true

Open
#343 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
c
Domain
networking

Research direction

Start with the CRC declaration and comments in fsw/src/cf_logical_pdu.h around lines 358-365, then inspect FD PDU processing in fsw/src/cf_cfdp.c around lines 726-737. Verify how crc_flag affects data_len and how EOF and FIN decoding reaches CF_CFDP_DecodeAllTlv. Done means CRC-present PDUs are handled consistently without dropping file data or causing decoding errors.

Written by the indexing model from the issue text.

Description

bug

Checklist (Please check before submitting)

  • I reviewed the Contributing Guide.
  • I performed a cursory search to see if the bug report is relevant, not redundant, nor in conflict with other tickets.

Describe the bug
The issue involves a difference in interpretation of the CFDP specification. In particular, the format and processing of CFDP PDUs when the PDU header indicates CRC present.

For FD PDUs, the code ignores 4 bytes instead of 2 bytes for the CRC at the end of the PDU (see context). That will result in ignoring the last 2 bytes of file data from FD PDUs encoded with a CRC.

If an EOF or FIN PDU is received with CRC present, the CRC at the end will (almost always) cause a decoding error in CF_CFDP_DecodeAllTlv called by CF_CFDP_DecodeEof/CF_CFDP_DecodeFin.

To Reproduce
Unknown.
If helpful, I could provide what I believe to be valid CFDP PDUs and show how their processing differs from my expectation.

Expected behavior
The software could refuse PDUs with crc_flag true,
or, preferably, it could decrement the data_len of (all) PDUs with crc_flag true by 2 (bytes).

Code snips
This code has the per PDU CRC declaration:
https://github.com/nasa/CF/blob/281a94188cd7d885a5aed01ee041f3ece2b0486f/fsw/src/cf_logical_pdu.h#L365
The comments on lines 358-363 do not match my understanding.

File data processing excerpt:
https://github.com/nasa/CF/blob/281a94188cd7d885a5aed01ee041f3ece2b0486f/fsw/src/cf_cfdp.c#L726-737

System observed on:
N/A

Additional context

Unfortunately, the CFDP standard 4.1 CRC PROCEDURES has an external reference for the CRC and the reference is wrong:
4.1.3.1 The CRC computation algorithm shall be the standard CCSDS Telecommand CRC
algorithm specified in 4.2.1.3 of the CCSDS Telecommand Recommendation (reference [4]).
and 232.0-B-3 section 4.2.1.3 does not specify a CRC.
However, the only CRC in 232.0-B-3 is defined in 4.1.4 Frame Error Control Word as a 2 octet field.

Reporter Info
Bob Wiegand, NASA/GSFC

Dominant language
C
Stars
123
Forks
82
Avg merge
2d 22h
Merged PRs (30d)
2

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nasa/CF

All issues in nasa/CF

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.