udpcl package

The UDPCL demonstration messaging and CL agent.

Subpackages

Submodules

Implementation of a symmetric UDPCL agent.

udpcl.agent.IP_PMTUDISC_PROBE = 3

Delay in milliseconds

class udpcl.agent.ExtensionKey(*values)

Bases: IntEnum

Extension map keys.

TRANSFER = 2
SENDER_LISTEN = 3
SENDER_NODEID = 4
STARTTLS = 5
PEER_PROBE = 6
PEER_CONFIRM = 7
ECN_COUNTS = 8
class udpcl.agent.BundleItem(address, port, file, local_if=None, local_address=None, local_port=None, transfer_id=None, total_length=None, ip_tos=0, sock_opts=<factory>)

Bases: object

State for RX and TX full bundles.

address: str
port: int
file: BinaryIO
local_if: Optional[int] = None

Optional local interface index

local_address: Optional[str] = None
local_port: Optional[int] = None
transfer_id: Optional[int] = None
total_length: Optional[int] = None
ip_tos: int = 0

The whole TOS (DSCP + ECN bits)

sock_opts: List[Tuple]

Additional three-tuple of socket.setsockopt() parameters

class udpcl.agent.Transfer(address, port, xfer_id, total_length, total_valid=None, valid=None, data=None)

Bases: object

State for fragmented transfers.

address: str
port: int
xfer_id: int
total_length: int
total_valid: Optional[Interval] = None
valid: Optional[Interval] = None
data: Optional[bytearray] = None
property key
validate(other)

Validate an other transfer against this base.

class udpcl.agent.AddressObject(text, proto=17)

Bases: object

Interpret a text address as an ipaddress object.

Parameters:

text (Optional[str]) – The input to convert.

class udpcl.agent.Conversation(family=None, peer_address=None, peer_port=None, local_if=None, local_address=None, local_port=None)

Bases: object

Bookkeep parameters of a UDP conversation which is address-and-port for each side.

family: Optional[int] = None
peer_address: Optional[_BaseAddress] = None
peer_port: Optional[int] = None
local_if: Optional[int] = None

Local interface index

local_address: Optional[_BaseAddress] = None
local_port: Optional[int] = None
static pat_match(lt, rt)

Match tuples by-value or if one of the sides has None (i.e. unspecified).

find_in(dictlike, default=None)

Search a dictionary for exact-match or pattern-match.

property key
make_local_socket()

Get a socket based on local requirements. :return: A UDP socket object.

get_peer_addr()

Get a peer address suitable for use with socket.sendto(). :return: An address tuple.

class udpcl.agent.EcnCounts(ect0=0, ect1=0, ce=0)

Bases: object

Count of ECN codepoints from a peer address.

ect0: int = 0
ect1: int = 0
ce: int = 0
class udpcl.agent.UdpSender(sock, sockaddr, opts=<factory>, ancdata=<factory>)

Bases: object

Functional class to send a UDP datagram with socket options.

sock: socket

Socket to send on.

sockaddr: Tuple

Peer destination address

opts: List[Tuple]

Additional three-tuple of socket.setsockopt() parameters

ancdata: List[Tuple]

Additional socket.sendmsg() ancillary data

class udpcl.agent.TxSendItem(item, sender=None, dgram_iter=None)

Bases: object

A single SDU item to transmit

item: BundleItem

Source bundle ID to signal on

sender: Callable[[bytes], None] = None

Callable to send one datagram with no extra parameters.

dgram_iter: Optional[Iterable[bytes]] = None

Current iterable of datagrams to pace.

class udpcl.agent.TxSendWait(agent, glib_timer_id=None, tok_avail=0, last_avail_ns=None, tok_rate=0, last_rate_ns=None, pri_item_queue=<factory>, tx_item_queue=<factory>, cur_item=None, cur_dgram=None, cur_ecn=None, last_ecn=None, srtt_ns=100000000, ecn_mss=1400, ecn_alpha=0, cwnd=0)

Bases: object

agent: Agent

The parent agent to report on

glib_timer_id: Optional[int] = None

GLib callback event ID

tok_avail: int = 0

Size of available bucket to send (millibytes)

last_avail_ns: Optional[int] = None

Time of last tok_avail update (nanoseconds)

tok_rate: int = 0

Rate of token availability (bytes per nanosecond)

last_rate_ns: Optional[int] = None

Time of last tok_rate update (nanoseconds)

pri_item_queue: List[TxSendItem]

Priority queue to process first

tx_item_queue: List[TxSendItem]

Normal queue to process in order

cur_item: Optional[TxSendItem] = None

Current iterable of datagrams to pace.

cur_dgram: Optional[bytes] = None

Next datagram to pace with definite size

cur_ecn: Optional[EcnCounts] = None

Counters most recently seen

last_ecn: Optional[EcnCounts] = None

