pyion: A Python Extension for the Interplanetary Overlay Network¶
- Author:
Marc Sanchez Net
- Address:
4800 Oak Grove Dr. Pasadena, CA 91109
- Contact:
- Organization:
Jet Propulsion Laboratory (JPL)
- Release:
R2024a
- Repository:
- Abstract:
pyionis provides a set of Python C extensions that interface with the Interplanetary Overlay Network (ION), JPL’s implementation of the Delay Tolerant Networking (DTN) protocol stack.
Introduction¶
pyion provides a Python interface to JPL’s Interplantary Overlay Network (ION) to send/receive data through ION, as well as a limited and still experimental set of management functions to modify the ION configuration during runtime. Note that pyion does NOT install ION during its setup process. Instead, installation of pyion is only possible if ION is already available and running in the host.
To quickly demonstrate how pyion works, here is a brief example of two Python nodes exchanging data by interfacing with ION’s implementation of the Bundle Protocol (BP).
Example 1: BP Transmitter
1import pyion
2
3# Create a proxy to node 1 and attach to ION
4proxy = pyion.get_bp_proxy(1)
5
6# Open endpoint 'ipn:1.1' and send data to 'ipn:2.1'
7with proxy.bp_open('ipn:1.1') as eid:
8 eid.bp_send('ipn:2.1', b'hello')
Example 2: BP Receiver
1import pyion
2
3# Create a proxy to node 2 and attach to it
4proxy = pyion.get_bp_proxy(2)
5
6# Listen to 'ipn:2.1' for incoming data
7with proxy.bp_open('ipn:2.1') as eid:
8 while eid.is_open:
9 try:
10 # This is a blocking call.
11 print('Received:', eid.bp_receive())
12 except InterruptedError:
13 # User has triggered interruption with Ctrl+C
14 break
Pyion interfaces with ION through a collection of proxies. Each proxy is intended to be linked to a protocol in the DTN protocol stack (i.e., there is a proxy to the BP protocol, as seen in the previous example, but there are different proxies to LTP and CFDP, as well ION’s SDR and PSM), as well as a node number. To avoid having muliple proxies to the same node, proxies should not be created directly by the user but rather instantiated using pyion.get_<type>_proxy(<node_number>). Proxies are used to manage service access points to a given protocol (e.g., endpoint for the BP, entity for CFDP, etc.). This includes opening and closing them, as well as interrupting their operation if necessary. In turn, the access point itself is typically only used to send and receive data.
Multiple ION Nodes in a Single Host¶
If multiple instances of ION are running on the same host, each one with its own node number, then the ION_NODE_LIST_DIR environment variable needs to be defined (see the ION manual for further details). This can be done from Python by simply calling
1import pyion
2pyion.ION_NODE_LIST_DIR = '/<desired path>/nodes'
Reporting Bugs¶
Known bugs are currently documented at https://github.com/msancheznet/pyion/issues. Please submit new issues if new problems and/or bug occur.
Installation Instructions¶
Pyion is currently not hosted in any Python repository (e.g., pip, conda) because installation of the package is only possible in computers where ION is already available.
To compile ION and pyion, several dependencies are needed. Therefore, to facilitate the installation process, here is a dockerfile that automates the building an Ubuntu-based Docker image with both ION and pyion installed in them.
The steps shown in the file can also be used to install both programs in a host computer manually, and minimal adaptions are needed to operate in other operating systems. Also, note
that this file assumes that ION and pyion 4.1.3 are being installed. It is provided here as guidance, and the user should modify as needed.
1 # Define base image and pull it
2 ARG IMAGE_NAME=ubuntu:20.04
3 FROM $IMAGE_NAME
4
5 # =====================================================
6 # === SET WORKING DIRECTORY
7 # =====================================================
8
9 # Set environment variables.
10 ENV HOME /home
11 ENV ION_HOME /home/ion-open-source-4.1.3
12 ENV PYION_HOME /home/pyion-4.1.3
13 ENV PYION_BP_VERSION BPv7
14
15 # Define working directory.
16 WORKDIR /home
17
18 # =====================================================
19 # === INSTALL DEPENDENCIES
20 # =====================================================
21
22 # Install basic dependencies
23 RUN apt update
24 RUN apt install -y git
25 RUN apt install -y --no-install-recommends man-db
26 RUN apt install -y --no-install-recommends build-essential
27 RUN apt install -y --no-install-recommends dos2unix
28
29 # Install ION adependencies
30 RUN apt install -y --no-install-recommends autotools-dev
31 RUN apt install -y --no-install-recommends automake
32 RUN apt install -y --no-install-recommends libtool
33
34 # Install Python dependencies
35 RUN apt install -y --no-install-recommends python3-dev
36 RUN apt install -y --no-install-recommends python3-setuptools
37
38 # Clean up (see https://www.fromlatest.io/#/ and
39 # https://hackernoon.com/tips-to-reduce-docker-image-sizes-876095da3b34)
40 RUN rm -rf /var/lib/apt/lists/*
41
42 # =============================================================
43 # === DOWNLOAD, COMPILE AND BUILD ION
44 # =============================================================
45
46 RUN git clone --single-branch --branch ion-open-source-4.1.3 https://github.com/nasa-jpl/ION-DTN.git $ION_HOME
47
48 RUN \
49 cd $ION_HOME && \
50 autoreconf -fi && \
51 ./configure && \
52 make && \
53 make install && \
54 ldconfig
55
56 # =============================================================
57 # === DOWNLOAD PYION FROM GITHUB AND COMPILE IT
58 # =============================================================
59
60 RUN git clone --single-branch --branch v4.1.3 https://github.com/msancheznet/pyion.git $PYION_HOME
61
62 RUN \
63 cd $PYION_HOME && \
64 find $PYION_HOME -type f -print0 | xargs -0 dos2unix && \
65 python3 setup.py install && \
66 chmod -R +x $PYION_HOME
67
68 # =====================================================
69 # === OPEN BASH TERMINAL UPON START
70 # =====================================================
71
72 # Define default command.
73 CMD ["tail", "-f", "/dev/null"]
To use this dockerfile in a host with Docker, simply run:
1docker build -t pyion_bpv7:4.1.3 -f .\pyion_v413_bpv7.dockerfile --build-arg IMAGE_NAME=ubuntu:20.04 .
- Note that to install pyion, three environment variables are used:
$ION_HOME, which points to the base path where the ION source code is located (i.e., it contains the ION manual)$PYION_HOME, which points to the base path where the pyion source code is located (i.e., it containssetup.py)$PYION_BP_VERSION. It must be set to eitherBPv6orBPv7, depending on which version of the BP was used when compiling ION.
Additionally, the user can also specify the LD_LIBRARY_PATH environment variable to indicate the location of the ION shared libraries (.h and .so files).
Finally, to use pyion with BPv6, ION must also be configured to use BPv6. This is achieved by using ./configure --enable-bpv6 while compiling ION.
Dependencies¶
The only dependency pyion uses is ION itself. All tests conducted to date have been performed using an Ubuntu-based operating system running in either a laptop, a Docker container, or a Raspberry Pi (arm architecture). The package might also work in other setups, but there is no guarantee that this is the case.
Pyion is internally built as a collection of Python C Extensions wrapped in Python classes or functions. These C extensions are compiled during the package’s installation process and require access to the ION’s public and potentially private interfaces (a collection of .h and .so files in an Ubuntu-based host). Therefore, setup.py makes the following assumptions on where these are located in the host file system:
Public ION Interface: Required for installing
pyion. It is assumed to be located at/usr/local/includeandusr/local/libunless the environment variableLD_LIBRARY_PATHis available.Private ION interface: Optional for installing
pyion. If not available, thenpyionhas all administrative functions disabled. To enable them, set the environment variableION_HOMEto ION’s root folder and then run the setup process.
Copyright and Licensing¶
Copyright (c) 2019, California Institute of Technology (“Caltech”). U.S. Government sponsorship acknowledged.
pyion is currently an open-source package distributed under the Apache 2.0 license.
Disclaimers¶
Pyion is an experimental package developed in an ad-hoc basis as projects identify new needs. Basic functionality such as sending/receiving from through BP, LTP or CFDP has been tested somewhat exhaustively and thus should be stable. Newer functionality such as monitoring the state of ION’s SDR and PSM, or performing administrative functions (e.g., modify the contact plan, change an LTP span configuration parameter) are still being developed and might contain errors or simply not work.
Contents¶
- 1. BPv6 vs. BPv7
- 2. Interface with the Bundle Protocol (BP)
- 3. Interface with the Lickelider Transmission Protocol (LTP)
- 4. Interface with the CCSDS File Delivery Protocol (CFDP)
- 5. Interface with ION’s Memory/Storage
- 6. ION Management Functions
- 7. Reference Guide
- 8. Copyright and Licensing