Commit graph

238 commits

Author SHA1 Message Date
Felix Walter
42d312d958 Merge branch '15-207-improve-contact-plan-handling-in-bdm' into 'master'
Improve contact plan handling in DFCF BDM and tools

Closes #207, #15, and #238

See merge request d3tn/ud3tn!199
2025-06-06 10:11:05 +02:00
Felix Walter
20eff9058b test/integration: Pin same version of jsonschema as in utils
Otherwise, we may get dependency conflicts, depending on the order in
which we install the modules and requirements file with pip.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-06 09:46:32 +02:00
Felix Walter
578b02a528 test: Clean up timeouts applied in ION-BIBE interop test
We should not need to wait between setting up individual contacts, as
the commands are even sent to different BPA instances. We only need to
wait after configuring the contacts and before sending the bundle, so
that the contact has definitely started.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-06 09:14:57 +02:00
Felix Walter
bc2fc915f2 test: Delay sending bundles in interoperability tests
We must ensure that the receiving end can start before injecting
bundles, otherwise this becomes a race condition. We saw this issue in
the ION-BIBE interoperability test.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-06 09:14:57 +02:00
Felix Walter
f657efd1fa test/integration: Use parentheses instead of backslash for continuation
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-06 09:01:41 +02:00
Felix Walter
2c4a8b9f71 test/integration: Add a test for bundle status reports
As discussed in #215.

Note: The basis of this code has been AI-generated using Claude Sonnet 4,
but it was reviewed line-by-line and heavily refactored.

Prompts:

- "Create a new integration test in `test/integration` that tests the
  newly-introduced status report feature. The test should send a bundle with
  a set report-to EID, which may be the (local) sender. The created status
  report should then be received and checked that it contains the
  correct data."
- There is an issue in `_wait_for_status_report`: `sub_client.receive_msg`
  can block indefinitely and there is no possibility to specify a timeout.
  However, you could make the test async which allows aborting the receive
  function. There is an async AAP2 client and an example for a test based
  on it in `test_aap2_async_client.py`.
- I updated the test file. Adapt it so it passes the flake8 check which
  gives the following errors: (pasted line-length issues)
- Extend the check of the received status report in the test by parsing it
  as valid BPv7 (RFC 9171) status report. An implementation that can be
  used for serializing status reports can be found in lines 525-566 of
  `pyd3tn/bundle7.py`. The status report is in CBOR format. We use the
  `cbor2` library in the project. The BPv7 spec can be found here:
  https://www.rfc-editor.org/rfc/rfc9171.html#name-bundle-status-reports

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-05 17:14:03 +02:00
Felix Walter
973f35d132 Implement status report support in AAP 2.0
This enables AAP 2.0 clients to receive status reports with a new ADU
flag (as we already deliver BIBE bundles). Moreover, it allows clients
to set a report-to EID and sets all of the status report flags on newly
created bundles in case a report-to EID is provided.

Closes: #241

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-05 17:13:17 +02:00
Felix Walter
dac4d4b0b8 CI: Bump interop testing images to include Jansson dependency
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-05 17:03:39 +02:00
Felix Walter
030b0bf75a routing/compat: Implement JSON configuration parser
This adds the JSON parser logic as an alternative to the custom legacy
format and also adds necessary tests.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-05 17:03:39 +02:00
Felix Walter
ed20c501cf test: Update Dockerfiles and introduce jansson dependency
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-05 17:03:39 +02:00
Felix Walter
229f884a57 python-ud3tn-utils: Introduce JSON configuration format
This introduces a JSON contact configuration format for the
deterministic first-contact forwarding (DFCF) implementation as a modern
alternative to our homebrewn configuration messages. For now, it is only
supported in the external DFCF BDM, but integration into the "router
agent" is planned.

Example JSON configuration string (from our tests):

```
{

    "command": "ADD",
    "node_id": "dtn://ud3tn2.dtn/",
    "cla_addr": "mtcp:127.0.0.1:4223",
    "reachable_eids": [
        "ipn:1.0"
    ],
    "contact_list": [
        {
            "start": 1401519306972,
            "end": 1401519316972,
            "data_rate": 2400,
            "reachable_eids": [
                "dtn://66553/",
                "dtn://89326/"
            ]
        },
        {
            "start": 1401519506972,
            "end": 1401519516972,
            "data_rate": 1200,
            "reachable_eids": [
                "dtn://12349/",
                "dtn://89326/"
            ]
        }
    ]
}
```

Closes: #15

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-05 17:03:39 +02:00
Felix Walter
4d39b9ccfa test/integration: Minor comment adjustments
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-05 17:03:39 +02:00
Felix Walter
9446988ed3 test/integration: Add contact configuration and query test
This adds a test for the new JSON-based query feature of the BDM. The
test is only enabled in the debug integration test for the external
dispatcher and does not run by default, as it does not specify an AAP
2.0 secret and also does not work with the built-in DFCF forwarding
module.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-05 17:03:39 +02:00
Felix Walter
d28545ff5e python-ud3tn-utils: Remove deprecated ManagementCommand
This had been removed from µD3TN for a long time.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-05 17:03:39 +02:00
Felix Walter
91b89facc0 Merge branch '244-strict-bpv7-validation' into 'master'
Improve validation of bundles before further processing

Closes #243 and #244

See merge request d3tn/ud3tn!219
2025-06-05 17:01:50 +02:00
Felix Walter
37ec79e249 bundle: Implement dedicated bundle validation before further processing
This adds a `bundle_is_valid` function checking for further MUST
constraints defined by the spec., which further processing inside uD3TN
may depend on.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-05 11:05:47 +02:00
Maximilian Nitsch
87c25c3e8a treewide: Bump python>=3.9
As Python 3.8 is end-of-life and the latest python-protobuf package
requires at least Python 3.9, the minimum Python version is set to 3.9.

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2025-06-03 17:12:08 +02:00
Felix Walter
7360d5ba33 test/run_hdtn_test: Increase timeout and prevent unbound var
When the system is under load, 500 ms may not be sufficient for the
instances to start. In this case, aap2-config terminates as it does not
find the socket. When this happens, the `TMPDIR` variable is still
unset, triggering another error message. This fixes both issues.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-10-22 11:39:34 +02:00
Felix Walter
bf9aa6ed28 CI: Add test for BPv7 bundle with huge block type
This tests for regressions concerning #227.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-10-22 11:20:12 +02:00
Felix Walter
5795169e54 test/decoder: Properly de-initialize parsers on error
Otherwise memory is leaked so we cannot run negative tests with memory
leak detection (ASAN) enabled.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-10-22 11:00:06 +02:00
Felix Walter
81a34fdaf3 test/decoder: Return a different exit code for parser errors
This enables us to differentiate from sanitizer errors - e.g. the UB
sanitizer returns 1 as exit status.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-10-22 10:53:07 +02:00
Felix Walter
bd74f2864b test/decoder: Remove unnecessary comment
We have implemented all four data types.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-10-22 09:52:30 +02:00
Felix Walter
b4250ffb9d test/decoder: Use correct string format specifier
We have adapted the length fields inside bundles to 64 bits, so we need
to use a 64-bit format specifier here.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-10-22 09:52:05 +02:00
Felix Walter
2fd0556f6c test: storage: Improve log output and enforce showing memory leaks
This makes the test show *all* logs in a sensible order and also enables
the display of memory leaks plus backtrace in case ASAN with leak checker
is active.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-09-30 15:54:28 +02:00
Felix Walter
4e40890c57 test: sqlite: Add test for storage persistence across restarts
This restarts µD3TN and the BDM after sending a bundle and triggers
sending it again after restarting both services.

Closes: #222

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-09-27 13:29:01 +02:00
Felix Walter
9ed31716d3
Merge branch 'v0.14-doc-updates'
See !195
2024-09-19 13:09:05 +02:00
Felix Walter
0b4550f765 cmdline: Rename eid to node-id
This was confusing users. We are adding a detailed explanation in the
man page and informing in the help text that the parameter refers to the
administrative endpoint of uD3TN.

Fixes: #213

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-09-13 15:18:03 +02:00
Felix Walter
0107627f76 test/integration: Add a test for the "must not fragment" bit
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-08-30 11:59:13 +02:00
Felix Walter
78bef1a089 Refactor FIB: Separate node entry from CLA link
The FIB fulfils two purposes: 1) map node IDs to next-hop CLA addresses
and 2) store the current status of a link associated with a given CLA
address.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-08-23 11:59:02 +02:00
Felix Walter
ff3b1a6bd1
Merge branch 'update/docker-images'
See !181
2024-08-09 14:59:55 +02:00
Felix Walter
6a230709ce test/ion_interoperability: Adapt BIBE test for ION changes
There have been recent changes in ION's BIBE implementation [1], which
necessitate adapting the configuration files. As a result, they do not
work with IONe anymore, which uses the old syntax. Thus, we will only
support BIBE interoperability with ION mainline and remove the
corresponding test. Nevertheless, some comments have been added to make
it work with IONe.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-24 17:59:11 +02:00
Maximilian Nitsch
e51d4ab992 test/dockerfiles: Update docker images
- ION:  4.0.1 => 4.1.3
- IONe: 1.0.1 => 1.1.0
- HDTN: 1.0.0 => 1.3.1
- DTN7: 0.19.0-732d1a0 => 0.21.0

For ION-DTN>=4.1.1 the official distribution site has moved to
GitHub[^1].

[^1]: https://github.com/nasa-jpl/ION-DTN
2024-07-24 17:59:10 +02:00
Felix Walter
87be9749af Re-integrate v0.13.0 routing code as "integrated default BDM"
This makes µD3TN behave the same as v0.13.0 when executed without an
additional commandline argument. A new commandline argument `-d` /
`--external-dispatch` is added, which enables the use of external BDMs.
The default forwarding implementation is now again provided using the
v0.13 code, extracted from e1621765a4 and
adapted to the new agent-based forwarding implementation.

Central changes to the old code include:

- A new "Routing Agent" that handles incoming configuration commands,
  FIB updates, and BDM dispatch requests.
- The use of the BDM authorization flag to authorize contact
  configuration commands.
- The Contact Manager now only triggers the creation and removal of
  links / FIB entries; bundle dispatch is triggered through the FIB and
  BDM callback functions of the Routing Agent.
- The fragmentation logic is adapted to store the original bundle along
  with an offset and length value, instead of pre-creating and storing
  the fragments.
- The bundle re-scheduling logic integrated into the Routing Agent is
  simplified and does not support changing the fragmentation parameters.
  A new function is added to the Router that searches for a new route
  for such fragments that were already scheduled at some point,
  considering them as un-fragmentable bundle with overridden fragment
  offset and length.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-15 00:46:14 +02:00
Felix Walter
ad4f56b62d Re-import v0.13.0 router code
This adds the code from e1621765a4 back
into the tree unchanged, but moved into two new directories, in
preparation of the following commit, which adds a routing agent on this
basis, to make it possible to review the diff properly.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-15 00:46:14 +02:00
Felix Walter
a76c06998f
Merge branch 'feature/aap2-maximum-bundle-size'
See !176
2024-07-05 12:39:11 +02:00
Felix Walter
d9da044a01 test: Give uD3TN some time to start before launching BDM
Otherwise it might crash in some rare cases because the socket is not yet
ready.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-04 16:03:31 +02:00
Felix Walter
234787d69f cmdline: Do not launch TCPSPP CLA by default
The main reason here is to not initialize a CLA that has a hard limit on
the maximum bundle size (TCPSPP) by default. TCPSPP is rarely used anyway,
so we can disable it and save some memory in the default configuration.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-04 16:01:42 +02:00
Maximilian Nitsch
9902fd072d python: Use cbor2 instead of the deprecated cbor library
Since the last update of the cbor[^1] library was in 2016 and the
repository no longer even exists, the cbor2[^2] python library is now
used instead.

[^1]: https://pypi.org/project/cbor/
[^2]: https://pypi.org/project/cbor2/

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2024-07-02 17:17:57 +02:00
Maximilian Nitsch
facd5246b7 test/sqlite_storage: Use run_aap_recv from python-ud3tn-utils package
Use the `run_aap_recv()` function from the python-ud3tn-utils package
instead of copying the code.

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2024-07-01 10:10:56 +02:00
Maximilian Nitsch
3ba8281796 treewide: Use python-ud3tn-utils scripts instead of those from tools/
Changes all occurrences of the old script paths from tools/ to the
scripts installed by python-ud3tn-utils.

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2024-07-01 10:10:56 +02:00
Maximilian Nitsch
fa6d159d10 python-ud3tn-utils: Add AAP + AAP2 tools
- Moves `tools/aap` + `tools/aap2` to `python-ud3tn-utils/aap*/bin/` to
  add the scripts to the python package
- Adds a `main()` function to each script to reference it
- Define `logger` as global variable
- Adds a symbolic link to keep compatibility with existing tooling
- Moves `tools/aap/aap_test.py` to `test/functional/`
- Adds additional dependencies (pyd3tn, cbor) to python-ud3tn-utils and
  the corresponding nix package
- Add scripts to python-ud3tn-utils `pyproject.toml`

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2024-07-01 10:10:56 +02:00
Felix Walter
13dc229c18
Merge branch 'hotfix/agent-null-registration-allows-all'
See !166
2024-06-26 13:33:55 +02:00
Felix Walter
63ea25e52a CI: Fix configuration for compat. BDM in integration tests
We must either allow accepting configuration from an external source or
use the AAPv2 method with authentication for the integration tests to
work. This uses one of both approaches in each of the tests, so both are
also validated to work.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-26 13:32:28 +02:00
Felix Walter
6df1fa7ae3 agent_manager: Allow more than one RPC BDM agent
For example, we want to allow aap2_config.py and a BDM to run
concurrently.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-26 10:31:41 +02:00
Felix Walter
2dcf3b35d9 aap2: Secure the control of the storage and BDMs through AAP 2.0
With the addition of the storage agent and the compat. BDM we have the
issue that two new agents accept configuration through bundles, which
cannot check that those bundles come from trustworthy sources. In the
past we restricted contact configuration messages to local clients and
performed an "EID spoofing detection" so that we could check the source
EID - if it is the same as the local node ID, we allowed the
configuration bundle to be processed. With AAPv2 and potentially more
security-relevant components (such as BDMs) appearing in the future, we
need a new mechanism.

The idea behind the implemented mechanism is to reuse the existing AAP
2.0 shared-secret authentication that is applied for BDMs themselves
also for sending configuration messages: We add the possibility to
register an AAP 2.0 RPC agent (one that sends commands *toward* uD3TN)
with the "dispatch" authorization flag. This client can then request a
special flag to be added when sending bundles. The new flag is only
added internally by uD3TN to its in-memory data structure and is
delivered to all internal agents as well as AAP 2.0 clients receiving
the marked bundles. Those agents and clients (such as the sqlite/storage
agent) can then easily check for the flag to be present and thus
determine whether the bundle comes from an authenticated and authorized
source.

Note: The `adu_flags` field for the BundleADU AAP 2.0 message is now a
`repeated` field to represent the option of multiple flags being present
(Protobuf does not support bit fields for this purpose).

Fixes: #187

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-26 10:23:17 +02:00
Felix Walter
2f17075ff3
Merge branch 'feature/sqlite-in-memory-db'
See !174
2024-06-26 10:04:30 +02:00
Maximilian Nitsch
ed6bdcbf96 SQLiteCLA: Support volatile in-memory database
Adds support for a volatile in-memory database by enabling support for
URI-based database file names. Since the in-memory DB can only be
accessed within the process, the integration tests are changed so that
external SQL queries are only performed when a persistent DB file is
used.

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2024-06-26 09:28:45 +02:00
Felix Walter
3fc93b6507 aap2: Pass the next-hop node ID and CLA address to the BDM
When transmission had been attempted and generated a "TX
success/failure" result, the BDM will need the information which
transmission is affected by the generated dispatch. Additionally, the
term "DispatchRequest" is imprecise, as uD3TN does not require the BDM
to dispatch the bundle in any case (it can do so, but especially after
TX success/failure, oftentimes, it is intended to just proceed with
normal bundle processing).

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-25 10:25:12 +02:00
Felix Walter
d238804c6a
Merge branch 'hotfix/bundle-serializer-result'
See !167
2024-06-25 10:20:59 +02:00
Felix Walter
ed83236222 test: stress: Allow for choosing between BDM and direct-disptach mode
This adds an argument to use either BDM-based or direct (FIB) dispatch
through pre-configured persistent links and makes the latter the
default. Also an AAP2 secret is passed, so uD3TN release builds can be
evaluated.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 12:39:59 +02:00