8.2. Transmitter classes

class pingparsing.PingTransmitter[source]

Transmitter class to send ICMP packets by using the OS built-in ping command.

count: int | None = None

Number of sending ICMP packets. This attribute will be ignored if the value is None.

packet_size: int | None = None

Specifies the number of data bytes to be sent.

ttl: int | None = None

Specifies the Time to Live.

ping_option: str | Sequence[str] = ""

Additional ping command option.

interface: str | None = None

Interface name or zone-id. The attribute required when destination is IPv6 link-local scope address.

timestamp: bool = False

[Only for Linux environment] If True, add a timestamp for each ping result. Defaults to False.

auto_codepage: bool = True

[Only for Windows environment] Automatically change the code page if True. Defaults to True.

property deadline: Time | None

Timeout before ping exits. You can specify either a number or a string (e.g. "1sec"). If only a number is specified and a unit is not found, the unit will be considered as seconds.

Unit

Available specifiers (str)

days

d/day/days

hours

h/hour/hours

minutes

m/min/mins/minute/minutes

seconds

s/sec/secs/second/seconds

milliseconds

ms/msec/msecs/millisecond/milliseconds

microseconds

us/usec/usecs/microsecond/microseconds

If both deadline and count are None, deadline is automatically set to the default value (3 seconds). Defaults to None.

Returns:

deadline

Return type:

humanreadable.Time

property destination: str

Hostname or IP address (IPv4/IPv6) to send ICMP packets.

property destination_host: str

Alias to destination

ping() PingResult[source]

Sending ICMP packets.

Returns:

ping command execution result.

Return type:

PingResult

Raises:

ValueError – If parameters are not valid.

property timeout: Time | None

Time to wait for a response per packet. You can specify either a number or a string (e.g. "1sec"). If only a number is specified and a unit is not found, the unit will be considered as seconds.

Unit

Available specifiers (str)

days

d/day/days

hours

h/hour/hours

minutes

m/min/mins/minute/minutes

seconds

s/sec/secs/second/seconds

milliseconds

ms/msec/msecs/millisecond/milliseconds

microseconds

us/usec/usecs/microsecond/microseconds

Use system default timeout if the value is None. Defaults to None. If the system does not support timeout in milliseconds, round up as seconds.

Returns:

timeout

Return type:

humanreadable.Time

class pingparsing.PingResult(stdout, stderr, returncode)[source]

Data class to store ping command execution result.

stdout: str | None

Standard output of ping command execution result.

stderr: str | None

Standard error of ping command execution result.

returncode: int

Return code of ping command execution result.