Commit graph

108 commits

Author SHA1 Message Date
Felix Walter
e16ec4c579 Enable building a BPv7 decoder binary
This adds a target `data-decoder` which builds a binary to decode a
specified binary file using uD3TN's parsing logic (based on the CLA RX
subsystem) and print details about it. In this first version only the
decoding of BPv7 bundles is implemented.

This binary can be used, e.g., for fuzz testing.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-16 11:34:14 +02:00
Felix Walter
1c6d91a1a0
Merge branch 'hotfix/mac-osx-compatibility'
See !105
2023-05-15 14:20:52 +02:00
Felix Walter
fe0404671d test/integration: Apply suggestion to make usage of TCP default socket easier
See https://gitlab.com/d3tn/ud3tn/-/merge_requests/109#note_1389996506

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-15 11:42:39 +02:00
Felix Walter
c641197313 test/integration: Also test AAP bundle ID encoding
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-15 11:40:47 +02:00
Felix Walter
fd4fe60fe4 test/integration: Add test for aap send/recv with bundle ID check
This is basically an extended `aap_test.py` as part of the integration
tests, which verifies the received AAP messages and also checks the
returned bundle ID if it contains a well-formed timestamp and sequence
number.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-15 11:40:47 +02:00
Felix Walter
62d563449f test: Remove the Unity wrappers for memory allocation functions
This adds a custom header that does explicitly not include the Unity
wrappers for malloc, free, etc. by defining the guard used by that header
file. This way we can remove the wrappers provided via the linker
altogether.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-15 11:39:29 +02:00
Felix Walter
adb80c8938 simple_queue: Remove queueItemsWaiting
We cannot easily support this on MacOS, but we do not use it except in
tests. Thus, remove it and make the tests only run on Linux and use
`sem_getvalue` directly.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-15 11:01:34 +02:00
Felix Walter
6112e9669c
Merge branch 'hotfix/parser-issues'
See !108
2023-05-15 10:43:20 +02:00
Felix Walter
6b88cbc673
Merge branch 'feature/add-bundle-unit-tests'
See !102
2023-05-15 10:43:02 +02:00
Oleksandr Nazymko
51fa02b77c Add unit tests for bundle operations
This adds unit tests for the functions in `components/ud3tn/bundle.c`.

Signed-off-by: Oleksandr Nazymko <oleksandr.nazymko@d3tn.com>
2023-05-15 08:46:46 +02:00
Felix Walter
62cadd3719 Move the node_prepare_and_verify to router_task
This removes the `hal_time` dependency of the `routing_table`, as it now
assumes that the provided `struct node` is ordered, free of conflicts,
and has valid contact timestamps. This is ensured by invoking
`node_prepare_and_verify` beforehand, in `router_process_command`.
The tests are updated accordingly.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-12 11:59:43 +02:00
Felix Walter
b4e3e5aae9 bundle7/parser: Add note why status is set to DONE even if CRC is invalid
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-12 09:14:37 +02:00
Felix Walter
278d3ef133
Merge branch 'feature/ione-interop'
See !99
2023-05-12 08:29:17 +02:00
Felix Walter
79de95398c CI: Integrate IONe v1.0.1
This adds a Dockerfile plus interoperability tests for the ION
experimental baseline release v1.0.1.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-12 08:21:44 +02:00
Felix Walter
cc479de85a test/ion_interoperability: Add test for receiving data from uD3TN in ION
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-12 08:07:42 +02:00
Felix Walter
54813d95c8 test/ion_interoperability: Add test receiving ION bundles in uD3TN
ION by default sends bundles encoded with CBHE (BPv6). This tests that we
can receive them. Also for BPv7 it makes sense to test reception, of
course. :-)

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-12 08:07:42 +02:00
Felix Walter
d9bd711c9a bundle6: Allow for receiving CBHE-encoded bundles
This also adds a test for it, sending bundles from within ION to uD3TN
in the "minimal forwarding test".

Fixes: #7

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-12 08:07:42 +02:00
Felix Walter
379f09d7af hal_time, agents: Remove the function to set the system time
This should be a function offered by the operating system, not by a
userland process like uD3TN.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-11 16:59:13 +02:00
Felix Walter
97d520db34 node: Adapt contact interval DTN timestamp unit to milliseconds
This changes the "from" and "to" fields in the contact struct to
milliseconds-based timestamps and adapts all dependent code. The contact
data format is kept second-based for backward compatibility.

The commit also introduces a new function to work with millisecond
timestamps in the remaining capacity calculation and modifies the tests
related to the latter such that they do not need to change the timestamp.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-11 16:59:13 +02:00
Felix Walter
3cd89eb6a5 bundle, agents: Switch time unit to milliseconds
...to align with the general decision to make DTN timestamps
millisecond-based.

