5. Interface with ION’s Memory/Storage

ION’s memory is divided in two parts, the Personal Space Management (PSM) and the Simple Data Recorder (SDR). The state of both the PSM and the SDR can be directly queried from pyion through the PsmProxy and SdrProxy, both of which are still experimental at this point.

Utilization of the PSM or SDR proxies works in a similar manner. The user starts a monitoring session during which the state of the system will be quiered at regular intervals as defined by the sampling rate (in Hz). Once the user has collected all necessary information, then both proxies must call stop_monitoring, a function that returns a dictionary of dictionaries, where the outer layer corresponds to the variable being monitored (e.g., small_pool, large_pool, summary, etc.) and the inner layer is a time index from the start of the monitoring sessions. This data can be then processed in tabular format using well-known data science libraries such as Pandas.

5.1. Example: Monitoring Session at Transmitter

 1import pyion
 2
 3# Create a proxy to node 1 and attach to ION
 4proxy = pyion.get_bp_proxy(1)
 5proxy.bp_attach()
 6
 7# Create proxy to SDR and PSM
 8sdr = pyion.get_sdr_proxy(1, 'node1')
 9psm = pyion.get_psm_proxy(1, 1)
10
11# Start monitoring at a rate of 100 Hz.
12sdr.start_monitoring(rate=100)
13psm.start_monitoring(rate=100)
14
15# Open endpoint 'ipn:1.1' and send data to 'ipn:2.1'
16with proxy.bp_open('ipn:1.1') as eid:
17    eid.bp_send('ipn:2.1', b'hello')
18
19# Get results
20sdr_res = sdr.stop_monitoring()
21psm_res = psm.stop_monitoring()