Fast pinger, version 2.22
(c) Copyright 2001 - 2008 Kwakkelflap
Written by Wouter Dhondt
Web: http://www.kwakkelflap.com
E-Mail: info@kwakkelflap.com

---------------------------------------------------------------------------------

Fping is a simple ping program, intended to be used instead of the
standard ping program that comes with windows. It was first made
to ping faster than once every second. Options have been added since
then and fping is now a very handy tool (at least I think it is).

PLATFORMS:
Windows 95, 98, NT 4.0, 2000, ME, XP, 2003 server, Vista and 2008 server

---------------------------------------------------------------------------------

Legal mumbo jumbo :

This program and the accompanying documentation are Copyright (C) 2001 - 2008
by Kwakkelflap.  You are allowed to redistribute it, provided that all 
the files in the original archive are distributed together and no changes
are made to any file in the distribution.  You can't charge for the 
program, only for distributing it.  You have to clearly identify me 
(Wouter Dhondt) as the author.

This program comes without any warranty either implied or expressed. In no
case shall the author be liable for any damage or unwanted behaviour of any
computer hardware and/or software.

The same things in English:

   - I own it.  It's mine.  Muahahaha!  (But I let you use it too.)

   - I can't guarantee that it works, or that it works correctly.

   - If it breaks, it's your fault.  But you do get to keep the pieces.

   - If it breaks something else, it's your fault too.

   - If you copy it, don't claim that you've made it yourself, or
     change it in any way; and copy both program and documentation.

   - You are free to offer the program on your web page.  All I ask for
     is that you give a link back to mine, and that you state that the
     program was made by Wouter Dhondt.

---------------------------------------------------------------------------------

Ping is one of the most useful network debugging tools available. The first ping 
program was written by Mike Muuss in December 1983 for use on Unix machines. Muuss 
named his program after the sonar sounds used for echolocation by submarines, 
although some say ping stands for "Packet InterNet Grouper". Ping sends a small 
packet of information containing an ICMP ECHO_REQUEST to a specified computer, 
which then sends an ECHO_REPLY packet in return. The ping program then evaluates 
this reply, and a report is shown. You can check several things with the ping 
program: can you reach another computer, how long does it take to bounce a packet 
off of another site, ... You can ping either a domain name, or an IP address. 
Functionality to show domain names when using IP addresses is supported. Even 
routing options are available, alas only 9 routes can be shown due to the 
structure of the IP header (RFC 792). Why did I write my own ping program? 
There are two main reasons: a) It wanted to know how the ping program worked. I 
found it really intriguing and was very curious and b) There was a need for a 
better ping program here at the lab where I work.

Usage:
fping <host(-list)> [-s data_size] [-S size1/size2] [-c] [-t time] [-w timeout]
             [-n count] [-h TTL] [-v TOS] [-r routes][-R min/max] [-a] [-f] 
	     [-b(-)] [-i] [-l] [-o] [-j] [-T] [-d ping_data] [-g host1/host2]
             [-H filename] [-L filename]
  
Options:
  -s : data_size in bytes up to 65500
  -S : size sweep. Ping with size1, size1 + 1, ..., size 2 datalength
  -c : continuous ping (higher priority than -n)
       to see statistics and continue - type Control-Break;
       to stop - type Control-C.
  -t : time between 2 pings in ms up to 1000000
  -w : timeout in ms to wait for each reply
  -n : number of echo requests to send
  -h : number of hops (TTL: 1 to 128) + print hops
  -v : Type Of Service (0 to 255)
  -r : record route (1 to 9 routes)
  -R : random length between min and max (disabled when using -S)
  -a : resolve addresses to hostnames
  -f : set Don't Fragment flag in packet
  -b : beep on every successful reply (- to beep on timeout)
  -i : use ICMP dll instead of raw socket (disables -r)
  -l : limit the output to ping results and errors
  -o : limit the output to ping statistics
  -j : print jitter with each reply (only when pinging one host)
  -T : print timestamp with each reply
  -D : print datestamp and timestamp with each reply
  -d : ping with specified data
  -g : ping IP range from host1 to host2
  -H : get hosts from filename (comma delimited, filename with full path)
  -L : logging to a text file

fping uses raw sockets. This can be a problem for NT / 2000 / XP system
users without administrator rights. Raw socket creation will fail
due to a silly and useless socket protection. Fping will switch
to the ICMP dll if this happens (to ping the micro$oft way). To 
disable this protection (and take full advantage of fping) you can
do the following:
a) NT4 users should change / add the following registry variable
and set its value to DWORD 1:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Afd\Parameters\DisableRawSecurity
b) 2000 / XP users should set the following registry variable to DWORD 1
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters\AllowUserRawAccess

Also, if you want to change the TOS on 2000/XP systems, you need to add the
following value in the registry and set it to 0:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\TCPip\Parameters\DisableUserTOSSetting

after you change the registry, you will need to reboot.
You can also run the reg file in accordance with your os.

Return Values:
Reply: 0
Reply timed out: 1
Host not found: 2
Packet size exceeds MTU: 3
Too few bytes: 4
Non-echo type: 5

Send questions (and bug reports) 2 support@kwakkelflap.com

---------------------------------------------------------------------------------

Known bugs: none

Possible future enhancements:
- loose and strict route ping options
- other ping options

---------------------------------------------------------------------------------

Revision History:

Version 2.22 (12/11/08)
- Fix for Win2K for the getaddrinfo() function (since version 2.19) (234)

Version 2.21 (31/10/08)
- Limit the output to statistics only (214)
- Use the real data size with -d option if not set with -s option (224)
- Removed the first 4 bytes of the RAW socket ping which had timing information (obsolete since 2.11) (224)
- Ping with random size and known data (225)
- Set the timer resolution to allow fast pings (231)

Version 2.20 (09/04/08)
- Calculate jitter when pinging one host (210)
- Print hops when using the TTL option for IPv4 (210)

Version 2.19 (07/04/08)
- Ping IPv6 address (189)

Version 2.18 (07/03/08)
- VS 2005 fix
- -g option bugfix
- Flush the output for each line
- x64 version

Version 2.17 (08/03/07)
- Fixed % sign with -i option
- Fixed recursive function block
- Display hostname when pinging multiple hosts
- Solved a problem with min time being max
- Fixed first ping time info
- Adjusted ICMP ping printout for parsing
- Average precision is the same as min and max

Version 2.16 (23/08/06)
- Log to file option
- Ping default with random data

Version 2.15 (10/04/06)
- Fixed a bug with the -d option

Version 2.14 (05/04/06)
- Use PC speaker instead of WAV for beep

Version 2.13 (13/02/06)
- Print the TOS with each ping
- Sequence check with RAW sockets
- Larger time between pings

Version 2.12 (09/06/05)
- g option added: host sweep

Version 2.11 (04/05/05)
- Use high precision timer
- datestamp option
- No need for comma's in host file, new line is also ok
- fixed a bug when there is only one host in the host file

Version 2.10 (23/02/05)
- Fix in the reply # indication in some cases (was always 1)
- Ping with random size

Version 2.09 (25/11/02)
- Bug fix: # of bytes with raw socket ping was incorrect

Version 2.08 (07/11/02)
- Fping size sweep
- Ping with specified data
- Retrieve hosts from comma delimited filename
- Removed self made linked list and using STL

Version 2.07 (25/06/02)
- Fping crashed in ICMP ping if no host was found with IP address
- Continue ping if host can't be found from IP address
- Space between return trip time and "ms" to allow better parsing
- Option to print timestamp with each reply

Version 2.06 (12/03/02)
- limit output option
- return values

Version 2.05 (16/10/01)
- ICMP WSAStartup & WSACleanup bug resolved.
- RAW Socket receive error time is now correct
- Usage programdir truncated
- Better invalid option parsing support
- Cleaned IP options struct (number of echo requests)
- Ping multiple hosts
- Reverse beep option

Version 2.04 (29/08/01)
- Zero ping statistics bug resolved
- ICMP dll option
- switch to ICMP dll if raw socket creation failed
- /? | -? gives usage info
- resolving addresses to hostnames (includes routing)
- internal IP options struct changed
- Don't Fragment flag can be set
- Option to beep on every successful reply

Version 2.03 (04/07/01)
- Routing

Version 2.02 (03/07/01)
- Generic error log messages instead of numbers as 10065
- Adjustable # of hops (TTL)
- Adjustable TOS