Adjustable PING delay. Is 128.0.0.1 always good ?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
alan_b
Expert
Posts: 357
Joined: 04 Oct 2008 09:49

Adjustable PING delay. Is 128.0.0.1 always good ?

#1 Post by alan_b » 22 Jan 2011 05:25

I have achieved Infinitesimally adjustable PING delay via

Code: Select all

ping -w %1 128.0.0.1 -n 1 > NUL


Is 128.0.0.1 always good for getting a "Request timed out." response from ping so that the -w option will control the delay ?

Supplementary question :-

Why is -w always wrong ?
Can I fix it somehow, perhaps in the registry ?
I find the actual delay achieved is 500 mSec more than I ask for,
e.g. the argument has to be 9500 if I really want 10000 mSec,
and an argument of 100 gives me 500 mSec.

I find a delay of only 200 mSec when I use
ping -w %1 127.0.0.1 -n 1

If I could fix this offset I should be able to control down to 200 mSec instead of 500 mSec.
My only option below 500 mSec seem to be
390 mSec via "PING Google.net -n 1 > NUL"
or something a bit smaller if I aim at a site that is not across the Atlantic.

Alan

aGerman
Expert
Posts: 4656
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Adjustable PING delay. Is 128.0.0.1 always good ?

#2 Post by aGerman » 22 Jan 2011 08:18

Hello Alan.

As far as I know 128.0.0.1 belongs to class B IP adresses and could be an guilty internet address. It's administered by ARIN (American Registry for Internet Numbers), you could ask them (just kidding :wink:).
But finaly it's a good question. I often use 0.0.0.0 because I know it's a reserved IP address ...


The reason why you have an additional delay of 200...500 ms is that ping is no internal function of cmd.exe. By calling ping your computer has to create a ping.exe process. It depends on the speed of your machine and on the current CPU use how much time it wastes. For me it's 150...250 ms.
Maybe it's a question of priority as well. Try something like
START /HIGH /WAIT /B PING ...
to find out.

Regards
aGerman

amel27
Expert
Posts: 177
Joined: 04 Jun 2010 20:05
Location: Russia

Re: Adjustable PING delay. Is 128.0.0.1 always good ?

#3 Post by amel27 » 22 Jan 2011 09:26

Hi All.

128.0.0.0/24 is Netherlands address pool. According to RFC 3330 we can use for this purposes two pools:
192.0.2.0/24 - This block is assigned as "TEST-NET" for use in documentation and example code. It is often used in conjunction with domain names example.com or example.net in vendor and protocol documentation. Addresses within this block should not appear on the public Internet.

198.18.0.0/15 - This block has been allocated for use in benchmark tests of network interconnect devices. Its use is documented in [RFC2544].

aGerman
Expert
Posts: 4656
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Adjustable PING delay. Is 128.0.0.1 always good ?

#4 Post by aGerman » 22 Jan 2011 09:39

Thanks for this information, amel27. I was never searching for it since 0.0.0.0 worked for me.

Regards
aGerman

alan_b
Expert
Posts: 357
Joined: 04 Oct 2008 09:49

Re: Adjustable PING delay. Is 128.0.0.1 always good ?

#5 Post by alan_b » 22 Jan 2011 12:31

aGerman wrote:I often use 0.0.0.0 because I know it's a reserved IP address ...
aGerman

Unfortunately the -w option is ignored and the immediate response is
"Destination specified is invalid."

aGerman wrote:By calling ping your computer has to create a ping.exe process.
aGerman

Comodo "Defense+" shows me that CMD.EXE invokes Windows\System32\Ping.exe,
and this is an ancient external command.
When you said "create a ping.exe process" were you referring to what I think I remember as "Building the IP stack" ?

aGerman wrote:Maybe it's a question of priority as well. Try something like
START /HIGH /WAIT /B PING ...
aGerman

Thanks, that does slightly reduce the excess when not much else is happening,
and will probably give me much faster and more reproducible results when website adverts push the Firefox CPU usage to 90%.

amel27 wrote:128.0.0.0/24 is Netherlands address pool.

Thanks for the information.
I would not want to inadvertently launch a PING and distract a Dutchman from sticking his finger in the sea defenses ! ! !

amel27 wrote:192.0.2.0/24 - This block is assigned as "TEST-NET"

I am now using 192.0.2.0

Regards and thanks to all
Alan

aGerman
Expert
Posts: 4656
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Adjustable PING delay. Is 128.0.0.1 always good ?

#6 Post by aGerman » 22 Jan 2011 13:56

alan_b wrote:When you said "create a ping.exe process" were you referring to what I think I remember as "Building the IP stack" ?


No, that's not the same. It takes exactly the same time to call each other external command/tool. I think if ping.exe is running then building the IP stack will need less than a ms.

Regards
aGerman

alan_b
Expert
Posts: 357
Joined: 04 Oct 2008 09:49

Re: Adjustable PING delay. Is 128.0.0.1 always good ?

#7 Post by alan_b » 22 Jan 2011 15:18

Thanks

I was surprised it takes so long for the executable to be launched.

I thought it might take a while visiting folders on the %PATH%,
but found it took just as long if I replaced PING with
C:\WINDOWS\system32\PING.EXE.

I had not realized that launching an exe takes so much longer than the rotational latency of my HDD.

Regards
Alan

aGerman
Expert
Posts: 4656
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Adjustable PING delay. Is 128.0.0.1 always good ?

#8 Post by aGerman » 22 Jan 2011 16:03

Hmm, using the full name is probably helpful if you have a lot of files in the current working directory. This is the place where cmd is searching first.
Usually the first directory in %path% is C:\Windows\System32, where cmd is searching next. Thats why it will not make a significant difference.

Regards
aGerman

alan_b
Expert
Posts: 357
Joined: 04 Oct 2008 09:49

Re: Adjustable PING delay. Is 128.0.0.1 always good ?

#9 Post by alan_b » 23 Jan 2011 03:22

It reminds me of my first P.C. with DOS 3.?

A very simple script took quite a time if it had a loop.
Then I copied it from the HDD to 5.25" floppy and ran from the floppy.
I could feel its pain as it clattered through the whole file reading it one line at a time until it got to the line just executed so it could then read and execute the next line ! !
I cannot now remember whether the script was a DOS batch file or a Dartmouth Basic interpreter program.

Fortunately I had the luxury of one Megabyte of RAM and Bill Gates decreed that anything more that 640 KB was wasted, so I included a RAM disk driver and at startup I copied all by scripts to the 360 KB RAM disk. That system flew.

Why do a succession of PINGs in my script each take so long to launch and do nothing ?
I thought XP had a cache in RAM that should remember what was loaded the first time,
and then repeat without clattering through the disk every time ! ! !

So glad I do not have UAC as well.

Regards
Alan

amel27
Expert
Posts: 177
Joined: 04 Jun 2010 20:05
Location: Russia

Re: Adjustable PING delay. Is 128.0.0.1 always good ?

#10 Post by amel27 » 23 Jan 2011 04:29

alan_b wrote:I thought XP had a cache in RAM that should remember what was loaded the first time, and then repeat without clattering through the disk every time ! ! !
Yes, XP have cache, but Windows dinamically operates its content. AFAIK impossible manually control individual file caching.

Caching whole BAT file will make impossible Self Modification feature. Otherwise, FOR loop cached whole block code between parentheses.

alan_b
Expert
Posts: 357
Joined: 04 Oct 2008 09:49

Re: Adjustable PING delay. Is 128.0.0.1 always good ?

#11 Post by alan_b » 23 Jan 2011 11:22

amel27 wrote:Caching whole BAT file will make impossible Self Modification feature. Otherwise, FOR loop cached whole block code between parentheses.


Oh dear, the more you tell me the less I know ! ! !

Typically I may end a script with PAUSE so I can see the results when launched by double clicking,
and if it crashes and never gets to PAUSE,
then I run CMD.EXE and use the CLI to run the script to see what it was doing when it crashed.
Then I edit to fix things and try again.
Once it sort of works I may fix it some more.

Bitter experience - If it stops at PAUSE and I fail to UN-Pause when I edit,
when I finish EDIT and try to run again, as soon as I UN-Pause then chaos breaks out, which I assume is because PAUSE was at file byte no. 1234 and I have now inserted an extra 100 bytes and UN-Pause now continues from 1235 instead of 1335.

Also with pre-XP using Command.com it always crashed when I tried to make the script self-modify.
The closest I ever got was for the script to copy itself with a different name,
and to append an extra line of code to the copy for future use.

I would appreciate a link to an example of successful self modifying batch code.

Regards
Alan

aGerman
Expert
Posts: 4656
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Adjustable PING delay. Is 128.0.0.1 always good ?

#12 Post by aGerman » 23 Jan 2011 11:51


alan_b
Expert
Posts: 357
Joined: 04 Oct 2008 09:49

Re: Adjustable PING delay. Is 128.0.0.1 always good ?

#13 Post by alan_b » 23 Jan 2011 13:19

Thanks for that link.

Sometimes I am too ambitious with my scripts and I have to debug them.
I have now realized that anything self-modifying will be complex and need a lot of debugging,
and trying to debug what changes of its own accord will damage my sanity.

Regards
Alan

Post Reply