1 | NAME |
1 | NAME |
2 | Net::FPing - quickly ping a large number of hosts |
2 | AnyEvent::FastPing - quickly ping a large number of hosts |
3 | |
3 | |
4 | SYNOPSIS |
4 | SYNOPSIS |
5 | use Net::FPing; |
5 | use AnyEvent::FastPing; |
6 | |
6 | |
7 | DESCRIPTION |
7 | DESCRIPTION |
8 | This module was written for a single purpose only: sendinf ICMP EHCO |
8 | This module was written for a single purpose only: sending ICMP EHCO |
9 | REQUEST packets as quickly as possible to a large number of hosts |
9 | REQUEST packets as quickly as possible to a large number of hosts |
10 | (thousands to millions). |
10 | (thousands to millions). |
11 | |
11 | |
12 | It employs a sending thread and is fully event-driven (using AnyEvent), |
12 | It employs a sending thread and is fully event-driven (using AnyEvent), |
13 | so you have to run an event model supported by AnyEvent to use this |
13 | so you have to run an event model supported by AnyEvent to use this |
14 | module. |
14 | module. |
15 | |
15 | |
16 | FUNCTIONS |
16 | FUNCTIONS |
17 | Net::FPing::ipv4_supported |
17 | AnyEvent::FastPing::ipv4_supported |
18 | Returns true if IPv4 is supported in this module and on this system. |
18 | Returns true if IPv4 is supported in this module and on this system. |
19 | |
19 | |
20 | Net::FPing::ipv6_supported |
20 | AnyEvent::FastPing::ipv6_supported |
21 | Returns true if IPv6 is supported in this module and on this system. |
21 | Returns true if IPv6 is supported in this module and on this system. |
22 | |
22 | |
23 | Net::FPing::icmp4_pktsize |
23 | AnyEvent::FastPing::icmp4_pktsize |
24 | Returns the number of bytes each IPv4 ping packet has. |
24 | Returns the number of bytes each IPv4 ping packet has. |
25 | |
25 | |
26 | Net::FPing::icmp6_pktsize |
26 | AnyEvent::FastPing::icmp6_pktsize |
27 | Returns the number of bytes each IPv4 ping packet has. |
27 | Returns the number of bytes each IPv4 ping packet has. |
28 | |
28 | |
29 | Net::FPing::icmp_ping [ranges...], $send_interval, $payload, \&callback |
29 | AnyEvent::FastPing::icmp_ping [ranges...], $send_interval, $payload, |
|
|
30 | \&callback |
30 | Ping the given IPv4 address ranges. Each range is an arrayref of the |
31 | Ping the given IPv4 address ranges. Each range is an arrayref of the |
31 | form "[lo, hi, interval]", where "lo" and "hi" are octet strings |
32 | form "[lo, hi, interval]", where "lo" and "hi" are octet strings |
32 | with either 4 octets (for IPv4 addresses) or 16 octets (for IPV6 |
33 | with either 4 octets (for IPv4 addresses) or 16 octets (for IPV6 |
33 | addresses), representing the lowest and highest address to ping (you |
34 | addresses), representing the lowest and highest address to ping (you |
34 | can convert a dotted-quad IPv4 address to this format by using |
35 | can convert a dotted-quad IPv4 address to this format by using |
… | |
… | |
71 | 11.0.0.1-11.0.255.255 with at most 1000 packets/s. Do not, however, |
72 | 11.0.0.1-11.0.255.255 with at most 1000 packets/s. Do not, however, |
72 | exceed 1000 packets/s overall: |
73 | exceed 1000 packets/s overall: |
73 | |
74 | |
74 | my $done = AnyEvent->condvar; |
75 | my $done = AnyEvent->condvar; |
75 | |
76 | |
76 | Net::FPing::icmp_ping |
77 | AnyEvent::FastPing::icmp_ping |
|
|
78 | [ |
77 | [v10.0.0.1, v10.0.0.15, .01], |
79 | [v10.0.0.1, v10.0.0.15, .01], |
78 | [v11.0.0.1, v11.0.255.255, .001], |
80 | [v11.0.0.1, v11.0.255.255, .001], |
|
|
81 | ], |
79 | .001, 0x12345678, |
82 | .001, 0x12345678, |
80 | sub { |
83 | sub { |
81 | warn "all ranges pinged\n"; |
84 | warn "all ranges pinged\n"; |
82 | $done->broadcast; |
85 | $done->broadcast; |
83 | } |
86 | } |
84 | ; |
87 | ; |
85 | |
88 | |
86 | $done->wait; |
89 | $done->wait; |
87 | |
90 | |
88 | Net::FPing::register_cb \&cb |
91 | AnyEvent::FastPing::register_cb \&cb |
89 | Register a callback that is called for every received ping reply |
92 | Register a callback that is called for every received ping reply |
90 | (regardless of whether a ping is still in process or not and |
93 | (regardless of whether a ping is still in process or not and |
91 | regardless of whether the reply is actually a reply ot a ping sent |
94 | regardless of whether the reply is actually a reply to a ping sent |
92 | earlier). |
95 | earlier). |
93 | |
96 | |
94 | The code reference gets a single parameter - an arrayref with an |
97 | The code reference gets a single parameter - an arrayref with an |
95 | entry for each received packet (replies are beign batched for |
98 | entry for each received packet (replies are beign batched for |
96 | greater efficiency). Each packet is represented by an arrayref with |
99 | greater efficiency). Each packet is represented by an arrayref with |
… | |
… | |
121 | "0.00090184211731", |
124 | "0.00090184211731", |
122 | 305419896 |
125 | 305419896 |
123 | ] |
126 | ] |
124 | ] |
127 | ] |
125 | |
128 | |
126 | Net::FPing::unregister_cb \&cb |
129 | AnyEvent::FastPing::unregister_cb \&cb |
127 | Unregister the callback again (make sure you pass the same |
130 | Unregister the callback again (make sure you pass the same |
128 | codereference as to "register_cb"). |
131 | codereference as to "register_cb"). |
129 | |
132 | |
130 | AUTHOR |
133 | AUTHOR |
131 | Marc Lehmann <schmorp@schmorp.de> |
134 | Marc Lehmann <schmorp@schmorp.de> |
132 | http://home.schmorp.de/ |
135 | http://home.schmorp.de/ |
133 | |
136 | |
134 | AUTHOR |
137 | AUTHOR |
135 | This software is distributed under the GENERAL PUBLIC LICENSE, |
138 | This software is distributed under the GENERAL PUBLIC LICENSE, version 2 |
136 | version 2 or any later. |
139 | or any later version or, at your option, the Artistic License. |
137 | |
140 | |