noc.core.ioloop.ping

Module Contents

noc.core.ioloop.ping.logger
noc.core.ioloop.ping.ICMPv4_PROTO
noc.core.ioloop.ping.ICMPv4_ECHOREPLY = 0
noc.core.ioloop.ping.ICMPv4_UNREACHABLE = 3
noc.core.ioloop.ping.ICMPv4_TTL_EXCEEDED = 11
noc.core.ioloop.ping.ICMPv4_ECHO = 8
noc.core.ioloop.ping.ICMPv6_PROTO
noc.core.ioloop.ping.ICMPv6_ECHO = 128
noc.core.ioloop.ping.ICMPv6_ECHOREPLY = 129
noc.core.ioloop.ping.MAX_RECV = 1500
noc.core.ioloop.ping._ERRNO_WOULDBLOCK
noc.core.ioloop.ping.IPv4_STRUCT
noc.core.ioloop.ping.ICMP_STRUCT
noc.core.ioloop.ping.TS_STRUCT
noc.core.ioloop.ping.IGNORABLE_ERRORS
class noc.core.ioloop.ping.PingSocket(io_loop=None, tos=None)

Bases: object

IPv4/IPv6 ping socket base

ECHO_TYPE
HEADER_SIZE
SNDBUF
RCVBUF
is_ready(self)

Service must call is_ready to determine ping socket is created properly

create_socket(self)
adjust_buffers(self)

Set send and receive buffers

ping(self, address, timeout, size, request_id, seq)

Send echo request and returns future

parse_reply(self, msg, ip)

Returns status, address, request_id, sequence

on_read(self, fd, events)
on_timeout(self, future)

Check future is not timed out

get_checksum(self, msg)

Calculate checksum (RFC-1071)

build_echo_request(self, size, request_id, seq)
send(self, address, msg)
on_send(self, *args, **kwargs)
class noc.core.ioloop.ping.Ping4Socket

Bases: noc.core.ioloop.ping.PingSocket

ICMPv4 Ping Socket

ECHO_TYPE
HEADER_SIZE = 28
create_socket(self)
parse_reply(self, msg, addr)

Returns status, address, request_id, sequence

class noc.core.ioloop.ping.Ping6Socket

Bases: noc.core.ioloop.ping.PingSocket

ICMPv6 Ping Socket

ECHO_TYPE
HEADER_SIZE = 48
create_socket(self)
parse_reply(self, msg, addr)

Returns status, address, request_id, sequence, rtt

class noc.core.ioloop.ping.Ping(io_loop=None, tos=None)

Bases: object

CHECK_FIRST = 0
CHECK_ALL = 1
iter_request
get_socket(self, address)

Return PingSocket instance

ping_check(self, address, size=64, count=1, timeout=1000, policy=CHECK_FIRST)

Perform ping check and return status :param address: IPv4/IPv6 address of host :param size: Packet size, in octets :param count: Maximal number of packets to send :param timeout: Ping timeout, in milliseconds :param policy: Check policy. CHECK_FIRST - return True on

first success. CHECK_ALL - return True when all checks succeded
Returns:Ping status as boolean
ping_check_rtt(self, address, size=64, count=1, timeout=1000, policy=CHECK_FIRST)

Perform ping check and return round-trip time :param address: IPv4/IPv6 address of host :param size: Packet size, in octets :param count: Maximal number of packets to send :param timeout: Ping timeout, in milliseconds :param policy: Check policy. CHECK_FIRST - return True on

first success. CHECK_ALL - return True when all checks succeded
Returns:rtt in seconds as float or None for failure