Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mininet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Olaf Bergmann
mininet
Commits
06d9e4bb
Commit
06d9e4bb
authored
10 years ago
by
cody burkard
Committed by
Bob Lantz
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
add example and test for multiple links
parent
38ce329e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/multiLink.py
+35
-0
35 additions, 0 deletions
examples/multiLink.py
examples/test/test_multiLink.py
+55
-0
55 additions, 0 deletions
examples/test/test_multiLink.py
with
90 additions
and
0 deletions
examples/multiLink.py
0 → 100755
+
35
−
0
View file @
06d9e4bb
#!/usr/bin/python
"""
This is a simple example that demonstrates multiple links
between nodes.
"""
from
mininet.cli
import
CLI
from
mininet.log
import
lg
,
info
from
mininet.net
import
Mininet
from
mininet.topo
import
Topo
def
runMultiLink
():
topo
=
simpleMultiLinkTopo
(
n
=
2
)
net
=
Mininet
(
topo
=
topo
)
net
.
start
()
CLI
(
net
)
net
.
stop
()
class
simpleMultiLinkTopo
(
Topo
):
def
__init__
(
self
,
n
,
**
kwargs
):
Topo
.
__init__
(
self
,
**
kwargs
)
h1
,
h2
=
self
.
addHost
(
'
h1
'
),
self
.
addHost
(
'
h2
'
)
s1
=
self
.
addSwitch
(
'
s1
'
)
for
_
in
range
(
n
):
self
.
addLink
(
s1
,
h1
)
self
.
addLink
(
s1
,
h2
)
if
__name__
==
'
__main__
'
:
lg
.
setLogLevel
(
'
info
'
)
runMultiLink
()
This diff is collapsed.
Click to expand it.
examples/test/test_multiLink.py
0 → 100755
+
55
−
0
View file @
06d9e4bb
#!/usr/bin/env python
'''
Test for multiple links between nodes
validates mininet interfaces against systems interfaces
'''
import
unittest
import
pexpect
class
testMultiLink
(
unittest
.
TestCase
):
prompt
=
'
mininet>
'
def
testMultiLink
(
self
):
p
=
pexpect
.
spawn
(
'
python -m mininet.examples.multiLink
'
)
p
.
expect
(
self
.
prompt
)
p
.
sendline
(
'
intfs
'
)
p
.
expect
(
'
s(\d): lo
'
)
intfsOutput
=
p
.
before
# parse interfaces from mininet intfs, and store them in a list
hostToIntfs
=
intfsOutput
.
split
(
'
\r\n
'
)[
1
:
3
]
intfList
=
[]
for
hostToIntf
in
hostToIntfs
:
intfList
+=
[
intf
for
intf
in
hostToIntf
.
split
()[
1
].
split
(
'
,
'
)
]
# get interfaces from system by running ifconfig on every host
sysIntfList
=
[]
opts
=
[
'
h(\d)-eth(\d)
'
,
self
.
prompt
]
p
.
expect
(
self
.
prompt
)
p
.
sendline
(
'
h1 ifconfig
'
)
while
True
:
p
.
expect
(
opts
)
if
p
.
after
==
self
.
prompt
:
break
sysIntfList
.
append
(
p
.
after
)
p
.
sendline
(
'
h2 ifconfig
'
)
while
True
:
p
.
expect
(
opts
)
if
p
.
after
==
self
.
prompt
:
break
sysIntfList
.
append
(
p
.
after
)
failMsg
=
(
'
The systems interfaces and mininet interfaces
\n
'
'
are not the same
'
)
self
.
assertEqual
(
sysIntfList
,
intfList
,
msg
=
failMsg
)
p
.
sendline
(
'
exit
'
)
p
.
wait
()
if
__name__
==
'
__main__
'
:
unittest
.
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment