distributed computing - Testing multicast with perl PortState -
i'm writing program creates network between processes , 1 of them "coordinator". coordinator should able check if other process dead or alive in network. wrote routine (permanently executed thread) checks seeing if process listening multicast port (by multicast port mean common port, let's 2000, between processes of same multicast group, , connection when message send uses "udp" protocol) using io::socket::portstate:
my %port_hash = ( udp => {'2000' => {} } ); $timeout = 5; while (1) { # checking system node $host_hr = check_ports($node_host, $timeout, \%port_hash); $isalive = $host_hr->{udp}{'2000'}{open}; if (!$isalive) { print "$node_host died"; } else { print "everything ok $node_host"; } }
then when lift 2 or more processes, works fine, says "everything ok host_x", if kill node "host_x" it's still printing same thing. (so, never recognizes when process dead).
i don't see problem is, if non-multicast port works perfectly, i'm guessing has fact multicast port.
is there way work kind of port? , if it's impossible do, what's best way check if process alive taking consideration coordinator has check lot of processes.
note: assume multicast stuff works fine (it sends messages way should)
this (6 year stale) bug report io::socket::portstate says checking broken udp.
however, since library tiny--it's single function of 30 lines, instead of bringing dependency project, i'd implement check myself, using perl core module io::socket::inet.
i can't tell how right, if read library code, see how it's done in library. however, still need fix bug udp work. after that, consider creating patch library , sending maintainer (use links on module page).
some more general notes on checking:
if point check machine reachable (i.e. online , routable), icmp (ping) internet layer should enough. using higher layer not tell more unless probing same port willing communicate to, , cost more overhead (at least tcp, maybe it's better udp it's still more.)
later when , try implement more "proper" check, recommend reading port scanning basics on nmap site. (come think of it, there's nmap library in cpan, bout bazooka shoot fly.)
Comments
Post a Comment