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
8ae7eb92
Commit
8ae7eb92
authored
Aug 24, 2010
by
Martín Ferrari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sample script
parent
adf25d81
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
23 deletions
+89
-23
benchmarks/linear-raw-throughput.py
benchmarks/linear-raw-throughput.py
+29
-23
sample.py
sample.py
+60
-0
No files found.
benchmarks/linear-raw-throughput.py
View file @
8ae7eb92
...
...
@@ -7,25 +7,31 @@ __doc__ = """Creates a linear network topology, and measures the maximum
end-to-end throughput for the specified packet size."""
def
usage
(
f
):
f
.
write
(
"Usage: %s --nodes=NUM
--pktsize=BYTES [
OPTIONS]
\
n
%s
\
n
\
n
"
%
f
.
write
(
"Usage: %s --nodes=NUM
[TOPOLOGY_OPTIONS] [TEST_
OPTIONS]
\
n
%s
\
n
\
n
"
%
(
os
.
path
.
basename
(
sys
.
argv
[
0
]),
__doc__
))
f
.
write
(
"Mandatory arguments:
\
n
"
)
f
.
write
(
" -n, --nodes=NUM Number of nodes to create
\
n
"
)
f
.
write
(
" -s, --pktsize=BYTES Size of packet payload
\
n
\
n
"
)
f
.
write
(
"Topology configuration:
\
n
"
)
f
.
write
(
" --use-p2p Use P2P switchs, to avoid bridging
\
n
"
)
f
.
write
(
" --delay=SECS Add delay emulation in switchs
\
n
"
)
f
.
write
(
" --jitter=PERCENT Add jitter emulation in switchs
\
n
"
)
f
.
write
(
" --bandwidth=BPS Maximum bandwidth of switchs
\
n
\
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
(
" -p, --packets=NUM Stop after NUM packets
\
n
"
)
f
.
write
(
" -b, --bytes=BYTES Stop after BYTES bytes sent
\
n
\
n
"
)
f
.
write
(
" -n, --nodes=NUM Number of nodes to create (mandatory)
\
n
"
)
f
.
write
(
" --use-p2p Use P2P links, to avoid bridging
\
n
"
)
f
.
write
(
" --delay=SECS Add delay emulation in links
\
n
"
)
f
.
write
(
" --jitter=PERCENT Add jitter emulation in links
\
n
"
)
f
.
write
(
" --bandwidth=BPS Maximum bandwidth of links
\
n
\
n
"
)
f
.
write
(
"Test specification:
\
n
"
)
f
.
write
(
" Parameters take single values or ranges of falues in the form "
+
"nnn-NNN, a test
\
n
"
)
f
.
write
(
" will be run for each possible combination.
\
n
"
)
f
.
write
(
" -s, --pktsize=BYTES Size of packet payload (mandatory)
\
n
"
)
f
.
write
(
" --bwlimit=BPS Apply bandwidth limitation in the "
+
"traffic generator
\
n
\
n
"
)
# background noise
f
.
write
(
"How long should each test run (defaults to -t 10):
\
n
"
)
f
.
write
(
" -t, --time=SECS Stop after SECS seconds
\
n
"
)
f
.
write
(
" -p, --packets=NUM Stop after NUM packets
\
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', "
+
f
.
write
(
" --format=FMT Valid values are `csv', `brief', "
+
"and `verbose'
\
n
"
)
def
main
():
...
...
@@ -89,7 +95,7 @@ def main():
elif
not
pktsize
:
error
=
"Missing mandatory --pktsize argument"
elif
use_p2p
and
(
delay
or
jitter
or
bandwidth
):
error
=
"Cannot use
switch emulation with P2P switch
s"
error
=
"Cannot use
links emulation with P2P link
s"
if
error
:
sys
.
stderr
.
write
(
"%s: %s
\
n
"
%
(
os
.
path
.
basename
(
sys
.
argv
[
0
]),
error
))
...
...
@@ -106,7 +112,7 @@ def main():
if
not
udp_perf
:
raise
RuntimeError
(
"Cannot find `udp-perf'"
)
nodes
,
interfaces
,
switch
s
=
create_topo
(
nr
,
use_p2p
,
delay
,
jitter
,
nodes
,
interfaces
,
link
s
=
create_topo
(
nr
,
use_p2p
,
delay
,
jitter
,
bandwidth
)
cmdline
=
[
udp_perf
,
"--server"
]
...
...
@@ -189,7 +195,7 @@ def dec2ip(dec):
def create_topo(n, p2p, delay, jitter, bw):
nodes = []
interfaces = []
switch
s = []
link
s = []
for i in range(n):
nodes.append(netns.Node())
if p2p:
...
...
@@ -212,12 +218,12 @@ def create_topo(n, p2p, delay, jitter, bw):
right = None
interfaces.append((left, right))
for i in range(n - 1):
switch
= netns.Switch(bandwidth = bw, delay = delay,
links
= netns.Switch(bandwidth = bw, delay = delay,
delay_jitter = jitter)
switch
.up = True
switch
.connect(interfaces[i][1])
switch
.connect(interfaces[i + 1][0])
switchs.append(switch
)
links
.up = True
links
.connect(interfaces[i][1])
links
.connect(interfaces[i + 1][0])
links.append(links
)
for i in range(n):
for j in (0, 1):
...
...
@@ -237,7 +243,7 @@ def create_topo(n, p2p, delay, jitter, bw):
nexthop = dec2ip(ipbase + 4 * i + 2))
nodes[n - 1 - i].add_route(prefix = "10.0.0.0", prefix_len = 30,
nexthop = dec2ip(ipbase + (n - 2 - i) * 4 + 1))
return nodes, interfaces,
switch
s
return nodes, interfaces,
link
s
if __name__ == "__main__":
main()
sample.py
0 → 100644
View file @
8ae7eb92
#/usr/bin/env python
# vim:ts=4:sw=4:et:ai:sts=4
import
netns
,
subprocess
# each Node is a netns
node0
=
netns
.
Node
()
node1
=
netns
.
Node
()
node2
=
netns
.
Node
()
print
"Nodes started with pids: %s
\
n
"
%
str
((
node0
.
pid
,
node1
.
pid
,
node2
.
pid
))
# interface object maps to a veth pair with one end in a netns
if0
=
netns
.
NodeInterface
(
node0
)
if1a
=
netns
.
NodeInterface
(
node1
)
# Between node1 and node2, we use a P2P interface
(
if1b
,
if2
)
=
netns
.
P2PInterface
.
create_pair
(
node1
,
node2
)
switch0
=
netns
.
Switch
(
bandwidth
=
100
*
1024
*
1024
,
delay
=
0.01
,
# 10 ms
delay_correlation
=
0.25
,
# 25% correlation
loss
=
0.005
)
# connect the interfaces
switch0
.
connect
(
if0
)
switch0
.
connect
(
if1a
)
# bring the interfaces up
switch0
.
up
=
if0
.
up
=
if1a
.
up
=
if1b
.
up
=
if2
.
up
=
True
# Add IP addresses
if0
.
add_v4_address
(
addr
=
'10.0.0.1'
,
prefix_len
=
24
)
if1a
.
add_v4_address
(
addr
=
'10.0.0.2'
,
prefix_len
=
24
)
if1b
.
add_v4_address
(
addr
=
'10.0.1.1'
,
prefix_len
=
24
)
if2
.
add_v4_address
(
addr
=
'10.0.1.2'
,
prefix_len
=
24
)
# RFC-4193 Unique local addresses.
# Pre-generated random block: fde2:4a1d:8870::/48
if0
.
add_v6_address
(
addr
=
'fde2:4a1d:8870:0::0'
,
prefix_len
=
32
)
if1a
.
add_v6_address
(
addr
=
'fde2:4a1d:8870:0::1'
,
prefix_len
=
32
)
if1b
.
add_v6_address
(
addr
=
'fde2:4a1d:8870:1::0'
,
prefix_len
=
32
)
if2
.
add_v6_address
(
addr
=
'fde2:4a1d:8870:1::1'
,
prefix_len
=
32
)
# Configure routing
node0
.
add_route
(
prefix
=
'10.0.1.0'
,
prefix_len
=
24
,
nexthop
=
'10.0.0.2'
)
node2
.
add_route
(
prefix
=
'10.0.0.0'
,
prefix_len
=
24
,
nexthop
=
'10.0.1.1'
)
node0
.
add_route
(
prefix
=
'fde2:4a1d:8870:1::'
,
prefix_len
=
32
,
nexthop
=
'fde2:4a1d:8870:0::1'
)
node2
.
add_route
(
prefix
=
'fde2:4a1d:8870:0::'
,
prefix_len
=
32
,
nexthop
=
'fde2:4a1d:8870:1::0'
)
# Test connectivity first. Run process, hide output and check return code
app0
=
node0
.
Popen
(
"ping -c 1 10.0.1.2"
,
shell
=
True
,
stdout
=
subprocess
.
NONE
)
ret
=
app0
.
wait
()
assert
ret
==
0
app1
=
node2
.
Popen
(
"ping -c 1 10.0.0.1"
,
shell
=
True
,
stdout
=
subprocess
.
NONE
)
ret
=
app1
.
wait
()
assert
ret
==
0
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