Commit graph

42 commits

Author SHA1 Message Date
Felix Walter
f2fb8f554c config.mk.example: Remove wrong comment
We set that to 0 for compatibility, not to 1.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2026-03-19 18:58:07 +01:00
Felix Walter
5660d27471 bundle7: Add flag to validate if there is no BIB and no primary CRC
See: #267

This adds a compile-time flag to reject such bundles, if needed.

Making this part of the validation routines all the time breaks our
interoperability with DTN7 (at least in the configuration we are using
in our interop. test).

Note that we cannot currently check the security targets, which is an
unordered CBOR array part of the BIB payload data. Thus, bundles without
CRC and with a BIB targeting *any* block, even if this excludes the
primary block, will be accepted when the option is turned on. See
follow-up issue #273.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2026-03-19 18:58:07 +01:00
Felix Walter
81b7060ba5 cla_mtcp: Enable ION interoperability
ION uses a 32-bit unsigned integer length field as header for the MTCP
packets. To be compatible with that, we add a compile-time setting
`CLA_MTCP_ION_STCP_COMPATIBILITY`.

Closes: #202

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2026-03-19 07:57:21 +01:00
Felix Walter
f4206db121 eid: Implement support for ipn 3-element string representation
This extends the conversion and validation functions for ipn EID strings
to implement support for the RFC9758 3-element format.

The only point that changes behavioral-wise by default is that now
`eid_to_string` returns the "ipn:a.n.s" for all EIDs with FQNN > 2^32-1,
except if the new compile-time configuration option
`EID_IPN_FORCE_2_ELEMENT` is enabled.

This also introduces a variant of `eid_to_string` with a second argument
to enforce the use of the 2-element format, which is used in the BPv6
implementation for constructing outgoing bundles (there is no 3-element
format in BPv6).

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2026-02-03 09:22:53 +01:00
Felix Walter
e819f8723b bundle7, tx: Implement creation of BPv7 previous node block
RFC9171 specifies this as a "SHOULD", so we should support it.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-09-16 17:17:51 +02:00
Felix Walter
4c274787cf Use BIBE AR type code 64443 by default
See: https://datatracker.ietf.org/doc/html/draft-ietf-dtn-bibect-05

Closes: #260

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-09-05 10:57:59 +02:00
Felix Walter
aebe697809 config.mk.example: Explain that the DISABLE_* flags apply when set
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-05 17:03:39 +02:00
Felix Walter
868bac67b6 router_agent, mk: Add stub of JSON configuration feature
This adds a function to decode JSON configuration via Jansson to the
router agent. The JSON functionality and, thus, the dependency on
Jansson, can be disabled during the build process by setting the
`DISABLE_JSON` compile-time flag (see `config.mk.example` for details).

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-05 17:03:39 +02:00
Felix Walter
fb2d0b021c cla, mk: Fix disabling SQLite functionality
Previously it was not possible to disable SQLite because of a linker
error. Also, `sqlite3.h` was always required to be present. This adds
an example to `config.mk.example` and fixes both issues.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2025-06-05 17:03:39 +02: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
Felix Walter
db7ff27ff4 cmdline: Documentation fixes related to AAP v1 arguments
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-10-02 07:49:46 +02:00
Felix Walter
17bd09a84b cmdline, docs: Enable TCP support for AAP 2.0
This allows for using AAP 2.0 over TCP, which the Python tools support
already. Note that the user must make sure that the socket is not
exposed externally.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-10-02 07:49:46 +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
ccbeac91f3 Unify and document compile-time options of compat. router
This prefixes all compile-time options of the compat. router with
`ROUTER_` and adds them to config.mk.example so they can be easily
discovered and adapted.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-15 00:46:14 +02:00
Felix Walter
bd9b92b823 bundle_processor: Enforce a maximum number of fragments
This ensures that internal counters do not overflow and we can prevent
DoS by BDM responses containing lots of next hops (e.g. in case of BDM
bugs) to some extent.

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
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
4de60633ba cla: Increase default CONTACT_TX_TASK_QUEUE_LENGTH to 100
Some CLAs may block sending to the underlying layer, e.g., the storage
CLA may wait for the DB to become ready. This increases the default
queue length to prevent blocking the BP in such cases.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 11:16:07 +02:00
Felix Walter
8aaf458a1f cla_sqlite: Set busy timeout to 100 ms
Read transactions need a short, blocking, lock for the database, during
which no write transaction can be started - this means the interaction
of the agent, TX, and RX tasks may block each other if anything takes
longer than 1 ms. Thus, we increase the timeout for blocking locks to
100 ms to significantly reduce that probability.

See: https://www.sqlite.org/src/doc/204dbc15a682125c/doc/wal-lock.md

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 11:16:07 +02:00
Felix Walter
72d3806066 aap2_agent: Switch to simple_queue to enforce clean termination
This enables a clean termination of all agent connections on program
exit without memory leaks that might previously occur due to the "pipe
queue" still holding some data (pointer to allocated memory) when
close() is called on the pipe. For that purpose, the "pipe queue" is
replaced by our standard hal_queue implementation, which also has a
higher performance as it does not require a syscall on every read/write
operation.

As hal_queue does not support poll() (it does not provide a fd), we
cannot check whether the socket has been closed by a subscribing AAP2
client while concurrently waiting for the internal queue. As an
alternative, this implements a liveliness check, which checks the sub.
connection opportunistically from the agent manager: When a new
registration is requested, existing registrations are first
"health-checked" and removed if down, so the new connection can take
over if an old one is down and this was not detected previously.

Based on the new infrastructure, a clean termination routine is
implemented that terminates all tasks transitively by terminating the
listener.

An AAP2 connection handler ("comm task") can terminate in two ways:
1. During runtime, when the connection is closed, it must clean up its own
   resources.
2. On program termination, all connections must be cleanly closed and
   all outstanding mesages handled.

For 1., we keep using detached threads and allow them to release all the
resources. This commit mainly introduces a mechanism for 2.: A list
tracking all comm. tasks is added that can be used to terminate and wait
for all of them on program termination. A "termination flag" indicates
whether tasks should clean up by themselves or the listener task takes
it over. Everything needs to be protected by mutexes for safe
concurrency.

There is specific handling for macOS, which does not signal other
threads clocking on a socket that the socket has been closed when
calling shutdown() but only when calling close() - thus, close() is
executed earlier on macOS. Also, macOS does not unblock poll() when the
socket is close()d, so we do not use it anymore to wait for data on an
RPC connection, but rather set SO_RCVTIMEO for active-client (RPC)
connections to enforce the keepalive timeout.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 10:36:30 +02:00
Felix Walter
b9aff2400d config: Set default bundle processor queue length to 4000
This makes it much more unlikely that the queue fills up, even under
high load. We however still need a long-term solution for the loop
issues sketched in #189.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 10:36:30 +02:00
Felix Walter
38d5d7d96f cla_sqlite: Register and create FIB entry on launch
This is required to allow bundles being forwarded to storage by
specifying the storage node (a configuration parameter) as next hop.

The CLA initialization is modified slightly to register the CLA before
executing `cla_launch` to ensure that the bundle processor knows about
it when it is executed.

This also moves the Sqlite CLA initialization to the `sqlite_launch`
function because the CLA has to be known ("registered") before we send
a signal to the BP (which is done during link creation).

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 10:36:30 +02:00
Felix Walter
89a6fad064 init: Load SQLite CLA by default
For working with BDMs we need it.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 10:36:30 +02:00
Felix Walter
6d2f204af5 Replace integrated next-hop forwarding with AAP 2.0
This adds functionality to dispatch bundles and control the FIB to AAP
2.0 and the bundle processor, replacing the old "router" completely.
AAP 2.0 is extended slightly to enable fragmentation.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-17 13:33:32 +02:00
Felix Walter
e72c1fdd74 fib: Implement a simple DTN FIB
This first version only supports a single CLA link per node ID. Apart
from this, multiple mappings from node ID to CLA address (N:1) can be added.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-17 13:33:31 +02:00
Felix Walter
3a3b12a8bc aap2: Document compile-time configuration options in config.mk.example
The backlog configuration option is renamed to indicate up front that it
is intended to be passed to listen().

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-03 14:41:59 +02:00
Maximilian Nitsch
55f762b804 SQLiteCLA: Use WAL journal mode and a busy timeout instead of retries
https://www.sqlite.org/wal.html
https://www.sqlite.org/src/doc/204dbc15a682125c/doc/wal-lock.md

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2024-06-03 13:41:58 +02:00
Maximilian Nitsch
1321c59c22 sqlite_agent: Add an agent to interact with the SQLiteCLA
The SQLiteAgent enables SQLiteCLA to read packages from the database and
return them to μD3TN. For this purpose, the SQLiteAgent writes commands
to the queue that SQLiteCLA is waiting for.

The SQLiteAgent itself can be controlled by protobuf messages that
describe which action is to be applied to which set of bundles.

Currently the operations "Push" and "Delete" are implemented and a
filter based on a destination EID pattern.

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2024-06-03 13:41:58 +02:00
Maximilian Nitsch
de33e8cc51 cla_sqlite: Implementation of the SQLite-based storage back-end
The SQLiteCLA makes it possible to write bundles, that are to be sent
via this CLA, to an SQLite database in order to persist them over a
longer period of time and also a restart of μD3TN.

The bundles are saved together with selected metadata (source EID,
destination EID, creation timestamp) in the "bundles" table. A
combination of source EID and creation timestamp is used as the primary
key.

To return bundles to μD3TN, they are read from the database and injected
via the cla_read() function, just like other CLAs that receive bundles.
To trigger this, commands are read from a queue that specify which
bundles are to be read from the database.

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2024-06-03 13:41:58 +02:00
Felix Walter
5f5269ec1a
Merge branch 'feature/162-clean-up-hal-task'
See !150
2023-12-20 16:25:50 +01:00
Felix Walter
75edf0cbd7 hal_config: Remove LINUX_SPECIFIC_API switch
We only used it for thread naming - the hal_platform malloc analysis
support was removed a long time ago. As we do not really need thread
naming and removed it when cleaning up hal_task, we do not need this
define anymore.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-12-20 10:32:48 +01:00
Felix Walter
c543afd3aa CLA: Make infinite retries the default
As we are ensuring that retries happen with a delay in between we can
infinitely retry connections during a contact. This ensures we can
establish a connection even if the peer becomes available significantly
later than the contact starts on our side. The setting can be configured
in `config.mk`.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-12-20 09:38:01 +01:00
Felix Walter
bcf6a49f43 CLA: Make abort() on final CLA link task termination optional
uD3TN can continue to run in this case, just without the given CLA. This
introduces a compile-time switch to select whether we want to kill uD3TN
in case a CLA finally fails.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-12-20 09:36:43 +01:00
Felix Walter
7b7ff98a2d cmdline, config.mk.example: Make it clear that log level 4 is debug-only
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-11-16 14:20:04 +01:00
Felix Walter
1b1285c126 cmdline: Set default log level for release builds to 2 (WARNING)
This reduced unnecessary clutter by default if we do not want to debug
uD3TN. Should also slightly increase performance by issuing less
`printf` statements.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-11-16 14:20:04 +01:00
Felix Walter
bef31704c5 aap2: Add an AAP2 implementation matching the current AAP feature set
This is a "meta-agent" based on the current AAPv1 implementation
(`application_agent.c`), which runs the new AAP2 protocol that is
implemented via Protobuf (using NanoPB). Please refer to the
corresponding design documents for further information on the protocol
itself.

Beside the on-wire encoding and future extension capabilities, the primary
difference from AAPv1 to AAP2 is that a connection is now a
unidirectional RPC-like channel. This ensures that acknowledgments
cannot be easily get out of order and makes client implementations
simpler. However, it also means that now a shared secret needs to be
passed by clients to enable registering for the same agent ID.

The following limitations of this first implementation are present:
- Only sending and receiving ADUs is supported.
- The shared secret is not checked - any app can register for the same
  agent ID as long as no other app has yet registered for the requested
  direction (subscribe or non-subscribe).
- Only one client per direction is supported at the moment. (It is at
  least planned to support multiplke subscribers for an agent ID.)
- The server does not expect acknowledgments from clients when they
  receive ADUs.
- The keepalive mechanism is not implemented.

In general, this reflects the feature set of AAPv1, but with massive
extension opportunities.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-11-08 15:11:52 +01:00
Felix Walter
e53a4b9ca3 CLA, mk: Make SO_REUSEPORT a documented compile-time option
Previously we were setting this every time that it was defined. The
switch from defining _POSIX_C_SOURCE in some files to defining
_XOPEN_SOURCE in the build system made the symbol disappear on Linux
with GCC, thus, making our current AAP test (which reuses ports) fail.

As SO_REUSEPORT is probably unintended in most cases and may rather lead
to unexpected behavior or even security issues, we should disable it by
default. #144

This commit re-introduces _DEFAULT_SOURCE as feature-test macro to
provide the Linux- and BSD-specific API SO_REUSEPORT, which is not
available otherwise.

Fixes: #144

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-10-26 14:44:49 +02:00
Felix Walter
8b7f7f8e1a config.mk.example: Document all possible compile-time definitions
See also !129

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-10-25 15:56:57 +02:00
Felix Walter
7338297b35 mk: Make options available via yes/no switches available in config.mk
This allows us to enable some options that were intended as CLI
arguments to `make` also via `config.mk` and documents those options in
`config.mk.example`.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-09-29 14:36:25 +02:00
Felix Walter
ab00791f2a mk: Document current build options in config.mk.example
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-09-29 14:36:25 +02:00
Marius Feldmann
691b7c3172 Remove STM32/FreeRTOS support from uD3TN
Former releases of uD3TN have included support for STM32/FreeRTOS.
Having this support from the first moment on was a good thing in
order to optimize for platforms with limited resources. As this
platform is not used in current uD3TN setups and as it results in quite
some maintenance work, it is removed with this commit. The removed parts
cover the implementation itself, tests, tools, documentation, parts of
the build/make scripts as well as licensing information.

Signed-off-by: Marius Feldmann <marius.feldmann@d3tn.com>
2022-03-22 00:05:13 +01:00
Felix Walter
0ce4bee910
Initial import of uPCN v0.8.0 source code
This is the initial commit for uD3TN. uD3TN is a fork of uPCN v0.8.0,
which will be developed and maintained in a public Git repository.

For questions concerning the history of and code provided with uPCN,
please get in touch with us via: contact <at> d3tn <dot> com

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2020-11-14 11:56:40 +01:00