|
| 1 | +================================= |
| 2 | +DTLS Handshake-Message Reassembly |
| 3 | +================================= |
| 4 | + |
| 5 | +.. module:: pcapkit.foundation.reassembly.dtls |
| 6 | + |
| 7 | +:mod:`pcapkit.foundation.reassembly.dtls` contains |
| 8 | +:class:`~pcapkit.foundation.reassembly.dtls.DTLS` only, which reconstructs a |
| 9 | +DTLS handshake message split across several records back to origin |
| 10 | +(:rfc:`6347#section-4.2.3`). |
| 11 | + |
| 12 | +.. autoclass:: pcapkit.foundation.reassembly.dtls.DTLS |
| 13 | + :no-members: |
| 14 | + :show-inheritance: |
| 15 | + |
| 16 | + .. autoproperty:: last |
| 17 | + |
| 18 | + .. automethod:: reassembly |
| 19 | + .. automethod:: submit |
| 20 | + .. automethod:: _datagram_from_fragment |
| 21 | + .. automethod:: _received_runs |
| 22 | + .. automethod:: _update_hole_descriptors |
| 23 | + |
| 24 | + .. autoattribute:: __protocol_name__ |
| 25 | + .. autoattribute:: __timeout__ |
| 26 | + |
| 27 | +Algorithm |
| 28 | +========= |
| 29 | + |
| 30 | +.. seealso:: |
| 31 | + |
| 32 | + This algorithm is an adaptation of the hole-descriptor algorithm described |
| 33 | + in :rfc:`815`, over a DTLS handshake message's own, simpler coordinate |
| 34 | + system: a byte offset into the message that neither wraps (unlike a TCP |
| 35 | + sequence number) nor needs an open upper bound (unlike IP's or TCP's |
| 36 | + not-yet-known total length) -- :rfc:`6347#section-4.2.3`'s fragment header |
| 37 | + gives every fragment of a message the same, already-known ``length``. |
| 38 | + |
| 39 | +A DTLS handshake record may carry more than one message fragment -- |
| 40 | +:rfc:`6347#section-4.2.3` allows several handshake messages (or fragments of |
| 41 | +them) to be coalesced into one record, and :meth:`SSL._read_tls_handshake_messages |
| 42 | +<pcapkit.protocols.application.ssl.SSL._read_tls_handshake_messages>` already |
| 43 | +reads however many fit rather than assuming exactly one. A fragment names the |
| 44 | +message it belongs to (``message_seq``), the message's total length |
| 45 | +(``length``), and its own byte range within that message (``fragment_offset``, |
| 46 | +``fragment_length``). A message is reassembled by punching the arriving |
| 47 | +fragment's range out of the message's hole list; it is whole once no hole |
| 48 | +remains. |
| 49 | + |
| 50 | +Terminology |
| 51 | +=========== |
| 52 | + |
| 53 | +.. glossary:: |
| 54 | + |
| 55 | + reasm.dtls.packet |
| 56 | + Data structure for **DTLS handshake-fragment reassembly** |
| 57 | + (:meth:`DTLS.reassembly <pcapkit.foundation.reassembly.dtls.DTLS.reassembly>`) |
| 58 | + is :class:`~pcapkit.foundation.reassembly.data.dtls.Packet` -- one |
| 59 | + fragment's own ``bufid``, ``message_seq``, ``fragment_offset``, |
| 60 | + ``fragment_length`` and raw ``payload``, built by |
| 61 | + :meth:`DTLS.read <pcapkit.protocols.application.dtls.DTLS.read>` from |
| 62 | + a single :class:`~pcapkit.protocols.data.application.dtls.DTLSHandshake`. |
| 63 | + |
| 64 | + reasm.dtls.datagram |
| 65 | + Data structure for **reassembled DTLS handshake message** (element of |
| 66 | + :attr:`DTLS.datagram <pcapkit.foundation.reassembly.reassembly.Reassembly.datagram>`) |
| 67 | + is :class:`~pcapkit.foundation.reassembly.data.dtls.Datagram` -- |
| 68 | + ``completed``, the original packet identifier, the packet numbers |
| 69 | + that built it, and ``body``, the reassembled payload (a contiguous |
| 70 | + :obj:`bytes`, or -- under ``strict=True`` and an incomplete message -- |
| 71 | + a :obj:`tuple` of the octet runs actually received). |
| 72 | + |
| 73 | + reasm.dtls.buffer |
| 74 | + Data structure for internal buffering |
| 75 | + (:attr:`DTLS._buffer <pcapkit.foundation.reassembly.reassembly.Reassembly._buffer>`) |
| 76 | + is :class:`~pcapkit.foundation.reassembly.data.dtls.Buffer` -- every |
| 77 | + message currently under reconstruction for one |
| 78 | + :data:`~pcapkit.foundation.reassembly.data.dtls.BufferID` (one UDP |
| 79 | + association at one DTLS epoch), each keyed by its |
| 80 | + :attr:`~pcapkit.foundation.reassembly.data.dtls.Packet.message_seq` and |
| 81 | + held as a :class:`~pcapkit.foundation.reassembly.data.dtls.Fragment` -- |
| 82 | + its hole descriptor list |
| 83 | + (:class:`~pcapkit.foundation.reassembly.data.dtls.HoleDescriptor`) and |
| 84 | + its zero-filled payload buffer. |
| 85 | + |
| 86 | +Data Models |
| 87 | +=========== |
| 88 | + |
| 89 | +.. module:: pcapkit.foundation.reassembly.data.dtls |
| 90 | +.. currentmodule:: pcapkit.foundation.reassembly.dtls |
| 91 | + |
| 92 | +.. autoclass:: pcapkit.foundation.reassembly.data.dtls.Packet |
| 93 | + :members: |
| 94 | + :show-inheritance: |
| 95 | + |
| 96 | +.. autodata:: pcapkit.foundation.reassembly.data.dtls.BufferID |
| 97 | + |
| 98 | +.. autoclass:: pcapkit.foundation.reassembly.data.dtls.DatagramID |
| 99 | + :members: |
| 100 | + :show-inheritance: |
| 101 | + |
| 102 | +.. autoclass:: pcapkit.foundation.reassembly.data.dtls.Datagram |
| 103 | + :members: |
| 104 | + :show-inheritance: |
| 105 | + |
| 106 | +.. autoclass:: pcapkit.foundation.reassembly.data.dtls.HoleDescriptor |
| 107 | + :members: |
| 108 | + :show-inheritance: |
| 109 | + |
| 110 | +.. autoclass:: pcapkit.foundation.reassembly.data.dtls.Fragment |
| 111 | + :members: |
| 112 | + :show-inheritance: |
| 113 | + |
| 114 | +.. autoclass:: pcapkit.foundation.reassembly.data.dtls.Buffer |
| 115 | + :members: |
| 116 | + :show-inheritance: |
| 117 | + |
| 118 | +Type Variables |
| 119 | +============== |
| 120 | + |
| 121 | +.. data:: _AT |
| 122 | + :module: pcapkit.foundation.reassembly.data.dtls |
| 123 | + :type: ipaddress.IPv4Address | ipaddress.IPv6Address |
| 124 | + |
| 125 | + IP address type. |
0 commit comments