Add BPv7 and TCPCL layers
This PR adds two new layers to scapy/contrib, implementing the PDUs for the following Delay Tolerant Networking (DTN) protocols: TCP Convergence Layer version 4 (RFC 9174) and Bundle Protocol version 7 (RFC 9171) with support for BPSec (RFC 9172). These protocols are fundamental to the DTN suite and included in nearly all implementations of DTN, which is widely used by NASA, ESA, etc. for experimental purposes and research on internetworking in space communications.
Unit tests are currently not included in this PR but the code has been unit tested in NASA's dtn-test-framework repository, which depends on these two layers and is used internally at NASA for formal software requirements verification. If required by the maintainers, I am willing to modify and import these unit tests into Scapy.
The implementation of these layers depends on two Python libraries: crcmod for computing checksums and flynn for decoding CBOR. I added some lines to the pyproject.toml to provide these as optional dependencies. The layers are implemented in the scapy.contrib.dtn directory and are otherwise self-contained. Please let me know if these optional dependencies or methods of organizing the code are not acceptable to the maintainers...
Hi there, thanks for your interest in Scapy !
Two quick things before I start a deeper review :
- For very specific use cases, we typically only use runtime dependencies (that prompt an error when trying to import the layer), rather than adding them to pyproject.toml
- Having a layer with no unit tests for a very specific protocol basically dooms it to breaking one day. While I understand that it really isn't fun to write them, we impose at least a few unit tests for new layers (dissecting a few packets, building a few packets and checking that the output is the same, etc.).
Also do not hesitate to run black on your files.
Codecov Report
:x: Patch coverage is 76.78832% with 159 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 80.87%. Comparing base (449142a) to head (4812c62).
:warning: Report is 36 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #4824 +/- ##
==========================================
- Coverage 80.91% 80.87% -0.04%
==========================================
Files 366 371 +5
Lines 90130 90815 +685
==========================================
+ Hits 72927 73451 +524
- Misses 17203 17364 +161
| Files with missing lines | Coverage Δ | |
|---|---|---|
| scapy/contrib/dtn/common.py | 95.00% <95.00%> (ø) |
|
| scapy/contrib/dtn/tcpcl_session.py | 95.71% <95.71%> (ø) |
|
| scapy/contrib/dtn/tcpcl.py | 95.91% <95.91%> (ø) |
|
| scapy/contrib/dtn/cbor.py | 71.08% <71.08%> (ø) |
|
| scapy/contrib/dtn/bpv7.py | 68.88% <68.88%> (ø) |
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
I removed the extra lines from pyproject.toml so it will just raise an import error e.g. if you evaluate import scapy.contrib.dtn.bpv7 when flynn or crcmod is not available.
I am reading the UTScapy documentation and will update the PR with unit tests when I figure everything out...
Btw you can add dependencies for the tests over here https://github.com/secdev/scapy/blob/449142a524ef2d24aecf390903aae47888073f2f/tox.ini#L35 !
I added unit tests. I believe the runtime dependency import errors should be fixed now for the CI checks, and also the formatting / code quality checks and SPDX checks.
~~One unit test is failing on Windows. Not sure why... appears to be a module unrelated to my PR.~~ Fixed in latest run