Commit graph

95 commits

Author SHA1 Message Date
Felix Walter
c4e2a837a3 aap2: Add a note on overriding the source EID
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2026-05-12 11:48:17 +02:00
Felix Walter
4c3dec3b16 python-d3tn-utils: Add tool to track FIB changes
This can be used for debugging the FIB and as example for developing
tools dealing with FIB changes.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2026-03-23 08:36:16 +01:00
Felix Walter
1ceea16c3c WIP: aap2_agent: Allow registering without an agent ID
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2026-03-18 10:05:55 +01:00
Felix Walter
92c9845713 python-ud3tn-utils: Reduce complexity of aap2-receive
(to satisfy flake8 and make the code more readable)

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2026-02-03 09:22:53 +01:00
Felix Walter
2284054cc6 python-ud3tn-utils: Allow specifying a custom source EID
With BDM auth, the AAP2 client can specify the source EID as well. This
implements corresponding logic for the aap2-send and aap2-receive utilities.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2026-02-03 09:22:53 +01:00
Felix Walter
70d1596057 python: Implement 3-element ipn EID format
This is inspired by the Python changes !222 but almost completely rewritten.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2026-02-03 09:22:53 +01:00
Felix Walter
77780672a5 Adjust license of Python modules and Protobuf to Apache/BSD
We want to be permissive concerning client code and alernative client
implementations. Thus, we re-license these parts under Apache 2.0 and
BSD licenses.

Note: D3TN has all rights to publish the relevant code under an
arbitrary license, thus, this change does not conflict with the previous
licensing scheme.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-08-15 14:41:42 +02:00
Felix Walter
e4e63721ed Merge branch '221-replace-asserts-by-exceptions' into 'master'
python: Replace some assert statements by proper checks

Closes #221

See merge request d3tn/ud3tn!224
2025-07-24 12:08:23 +02:00
Felix Walter
91d8d806a4 Merge branch 'switch-aap-config-to-json' into 'master'
python-ud3tn-utils: Switch config. tools to JSON-based config

See merge request d3tn/ud3tn!228
2025-07-24 09:02:46 +02:00
Felix Walter
12d6a17517 python-ud3tn-utils: Switch config. tools to JSON-based config
The format is more modern and supports characters in the configuration
commands (e.g., as part of EIDs), which were previously forbidden.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-07-23 14:05:17 +02:00
Oleksandr Nazymko
144e685834 Validate EIDs in AAP2 tools
This adds usage of pyd3tn validate_eid function for AAP2 tools.

Signed-off-by: Oleksandr Nazymko <oleksandr.nazymko@d3tn.com>
2025-07-10 09:19:39 +02:00
Felix Walter
9c2ac1a0a5 python: Replace some assert statements by proper checks
`assert` is only for debugging purposes and will not be executed if `-O`
is turned on.

This was partially implemented using AI, but heavily refactored.
Prompts:

- > One can disable the assert statement by passing -O to the Python interpreter. However, this leads to the statements inside the assert not being executed. Some scripts in the µD3TN codebase perform important actions in that context. We should check and, if necessary, refactor relevant uses of assert such that they only check for bugs. In places where an assert currently checks for issues with e.g. input data (things that can occur at runtime but are no bug in our Python code), regular exceptions should be used instead.
- (on one occasion) > This does not depend on input data. It would be a bug if the assertion is not true. Thus, it can be kept here.

Afterwards, the formatting was adjusted manually and the introduced
exceptions in the AAP2 tools were replaced by a log message plus
`sys.exit(1)` manually.

