UDP¶
A UDP SMPTransport for Network connections like Wi-Fi or Ethernet.
logger = logging.getLogger(__name__)
module-attribute
¶
IPV4_HEADER_SIZE: Final = 20
module-attribute
¶
Minimum IPv4 header size in bytes.
IPV6_HEADER_SIZE: Final = 40
module-attribute
¶
IPv6 header size in bytes.
UDP_HEADER_SIZE: Final = 8
module-attribute
¶
UDP header size in bytes.
IPV4_UDP_OVERHEAD: Final = IPV4_HEADER_SIZE + UDP_HEADER_SIZE
module-attribute
¶
Total overhead (28 bytes) to subtract from MTU to get maximum UDP payload (MSS) for IPv4.
Per RFC 8085 section 3.2, applications must subtract IP and UDP header sizes from the PMTU to avoid fragmentation.
IPV6_UDP_OVERHEAD: Final = IPV6_HEADER_SIZE + UDP_HEADER_SIZE
module-attribute
¶
Total overhead (48 bytes) to subtract from MTU to get maximum UDP payload (MSS) for IPv6.
Per RFC 8085 section 3.2, applications must subtract IP and UDP header sizes from the PMTU to avoid fragmentation.
SMPUDPTransport
¶
Bases: SMPTransport
Source code in src/smpclient/transport/udp.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
mtu: int
property
¶
The Maximum Transmission Unit (MTU) in 8-bit bytes.
max_unencoded_size: int
property
¶
Maximum UDP payload size (MSS) to avoid fragmentation.
Subtracts IPv4/IPv6 and UDP header overhead from MTU per RFC 8085 section 3.2. The IP version is auto-detected after connection.
__init__(mtu: int = 1500) -> None
¶
Initialize the SMP UDP transport.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mtu
|
int
|
The Maximum Transmission Unit (MTU) of the link layer in bytes. IP and UDP header overhead will be subtracted to calculate the maximum UDP payload size (MSS) to avoid fragmentation per RFC 8085 section 3.2. |
1500
|
Source code in src/smpclient/transport/udp.py
connect(address: str, timeout_s: float, port: int = 1337) -> None
async
¶
Connect the SMPTransport.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
address
|
str
|
The SMP server address. |
required |
timeout_s
|
float
|
The connection timeout in seconds. |
required |
Source code in src/smpclient/transport/udp.py
disconnect() -> None
async
¶
Disconnect the SMPTransport.
Source code in src/smpclient/transport/udp.py
send(data: bytes) -> None
async
¶
Send the encoded SMPRequest data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
bytes
|
The encoded |
required |
Source code in src/smpclient/transport/udp.py
receive() -> bytes
async
¶
Receive the decoded SMPResponse data.
Returns:
| Type | Description |
|---|---|
bytes
|
The |
Source code in src/smpclient/transport/udp.py
send_and_receive(data: bytes) -> bytes
async
¶
Send the encoded SMPRequest data and receive the decoded SMPResponse.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
bytes
|
The encoded |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
The |