For instance a range of 4 addresses takes up to 20 minutes for the script to complete. That's doable but with a /24, this is simply too long. Now I have read that this kind of nmap port scanning takes a long time but is there something wrong with my code that makes it very slow?

No. Nothing particular.

You are calling ->tcp_ports('open') for each of the hosts you are investigating. In order to be able to tell you which ports are open, NMap will have to scan all of the ports for each host.

You say that it is takig 20 for 4 hosts; so 300 seconds per host. Assuming that NMap is limiting itself to the bottom 1024 privileged ports on each host, that means 300 / 1024 = 0.293 seconds per port. Active ports may well respond more quickly than that, but for inactive ports NMap will have to wait a certain amount of time before it times the port out and concludes it is not active. That calculation assumes that NMap scans the ports serially.

It is also possible that NMap scans the ports in parallel; and that the commonly used default timeout of 300 seconds means that every host will always take a minimum of 5 minutes to scan, unless it all 1024 ports are open.

Does NMAP::Parser, or one of its dependents allow you to configure the timeout?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: NMAP Parser very slow by BrowserUk
in thread NMAP Parser very slow by Noosrep

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.