source: project/wiki/eggref/4/eping @ 29235

Last change on this file since 29235 was 29235, checked in by svnwiki, 7 years ago

Anonymous wiki edit for IP [82.48.202.199]:

File size: 9.1 KB
Line 
1[[tags: egg]]
2[[toc:]]
3
4== eping
5
6eping is a Scheme implementation of the ICMP ping utility. Although it can be used like an average OS ping utility, eping is intended to be used programmatically (e.g. for gathering statistics, monitoring). It uses raw sockets thus a privileged account must be used.
7
8<enscript highlight=scheme>
9[procedure] (eping HOST #!key (mode 'probe)
10                              (count #f)
11                              (timeout 1000)
12                              (interval 1000)
13                              (ttl 64)
14                              (tos 0)
15                              (dont-fragment #f)
16                              (src-addr #f)
17                              (id #f)
18                              (seq-start 0)
19                              (size 56)
20                              (pattern "")
21                              (recv-min #f)
22                              (lost-max #f)
23                              (cons-recv-min #f)
24                              (cons-lost-max #f)
25                              (msg1 "%i is alive%n")
26                              (msg2 "")
27                              (dotcols 0)
28                              (quiet #t))
29</enscript>
30
31HOST can be either an IPv4 address or an hostname: '192.168.1.1 , "192.168.1.1" , 'example.com, "example.com" are all valid hosts.
32
33eping supports four modes of operation: ''probe'' (default), ''stats'', ''dot'' and ''mtu''.
34
35=== Probe mode
36
37In this mode eping returns true or false if it considers an host alive or unreachable respectively. The default behavior is to consider an host alive as soon as an echo reply is received. If no reply is received in ''count'' attempts, the host is considered unreachable. If not specified, ''count'' is 5 by default. Probe mode is the default one so it can be omitted as parameter.
38
39<enscript highlight=scheme>
40(eping "call-cc.org")
41
42===> #t
43</enscript>
44
45The aliveness criteria can be changed through the four parameters ''recv-min'', ''lost-max'', ''cons-recv-min'', ''cons-lost-max'' (see "Parameters" section). As soon as one of these conditions is met eping returns the associated boolean value. If no condition is met in ''count'' attempts ''#f'' is returned.
46
47In non-quiet 'submode' a message is displayed as well.
48
49<enscript highlight=scheme>
50(eping "call-cc.org" quiet: #f)
51209.172.49.65 is alive
52</enscript>
53
54The output message can be customized through the ''msg1'' and ''msg2'' parameters.
55
56=== Stats mode
57
58In stats mode eping returns a vector of statistics #(sent lost rtt-min rtt-avg rtt-max rtt-std). The rtt values are expressed in ''ms''.
59
60<enscript highlight=scheme>
61(eping "call-cc.org" mode: 'stats)
62
63==> #(5 0 133 134.2 136 0.92)
64</enscript>
65
66In non-quiet 'submode' the output resembles a standard ping utility:
67
68<enscript highlight=scheme>
69(eping "call-cc.org" mode: 'stats quiet: #f)
7064 bytes from 209.172.49.65: icmp_seq=0 ttl=52 time=139ms
7164 bytes from 209.172.49.65: icmp_seq=1 ttl=52 time=227ms
7264 bytes from 209.172.49.65: icmp_seq=2 ttl=52 time=135ms
7364 bytes from 209.172.49.65: icmp_seq=3 ttl=52 time=170ms
7464 bytes from 209.172.49.65: icmp_seq=4 ttl=52 time=256ms
75
76--- call-cc.org ping statistics ---
775 packets transmitted, 5 packets received, 0% packet loss
78round-trip min/avg/max/stddev = 135.0/185.4/256.0/48.26 ms
79</enscript>
80
81Ctrl-\ (SIGQUIT) can be used to print partial statistics without stopping the ping (POSIX platforms only). Ctrl-C can be used to stop and collect the statistics at any moment.
82
83By default 5 packets are sent. The ''count'' option can be used to change this value (0 meaning continuos operation).
84
85=== Dot mode
86
87In this mode eping returns a single character for each echo request:
88
89* [.] Echo reply received
90* [!] No response
91* [N] Network unreachable
92* [H] Host unreachable
93* [P] Protocol unreachable
94* [F] Packet too big and DF bit set
95* [A] Administratively filtered
96* [T] Time to live exceeded
97* [O] Network/Host unreachable for TOS
98* [U] Unreachable (generic error)
99
100<enscript highlight=scheme>
101(eping "call-cc.org" mode: 'dot quiet: #f timeout: 134 count: 20)
102..!...!....!.!!!....
103</enscript>
104
105The ''dotcols'' parameter can be used to set the number of chars to be printed before a newline. The default behavior (0) inserts a newline only after the last echo request.
106
107<enscript highlight=scheme>
108(eping "call-cc.org mode": 'dot quiet: #f timeout: 134 count: 20 dotcols: 5)
109!...!
110....!
111...!.
112!....
113</enscript>
114
115In quiet 'submode' a string built from the generated characters is returned.
116
117<enscript highlight=scheme>
118(eping "call-cc.org" mode: 'dot count: 3)
119"..."
120</enscript>
121
122=== Mtu mode
123
124In mtu mode eping attempts to compute the MTU in the path. To speed up the process it is advisable to lower the default 1000''ms'' echo requests interval time (''interval'' option).
125
126<enscript highlight=scheme>
127(eping "call-cc.org" mode: 'mtu interval: 250)
128
129===> 1492
130</enscript>
131
132Lossy links may slow down or even prevent the convergence. The ''count'' option can be used to increase the number of attempts (default is 64). If mtu can't be computed ''#f'' is returned.
133
134=== Parameters
135
136==== General
137
138* '''count''' The number of echo requests to be sent. The default is 5 for modes
139  other than ''mtu'' and 64 for ''mtu'' mode. If set to 0 echo requests are sent
140  until a probe condition is met (''probe'' mode), mtu is computed (''mtu'' mode)
141  or SIGINT (Ctrl-C) is received (all modes).
142
143* '''timeout''' The amount of time in ''ms'' to let pass before considering an host
144  unreachable (default is 1000ms).
145
146* '''interval''' The interval in ''ms'' between echo requests (default is
147  1000ms). This value can't be set lower than ''timeout'' (this rule is enforced
148  lowering *timeout* in case).
149
150==== IP
151
152* '''ttl''' / '''tos''' Respectively the Time To Live and TOS in the IP header.
153
154* '''dont-fragment''' Sets the Don't Fragment (DF) flag in the IP header.
155
156* '''src-addr''' Binds the ICMP socket to a specific IP address.
157
158==== ICMP
159
160* '''size''' The ICMP payload size.
161
162* '''pattern''' A string used to fill the payload (repeated if necessary).
163
164* '''id''' The Identifier field (0-65535). By default it is generated randomly
165  for every invocation of the eping function.
166
167* '''seq-start''' The initial sequence of the echo requests (0 by default).
168
169==== Probing
170
171* '''recv-min''' Minimum number of received replies before considering an host
172  alive.
173
174* '''lost-max''' Maximum number of missed replies before considering an host
175  unreachable.
176
177* '''cons-recv-min''' Minimum number of consecutive received replies before
178  considering an host alive.
179
180* '''cons-lost-max'''  Maximum number of consecutive missed replies before
181  considering an host unreachable.
182
183==== Output
184
185* '''msg1''' The message displayed when an host is considered alive. The default
186  message is "%i is alive%n" where %i is interpreted as the IP address of the
187  host. Similarly %h is interpreted as the hostname while %n inserts a newline.
188
189* '''msg2'''  The message displayed when an host is considered unreachable. By
190  default it is an empty string.
191
192* '''dotcols''' In ''dot'' mode the number of displayed chars before a newline is
193  inserted. By default (0) a newline is inserted only after the last displayed
194  char.
195
196* '''quiet''' By default eping doesn't display anything unless this option is set
197  to ''#f''.
198
199=== Installation
200<enscript highlight=bash>
201chicken-install eping
202</enscript>
203
204=== Usage
205<enscript highlight=scheme>
206(use eping)
207</enscript>
208=== About this egg
209The source code is hosted at [[https://bitbucket.org/miklam/eping/|Bitbucket]]. Feel free to send pull requests or open an issue there. Alternatively, send an e-mail to [[mailto://chicken-users@nongnu.org|chicken-users]] mailing list for information or requests.
210==== Version History
211; 1.0 : Initial release
212==== Author
213Michele La Monaca
214==== License
215 Copyright (c) 2013
216 Michele La Monaca (mikele~lamonaca.net)
217 All rights reserved.
218 
219 Redistribution and use in source and binary forms, with or without
220 modification, are permitted provided that the following conditions are
221 met:
222 
223 1) Redistributions of source code must retain the above copyright
224 notice, this list of conditions and the following disclaimer.
225 
226 2) Redistributions in binary form must reproduce the above copyright
227 notice, this list of conditions and the following disclaimer in the
228 documentation and/or other materials provided with the distribution.
229 
230 3) Neither the name of the author nor the names of its contributors
231 may be used to endorse or promote products derived from this software
232 without specific prior written permission.
233 
234 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
235 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
236 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
237 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
238 COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
239 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
240 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
241 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
242 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
243 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
244 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
245 OF THE POSSIBILITY OF SUCH DAMAGE.
Note: See TracBrowser for help on using the repository browser.