mirror of
https://gitlab.com/d3tn/ud3tn.git
synced 2026-08-13 12:33:27 +02:00
Prepare PyPi packages
To distribute the pyD3TN DTN protocol implementations as well as the uD3TN python utilities on PyPi, the Python code is organized in separate directories and the PyPi packaging guideline is applied. The restructuring also requires an adjustment of the imports in the scripts in tools/ and test/. Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
This commit is contained in:
parent
99d4a276e1
commit
45bbccebb6
44 changed files with 298 additions and 107 deletions
|
|
@ -174,7 +174,7 @@ python-stylecheck:
|
|||
script:
|
||||
- make virtualenv
|
||||
# We ignore the alignment spaces in pyupcn and bare except in the tests.
|
||||
- source .venv/bin/activate && python -m flake8 pyupcn test/integration tools/aap tools/cla --max-complexity=12 --per-file-ignores='pyupcn/*.py:E221,test/integration/*:E722'
|
||||
- source .venv/bin/activate && python -m flake8 pyd3tn python-ud3tn-utils test/integration tools/aap tools/cla --max-complexity=12 --per-file-ignores='python-ud3tn-utils/ud3tn_utils/*.py:E221,pyd3tn/*.py:E221,test/integration/*:E722'
|
||||
|
||||
clang-tidy-posix:
|
||||
stage: code_quality_test
|
||||
|
|
|
|||
|
|
@ -533,7 +533,7 @@ OF SUCH DAMAGE.
|
|||
- Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams
|
||||
- external/unity/*
|
||||
- Copyright (c) 2015 Bastian Molkenthin
|
||||
- pyupcn/crc.py
|
||||
- pyd3tn/pyd3tn/crc.py
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
The source code available in the components/, include/, pyupcn/, test/ and
|
||||
tools/ folders and subfolders of them and not explicitly mentioned to be
|
||||
taken from other sources is distributed under the following license:
|
||||
The source code available in the components/, include/, test/ and tools/
|
||||
folders and subfolders of them and not explicitly mentioned to be taken from
|
||||
other sources is distributed under the license provided below. The Python
|
||||
modules available in pyd3tn/ and python-ud3tn-utils/ are subject to the
|
||||
licenses documented in the module directories.
|
||||
|
||||
Copyright (c) 2014-2020, µPCN team (see below)
|
||||
Copyright (c) 2020, µD3TN team and D3TN GmbH (Contact: contact@d3tn.com)
|
||||
|
|
|
|||
8
Makefile
8
Makefile
|
|
@ -127,10 +127,9 @@ virtualenv:
|
|||
@python3 -m venv --without-pip $(VENV)
|
||||
@echo "Install latest pip package ..."
|
||||
@$(GET_PIP)
|
||||
@echo "Install pyupcn to site-packages ..."
|
||||
@$(VENV)/bin/python ./pyupcn/install.py
|
||||
@echo "Install dependencies ..."
|
||||
@$(PIP) install -U -r ./pyupcn/requirements.txt
|
||||
@echo "Install local dependencies to site-packages..."
|
||||
@$(PIP) install -U -e ./pyd3tn ./python-ud3tn-utils
|
||||
@echo "Install additional dependencies ..."
|
||||
@$(PIP) install -U -r ./test/integration/requirements.txt
|
||||
@$(PIP) install -U -r ./tools/analysis/requirements.txt
|
||||
@$(PIP) install -U -r ./tools/cla/requirements.txt
|
||||
|
|
@ -144,7 +143,6 @@ virtualenv:
|
|||
.PHONY: update-virtualenv
|
||||
update-virtualenv:
|
||||
$(PIP) install -U setuptools pip wheel
|
||||
$(PIP) install -U -r ./pyupcn/requirements.txt
|
||||
$(PIP) install -U -r ./test/integration/requirements.txt
|
||||
$(PIP) install -U -r ./tools/analysis/requirements.txt
|
||||
$(PIP) install -U -r ./tools/cla/requirements.txt
|
||||
|
|
|
|||
|
|
@ -120,9 +120,10 @@ in `./doc/testing.md`.
|
|||
License
|
||||
-------
|
||||
|
||||
The code in `./components`, `./include`, `./pyupcn`, `./test`, and `./tools`
|
||||
has been developed specifically for µD3TN and is released under a BSD 3-clause
|
||||
license. The license can be found in `./LICENSE.txt`.
|
||||
The code in `./components`, `./include`, `./pyd3tn`, `./python-ud3tn-utils`,
|
||||
`./test`, and `./tools` has been developed specifically for µD3TN and is
|
||||
released under a BSD 3-clause license. The license can be found in
|
||||
`./LICENSE.txt`, `./pyd3tn/LICENSE`, and `./python-ud3tn-utils/LICENSE`.
|
||||
|
||||
External code
|
||||
-------------
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* CRC implementation based on lookup tables
|
||||
*
|
||||
* The tables are generated by the Python module in "pyupcn/crc.py". This
|
||||
* script is based on the JavaScript implementation on:
|
||||
* The tables are generated by the Python module in "pyd3tn/pyd3tn/crc.py".
|
||||
* This script is based on the JavaScript implementation on:
|
||||
*
|
||||
* http://www.sunshine2k.de/coding/javascript/crc/crc_js.html
|
||||
*
|
||||
|
|
@ -188,7 +188,7 @@ uint16_t crc16_ccitt_false(const uint8_t *data, size_t len)
|
|||
* Initial value: 0xffffffff
|
||||
* Final XOR value: 0xffffffff
|
||||
*
|
||||
* import pyupcn.crc as crc
|
||||
* import pyd3tn.crc as crc
|
||||
* print(", ".join(hex(e) for e in crc.crc32_c.calculate_crc_table_reflected()))
|
||||
*/
|
||||
static const uint32_t crc32_table[256] = {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ test implementations. The scripts are located in the [tools/](tools/) directory.
|
|||
The integration test toolchain can be found in the
|
||||
[test/integration/](test/integration/) directory. Both leverage a Python 3
|
||||
implementation of several DTN protocols and convergence layers, provided in the
|
||||
[pyupcn/](pyupcn/) directory.
|
||||
[pyd3tn/](pyd3tn/) directory.
|
||||
|
||||
A [venv](https://docs.python.org/3/library/venv.html) is used to isolate the
|
||||
µD3TN Python environment from the system. The Makefile target `virtualenv`
|
||||
|
|
@ -34,10 +34,10 @@ source .venv/bin/activate
|
|||
```
|
||||
|
||||
The `tools/` directory is added to the virtualenv site-packages allowing the
|
||||
import of packages residing in `tools/` like the `pyupcn` package, e.g.
|
||||
import of packages residing in `tools/` like the `pyd3tn` package, e.g.
|
||||
|
||||
```python
|
||||
from pyupcn.bundle7 import serialize_bundle7
|
||||
from pyd3tn.bundle7 import serialize_bundle7
|
||||
|
||||
serialize_bundle7("dtn:GS1", "dtn:GS2", b"Hello world!")
|
||||
```
|
||||
|
|
|
|||
4
pyd3tn/.gitignore
vendored
Normal file
4
pyd3tn/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
build/
|
||||
dist/
|
||||
*.egg-info/
|
||||
|
||||
27
pyd3tn/LICENSE
Normal file
27
pyd3tn/LICENSE
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2014-2020, µPCN team
|
||||
Copyright (c) 2020, µD3TN team and D3TN GmbH (Contact: contact@d3tn.com)
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the µD3TN team nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL the µD3TN team BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
39
pyd3tn/README.md
Normal file
39
pyd3tn/README.md
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
# pyD3TN
|
||||
|
||||
pyD3TN is a collection of protocol implementations of the *Delay-Tolerant
|
||||
Networking (DTN) Architecture* ([RFC4838][rfc4838]) for Python.
|
||||
|
||||
Besides the *Bundle Protocol* implementations [BPv6][bpv6] and [BPv7][bpv7],
|
||||
implementations of the *Convergence Layer Adapters* (CLAs) for TCP
|
||||
([MTCP][mtcp], [TCPCLv3][tcpclv3]) and the Space Packet Protocol ([SPP][spp])
|
||||
are included.
|
||||
|
||||
## Installation
|
||||
|
||||
From source:
|
||||
|
||||
```sh
|
||||
git clone https://gitlab.com/d3tn/ud3tn
|
||||
cd pyd3tn
|
||||
python setup.py install
|
||||
```
|
||||
|
||||
From [PyPi](https://pypi.org/project/pyD3TN/) directly:
|
||||
|
||||
```sh
|
||||
pip install pyd3tn
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
pyD3TN is maintained as part of the µD3TN project and follows its development
|
||||
processes. Please see the [µD3TN][ud3tn] repository for the code and further
|
||||
information.
|
||||
|
||||
[rfc4838]: https://tools.ietf.org/html/rfc4838
|
||||
[bpv6]: https://tools.ietf.org/html/rfc5050
|
||||
[bpv7]: https://tools.ietf.org/html/draft-ietf-dtn-bpbis-25
|
||||
[mtcp]: https://tools.ietf.org/html/draft-ietf-dtn-mtcpcl-00
|
||||
[tcpclv3]: https://tools.ietf.org/html/rfc7242
|
||||
[spp]: https://public.ccsds.org/Pubs/133x0b2e1.pdf
|
||||
[ud3tn]: https://gitlab.com/d3tn/ud3tn
|
||||
5
pyd3tn/pyd3tn/__init__.py
Normal file
5
pyd3tn/pyd3tn/__init__.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
"""Protocol implementations of the DTN architecture"""
|
||||
|
||||
from . import bundle6, bundle7, mtcp, spp, tcpcl
|
||||
|
||||
__all__ = ['bundle6', 'bundle7', 'mtcp', 'spp', 'tcpcl']
|
||||
|
|
@ -8,16 +8,6 @@ Dependencies:
|
|||
.. code:: bash
|
||||
|
||||
pip install cbor
|
||||
|
||||
Usage:
|
||||
If you are in the root directory of the µPCN project you can simply run:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
python3 -m tools.pyupcn
|
||||
|
||||
This will execute the ``__main__.py`` script next to this file.
|
||||
See PEP 3122 for more details about it.
|
||||
"""
|
||||
import struct
|
||||
import threading
|
||||
|
|
@ -83,7 +83,7 @@ class MTCPConnection(MTCPSocket):
|
|||
|
||||
.. code:: python
|
||||
|
||||
from pyupcn.mtcp import MTCPConnection
|
||||
from pyd3tn.mtcp import MTCPConnection
|
||||
|
||||
with MTCPConnection('127.0.0.1', 4224) as conn:
|
||||
conn.send(bundle)
|
||||
|
|
@ -346,7 +346,7 @@ class TCPSPPConnection(object):
|
|||
|
||||
.. code:: python
|
||||
|
||||
from pyupcn.spp import TCPSPPConnection
|
||||
from pyd3tn.spp import TCPSPPConnection
|
||||
|
||||
with TCPSPPConnection('127.0.0.1', 4223) as conn:
|
||||
conn.send(bundle)
|
||||
|
|
@ -78,7 +78,7 @@ class TCPCLConnection(object):
|
|||
|
||||
.. code:: python
|
||||
|
||||
from pyupcn.tcpcl import TCPCLConnection
|
||||
from pyd3tn.tcpcl import TCPCLConnection
|
||||
|
||||
with TCPCLConnection('dtn://my-eid.dtn', '127.0.0.1', 4223) as conn:
|
||||
conn.send(bundle)
|
||||
|
|
@ -270,7 +270,7 @@ class TCPCLServer(object):
|
|||
.. code:: python
|
||||
|
||||
import asyncio
|
||||
from pyupcn.tcpcl import TCPCLServer
|
||||
from pyd3tn.tcpcl import TCPCLServer
|
||||
|
||||
async def listen():
|
||||
async with TCPCLServer('dtn:me', '127.0.0.1', 42420) as server:
|
||||
20
pyd3tn/setup.py
Normal file
20
pyd3tn/setup.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import setuptools
|
||||
|
||||
with open('README.md', 'r') as file:
|
||||
long_description = file.read()
|
||||
|
||||
setuptools.setup(
|
||||
name='pyD3TN',
|
||||
version='0.1.0',
|
||||
author='D3TN GmbH',
|
||||
author_email='contact@d3tn.com',
|
||||
description='Collection of DTN protocol implementations',
|
||||
long_description=long_description,
|
||||
long_description_content_type='text/markdown',
|
||||
url='https://gitlab.com/d3tn/ud3tn',
|
||||
packages=['pyd3tn'],
|
||||
install_requires=['cbor'],
|
||||
python_requires='>=3.7',
|
||||
)
|
||||
4
python-ud3tn-utils/.gitignore
vendored
Normal file
4
python-ud3tn-utils/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
build/
|
||||
dist/
|
||||
*.egg-info/
|
||||
|
||||
27
python-ud3tn-utils/LICENSE
Normal file
27
python-ud3tn-utils/LICENSE
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2014-2020, µPCN team
|
||||
Copyright (c) 2020, µD3TN team and D3TN GmbH (Contact: contact@d3tn.com)
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the µD3TN team nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL the µD3TN team BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
44
python-ud3tn-utils/README.md
Normal file
44
python-ud3tn-utils/README.md
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# python-uD3TN-utils
|
||||
|
||||
The Python package uD3TN-utils is a utility library to simplify the interaction
|
||||
with the uD3TN daemon within python applications.
|
||||
|
||||
The included `AAPClient` enables user-friendly communication with the uD3TN
|
||||
daemon via local or remote sockets using the Application Agent Protocol (AAP).
|
||||
Besides sending and receiving bundles, it is also possible to change the
|
||||
configuration of the uD3TN daemon via AAP messages.
|
||||
|
||||
## Installation
|
||||
|
||||
From source:
|
||||
|
||||
```sh
|
||||
git clone https://gitlab.com/d3tn/ud3tn
|
||||
cd python-ud3tn-utils
|
||||
python setup.py install
|
||||
```
|
||||
|
||||
From [PyPi](https://pypi.org/project/ud3tn-utils) directly:
|
||||
|
||||
```sh
|
||||
pip install ud3tn-utils
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
```python
|
||||
from ud3tn_utils.aap import AAPUnixClient
|
||||
|
||||
with AAPUnixClient() as aap_client:
|
||||
aap_client.register()
|
||||
aap_client.send_str(aap_client.eid(), "Hello World")
|
||||
print(aap_client.receive())
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
pyD3TN is maintained as part of the µD3TN project and follows its development
|
||||
processes. Please see the [µD3TN][ud3tn] repository for the code and further
|
||||
information.
|
||||
|
||||
[ud3tn]: https://gitlab.com/d3tn/ud3tn
|
||||
19
python-ud3tn-utils/setup.py
Normal file
19
python-ud3tn-utils/setup.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import setuptools
|
||||
|
||||
with open('README.md', 'r') as file:
|
||||
long_description = file.read()
|
||||
|
||||
setuptools.setup(
|
||||
name='ud3tn-utils',
|
||||
version='0.1.0',
|
||||
author='D3TN GmbH',
|
||||
author_email='contact@d3tn.com',
|
||||
description='μD3TN Utilities',
|
||||
long_description=long_description,
|
||||
long_description_content_type='text/markdown',
|
||||
url='https://gitlab.com/d3tn/ud3tn',
|
||||
packages=['ud3tn_utils', 'ud3tn_utils.aap'],
|
||||
python_requires='>=3.6',
|
||||
)
|
||||
5
python-ud3tn-utils/ud3tn_utils/__init__.py
Normal file
5
python-ud3tn-utils/ud3tn_utils/__init__.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
"""Python library for the µD3TN project"""
|
||||
|
||||
from . import config
|
||||
|
||||
__all__ = ['config']
|
||||
11
python-ud3tn-utils/ud3tn_utils/aap/__init__.py
Normal file
11
python-ud3tn-utils/ud3tn_utils/aap/__init__.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
from .aap_client import AAPClient, AAPTCPClient, AAPUnixClient
|
||||
from .aap_message import AAPMessage, AAPMessageType, InsufficientAAPDataError
|
||||
|
||||
__all__ = [
|
||||
'AAPClient',
|
||||
'AAPTCPClient',
|
||||
'AAPUnixClient',
|
||||
'AAPMessage',
|
||||
'AAPMessageType',
|
||||
'InsufficientAAPDataError'
|
||||
]
|
||||
|
|
@ -5,7 +5,7 @@ import logging
|
|||
import socket
|
||||
import uuid
|
||||
|
||||
from pyupcn.aap import AAPMessage, AAPMessageType, InsufficientAAPDataError
|
||||
from .aap_message import AAPMessage, AAPMessageType, InsufficientAAPDataError
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
"""uPCN Application Agent Protocol (AAP) Python implementation.
|
||||
"""μD3TN Application Agent Protocol (AAP) Python implementation.
|
||||
|
||||
Usage:
|
||||
Use the AAPMessage class to build, serialize, and parse AAP messages.
|
||||
For a description of the protocol, see doc/upcn_aap.md.
|
||||
For a description of the protocol, see
|
||||
https://gitlab.com/d3tn/ud3tn/-/blob/master/doc/ud3tn_aap.md.
|
||||
"""
|
||||
|
||||
import struct
|
||||
|
|
@ -3,11 +3,29 @@ import time
|
|||
import struct
|
||||
|
||||
from collections import namedtuple
|
||||
from .helpers import unix2dtn
|
||||
from datetime import datetime, timezone
|
||||
|
||||
UNIX_EPOCH = datetime(1970, 1, 1, tzinfo=timezone.utc)
|
||||
DTN_EPOCH = datetime(2000, 1, 1, tzinfo=timezone.utc)
|
||||
UNIX_TO_DTN_OFFSET = (DTN_EPOCH - UNIX_EPOCH).total_seconds()
|
||||
assert UNIX_TO_DTN_OFFSET == 946684800
|
||||
|
||||
|
||||
def unix2dtn(unix_timestamp):
|
||||
"""Converts a given Unix timestamp into a DTN timestamp
|
||||
|
||||
Its inversion is :func:`dtn2unix`.
|
||||
|
||||
Args:
|
||||
unix_timestamp: Unix timestamp
|
||||
Returns:
|
||||
numeric: DTN timestamp
|
||||
"""
|
||||
return unix_timestamp - UNIX_TO_DTN_OFFSET
|
||||
|
||||
|
||||
class RouterCommand(enum.IntEnum):
|
||||
"""uPCN Command Constants"""
|
||||
"""uD3TN Command Constants"""
|
||||
ADD = 1
|
||||
UPDATE = 2
|
||||
DELETE = 3
|
||||
|
|
@ -15,7 +33,7 @@ class RouterCommand(enum.IntEnum):
|
|||
|
||||
|
||||
Contact = namedtuple('Contact', ['start', 'end', 'bitrate'])
|
||||
Contact.__doc__ = """named tuple holding upcn contact information
|
||||
Contact.__doc__ = """named tuple holding uD3TN contact information
|
||||
|
||||
Attrs:
|
||||
start (int): DTN timestamp when the contact starts
|
||||
|
|
@ -45,8 +63,8 @@ def make_contact(start_offset, duration, bitrate):
|
|||
|
||||
|
||||
class ConfigMessage(object):
|
||||
"""upcn configuration message that can be processes by its config agent.
|
||||
These messages are used to configure contacts in upcn.
|
||||
"""uD3TN configuration message that can be processes by its config agent.
|
||||
These messages are used to configure contacts in uD3TN.
|
||||
|
||||
Args:
|
||||
eid (str): The endpoint identifier of a contact
|
||||
|
|
@ -73,7 +91,7 @@ class ConfigMessage(object):
|
|||
)
|
||||
|
||||
def __str__(self):
|
||||
# missing escaping has to be addresses in uPCN
|
||||
# missing escaping has to be addresses in uD3TN
|
||||
for part in [self.eid, self.cla_address] + self.reachable_eids:
|
||||
assert "(" not in part
|
||||
assert ")" not in part
|
||||
|
|
@ -110,7 +128,7 @@ class ConfigMessage(object):
|
|||
|
||||
|
||||
class ManagementCommand(enum.IntEnum):
|
||||
"""uPCN Management Command Constants"""
|
||||
"""uD3TN Management Command Constants"""
|
||||
SET_TIME = 0
|
||||
|
||||
|
||||
|
|
@ -1 +0,0 @@
|
|||
"""Python tools for the µPCN project"""
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
"""Simple installation script for Python modules in the tools/ directory of the
|
||||
µPCN project.
|
||||
|
||||
Usage:
|
||||
Simply execute this script with the Python interpret of your choice. The
|
||||
tools/ directory will be added to the system paths.
|
||||
|
||||
.. code:: bash
|
||||
|
||||
python tools/pyupcn/install.py
|
||||
"""
|
||||
import site
|
||||
import os
|
||||
|
||||
tools_dir = os.path.abspath(os.path.join(__file__, '../..'))
|
||||
site_dir = site.getsitepackages()[0]
|
||||
|
||||
|
||||
def install():
|
||||
"""Adds a ``.pth`` file to the site-packages directory of the Python
|
||||
interpreter executing this script. The .pth file contains the path to the
|
||||
``tools/`` directory of the µPCN project.
|
||||
"""
|
||||
with open(os.path.join(site_dir, 'pyupcn.pth'), 'w') as fd:
|
||||
fd.write(tools_dir)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
install()
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
# Python dependencies for the pyupcn package
|
||||
cbor
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import os
|
||||
|
||||
from pyupcn.agents import ConfigMessage, RouterCommand
|
||||
from pyupcn.bundle7 import Bundle, CRCType
|
||||
from ud3tn_utils.config import ConfigMessage, RouterCommand
|
||||
from pyd3tn.bundle7 import Bundle, CRCType
|
||||
|
||||
USER_SELECTED_CLA = os.environ.get("CLA", None)
|
||||
TESTED_CLAS = [USER_SELECTED_CLA] if USER_SELECTED_CLA else [
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@ import copy
|
|||
|
||||
import pytest
|
||||
|
||||
from pyupcn.agents import ConfigMessage, make_contact
|
||||
from pyupcn.bundle7 import serialize_bundle7, BundleProcFlag
|
||||
from pyupcn.spp import TCPSPPConnection
|
||||
from ud3tn_utils.config import ConfigMessage, make_contact
|
||||
|
||||
from pyd3tn.bundle7 import serialize_bundle7, BundleProcFlag
|
||||
from pyd3tn.spp import TCPSPPConnection
|
||||
|
||||
from .helpers import (
|
||||
TESTED_CLAS,
|
||||
|
|
@ -113,7 +114,7 @@ def receive_and_check(conn, validate_func, is_frag_func, expected_bundles):
|
|||
print("Waiting to receive bundle #{}...".format(i))
|
||||
try:
|
||||
bdl = conn.recv_bundle()
|
||||
except:
|
||||
except Exception:
|
||||
print("Reception did not finish.")
|
||||
raise
|
||||
decoded = validate_func(bdl, None)
|
||||
|
|
|
|||
|
|
@ -3,12 +3,15 @@ import math
|
|||
|
||||
import pytest
|
||||
|
||||
from pyupcn.agents import ConfigMessage, make_contact, serialize_set_time_cmd
|
||||
from pyupcn.bundle7 import serialize_bundle7
|
||||
from pyupcn.bundle6 import serialize_bundle6
|
||||
from pyupcn.mtcp import MTCPConnection
|
||||
from pyupcn.spp import TCPSPPConnection
|
||||
from pyupcn.tcpcl import TCPCLConnection
|
||||
from ud3tn_utils.config import (
|
||||
ConfigMessage, make_contact, serialize_set_time_cmd
|
||||
)
|
||||
|
||||
from pyd3tn.bundle7 import serialize_bundle7
|
||||
from pyd3tn.bundle6 import serialize_bundle6
|
||||
from pyd3tn.mtcp import MTCPConnection
|
||||
from pyd3tn.spp import TCPSPPConnection
|
||||
from pyd3tn.tcpcl import TCPCLConnection
|
||||
|
||||
from .helpers import (
|
||||
TESTED_CLAS,
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@
|
|||
import argparse
|
||||
import logging
|
||||
|
||||
from pyupcn.agents import ConfigMessage, make_contact
|
||||
from ud3tn_utils.aap import AAPTCPClient, AAPUnixClient
|
||||
|
||||
from ud3tn_utils.config import ConfigMessage, make_contact
|
||||
|
||||
from aapclient import AAPTCPClient, AAPUnixClient
|
||||
|
||||
from helpers import (
|
||||
add_socket_group_parser_arguments,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import argparse
|
|||
import logging
|
||||
import sys
|
||||
|
||||
from aapclient import AAPUnixClient, AAPTCPClient
|
||||
from ud3tn_utils.aap import AAPUnixClient, AAPTCPClient
|
||||
from helpers import add_common_parser_arguments, logging_level
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
import argparse
|
||||
import logging
|
||||
|
||||
from aapclient import AAPUnixClient, AAPTCPClient
|
||||
from ud3tn_utils.aap import AAPUnixClient, AAPTCPClient
|
||||
from helpers import add_common_parser_arguments, logging_level
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
# encoding: utf-8
|
||||
|
||||
from aapclient import AAPUnixClient
|
||||
from ud3tn_utils.aap import AAPUnixClient
|
||||
|
||||
AGENT_ID = "testagent"
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
import socket
|
||||
import sys
|
||||
|
||||
from pyupcn.bundle7 import Bundle
|
||||
from pyupcn.mtcp import MTCPSocket
|
||||
from pyd3tn.bundle7 import Bundle
|
||||
from pyd3tn.mtcp import MTCPSocket
|
||||
|
||||
|
||||
def main():
|
||||
|
|
|
|||
|
|
@ -3,10 +3,11 @@
|
|||
|
||||
import time
|
||||
|
||||
from pyupcn.agents import ConfigMessage, make_contact
|
||||
from pyupcn.bundle7 import serialize_bundle7, Bundle
|
||||
from pyupcn.bundle6 import serialize_bundle6
|
||||
from pyupcn.mtcp import MTCPConnection
|
||||
from ud3tn_utils.config import ConfigMessage, make_contact
|
||||
|
||||
from pyd3tn.bundle7 import serialize_bundle7, Bundle
|
||||
from pyd3tn.bundle6 import serialize_bundle6
|
||||
from pyd3tn.mtcp import MTCPConnection
|
||||
|
||||
|
||||
SENDING_GS_DEF = ("dtn://sender.dtn", "sender")
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import logging
|
||||
import signal
|
||||
import asyncio
|
||||
from pyupcn.tcpcl import TCPCLServer, logger
|
||||
from pyd3tn.tcpcl import TCPCLServer, logger
|
||||
|
||||
|
||||
DEFAULT_INCOMING_EID = "dtn:1"
|
||||
|
|
|
|||
|
|
@ -5,14 +5,15 @@ import time
|
|||
import socket
|
||||
import argparse
|
||||
|
||||
from pyupcn.tcpcl import (
|
||||
from ud3tn_utils.config import ConfigMessage, make_contact
|
||||
|
||||
from pyd3tn.tcpcl import (
|
||||
serialize_tcpcl_contact_header,
|
||||
decode_tcpcl_contact_header,
|
||||
serialize_tcpcl_single_bundle_segment,
|
||||
)
|
||||
from pyupcn.agents import ConfigMessage, make_contact
|
||||
from pyupcn.bundle6 import serialize_bundle6
|
||||
from pyupcn.bundle7 import serialize_bundle7
|
||||
from pyd3tn.bundle6 import serialize_bundle6
|
||||
from pyd3tn.bundle7 import serialize_bundle7
|
||||
|
||||
DEFAULT_OUTGOING_EID = "dtn:2"
|
||||
DEFAULT_INCOMING_EID = "dtn:1"
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@
|
|||
|
||||
import socket
|
||||
|
||||
from pyupcn.agents import ConfigMessage, make_contact
|
||||
from pyupcn.bundle7 import serialize_bundle7, Bundle
|
||||
from pyupcn.bundle6 import serialize_bundle6
|
||||
from pyupcn.spp import SPPPacket, SPPPacketHeader, SPPTimecode
|
||||
from ud3tn_utils.config import ConfigMessage, make_contact
|
||||
|
||||
from pyd3tn.bundle7 import serialize_bundle7, Bundle
|
||||
from pyd3tn.bundle6 import serialize_bundle6
|
||||
from pyd3tn.spp import SPPPacket, SPPPacketHeader, SPPTimecode
|
||||
|
||||
|
||||
DEFAULT_OUTGOING_EID = "dtn:2"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue