Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nemu3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
nemu3
Commits
dce284fa
Commit
dce284fa
authored
Aug 12, 2010
by
Martín Ferrari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better output, including csv
parent
083bae26
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
9 deletions
+34
-9
benchmarks/linear-raw-throughput.py
benchmarks/linear-raw-throughput.py
+34
-9
No files found.
benchmarks/linear-raw-throughput.py
View file @
dce284fa
#!/usr/bin/env python
#!/usr/bin/env python
# vim: ts=4:sw=4:et:ai:sts=4
# vim: ts=4:sw=4:et:ai:sts=4
import
getopt
,
netns
,
os
,
os
.
path
,
re
,
select
,
subprocess
,
sys
import
csv
,
getopt
,
netns
,
os
,
os
.
path
,
re
,
select
,
subprocess
,
sys
__doc__
=
"""Creates a linear network topology, and measures the maximum
__doc__
=
"""Creates a linear network topology, and measures the maximum
end-to-end throughput for the specified packet size."""
end-to-end throughput for the specified packet size."""
def
usage
(
f
):
def
usage
(
f
):
f
.
write
(
"Usage: %s --nodes=
<n> --pktsize=<n> [OPTIONS]
\
n
\
n
%s
\
n
\
n
"
%
f
.
write
(
"Usage: %s --nodes=
NUM --pktsize=BYTES [OPTIONS]
\
n
%s
\
n
\
n
"
%
(
os
.
path
.
basename
(
sys
.
argv
[
0
]),
__doc__
))
(
os
.
path
.
basename
(
sys
.
argv
[
0
]),
__doc__
))
f
.
write
(
"Mandatory arguments:
\
n
"
)
f
.
write
(
"Mandatory arguments:
\
n
"
)
f
.
write
(
" -n, --nodes=N
ODES
Number of nodes to create
\
n
"
)
f
.
write
(
" -n, --nodes=N
UM
Number of nodes to create
\
n
"
)
f
.
write
(
" -s, --pktsize=BYTES Size of packet payload
\
n
\
n
"
)
f
.
write
(
" -s, --pktsize=BYTES Size of packet payload
\
n
\
n
"
)
f
.
write
(
"Topology configuration:
\
n
"
)
f
.
write
(
"Topology configuration:
\
n
"
)
...
@@ -22,7 +22,11 @@ def usage(f):
...
@@ -22,7 +22,11 @@ def usage(f):
f
.
write
(
"How long should the benchmark run (defaults to -t 10):
\
n
"
)
f
.
write
(
"How long should the benchmark run (defaults to -t 10):
\
n
"
)
f
.
write
(
" -t, --time=SECS Stop after SECS seconds
\
n
"
)
f
.
write
(
" -t, --time=SECS Stop after SECS seconds
\
n
"
)
f
.
write
(
" -p, --packets=NUM Stop after NUM packets
\
n
"
)
f
.
write
(
" -p, --packets=NUM Stop after NUM packets
\
n
"
)
f
.
write
(
" -b, --bytes=BYTES Stop after BYTES bytes sent
\
n
"
)
f
.
write
(
" -b, --bytes=BYTES Stop after BYTES bytes sent
\
n
\
n
"
)
f
.
write
(
"Output format:
\
n
"
)
f
.
write
(
" --format=FMT Valid values are `csv', `brief', "
+
"and `verbose'
\
n
"
)
def
main
():
def
main
():
error
=
None
error
=
None
...
@@ -30,13 +34,14 @@ def main():
...
@@ -30,13 +34,14 @@ def main():
try
:
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"hn:s:t:p:b:"
,
[
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"hn:s:t:p:b:"
,
[
"help"
,
"nodes="
,
"pktsize="
,
"time="
,
"packets="
,
"bytes="
,
"help"
,
"nodes="
,
"pktsize="
,
"time="
,
"packets="
,
"bytes="
,
"use-p2p"
,
"delay="
,
"jitter="
,
"bandwidth="
])
"use-p2p"
,
"delay="
,
"jitter="
,
"bandwidth="
,
"format="
])
except
getopt
.
GetoptError
,
err
:
except
getopt
.
GetoptError
,
err
:
error
=
str
(
err
)
# opts will be empty
error
=
str
(
err
)
# opts will be empty
pktsize
=
nr
=
time
=
packets
=
nbytes
=
None
pktsize
=
nr
=
time
=
packets
=
nbytes
=
None
use_p2p
=
False
delay
=
jitter
=
bandwidth
=
None
delay
=
jitter
=
bandwidth
=
None
use_p2p
=
False
format
=
"verbose"
for
o
,
a
in
opts
:
for
o
,
a
in
opts
:
if
o
in
(
"-h"
,
"--help"
):
if
o
in
(
"-h"
,
"--help"
):
...
@@ -61,6 +66,12 @@ def main():
...
@@ -61,6 +66,12 @@ def main():
elif
o
in
(
"--use-p2p"
):
elif
o
in
(
"--use-p2p"
):
use_p2p
=
True
use_p2p
=
True
continue
# avoid the value check
continue
# avoid the value check
elif
o
==
"--format"
:
if
a
not
in
(
'csv'
,
'brief'
,
'verbose'
):
error
=
"Invalid format: %s"
%
a
break
format
=
a
continue
else
:
else
:
raise
RuntimeError
(
"Cannot happen"
)
raise
RuntimeError
(
"Cannot happen"
)
# In all cases, I take a number
# In all cases, I take a number
...
@@ -78,8 +89,10 @@ def main():
...
@@ -78,8 +89,10 @@ def main():
error
=
"Cannot use link emulation with P2P links"
error
=
"Cannot use link emulation with P2P links"
if
error
:
if
error
:
sys
.
stderr
.
write
(
"%s: %s
\
n
\
n
"
%
(
os
.
path
.
basename
(
sys
.
argv
[
0
]),
error
))
sys
.
stderr
.
write
(
"%s: %s
\
n
"
%
(
os
.
path
.
basename
(
sys
.
argv
[
0
]),
error
))
usage
(
sys
.
stderr
)
sys
.
stderr
.
write
(
"Try `%s --help' for more information.
\
n
"
%
os
.
path
.
basename
(
sys
.
argv
[
0
]))
#usage(sys.stderr)
sys
.
exit
(
2
)
sys
.
exit
(
2
)
if
not
(
time
or
nbytes
or
packets
):
if
not
(
time
or
nbytes
or
packets
):
...
@@ -100,6 +113,8 @@ def main():
...
@@ -100,6 +113,8 @@ def main():
cmdline
.
append
(
"--max-pkts=%d"
%
packets
)
cmdline
.
append
(
"--max-pkts=%d"
%
packets
)
if
nbytes
:
if
nbytes
:
cmdline
.
append
(
"--max-bytes=%d"
%
nbytes
)
cmdline
.
append
(
"--max-bytes=%d"
%
nbytes
)
if
format
==
"verbose"
:
cmdline
.
append
(
"--verbose"
)
srv
=
nodes
[
0
].
Popen
(
cmdline
,
stdout
=
subprocess
.
PIPE
)
srv
=
nodes
[
0
].
Popen
(
cmdline
,
stdout
=
subprocess
.
PIPE
)
...
@@ -128,7 +143,17 @@ def main():
...
@@ -128,7 +143,17 @@ def main():
srv
.
wait
()
srv
.
wait
()
clt
.
wait
()
clt
.
wait
()
print
out
.
strip
()
out
=
out
.
strip
()
if
format
!=
"csv"
:
print
"Command line: %s"
%
(
" "
.
join
(
sys
.
argv
[
1
:]))
print
out
.
strip
()
return
data
=
out
.
split
(
" "
)
data
=
map
(
lambda
s
:
s
.
partition
(
":"
)[
2
],
data
)
writer
=
csv
.
writer
(
sys
.
stdout
)
writer
.
writerow
([
" "
.
join
(
sys
.
argv
[
1
:])]
+
data
)
def
ip2dec
(
ip
):
def
ip2dec
(
ip
):
match
=
re
.
search
(
r'^(\
d+)
\.(\
d+)
\.(\
d+)
\.(\
d+)$
', ip)
match
=
re
.
search
(
r'^(\
d+)
\.(\
d+)
\.(\
d+)
\.(\
d+)$
', ip)
...
...
Write
Preview
Markdown
is supported
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