Link
rpps.link ¶
Link transform: data bits <-> packets: framing (HDLC, byte stuffing) and integrity checks (CRC, composite, checksum), defined in
config/crc, config/frame and config/header/link. Decoding refuses channel bits: decode them first (or rp.code.Uncoded() for no FEC)
A link header decodes packets too: a header inside a frame's payload ({"link": "frame"} then {"link": "header"}, the
frame step's frame and frame_bits driving the header's frame and length) strips a frame's own header and reads it.
Packets that cross frames (rpps.link.packets, {"link": "packets"}): a stream of packets in fixed frames' data fields,
cut back out by a pointer (CCSDS first header pointer, DVB-S2 SYNCD) and each packet's length, per channel.
Captures (rpps.link.capture): a profile's messages as packets of a link type (config/linktype), for Wireshark and
interfaces (rpps.source.PcapSink, rpps.source.Tun), each rule with its inverse for transmitting.
Modules:
| Name | Description |
|---|---|
bytestuff |
|
capture |
Captures: decoded frames as packets of a link type, for Wireshark (rpps.source.PcapSink) or an interface (rpps.source.Tun) |
check |
Composite checks: a check field built from CRCs over transformed views of the message |
checksum |
Checksums that are not CRCs: sums, ones' complement (Internet), Fletcher, Adler, XOR (LRC) |
crc |
|
encap |
Encapsulation parent classes |
fields |
Fields: what a frame's bits say, as a definition (link headers, frame payloads, a profile step's messages) |
gse |
Generic Stream Encapsulation (ETSI TS 102 606-1): PDUs in the data fields of DVB-S2 BBFRAMEs |
hdlc |
|
header |
Link headers: fields, a CRC, and the payload they announce (rpps.profile.control) |
kernels |
Batch kernels of the link operators: |
packets |
Packets that cross frames: a stream of packets carried in the data fields of fixed frames, cut back into packets |
serial |
Link definitions, one resource each: config/crc, config/frame, config/header/link; |
bytestuff ¶
Classes:
| Name | Description |
|---|---|
bytestuff |
Byte-stuffed framing (SLIP, KISS, asynchronous PPP): a flag byte between frames, and an escape byte before any |
bytestuff ¶
bytestuff(log, flag=192, escape=219, escapes=None, xor=None, escaped=None, fcs=None, refin=False, min_bytes=1)
Bases: _code
Byte-stuffed framing (SLIP, KISS, asynchronous PPP): a flag byte between frames, and an escape byte before any flag or escape byte inside one, defined by config (see config/frame)
flag: the frame delimiter (SLIP / KISS 0xC0, PPP 0x7E). escape: the escape byte (0xDB, 0x7D). escapes: {byte: what
follows the escape for it} (SLIP: {0xC0: 0xDC, 0xDB: 0xDD}); or xor: the escaped byte is the byte XOR this (PPP 0x20),
for the bytes in escaped (flag and escape when not given). fcs: a crc (or checksum) appended to each frame, or None.
refin: bytes sent least significant bit first (a UART); the bit stream is in bytes from its first bit.
min_bytes: shortest frame (with the FCS) kept.
The same interface as hdlc: encode(frames) the bits of a list of byte frames; frames_at(bits) every frame between
flags as (index of its opening flag's first bit, payload, fcs ok) and the aborts (an escape before a byte it doesn't
escape); decode_stream(bits, held) for a stream cut anywhere.
Methods:
| Name | Description |
|---|---|
frame |
The bytes of one frame: flag, the stuffed payload and FCS, flag |
frames_at |
Frames as (index of the opening flag in |
consumed |
How many of these bits are done with: whole bytes up to the last flag (a frame may be open there), or all whole |
decode_stream |
Decode |
Source code in src/rpps/link/bytestuff.py
frame ¶
The bytes of one frame: flag, the stuffed payload and FCS, flag
Source code in src/rpps/link/bytestuff.py
frames_at ¶
Frames as (index of the opening flag in bits, payload bytes, fcs ok, the FCS bytes received: b"" without an
FCS), and the number of aborted frames
Source code in src/rpps/link/bytestuff.py
consumed ¶
How many of these bits are done with: whole bytes up to the last flag (a frame may be open there), or all whole bytes when there is no flag (nothing can start one) or the frame after it has run too long
Source code in src/rpps/link/bytestuff.py
decode_stream ¶
Decode held (what the last call kept) and bits together: (data bits of the good frames, what to hold).
frames: a list to append every frame found to, as frames_at gives them (index in held + bits)
Source code in src/rpps/link/bytestuff.py
capture ¶
Captures: decoded frames as packets of a link type, for Wireshark (rpps.source.PcapSink) or an interface (rpps.source.Tun)
A profile's messages (rpps.profile.message) hold what each step decoded; a capture says how a kind of message becomes
the bytes a link type expects, and back again on transmit. Profiles say it in "capture", one rule a message kind:
"capture": {"pdu": {"linktype": "ble_ll_phdr", a config/linktype definition (or "find", below)
"include": ["header", "payload", "fcs"], the message's parts, in order (Message.parts)
"transform": [{"prefix": "0x8E89BED6", "bytes": 4, "order": "little"},
{"header": "ble_phdr", "channel": "channel"}],
"drop": "type == 3", messages left out (an expression over fields)
"fields": ["type.name", "length"]}, fields named in the packet's comment (true: all)
"frame": false} a kind not captured
A kind without a rule goes out as Wireshark's exported PDU (upper_pdu) to its "data" dissector, so it is still seen.
Parts. A step that knows more of its frame than the payload emits the whole frame with where each part is (a link
header: header, payload, FCS; an HDLC frame: payload, FCS). include takes them in order; without it the payload alone.
Transforms, applied in order, each with an inverse for transmit (unpacket):
| Transform | Receive | Transmit |
|---|---|---|
{"bit_order": "lsb"} |
each byte's bits reversed | the same |
{"prefix": v, "bytes": n, "order": "big"} |
n bytes of v (a constant, a field, an expression) before |
taken off (a field name: its value read back) |
{"suffix": v, "bytes": n, "order": "big"} |
after | taken off |
{"strip": {"head": n, "tail": m}, "fill": 0} |
n bytes off the front, m off the end (expressions) | put back, fill |
{"set": {"at": i, "value": v}, "was": w} |
byte i set to v (a restored sync byte) | set to w, when given |
{"fcs": "<crc definition>", "order": "big"} |
a check over the bytes so far, appended | checked and taken off |
{"header": "radiotap" \| "ble_phdr", ...} |
a pseudo-header built from the message (below) | taken off |
{"restore": "ppp_acfc_pfc"} |
a named repair an expression can't make (below) | its inverse |
Expressions see the message's fields (a group's as group.field), the profile's parameters, and size (the bytes so far).
Pseudo-headers. radiotap (802.11): flags (FCS at the end when fcs is true), rate (an expression in 500 kb/s
units), channel (MHz; the message's frequency when not given), 2.4 GHz CCK. ble_phdr (LINKTYPE_BLUETOOTH_LE_LL_WITH_PHDR):
the RF channel (0..39), dewhitened, the CRC checked and its verdict (the message's crc_ok).
Restores. ppp_acfc_pfc: puts back the address and control bytes (0xFF 0x03) a peer left out (ACFC), and widens a
one-byte protocol field (PFC) to two (RFC 1661 6.5, 6.6); transmitting, nothing to undo (uncompressed is always valid).
Finding a link type in a frame ("linktype": "find", "find": {"in": ["ethernet", "ipv4", "ipv6"], "max": 64}):
a frame with a header nobody describes, then a frame of a known link type. Each offset from min to max is tried
against the link types' signature (fields, a valid expression over them and size, a check over bytes that comes
out zero, and next: what follows by a field, an EtherType's IPv4); the first offset with the best score wins (1: the
fields are valid; 2: and the check holds; one more for each layer inside that scores too), at least score. The bytes before it are left out, and the packet takes that link type. Only where a frame starts is found:
nothing above the link layer is read. No match: the frame goes out whole, as exported PDU data, and is counted.
Exported PDU (upper_pdu): tags then the payload. The rule's dissector names Wireshark's dissector
("lte_rrc.bcch_dl_sch"); the protocol column says the profile and kind, the info column the check and fields.
Classes:
| Name | Description |
|---|---|
LinkType |
A link type (config/linktype): its pcap number ( |
Packet |
One captured frame: its link type and bytes, and what it was (from its message) |
Capture |
One message kind's capture rule (see module): |
Captures |
A profile's capture rules, by message kind ( |
Functions:
| Name | Description |
|---|---|
linktype |
A link type by name: |
convert |
A packet of link type |
by_dlt |
The link type of a pcap link type number (None: not one of config/linktype) |
linktypes |
Every link type's name |
find |
(offset, LinkType) where a frame of one of these link types starts in |
exported_pdu |
Wireshark's exported PDU (LINKTYPE_WIRESHARK_UPPER_PDU): tags (dissector, protocol and info columns), the end tag, |
unexported_pdu |
(dissector, payload) of an exported PDU |
LinkType ¶
A link type (config/linktype): its pcap number (dlt), the Linux ARPHRD a TUN takes for it (arphrd, proto:
the EtherType a TUN's packet information says), Wireshark's dissector, what it says of an FCS, and a signature
Methods:
| Name | Description |
|---|---|
score |
How well |
Source code in src/rpps/link/capture.py
score ¶
How well data starts a frame of this link type: 0 not at all, 1 its fields are valid, 2 and its check holds;
with a next (what follows, by a field: an EtherType), one more than what follows scores, when it scores.
bits: data unpacked already (MSB first), at least as far as the signature reads
Source code in src/rpps/link/capture.py
Packet ¶
Packet(linktype, data, profile='', kind='', check=None, crc_ok=None, sample=0, time=None, freq=None, quality=None, fields=None)
One captured frame: its link type and bytes, and what it was (from its message)
linktype: a LinkType; data: the bytes as the link type has them. profile, kind, check, crc_ok, sample, time, freq, quality: the message's; fields: the fields the rule names; comment(): one line of them, for a capture's comment
Source code in src/rpps/link/capture.py
Capture ¶
One message kind's capture rule (see module): packet(message) the Packet (None: dropped), unpacket(bytes) the
payload bytes and fields to transmit
Methods:
| Name | Description |
|---|---|
packet |
The message as a Packet of this rule's link type; None when |
forward |
The transforms applied to bytes alone (no message: no pseudo-headers, fields or parameters) |
unpacket |
(bytes, fields) for transmitting a packet of this rule's link type: the transforms undone in reverse (a prefix |
Source code in src/rpps/link/capture.py
packet ¶
The message as a Packet of this rule's link type; None when drop says so
Source code in src/rpps/link/capture.py
forward ¶
The transforms applied to bytes alone (no message: no pseudo-headers, fields or parameters)
Source code in src/rpps/link/capture.py
unpacket ¶
(bytes, fields) for transmitting a packet of this rule's link type: the transforms undone in reverse (a prefix named by a field gives that field). The bytes are the included parts, in order (the profile's Encoder splits them)
Source code in src/rpps/link/capture.py
Captures ¶
A profile's capture rules, by message kind ("capture" in a profile; see module). packet(message): its Packet,
None for a kind not captured or a message dropped. A kind without a rule: exported PDU data
Methods:
| Name | Description |
|---|---|
rule |
The rule for a kind (False: not captured) |
linktypes |
The link types the rules give, by kind (None: found per frame) |
Source code in src/rpps/link/capture.py
linktype ¶
A link type by name: linktype("ieee802_15_4") (config/linktype)
Source code in src/rpps/link/capture.py
convert ¶
A packet of link type src as one of link type dst, where one is the other with transforms (a link type's
"from": {other: [transforms]}, as a capture rule's: 802.15.4 with FCS is 802.15.4 without, its FCS appended; AX.25
with its KISS byte is AX.25 with a 0 before). ValueError where neither says how (or a check to take off fails)
Source code in src/rpps/link/capture.py
by_dlt ¶
The link type of a pcap link type number (None: not one of config/linktype)
linktypes ¶
find ¶
(offset, LinkType) where a frame of one of these link types starts in data: the best score, the first offset
of it, from lo to hi; (None, None) when none scores least
Source code in src/rpps/link/capture.py
exported_pdu ¶
Wireshark's exported PDU (LINKTYPE_WIRESHARK_UPPER_PDU): tags (dissector, protocol and info columns), the end tag, then the payload. Each tag: its type and length (16 bits, big endian), the value padded with zeros to 4 bytes
Source code in src/rpps/link/capture.py
unexported_pdu ¶
(dissector, payload) of an exported PDU
Source code in src/rpps/link/capture.py
check ¶
Composite checks: a check field built from CRCs over transformed views of the message
{"base": "crc", "type": "composite",
"parts": [{"crc": "crc8_smbus"}, CRC-8 of the message
{"crc": "crc8_smbus", "input": ["nibble_swap"]}], CRC-8 of the message with each byte's nibbles swapped
"combine": "concat", the field: the parts' fields in order (or "xor")
"check": "0x...."} optional: compute(b"123456789"), verified on load
A part is a crc definition (crc, a config/crc name) with optional input transforms, applied in order to the message
bytes before its register runs, and output transforms on its value. A transform is a name or {"op": name, ...args}:
nibble_swap each byte's two nibbles swapped
reverse_bits each byte's bits reversed
reverse_bytes the bytes in reverse order
invert every bit inverted
{"op": "xor", "value": ...} XORed with a byte, or a list of bytes repeated over the message
{"op": "skip", "n": 2} the message without its first n bytes
{"op": "take", "n": 4} the first n bytes (a negative n: all but the last -n)
outputs: reflect (the value's bits reversed over the part's width), invert (all ones XORed on).
register(name) adds a transform from Python, fn(data: np.ndarray[uint8], **args) -> np.ndarray[uint8], which a definition
then names. A composite has the crc interface (width, compute, compute_bits, field, syndrome, encode, decode), so it goes
wherever a CRC does: an HDLC frame's fcs, a link header's crc or fcs. Each part's field is sent the way its own CRC
sends it; for xor the first part's conventions apply and every part has its width.
Classes:
| Name | Description |
|---|---|
Part |
One CRC over a transformed view of the message |
composite |
A check from several CRC parts, concatenated or XORed (see the module docstring) |
Functions:
| Name | Description |
|---|---|
register |
Register a byte transform a composite check's parts can name in "input": fn(data uint8 array, **args) -> uint8 array |
Part ¶
One CRC over a transformed view of the message
Source code in src/rpps/link/check.py
composite ¶
Bases: _code
A check from several CRC parts, concatenated or XORed (see the module docstring)
Methods:
| Name | Description |
|---|---|
compute |
The check of bytes: each part's CRC of its view, combined |
compute_bits |
The check of a bit stream, in the order sent |
field |
The check field of message bits, as sent after them |
Source code in src/rpps/link/check.py
register ¶
Register a byte transform a composite check's parts can name in "input": fn(data uint8 array, **args) -> uint8 array
checksum ¶
Checksums that are not CRCs: sums, ones' complement (Internet), Fletcher, Adler, XOR (LRC)
{"base": "crc", "type": "checksum", "algorithm": "internet", sum | internet | fletcher | adler | xor
"width": 16, bits of the value (sum, xor: 8, 16 or 32)
"word": 16, "endian": "big", sum, xor: the message read as words of this many bits
"negate": false, sum: the two's complement of the sum (Intel HEX, NMEA's
is xor) so that message + checksum sums to 0
"xorout": "0x0", XORed onto the value
"refin": false, the bytes are sent least significant bit first
"order": "big", the value's bytes as sent after the message
"check": "0x...."} optional: compute(b"123456789"), verified on load
internet RFC 1071: the ones' complement of the ones' complement sum of big-endian 16-bit words (a last odd byte
padded with a zero)
fletcher width 16: two sums of bytes mod 255 (value sum2 << 8 | sum1); width 32: of 16-bit words (`endian`) mod 65535
adler Adler-32 (zlib): sums of bytes mod 65521, value s2 << 16 | s1
It has the crc interface (width, compute, compute_bits, to_bytes, to_bits, field, syndrome, encode, decode), so it goes
wherever a CRC does: an HDLC or byte-stuffed frame's fcs, a link header's crc or fcs, a composite check's part.
Classes:
| Name | Description |
|---|---|
checksum |
|
checksum ¶
checksum(log, algorithm='sum', width=8, word=8, endian='big', negate=False, xorout=0, refin=False, order='big', check=None, name='checksum')
Bases: _code
Methods:
| Name | Description |
|---|---|
compute |
The checksum of bytes |
compute_bits |
The checksum of a bit stream in the order sent: whole bytes, each least significant bit first with |
Source code in src/rpps/link/checksum.py
compute ¶
The checksum of bytes
Source code in src/rpps/link/checksum.py
compute_bits ¶
The checksum of a bit stream in the order sent: whole bytes, each least significant bit first with refin
Source code in src/rpps/link/checksum.py
crc ¶
Classes:
| Name | Description |
|---|---|
crc |
Parametrised CRC (Rocksoft model: width, poly, init, refin, refout, xorout), any width from 1 to 64 |
crc ¶
Bases: _code
Parametrised CRC (Rocksoft model: width, poly, init, refin, refout, xorout), any width from 1 to 64
Two views of the same register
compute(data) bytes / a uint8 array, as the catalogues define it: with refin each byte goes in least
significant bit first. compute(b"123456789") is the catalogue's check value.
compute_bits(bits) a bit stream of any length, fed in the order given (the order it is sent). refin is then
already in the order of the bits; refout and xorout apply as usual, so
compute(data) == compute_bits(np.unpackbits(data, bitorder="little" if refin else "big")).
encode(bits) appends the CRC to a message of any length and decode(bits) strips it (status=True: [0] if it checked out, [-1] if not). Both work on the
bit stream as sent: the CRC follows the message bits the way the register would shift it out, most significant
bit first, or least significant first when refout is set (HDLC's FCS, BLE). A received frame passes when the CRC
over the message equals the CRC field.
mask: XORed onto the CRC value by encode / decode / syndrome, for standards that overlay something on it (LTE's antenna port mask or RNTI, the Mode S address). syndrome(bits) is the received CRC field XOR the computed one: 0 for a good frame, the overlay (or an error pattern) otherwise.
Methods:
| Name | Description |
|---|---|
compute |
CRC of bytes (catalogue convention: |
compute_bits |
CRC of a bit stream of any length, bits fed in the order given |
to_bytes |
The CRC as bytes, the way catalogue protocols append it to byte data (little-endian when refout) |
to_bits |
The CRC field as sent after the message bits |
from_bits |
Value of a received CRC field (inverse of to_bits) |
field |
The CRC field of message bits, as it is sent after them (bools, |
encode |
Message bits followed by their CRC field |
syndrome |
Received CRC field XOR the CRC of the message (and |
Source code in src/rpps/link/crc.py
compute ¶
CRC of bytes (catalogue convention: refin feeds each byte least significant bit first)
Source code in src/rpps/link/crc.py
compute_bits ¶
CRC of a bit stream of any length, bits fed in the order given
Source code in src/rpps/link/crc.py
to_bytes ¶
The CRC as bytes, the way catalogue protocols append it to byte data (little-endian when refout)
to_bits ¶
The CRC field as sent after the message bits
from_bits ¶
Value of a received CRC field (inverse of to_bits)
Source code in src/rpps/link/crc.py
field ¶
encode ¶
syndrome ¶
Received CRC field XOR the CRC of the message (and mask): 0 when the frame checks out
encap ¶
Encapsulation parent classes
Classes:
| Name | Description |
|---|---|
Encap |
Parent of framing / integrity-check definitions: the link transform, data bits <-> packets |
CRC |
CRC defined by config: width, poly, init, refin, refout, xorout (hex strings or ints), check value; or a composite |
Frame |
Framing (HDLC: bit stuffing; bytes: byte stuffing, SLIP / KISS / PPP) defined by config; the FCS is another config, |
Encap ¶
Bases: Coding
Parent of framing / integrity-check definitions: the link transform, data bits <-> packets
Methods:
| Name | Description |
|---|---|
load |
Load from json: the |
Source code in src/rpps/code/coding.py
load
staticmethod
¶
Load from json: the type picks CRC or HDLC
Source code in src/rpps/link/encap.py
CRC ¶
Bases: Encap
CRC defined by config: width, poly, init, refin, refout, xorout (hex strings or ints), check value; or a composite check (type "composite": CRC parts over transformed views of the message, rpps.link.check)
Source code in src/rpps/code/coding.py
Frame ¶
Bases: Encap
Framing (HDLC: bit stuffing; bytes: byte stuffing, SLIP / KISS / PPP) defined by config; the FCS is another config,
fcs, from config/crc
As an operator: packet * frame gives one frame's bits (flags, stuffing, FCS) per call; bits / frame the payload bits of
the frames whose FCS checks out, however the stream is cut (an open frame waits for its closing flag in the next block)
Receiving, each good frame's payload starts with a publication, {"frame": where the frame starts, "frame_bits": its
payload's bits}, at its place in the output, and an anchor there: a step after it (a link header that strips the
frame's own header, {"link": "header"} driven by "frame" and "length": "frame_bits") reads frame by frame.
Every frame's message carries the whole frame as received, payload then FCS (Message.frame, parts)
Methods:
| Name | Description |
|---|---|
decode |
|
Source code in src/rpps/code/coding.py
decode ¶
bits / frame: the good frames' payloads; every frame, good or not, also emitted as a message from its opening
flag (rpps.profile.message: bytes, crc_ok the FCS's verdict)
Source code in src/rpps/link/encap.py
fields ¶
Fields: what a frame's bits say, as a definition (link headers, frame payloads, a profile step's messages)
A schema is a list of fields, read in order from the bits (most significant bit first unless order says otherwise):
{"name": "length", "bits": 8} an unsigned integer
{"name": "alt", "bits": 12, "signed": true, two's complement; value = raw*scale + offset
"scale": 25, "offset": -1000}
{"name": "type", "bits": 4, "order": "lsb", bits least significant first; `enum` adds "type.name"
"enum": {"0": "ADV_IND", "2": "ADV_NONCONN_IND"}}
{"name": "data", "type": "bytes", "bytes": "length - 1"} bytes (a count or an expression over the fields before, or
"*": the group's whole bytes left; on build, the value's);
"reverse": true for an address sent low octet first
{"name": "call", "type": "text", "bytes": 6, "shift": 1} ASCII, each byte shifted right `shift` bits (AX.25), stripped;
"encoding": "dvb": EN 300 468 annex A (a table byte first)
{"name": "freq", "type": "bcd", "bits": 32, "scale": 10} BCD digits, then scale/offset; "mjd": a date ("2026-11-26"),
"time": BCD pairs ("12:34:56", 16 bits "12:34")
{"name": "pid", "bits": 8, "if": "(control & 1) == 0"} only if the expression holds over the fields before (per
frame; a definition's "when" is decided at load, by params)
{"name": "pcr", "from": 48, "bits": 33} at a bit position (from the start of the schema or group)
{"name": "ads", "fields": [...], "repeat": "*"} a group: a dict; repeated: a list. repeat: a count, an
{"name": "addr", "fields": [...], "until": "ext == 1"} expression, or "*" (until the bits end); until: after each
element, stop when its fields make the expression true
{"name": "fmt", "fields": [...], "bytes": "fmt_length"} a sized group: exactly that many bytes (the rest skipped;
padded with zeros on build); with "repeat": "*" a list
filling them (its bytes are there for len() on build)
{"name": "descs", "group": "descriptor", ...} the definition's "groups": {"descriptor": [...]} as fields
{"name": "stuff", "align": 8} stuffing bits to a multiple of 8 from the group's start
{"name": "count", "bits": 8, "tx": "len(items) - 1"} on build, when not given: from the group's values (its lists
and a sized group's bytes are there for len())
Expressions are the definitions' (rpps._config.evaluate) over the fields read so far (a group's own first, then its
parents') and left, the bits not yet read. A field's bits may be an expression too.
parse(bits) gives (values, bits used) and raises Short when the bits end before the schema does (a header waiting for
the rest of its bits); build(values) gives the bits (transmit), fields not given taken from their "tx", else their
"default", else 0; an enum field may be given by name ("mod.name": "psk/qpsk"), a uint by its bits (a sequence of 0/1).
Classes:
| Name | Description |
|---|---|
Short |
The bits ended before the schema did |
Schema |
|
Functions:
| Name | Description |
|---|---|
mjd_date |
A Modified Julian Date as an ISO date (EN 300 468 annex C) |
mjd_of |
The Modified Julian Date of an ISO date |
dvb_text |
A DVB string (EN 300 468 annex A): a first byte below 0x20 names its table (latin-1 stands in for ISO 6937, the |
dvb_bytes |
A DVB string's bytes: as they are when printable ASCII, else UTF-8 after its table byte (0x15) |
Schema ¶
Methods:
| Name | Description |
|---|---|
parse |
(values, bits used) of the schema read from |
build |
The bits of these values (see the module for fields not given); scope: values expressions may name too |
Attributes:
| Name | Type | Description |
|---|---|---|
top |
The names of the top-level fields |
|
fixed_bits |
Bits of the schema when every field has a fixed size and none is conditional or repeated, else None |
Source code in src/rpps/link/fields.py
fixed_bits
property
¶
Bits of the schema when every field has a fixed size and none is conditional or repeated, else None
parse ¶
(values, bits used) of the schema read from bits; raises Short when they end first
Source code in src/rpps/link/fields.py
build ¶
The bits of these values (see the module for fields not given); scope: values expressions may name too
Source code in src/rpps/link/fields.py
mjd_date ¶
mjd_of ¶
dvb_text ¶
A DVB string (EN 300 468 annex A): a first byte below 0x20 names its table (latin-1 stands in for ISO 6937, the default); emphasis codes go, 0x8A is a line break
Source code in src/rpps/link/fields.py
dvb_bytes ¶
A DVB string's bytes: as they are when printable ASCII, else UTF-8 after its table byte (0x15)
gse ¶
Generic Stream Encapsulation (ETSI TS 102 606-1): PDUs in the data fields of DVB-S2 BBFRAMEs
{"link": "gse", "protocols": [130]} receive: the PDUs of those protocol types, each a frame of its own
A data field holds GSE packets one after the other, then padding (a packet header of zeros) to its end; a packet never crosses into the next data field, so a PDU too long for what is left is sent in fragments (Start, End indicators; a fragment id), the first saying the PDU's total length, the last carrying a CRC-32 (MPEG-2) over the whole of it.
S E LT GSE_Length(12) [Frag_ID(8)] [Total_Length(16)] [Protocol_Type(16) Label(6 | 3 | 0 bytes)] data [CRC_32]
Receiving takes the data fields as a frame each (its start where a profile's BBHEADER says one starts: the step's
frame control); every whole PDU is a message (kind "gse": protocol, label, length, its bytes), a fragmented one whose
CRC fails a failed message. The PDUs of the protocols asked for (all: none given) come out, each published as a frame
of its own ({"frame": k, "protocol", "pdu_bits"}) so the steps after (a table's header) read each by itself.
Protocol types below 0x0600 are taken as the PDU's own type, not an extension header (DVB-RCS2's NCR 0x0081 and lower
layer signalling 0x0082 are used so); extension headers are not read.
Transmitting a stream of data fields is pack(pdus, size): the PDUs fragmented across data fields of size bytes,
each padded to its end (what a profile's BBHEADER then frames).
Classes:
| Name | Description |
|---|---|
GSE |
|
Functions:
| Name | Description |
|---|---|
pack |
Data fields of |
GSE ¶
pack ¶
Data fields of size bytes carrying the PDUs [(protocol type, payload bytes) or (protocol, payload, label
bytes)] in GSE packets: whole where they fit, else fragmented (the first fragment as long as the field allows, the
rest in the next fields), every field padded with zeros
Source code in src/rpps/link/gse.py
hdlc ¶
Classes:
| Name | Description |
|---|---|
hdlc |
HDLC framing: flags, bit stuffing and an FCS, defined by config (see config/frame) |
hdlc ¶
Bases: _code
HDLC framing: flags, bit stuffing and an FCS, defined by config (see config/frame)
fcs: a crc instance. flag: the flag byte (0x7E). stuff: ones before a zero is inserted (5)
nrzi: line coding (a 0 is a transition, a 1 is no change). Bytes go out least significant bit first.
min_bytes: shortest frame (including the FCS) accepted.
encode(frames) takes a list of bytes. decode(bits) returns the frames whose FCS checks out (status=True: also 0 or -1 per frame found, by its FCS); deframe(bits) gives every frame with its FCS verdict, and the aborts.
Methods:
| Name | Description |
|---|---|
frame |
Bits of one frame: flag, stuffed payload + FCS, flag |
deframe |
Frames as (payload bytes, fcs ok) in the bit stream, and the number of aborted frames |
frames_at |
Frames as (index of the opening flag in |
consumed |
How many of these bits are done with: up to the last flag (a frame may be open there), or all but a flag's |
decode_stream |
Decode |
Source code in src/rpps/link/hdlc.py
frame ¶
Bits of one frame: flag, stuffed payload + FCS, flag
deframe ¶
Frames as (payload bytes, fcs ok) in the bit stream, and the number of aborted frames
frames_at ¶
Frames as (index of the opening flag in bits, payload bytes, fcs ok, the FCS bytes received), and the number of
aborted frames
Source code in src/rpps/link/hdlc.py
consumed ¶
How many of these bits are done with: up to the last flag (a frame may be open there), or all but a flag's worth when nothing can start one. The rest waits for the next block, so a frame cut by a block boundary is whole
Source code in src/rpps/link/hdlc.py
decode_stream ¶
Decode held (what the last call kept) and bits together: (data bits of the good frames, what to hold).
frames: a list to append every frame found to, as frames_at gives them (index in held + bits)
Source code in src/rpps/link/hdlc.py
header ¶
Link headers: fields, a CRC, and the payload they announce (rpps.profile.control)
A definition, config/header/link/rp.link.load("header/ieee80211b_plcp"):
{"base": "header", "type": "link", "comment": "...", "ref": "...",
"order": "lsb", field bits sent least ("lsb") or most ("msb") significant first
"payload_fields": [...], what the payload says, for its message (rpps.link.fields), read
with the header's fields in scope: Message.fields["payload"]
"payload_order": "lsb", the payload's bytes sent least significant bit first (BLE, 802.11);
out (and in, transmitting) come bytes most significant bit first,
as everywhere else. Default "msb": the payload as sent
"fields": [{"name": "signal", "bits": 8}, (a schema: rpps.link.fields; conditional, repeated and
expression-sized fields make a header read as it comes)
{"name": "length", "bits": 16,
"tx": "(bits*10 + signal - 1)//signal"}, transmit: its value from the payload's bits and the other
...], fields (an expression, as "expr" takes, worked out per frame);
else the controlled value, its "default", or 0
"crc": "crc16_genibus", a crc definition over the field bits, sent after them
"fcs": "crc24_ble", a crc definition over header and payload, sent after the payload;
{"crc": ..., "if": "ssi == 1"}: only on frames whose fields say so
"payload": "length*signal//10", receive: payload bits after the header, from the fields (and
`length`, a framed header's frame length: "length - 48 - 32*ocf")
"preamble": {"ones": 128, "word": "0xF3A0", "bits": 16}, transmit: sent before the header (in `order`)
"framed": true, frames of `length` bits (a controlled parameter: DVB-S2 Kbch),
the payload padded to fill them
"length": 96} framed: the frame length until a control sets one (fixed blocks)
Receiving, each frame starts where a profile applies a change (a delimiter before it publishes frame starts), or, framed,
length bits after the last. The header's fields, with "bits" (the payload's length), are published from the payload's
first bit for the payload's length, and {"frame_bits": header + payload} from the frame's first bit (rp.base.control.publish),
so a profile can drive the rate of the payload and the length of the frame. A header whose CRC fails is counted, and its
frame dropped; so is a frame whose FCS fails (fcs_failed). Out come the payloads. Every frame is also emitted as a
message (rpps.profile.message) from its first bit: its fields, its payload, and crc_ok (the FCS's verdict, else the
header CRC's, else None); a failed one too (crc_ok False, the fields as far as they were read). select ({field: value}) keeps only
the frames whose fields have those values: the others are used up, counted (skipped), and neither given nor published
(one of a DVB-S2 multistream's input streams by its ISI).
Transmitting, a frame starts at each change a profile applies: its fields are the controlled values; framed, its payload
is length minus the header, else everything until the next frame start (one frame per call). The fields are published
from the payload's first bit, and {"frame_bits": the frame's bits} from the frame's first bit after the preamble, so the
steps after the header can restart per frame (a whitening sequence, a sync marker) where a profile's controls say so.
Classes:
| Name | Description |
|---|---|
Header |
|
Header ¶
Header(name, fields, order='msb', crc=None, payload=None, preamble=None, framed=False, fcs=None, payload_order='msb', payload_fields=None, groups=None)
Bases: Pipe
Methods:
| Name | Description |
|---|---|
control |
A frame starts here (receive and transmit); length: its bits, framed; fields: transmit values |
kernel |
The batch decoder of a framed header of fixed size with a known frame length, its payload as sent, no FCS and no |
need |
The header's bits, CRC included, as far as these first bits of it say (more once more of it is read) |
parse |
(fields, CRC ok) of a header's bits |
payload_values |
What |
build |
A header's bits for these field values |
payload_bits |
The payload's bits: the |
frame_fcs |
The FCS bits this frame carries ( |
Source code in src/rpps/link/header.py
control ¶
A frame starts here (receive and transmit); length: its bits, framed; fields: transmit values
Source code in src/rpps/link/header.py
kernel ¶
The batch decoder of a framed header of fixed size with a known frame length, its payload as sent, no FCS and no
select (rpps.link.kernels.HeaderDecode); None otherwise (the frames go through the operator one at a time)
Source code in src/rpps/link/header.py
need ¶
The header's bits, CRC included, as far as these first bits of it say (more once more of it is read)
Source code in src/rpps/link/header.py
parse ¶
(fields, CRC ok) of a header's bits
Source code in src/rpps/link/header.py
payload_values ¶
What payload_fields reads of a payload (bytes most significant bit first), the header's fields in scope;
None when it doesn't fit
Source code in src/rpps/link/header.py
build ¶
payload_bits ¶
The payload's bits: the payload expression over the fields (and length, a framed header's frame length)
Source code in src/rpps/link/header.py
frame_fcs ¶
The FCS bits this frame carries (fcs with an "if": only some frames do)
Source code in src/rpps/link/header.py
kernels ¶
Batch kernels of the link operators: HeaderDecode of a framed header (rpps.parallel)
Checked row for row against the operator run frame by frame (tests/unit/parallel/test_batch_kernels.py). The header bits of each
row come to the host (a few bytes) to be read; the payloads are cut on whichever xp the batch is on
Classes:
| Name | Description |
|---|---|
HeaderDecode |
A framed header ( |
HeaderDecode ¶
Bases: Kernel
A framed header (rpps.link.header.Header) of fixed size, one frame a row: its fields and CRC read, and the payload
they announce given (payload, at most the frame's length less the header). A row whose header fails its CRC is
dropped (the operator gives it no payload, and a message with crc_ok False); one shorter than its header gives nothing,
as the operator does. Rows of one batch give payloads of one length (as LoopKernel asks)
Source code in src/rpps/link/kernels.py
packets ¶
Packets that cross frames: a stream of packets carried in the data fields of fixed frames, cut back into packets
{"link": "packets", "id": "space", "params": ["fhp", "vcid", "vc_count"], what a header before it gives
"frame_fields": [...], read at the start of each frame's data (in band: a pointer byte)
"active": "1", frames that carry packets at all (others are passed over)
"starts": "fhp != 2047", a packet starts in this frame (else it only continues one)
"pointer": "8*fhp", where, in bits from the data's start (after the frame_fields)
"idle_frame": "fhp == 2046", a frame of idle data only
"channel": "vcid", "count": "vc_count", "modulo": 256, streams kept apart, and their frame counts
"fields": [...], the packet's header (rpps.link.fields)
"length": "8*(length + 7)", its whole length in bits, from those fields
"idle": "apid == 2047", idle packets: used up, not given
"end": "table_id == 255", filler: the rest of the frame is not packets
"carried_check": {"crc": "crc8_dvbs2", "bits": 8, "restore": "0x47"},
"keep": "8*188", the packet's first bits given; the rest of it is its trailer
"trailer": [...], fields read there and taken off (DVB-S2's ISSY and DNP)
"insert": {"count": "dnp", "bits": 1504, packets put back before it: `count` of them, each `head` then
"head": "0x471FFF10", "fill": 255}, `fill` bytes to `bits` (the null packets DVB-S2 deleted)
"defaults": {"upl": 1504}, values of the params before any control (transmit: all there is)
(a list of numbers too: `pid in more`)
"tx": {"syncd": "pointer if start else 65535"}} transmit: the fields published at each frame's start
A header step before it (a transfer frame's, a BBHEADER, a transport packet's) drives it from each frame's data: the
profile's controls give it frame (a frame starts here), length (the data's bits; bits of a header) and the
params it names. Each frame's data is taken whole, then cut: what comes before the pointer finishes the packet the
last frame of its channel left open; from the pointer, packets follow one another, each length long, the last one
left open for the next frame. A frame lost (its channel's count skips: modulo), or a packet whose end doesn't meet
the pointer, drops only the packets that crossed it (est[id]: "lost", "misaligned"); the stream picks up again at
the next pointer. A pointer the open packet does end at is counted est[id]["aligned"]: the packets' own lengths
meeting the frames' pointers is the layer's check (random data's lengths run past them), which blind identification
reads to tell a packet layer that is there from one that isn't (rpps.analysis.signal_profile). Bits left before a pointer that are fewer than a header are filler (no packet fits there). A
packet's length of zero or over max bits (default 65536*8) is taken as lost sync.
Every packet is a message (kind: the step's id) with its header's fields and the channel, its frame the whole
packet (parts: header, payload); good packets come out, one after another, each published as a frame of its own
({"frame", "packet_bits"}) for a step after it.
Trailer and inserted packets (DVB-S2 null-packet deletion, EN 302 307-1 annex D.3): a user packet length long
carries more than the packet it stands for (an ISSY field, the DNP byte). Once checked, its first keep bits are the
packet; the trailer fields are read from the rest (into its message's fields) and taken off. insert then puts
count packets back before it (the null packets deleted since the last one: bits long, head then fill bytes);
they are given and published as frames like the others, but are not messages (counted: est[id]["inserted"]).
Carried check (DVB-S2 TS mode, EN 302 307-1 5.1.4): a packet's first bits are a check over the packet before
(all of it but those first bits): each packet is given once the next has said whether it was good, its first bits
then set to restore (the sync byte 0x47 the check stood in for). The last packet of a stream is given unchecked.
Transmitting packs a stream of packets back to back into the frames' data fields. A frame starts at each control
(length: its data field's bits, the profile's framer giving it); at each start the tx fields are worked out and
published for the header step after it to build that frame with: over the params (defaults), pointer (bits from the
data field's start to the first packet starting in it), start (1 when one does, else 0) and frame (the frames
so far). A carried check is made (each packet's first bits the check of the one before; the first packet's zeros).
The packets' lengths come from their own header (fields, length); a frame start is published once the first
packet starting at or after it is seen, so the output from a frame start may wait up to a packet. Not transmitted: frame_fields (a pointer
in the data field), a trailer of any bits (ISSY, null-packet deletion), channels of their own; the step refuses them.
Shipped: ccsds/tm_packets (space packets out of TM transfer frames by their first header pointer), dvbs2/ts
(transport stream packets out of BBFRAMEs in TS mode by SYNCD and UPL, null packets deleted put back; transmitted too),
dvbs2/mpe and dvbs2/ule (sections and SNDUs out of the transport packets of one PID, by the pointer field). A
profile's capture rule then sends them on.
Classes:
| Name | Description |
|---|---|
Packets |
Packets cut from frames' data fields (see module) |
Packets ¶
Bases: Pipe
Packets cut from frames' data fields (see module)
Source code in src/rpps/link/packets.py
serial ¶
Link definitions, one resource each: config/crc, config/frame, config/header/link; rp.link.load("crc/crc32_mpeg2")
crc {"base": "crc", "type": "crc", "width": 16, "poly": "0x1021", "init": "0x0", "xorout": "0x0",
"refin": false, "refout": false, the reveng catalogue fields (numbers or hex strings)
"check": "0x29b1"} optional: the CRC of b"123456789", verified on load
width is 1 to 64 bits; encode / decode / syndrome work on bit streams of any length (see crc)
{"base": "crc", "type": "composite", a check from CRC parts over transformed views of the message
"parts": [{"crc": "crc8_smbus"}, {"crc": "crc8_smbus", "input": ["nibble_swap"]}],
"combine": "concat"} (or "xor"); goes wherever a crc does (see rpps.link.check)
{"base": "crc", "type": "checksum", a sum, ones' complement (Internet), Fletcher, Adler or XOR checksum
"algorithm": "internet", ...} (see rpps.link.checksum); goes wherever a crc does
frame {"base": "frame", "type": "hdlc", "flag": "0x7E", "stuff": 5, "nrzi": false,
"fcs": "crc16_x25", the name of a crc definition
"min_bytes": 4}
{"base": "frame", "type": "bytes", byte stuffing (SLIP, KISS, asynchronous PPP; see bytestuff)
"flag": "0xC0", "escape": "0xDB",
"escapes": {"0xC0": "0xDC", "0xDB": "0xDD"}, what follows the escape for each byte, or "xor": "0x20" for
"fcs": null, "refin": false} the bytes in "escaped"; an optional fcs; refin: LSB first
header {"base": "header", "type": "link", "fields": [...], "crc": ..., "payload": "..."} fields, CRC and payload length of a
frame's header, driven and published through a profile (see rpps.link.header)
Functions:
| Name | Description |
|---|---|
root |
Directory holding the encapsulation definitions |
ls |
List available definitions: {category: [names]} |
load |
Load a link definition by " |
root ¶
ls ¶
List available definitions: {category: [names]}
blind: only what the blind tools try (rp._config.ls): no definitions tagged "example", and only the selected tags (rp.select_tags)
Source code in src/rpps/link/serial.py
load ¶
Load a link definition by "load("crc/crc32_mpeg2"), load("frame/hdlc"), load("header/ble_adv")
(config/path. kind: crc | frame | header.
A bare name works while one definition of the three kinds has it