Counters from last cycle

srtt_ns: int = 100000000

Estimated or assumed RTT (nanoseconds); default 100ms

ecn_mss: int = 1400

Estimated or assumed path MSS (bytes)

ecn_alpha: float = 0

Estimated alpha parameter (average CE marking rate)

cwnd: float = 0

Congestion control window size (datagram count)

start()

Set up timer callbacks as necessary

stop()
tick()

Increment the token counter.

Return type:

bool

udpcl.agent.range_encode(intvls)
Return type:

List[int]

udpcl.agent.range_decode(pairs)
Return type:

Interval

class udpcl.agent.Agent(config, bus_kwargs=None)

Bases: Object

Overall agent behavior.

Parameters:
  • config (Config) – The agent configuration object.

  • bus_kwargs (dict or None) – Arguments to dbus.service.Object constructor. If not provided the default dbus configuration is used.

DBUS_IFACE = 'org.ietf.dtn.udpcl.Agent'
is_transfer_idle()

Determine if the agent is idle.

Returns:

True if there are no data being processed RX or TX side.

set_on_stop(func)

Set a callback to be run when this agent is stopped.

Parameters:

func – The callback, which takes no arguments.

stop()

Immediately stop the agent and disconnect any sessions.

exec_loop()

Run this agent in an event loop. The on_stop callback is replaced to quit the event loop.

listen(address, port, opts=None)

Begin listening for incoming transfers and defer handling connections to glib event loop.

listen_stop(address, port)

Stop listening for transfers on an existing port binding.

polling_start(item)
polling_received(*args, **keywords)

Signal when a receive-path accept is received.

pmtud_start(address, port, stepcount)
recv_bundle_finished(*args, **keywords)

Indicate that a bundle has been received.

recv_bundle_get_queue()
recv_bundle_pop_data(bid)
recv_bundle_pop_file(bid, filepath)
send_bundle_fileobj(file, tx_params)

Send bundle from a file-like object.

Parameters:
  • file (file-like) – The file to send.

  • tx_params – Additional transfer parameters.

Returns:

The new transfer ID.

Return type:

int

send_bundle_data(data, tx_params)

Send bundle data directly.

send_bundle_started(*args, **keywords)
send_bundle_finished(*args, **keywords)

Command entry points.

udpcl.cmd.main()

Agent command entry point.

Agent configuration data.

class udpcl.config.ListenConfig(address, port=4556, multicast_member=<factory>)

Bases: object

address: str
port: int = 4556
multicast_member: List[Dict]
property opts

Encode options dictionary

class udpcl.config.PollConfig(address, port=4556, local_address=None, local_port=None, interval_ms=60000)

Bases: object

address: str
port: int = 4556
local_address: Optional[str] = None
local_port: Optional[int] = None
interval_ms: int = 60000
class udpcl.config.MulticastConfig(ttl=None)

Bases: object

ttl: Optional[int] = None
class udpcl.config.Config(log_level=None, enable_test=<factory>, bus_addr=None, bus_service=None, dtls_enable_tx=True, dtls_version=None, dtls_ciphers=None, dtls_ca_file=None, dtls_cert_file=None, dtls_key_file=None, require_tls=False, node_id='', default_tx_address=None, default_tx_port=None, mtu_default=None, ecn_init=True, ecn_feedback=True, ecn_feedback_min=datetime.timedelta(microseconds=20000), ecn_feedback_max=datetime.timedelta(seconds=1), multicast=<factory>, init_listen=<factory>, polling=<factory>)

Bases: object

Agent configuration.

log_level: Optional[str] = None
enable_test: Set[str]
bus_addr: Optional[str] = None
bus_service: Optional[str] = None
dtls_enable_tx: bool = True
dtls_version: Optional[str] = None
dtls_ciphers: Optional[str] = None
dtls_ca_file: Optional[str] = None
dtls_cert_file: Optional[str] = None
dtls_key_file: Optional[str] = None
require_tls: bool = False
node_id: str = ''
default_tx_address: Optional[str] = None
default_tx_port: Optional[int] = None
mtu_default: Optional[int] = None
ecn_init: bool = True

True if outgoing data packets are marked as ECT(1)

ecn_feedback: bool = True

True if incoming ECN-marked packets are responded to with feedback.

ecn_feedback_min: timedelta = datetime.timedelta(microseconds=20000)

Maximum interval between ECN feedback

ecn_feedback_max: timedelta = datetime.timedelta(seconds=1)

Maximum interval between ECN feedback

multicast: MulticastConfig
init_listen: List[ListenConfig]
polling: List[PollConfig]
from_file(fileobj)

Load configuration from a YAML file. :type fileobj: :param fileobj: The file to read from.

property bus_conn
get_ssl_connection(sock, server_side)

Get an dtls.SSLConnection object configured for this peer.