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_expired()
¶
Get list of sessions with expired timeouts.
Returns:
Type | Description |
---|---|
Optional[List[str]]
|
|
Optional[List[str]]
|
|
get_fd()
¶
Get socket's file descriptor.
Returns:
Type | Description |
---|---|
int
|
file descriptor for open socket. |
recv()
¶
Receive all awaiting packets.
Returns:
Type | Description |
---|---|
Optional[Dict[str, float]]
|
|
Optional[Dict[str, float]]
|
|
send(addr, request_id, seq, size)
¶
Generate and send icmp request packet.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
addr |
str
|
Destination address. |
required |
request_id |
int
|
ICMP request id. |
required |
seq |
int
|
ICMP sequental number. |
required |
size |
int
|
Outgoing packet's size in bytes, including IP header. |
required |
set_accelerated(a)
¶
Enable platform-dependend raw socket processing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a |
bool
|
Enable or disable an acceleration. * True - enable, when platform supports acceleration. * False - disable the acceleration. |
required |
set_coarse(ct)
¶
Switch between the internal timer implemenetation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ct |
bool
|
Use
|
required |
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_timeout(timeout)
¶
Set default ping timeout.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timeout |
int
|
Ping timeout, in nanoseconds. |
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 |