Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Net::ping is very unstable

by Perlbotics (Archbishop)
on Apr 09, 2015 at 11:37 UTC ( [id://1122912]=note: print w/replies, xml ) Need Help??


in reply to Net::ping is very unstable

Perhaps a firewall on the way to the host or the hosts own TCP stack configuration is interpreting your tests as a SYN-flood attack, consequently suppressing the ACK? What's the frequency of your tests?
I had no problems with Net::Ping in the past.

Update (in response to code block below): I second Corions advice given in Re^7: Net::ping is very unstable. (behold the use of [id://1122924] to point to that node ;-)

Replies are listed 'Best First'.
Re^2: Net::ping is very unstable
by Anonymous Monk on Apr 09, 2015 at 13:29 UTC
    #!/usr/bin/perl -w #use strict; use warnings; use IO::Handle; use Socket; use threads; use IO::Socket::INET; use Net::Ping; open(pctxt,'./pc.txt')||die "error open $!"; open(pc_log, ">./pclog.txt")||die "error open $!"; my $stime = time; while($read_data = <pctxt>) { #chomp; $read_data=~s/\s//g; $read_data=~s/" "//g; thread($read_data); } my $etime = time; my $diff = $etime-$stime; print "$diff \n"; close(pc_log); close(pctxt); sub thread { my $net = shift; my @ip = (1..255); my $port = 12345; my $thr0 = threads->new(\&scan, $net,@ip[0..15]); my $thr1 = threads->new(\&scan, $net,@ip[16..31]); my $thr2 = threads->new(\&scan, $net,@ip[32..47]); my $thr3 = threads->new(\&scan, $net,@ip[48..63]); my $thr4 = threads->new(\&scan, $net,@ip[64..79]); my $thr5 = threads->new(\&scan, $net,@ip[80..95]); my $thr6 = threads->new(\&scan, $net,@ip[96..111]); my $thr7 = threads->new(\&scan, $net,@ip[112..127]); my $thr8 = threads->new(\&scan, $net,@ip[128..143]); my $thr9 = threads->new(\&scan, $net,@ip[144..159]); my $thr10 = threads->new(\&scan, $net,@ip[160..175]); my $thr11 = threads->new(\&scan, $net,@ip[176..191]); my $thr12 = threads->new(\&scan, $net,@ip[192..207]); my $thr13 = threads->new(\&scan, $net,@ip[208..223]); my $thr14 = threads->new(\&scan, $net,@ip[224..239]); my $thr15 = threads->new(\&scan, $net,@ip[240..254]); $thr0->join(); $thr1->join(); $thr2->join(); $thr3->join(); $thr4->join(); $thr5->join(); $thr6->join(); $thr7->join(); $thr8->join(); $thr9->join(); $thr10->join(); $thr11->join(); $thr12->join(); $thr13->join(); $thr14->join(); $thr15->join(); } sub scan { my ($net,@ip) = @_; foreach my $ip (@ip) { $host ="$net$ip"; if (Is_Host_Alive($host)) { my $socket = new IO::Socket::INET( PeerHost =>$host, PeerPort =>'12345', Proto =>'tcp' );# or die "ERROR in Socket Creation : $!\n"; if (($socket) && scan700($host)) { print "$host not shutdown \n"; } } # $socket->close(); } } sub scan700 { my ($ip) = @_; $host = "$ip"; my $socket = new IO::Socket::INET( PeerHost =>$host, PeerPort =>'700', Proto =>'tcp' );# or die "ERROR in Socket Creation : $!\n"; if($socket) { print "$host is ATM \n"; return 0; } #$socket->close(); return 1; } sub Is_Host_Alive { my ($host) = @_; my $tmp_icmp=Net::Ping->new('icmp'); if(!$tmp_icmp->ping($host)) { #print "$host ping unreachable \n"; $tmp_icmp->close; return 0; } $tmp_icmp->close; return 1; }

    "pc.txt" file as following:
    192.168.1.
    192.168.2.
    .....
    192.168.150.
    I want to check that whether so many net's hosts have been opened by port 12345 and not by port 700 or not.
    Can you give me better advice for the result?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1122912]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-20 04:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found