See: #221

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-07-09 09:16:24 +02:00
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
a8a6f8c845 python: Apply review comments from !199
- Use format strings
- Use enum field instead of magic number
- Cast to enum type
- Add type annotations to parse functions
- Improve docstrings mentioning Set types where function accepts Iterable

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-06 09:14:53 +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
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
1cc9560852 BDM: Be more permissive about the allowed parts of a config message
We implicitly expected all incoming config message data structures to
contain a list of contacts as well as a list of reachable EIDs in both the
config message and each contact in the contact list itself. This may not
always be the case if the config command does not contain such fields.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-05 17:03:39 +02:00
Felix Walter
89957b9e81 python-ud3tn-utils: BDM: Fix re-scheduling upon contact removal
Previously, we were relying on a race condition for re-scheduling: if a
suitable contact is ongoing, even if it is in the process of being
dropped, it will be considered for re-scheduling a bundle.

This explicitly ignores the contact being dropped.

Due to the increased complexity, `_calc_bundle_schedule` is refactored
slightly.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-05 17:03:39 +02:00
Felix Walter
e6380b3c8a python-ud3tn-utils: BDM: Fix updating existing contacts
When we update an existing contact, e.g, to change the set of reachable
EIDs, we delete the previous entry, cancel the task, and add a new
entry. For this to work, we must wait for the task to terminate after
cancellation.

Additionally, we relax the check for which contacts to update to include
contacts that compare equal, which might be the case if only the
"reachable EIDs" list is different.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-05 17:03:39 +02:00
Felix Walter
6aa7fdcb33 python-ud3tn-utils: Do not add contacts that are ongoing
This would result in conflicts. We previously used an assertion to
ensure it, however, this could be triggered by external config commands
and crashed the BDM.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-05 17:03:39 +02:00
Felix Walter
1e7413297b python-ud3tn-utils: Fix BDM not dropping contact if connection fails
If the link cannot be established, we need a timeout to remove the
contact from the active contacts set.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-05 17:03:39 +02:00
Felix Walter
fe56b0846d python-ud3tn-utils, BDM: Allow querying contact plan
This re-impplements the QUERY command through our configuration
interface so we can get the contact plan back out of the BDM.
aap2_config.py is extended such that it allows for querying and deleting
contacts.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-05 17:03:39 +02:00
Felix Walter
348c56ea2e python-ud3tn-utils: Move config parser from BDM to library
As this can also be used for the built-in routing agent, we provide the
functionality in the shared Python 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
Maximilian Nitsch
94218d6116 python-ud3tn-utils: Re-generate protobuf files
Regenerates the Python protobuf bindings with the updated `protoc`.

```sh
make aap2-proto-headers
make storage-agent-proto-headers
```

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2025-06-05 10:58:12 +02:00
Felix Walter
cf727900db python-ud3tn-utils: Do not allow empty strings where not applicable
As discussed in !214 we add a validation based on `argparse` so the user
receives a nice error message when trying to pass an empty string to an
argument for which this is not valid.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-05-09 10:51:52 +02:00
Maximilian Nitsch
f152663e32 python-ud3tn-utils: Rebuild protobuf language bindings
Since the updated nixpkgs contains a new python.protobuf package version
(4.25.3 -> 5.28.3), the language bindings are regenerated.

See: https://gitlab.com/d3tn/ud3tn/-/issues/200

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2024-12-05 18:07:10 +01:00
Felix Walter
6b99068daf aap2: Change default TCP port to 4244
The defaults for the AAP and AAP 2.0 TCP ports were the same. Thus, if
we specify a TCP host for both, µD3TN will terminate on startup as the
port is already in use by one agent but it tries to bind to it with
both.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-11-16 13:31:40 +01:00
Fiona Fuchs
e249cc3006 Add index.md file, change documentation structure, add new elements and images to folders, add CSS
This performs the following actions:
- change overall documentation tree to adjust to existing material
- add CSS for improved visuals
- add folders to improve structure
- move the README of the Contact Plan Reader to the doc folder and integrate it into the documentation
- add file for 'Home' to provide a starting point for the documentation

