Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
cbe89168
Commit
cbe89168
authored
Nov 18, 2005
by
Russ Fish
Browse files
Add platform-dependent ping code for Windows.
parent
32560429
Changes
1
Show whitespace changes
Inline
Side-by-side
event/linktest/linktest.pl.in
View file @
cbe89168
...
...
@@ -597,18 +597,25 @@ sub ping_node {
# set deadline to prevent long waits
my
$cmd
;
my
$ttlarg
=
"";
if
(
$ttl
)
{
if
(
$platform
eq
BSD
)
{
$
cmd
=
"
/sbin/ping -c
$send_count
-q -i
$send_rate
-t
$timeout
-m
$ttl
$host
";
$
ttlarg
=
"
-m
$ttl
";
}
elsif
(
$platform
eq
LINUX
)
{
$cmd
=
"
/bin/ping -c
$send_count
-q -i
$send_rate
-w
$timeout
-t
$ttl
$host
";
$ttlarg
=
"
-t
$ttl
";
}
elsif
(
$platform
=~
/CYGWIN/
)
{
# The Windows system ping has a TTL arg; Cygwin ping doesn't.
$ttlarg
=
"
-i
$ttl
";
}
}
}
else
{
if
(
$platform
eq
BSD
)
{
$cmd
=
"
/sbin/ping -c
$send_count
-q -i
$send_rate
-t
$timeout
$host
";
$cmd
=
"
/sbin/ping -c
$send_count
-q -i
$send_rate
-t
$timeout
$ttlarg
$host
";
}
elsif
(
$platform
eq
LINUX
)
{
$cmd
=
"
/bin/ping -c
$send_count
-q -i
$send_rate
-w
$timeout
$host
";
}
$cmd
=
"
/bin/ping -c
$send_count
-q -i
$send_rate
-w
$timeout
$ttlarg
$host
";
}
elsif
(
$platform
=~
/CYGWIN/
)
{
# Neither Windows nor Cygwin ping has either send rate or timeout.
# Windows ping doesn't have -q, but it does have TTL, so use it.
$cmd
=
"
/cygdrive/c/WINDOWS/system32/ping.exe -n
$send_count
$ttlarg
$host
";
}
# note backticks passes SIGINT to child procs
...
...
@@ -621,6 +628,9 @@ sub ping_node {
$count
=
$
1
;
}
elsif
(
$platform
eq
LINUX
&&
$result
=~
/(\d+) received/
)
{
$count
=
$
1
;
}
elsif
(
$platform
=~
/CYGWIN/
&&
$results
[
$reslt_cnt
-
3
]
=~
/Received = (\d+)/
)
{
$count
=
$
1
;
}
if
(
$count
)
{
...
...
@@ -628,6 +638,9 @@ sub ping_node {
if
(
$result
=~
/\d+\.\d+\/(\d+\.\d+)\/\d+\.\d+\/(\d+\.\d+)/
)
{
$avg_latency
=
$
1
;
$stddev
=
$
2
;
}
elsif
(
$result
=~
/Average = (\d+)ms/
)
{
$avg_latency
=
$
1
;
$stddev
=
0.03
;
# Stddev is not reported on Windows.
}
}
return
(
$count
,
$avg_latency
,
$stddev
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment