Ted Lee wrote:

>Hey guys,
>
>I've been playing with Perl, and I've built a simple ICMP Ping sweep program
>that accepts start and end IP, and pings every host in between.
>
>Question I have is, I want to reduce the time it takes to do so, I was
>considering spawning a processes for X number of hosts to ping.
>
>So, say I want to ping 10.8.0.0 - 10.8.2.0, I'd spawn 2 processes for the
>tasks, one for each 255 host block.
>
>Thing is, I don't know how to do this, properly, and explanations of Fork()
>seemed to be not very friendly to MS based Perl programming.
>
>Any suggestions?
>
I'm beginning to sound like a broken record on these fork() on win32 
questions...

Stay away from fork on win32 and multi-threading is pretty much out of 
the question.  Instead focus on using open, open2 and pipes.  For 
example: you could write your program so that if given the range 
10.8.0.0 - 10.8.2.0 it recursively calls itself having a child process 
look at 10.8.0.1 10.8.0.255 checking out 10.8.0.0 - 10.8.0.255 itself. 
 It would look something like this:

# Lets pretend we've written a function, parse_ranges() that decides how 
much
# each process will take.  Assume ranges are of the form <startip>-<endip>
my($range, $child_range) = parse_ranges($ARGV[0]);
if($child_range){
    open CHILD, "perl ping_sweep.pl $child_range |";
}

my @active_ips = ping_sweep($range);

foreach(@active_ips){ print "$_\n" }

if($child_range){
    while(<CHILD>){ print };
}

Of course I have faith that your need to ping sweep ranges of IP's is 
simply to find problems in your own network or some other legitimate 
use, because if you go and do something illegal then, under existing 
cyber-crime laws I can be punished for helping you with this.  You may 
even be considered a terrorist and I your accomplice and therefore a 
terrorist as well...  where did all that end up anyway.

- Johnathan


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to