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
2c085546
Commit
2c085546
authored
Oct 22, 2010
by
Martín Ferrari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enhance the sample script with some xterms
parent
94f83fec
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
6 deletions
+19
-6
sample.py
sample.py
+19
-6
No files found.
sample.py
View file @
2c085546
#!/usr/bin/env python
# vim:ts=4:sw=4:et:ai:sts=4
import
netns
,
subprocess
import
os
,
netns
,
subprocess
,
time
xterm
=
netns
.
environ
.
find_bin
(
"xterm"
)
X
=
"DISPLAY"
in
os
.
environ
and
xterm
# each Node is a netns
node0
=
netns
.
Node
()
node1
=
netns
.
Node
()
node2
=
netns
.
Node
()
node0
=
netns
.
Node
(
forward_X11
=
X
)
node1
=
netns
.
Node
(
forward_X11
=
X
)
node2
=
netns
.
Node
(
forward_X11
=
X
)
print
"Nodes started with pids: %s"
%
str
((
node0
.
pid
,
node1
.
pid
,
node2
.
pid
))
...
...
@@ -17,8 +20,8 @@ if1a = netns.NodeInterface(node1)
switch0
=
netns
.
Switch
(
bandwidth
=
100
*
1024
*
1024
,
delay
=
0.
01
,
# 1
0 ms
delay_jitter
=
0.0
01
,
# 1
ms
delay
=
0.
1
,
# 10
0 ms
delay_jitter
=
0.0
1
,
# 10
ms
delay_correlation
=
0.25
,
# 25% correlation
loss
=
0.005
)
...
...
@@ -51,6 +54,16 @@ ret = app1.wait()
assert
ret
==
0
print
"Connectivity IPv4 OK!"
if
X
:
app1
=
node1
.
Popen
(
"%s -geometry -0+0 -e %s -ni %s"
%
(
xterm
,
netns
.
environ
.
tcpdump_path
,
if1b
.
name
),
shell
=
True
)
time
.
sleep
(
3
)
app0
=
node0
.
Popen
(
"%s -geometry +0+0 -e ping -c 10 10.0.1.2"
%
xterm
,
shell
=
True
)
app0
.
wait
()
app1
.
signal
()
app1
.
wait
()
# Now test the network conditions
# When using a args list, the shell is not needed
app2
=
node2
.
Popen
([
"ping"
,
"-q"
,
"-c100000"
,
"-f"
,
"10.0.1.2"
],
...
...
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