Signed-off-by: Fiona Fuchs <fiona.fuchs@d3tn.com>
2024-11-15 07:59:32 +01:00
Felix Walter
c44ac9c936 python-ud3tn-utils: BDM: Allow for enabling keepalive
When connecting to µD3TN with the client behind a NAT gateway, the connection
may be dropped silently after a while if no data is flowing from µD3TN to the
AAP 2.0 subscriber (i.e., if no bundles are received for a while). µD3TN
allows us to set a keepalive interval to prevent this, which was however
only exposed by aap2-receive and aap2-ping previously. As the BDMs may
also hold long-living receiving connections, this capability is added to
them as well.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-10-02 07:49:46 +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
183d8f137a tools: DFCF BDM: Correct calculation of total bundle size
If the bundle must not be fragmented and, thus, `min_frag_size_first`
equals `serialized_size` and `min_frag_size_last` equals zero, we must
not treat `min_frag_size_first` as header size and add it to the
remaining payload size in the calculation of the total serialized size
in the BDM.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-08-30 11:57:04 +02:00
Felix Walter
fe01fd538e python: aap2-bdm-ud3tn-routing: Adapt to AAP2 and FIB changes
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-08-23 11:59:18 +02:00
Felix Walter
89550209a0 python: aap2-configure-link: Adapt to AAP2 and FIB changes
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-08-23 11:59:18 +02:00
Felix Walter
21dd896d6f python: aap2: Add function to get the ResponseStatus as string
It is often required to print a proper error message if an unexpected
ResponseStatus is received from µD3TN. Because ResponseStatus is an enum
generated by Protobuf, there seems to be no easy-to-use `name` property.
Thus, we provide a function for mapping the integer values to a readable
string representation in the AAP2Client class.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-08-23 11:59:18 +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
459e1b60ff python: aap: Make behavior of AAP (v1) tools consistent with AAPv2
This adapts the v1 tools to the recent changes in the AAPv2 tools so
they use the same return codes and (error) messages.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-08-09 15:02:19 +02:00
Felix Walter
36a1f8bfc9 python: aap2: Properly handle communication errors when receiving
We are using exceptions for signaling users of the AAP2Client that
communication with µD3TN failed when receiving data, however, we did not
differentiate between normal connection closure and abnormal conditions.
This adds a `AAP2ServerDisconnected` exception to signal that µD3TN has
closed the connection. The supplied tools are adapted to properly handle
both this new exception and other usual cases for termination such as
keyboard interrupts, so that no unnecessary stack traces are printed.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-08-09 15:02:19 +02:00
Felix Walter
62afaffac7 python-ud3tn-utils: Inform that contact plan script can still be used
This extends the message printed by aap_contact_plan_reader.py to
explain that it can still be used if we launch µD3TN with the
--allow-remote-config commandline flag.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-15 23:42:09 +02:00
Felix Walter
487ae5bf72 python-ud3tn-utils: Remove aap_storage_agent.py
This script is outdated as it does not support the newest approach to
filter bundles and also does not support the authorization required by
the storage agent (the flag is set via AAP 2.0).

aap2_storage_agent.py should be used instead.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-15 23:39:59 +02:00
Felix Walter
a76c06998f
Merge branch 'feature/aap2-maximum-bundle-size'
See !176
2024-07-05 12:39:11 +02:00
Felix Walter
721e471876 python: BDM: Implement max. bundle size in compat. BDM
This uses the value provided via AAPv2 to reduce the size of the
scheduled bundles to ensure the maximum bundle size is not exceeded.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-04 16:03:31 +02:00
Felix Walter
ee59a74443 aap2, cla, cmdline: Pass maximum bundle size to BDM
We should be able to honor the fragmentation threshold again. This
passes the maximum bundle size variable to the AAPv2 agent. The value is
determined as the minimum of all maximum bundle sizes reported by the
CLAs and the one specified on the command line, with the special case
of the value 0, which means a maximum bundle size of 2^64 ("unlimited").

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-04 16:00:30 +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
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
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
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
7b959e4cb8 aap2, FIB: Implement direct dispatch
This adds a "flags" field to the FIB link, allowing for configuring a
link for "direct dispatch", i.e., to make it usable without first
contacting a BDM. It is important to make this optional as otherwise
contact-based routing and QoS could not be implemented properly via a
BDM.

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