gufo.ping.proto¶
SocketWrapper protocol definition.
SocketProto
¶
Bases: Protocol
SocketWrapper protocol.
Socket wrapper is the PyO3-wrapped Rust code, implementing low-level details of the PingSocket.
bind(addr)
¶
Bind to source address.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
addr
|
str
|
Source Address |
required |
clean_ip(addr)
¶
Normalize IP address to a stable form.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
addr
|
str
|
IP address |
required |
Returns:
| Type | Description |
|---|---|
str
|
Normalized address |
get_fd()
¶
Get socket's file descriptor.
Returns:
| Type | Description |
|---|---|
int
|
file descriptor for open socket. |
recv()
¶
Receive all awaiting packets.
Returns:
| Type | Description |
|---|---|
dict[int, float] | None
|
|
dict[int, float] | None
|
|
send(addr, size)
¶
Generate and send icmp request packet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
addr
|
str
|
Destination address. |
required |
size
|
int
|
Outgoing packet's size in bytes, including IP header. |
required |
Returns:
| Type | Description |
|---|---|
int
|
session id. |
set_recv_buffer_size(size)
¶
Set incoming socket's buffer size.
If the requested size is too big, adjust to proper size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
int
|
Requested recv buffer size, in bytes. |
required |
set_send_buffer_size(size)
¶
Set outgoing socket's buffer size.
If the requested size is too big, adjust to proper size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
int
|
Requested send buffer size, in bytes. |
required |
set_tclass(tclass)
¶
Change outgoing packets' IPv6 TCLASS field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tclass
|
int
|
TCLASS value. |
required |
set_tos(tos)
¶
Change outgoing packets' ToS/DSCP field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tos
|
int
|
ToS value. |
required |
set_ttl(ttl)
¶
Change outgoing packets' time-to-live field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ttl
|
int
|
TTL value. |
required |
set_unicast_hops(ttl)
¶
Change outgoing packets' unicast hops (IPv6 TTL).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ttl
|
int
|
TTL value. |
required |