See: #53

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-11 16:59:13 +02:00
Felix Walter
7a3816ca42 node: Add unit suffix to contact interval fields
This clearly identifies that we are working with seconds here.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-11 16:59:13 +02:00
Felix Walter
67fe84a395 node: Identify unit for bitrate in field name
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-11 16:59:13 +02:00
Felix Walter
01de2f7720 bibe_internal_forwarding_test: Wait for uD3TN to exit
This allows for capturing sanitizer warnings in the test and removes the
need to kill all uD3TN instances (just those launched by the test).

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-11 16:54:50 +02:00
Felix Walter
279ba8463e bibe_internal_forwarding_test: Do not recreate venv
This adapts the BIBE test to the behavior of the other functional tests
(ION interoperability), expecting the dependencies to be present when
run. The CI config is adapted to use the prepared Docker image,
preventing reinstallation of Python dependencies during the CI job.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-11 16:54:50 +02:00
Felix Walter
181c94f0a8 CI: Use dedicated Docker image
This prevents installing deps in each run.

Fixes: #16

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-11 16:54:50 +02:00
Felix Walter
0389435a6c CI: Add a Dockerfile for the other CI tests
This adds a Dockerfile containing everything needed in our other tests
(Clang, Python, Python dependencies, Netcat).

See also: #16

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-11 16:54:50 +02:00
Felix Walter
b6754ff841 test/ion_interoperability: Use new syntax to add ION egress plans
In newer versions of ION the `ionstart` utility may not execute the
`dtn2admin` program, so our egress plans were not loaded properly.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-11 16:40:53 +02:00
Felix Walter
951b4cf3c1 CI: Use ION Docker image in BIBE interoperability test
Note that this needs to extend the preparation script for build uD3TN in
case of the ION BIBE interop test with the proper compatibility flag.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-11 16:40:53 +02:00
Felix Walter
67133f8bdf test/ion_interoperability: Enable "watch" option of ION in dtn test
This way we see what happens with the bundle.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-11 16:40:53 +02:00
Felix Walter
4c33209557 CI: test/ion_interoperability: Add tests for the ipn: scheme
This makes the ion interop testing script flexible such that we can
specify the EID scheme to be used. Two additional CI tests are added for
the ipn scheme. Note that these use the newest version of ION while
there still seems to be incompatibility for dtn EIDs with these (see
issue #116).

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-11 16:40:53 +02:00
Felix Walter
ec2bcb901c CI: test/ion_interoperability: Use the Docker image
This makes the ION interoperability tests assume a prepared environment
(ION, uD3TN compiled, Python deps, ...) and, thus, only execute the test
run itself. The CI routines make use of the new Docker image.

Additionally a timeout for stopping ION is added (#120).

Fixes: #120
See also: #16

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-11 16:40:53 +02:00
Felix Walter
43ae0e59ef test: Add Dockerfiles and scripts for ION interoperability testing
This provides two new Dockerfiles for testing, one just containing ION
and one with an additional Python3 virtual environment for
interoperability testing.

Additionally, two scripts are provided:
* build_docker_images.sh: build images that can be pushed to the
  registry and then used by the CI toolchain
* prepare_for_test.sh: a script to be run inside a newly created Docker
  container based on the provided `ion-interop` image, to build uD3TN
  and add the Python modules from the uD3TN source tree efficiently

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-11 16:40:53 +02:00
Felix Walter
5748edf83d test/ion_interoperability: Reduce file descriptor limit before test
This artificially reduces the maximum number of open file descriptors to
make ION services start faster and address an issue with huge delays on
systems that have this limit set to 2^30-8 (observed in container
runtimes #121)

Fixes: #121

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-11 07:56:20 +02:00
Felix Walter
1237eaa2db Remove heap-allocated Task_t
`hal_task_create` returned a reference to the new task allocated on the
heap via `malloc`. We commonly used the pattern to `free` this reference
from the new thread which, however, could result in race conditions and
other synchronization issues. We added a fix using a semaphore in the
application agent, but this would have been needed in other places (CLA,
...) as well. As we do not make use of the task reference anywhere
besides in the CLA for error handling, we can remove the heap-allocated
value altogether and replace it with an `enum ud3tn_result` to simplify
things and circumvent the named synchronization issues.

In the case of the CLA function `cla_link_init`, logic is introduced to
request the RX task to exit immediately in case the TX task cannot be
launched.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 17:23:55 +02:00
Felix Walter
69e4095dcb Remove hal_random
The test was returning indeterministic errors and we did not even use
the function anymore.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 17:23:55 +02:00
Felix Walter
7678ba7feb test/unit: Remove test of system time
This test was prone to off-by-one errors if the time advanced between
calls. It is also unnecessary as we do not use a special clock
implementation anymore and !85 will fully remove the function to mock
the system time.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 17:23:27 +02:00
Felix Walter
dc7de610c2 test/unit: Relax requirements on indeterministic tests
We have two test cases that are randomly influenced by the system they
are running on. This makes the checks in these tests more forgiving to
random variations that may occur.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 17:23:27 +02:00
Felix Walter
995f0db342 test/integration: Fix indeterministic failure in bundle age int. test
This adds some tolerance for the bundle age check, such that it does not
have to be within a fractional millisecond bound.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 17:23:27 +02:00
Felix Walter
be1f3ffd5a test: Remove malloc test
We do not need to test that `malloc()` works. It is not part of our
program.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 15:07:16 +02:00
Felix Walter
a42a7dfa26 test/integration: Wait for uD3TN to process node deletion on test end
This ensures the next test's config is not received (via another CLA)
before the deletion has been processed.

Unfortunately, we have no way to determine whether a command has been
processed by uD3TN (there is no operation to query it), so we have to
rely on a simple timeout. This will change with the new forwarding
interface, see the corresponding Milestone.

Fixes: #110

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 15:07:16 +02:00
Felix Walter
90fd0b4c33 routing_table: Explicitly free contact list upon deletion
There was a rare memory leak if the contact was not found in the target
list (e.g., already deleted earlier).

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 15:07:16 +02:00
Felix Walter
2fc9c6c03e aap_receive, tests: Print a line feed after every received bundle
This makes the testing logs prettier and may help in decoding the
responses received by aap_receive.py.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 14:37:11 +02:00
Felix Walter
1929c71053 test/ion_interoperability: Skip maybe-uninitialized warning
There are issues with newer toolchains and ION 4.0.0

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 14:37:11 +02:00
Felix Walter
8c4ce47724 CI: Remove stdbuf statements from tests
We do not need this anymore due to making logging line-buffered and it
collides with ASAN in some cases.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 14:37:11 +02:00
Felix Walter
a7e41d0e60 test/unit: Make uint32 to wchar_t unsigned-to-signed conversion explicit
Otherwise we may be warned of a value-changing conversion.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 14:32:47 +02:00
Felix Walter
acf4a675c5 test/unit: Use TEST_ASSERT_EQUAL_UINT8_ARRAY instead *_EQUAL_MEMORY
The latter may cause UB according to Clang's UB sanitizer.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 14:32:47 +02:00
Felix Walter
dd6d34d707 hal_time: Make time functions thread-safe
Do not return a reference to a non-thread-safe global variable:
ctime() is not thread safe. As we only use the function in logging, we
can directly print the return value, protected by a mutex.

This also adapts the tests and makes the initialization routine always
run. To use the system time again, UINT64_MAX can be passed.

Found by Clang's thread (data race) sanitizer.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 14:32:47 +02:00
Felix Walter
2fc9e11b7e bundle: Fix potential uint wrap-around in expiration time calculation
We were taking the current time value in milliseconds and sometimes
subtracting larger values from it. This cleans up the calculations to
always determine the expiration time as uint64_t and compare it against
the current uint64_t timestamp.

It further removes the unnecessary "current timestamp" parameter in
`bundle_get_expiration_time_s` (we now store the reception time with the
bundle, so, do not need this anymore) and avoids a integer wrap-around
case in the function.

Note that the current time cancels out in the age block-based
calculation as we can use the reception timestamp there and offset it by
the calculated relative remaining lifetime.

Found by Clang's UB sanitizer.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 14:31:17 +02:00
Felix Walter
cc4c79848b CI: Run unit and integration tests with sanitizers
This enables ASAN and UBSAN in our unit and integration tests.
Another integration test using the thread (data race) sanitizer is added
to detect such issues as well.

The tests are extended such that they wait for uD3TN (all instances if
we launch multiple ones) to terminate, to allow for exit checks of
sanitizers to run. For example, ASAN and the thread sanitizer make use
of this and we need to obtain the exit status code to tell whether the
CI job succeeded or not.

Note that memory leak detection is turned off in the unit tests as they
do not properly deallocate temporary variables, see: #104

aap_send and aap_receive are always invoked with `-v` to get more
information on what happens there in the tests.

Fixes: #55

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2023-05-10 14:24:31 +02:00
Felix Walter
c63eaa0cd0 routing_table: Merge overlapping contacts during configuration
Previously we would simply ignore any contact that was overlapping. This
changes the routing table's behavior such that overlapping contacts with
the same node are merged and overlapping contacts with multiple
different nodes are just allowed and added alongside each other. The
maximum number of contacts defined by `MAX_CONCURRENT_CONTACTS` now is
just a limitation of the Contact Manager which will not process more
than that number of contacts at the same time. (If one of them ends, a
concurrent contact that was not handled can be added.)

This change requires, however, that overlapping contacts are properly
rejected in router commands. This is achieved by a corresponding update
of the add/update/delete functions and an extension of the preliminary
checks.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2022-12-07 21:04:30 +01:00