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
cee62eb2
Commit
cee62eb2
authored
10 years ago
by
Brian O'Connor
Browse files
Options
Downloads
Patches
Plain Diff
adding natnet example test
parent
735080a8
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/natnet.py
+3
-3
3 additions, 3 deletions
examples/natnet.py
examples/test/test_natnet.py
+57
-0
57 additions, 0 deletions
examples/test/test_natnet.py
with
60 additions
and
3 deletions
examples/natnet.py
+
3
−
3
View file @
cee62eb2
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
h0
h0
|
|
s0
s0
|
|
----------------
----------------
| |
| |
nat1 nat2
nat1 nat2
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
from
mininet.util
import
irange
from
mininet.util
import
irange
class
InternetTopo
(
Topo
):
class
InternetTopo
(
Topo
):
"
TODO:
Single switch connected to n hosts.
"
"
Single switch connected to n hosts.
"
def
__init__
(
self
,
n
=
2
,
h
=
1
,
**
opts
):
def
__init__
(
self
,
n
=
2
,
h
=
1
,
**
opts
):
Topo
.
__init__
(
self
,
**
opts
)
Topo
.
__init__
(
self
,
**
opts
)
...
@@ -57,7 +57,7 @@ def __init__(self, n=2, h=1, **opts):
...
@@ -57,7 +57,7 @@ def __init__(self, n=2, h=1, **opts):
self
.
addLink
(
host
,
switch
)
self
.
addLink
(
host
,
switch
)
def
run
():
def
run
():
"
TODO:
Create network and run
simple performance test
"
"
Create network and run
the CLI
"
topo
=
InternetTopo
()
topo
=
InternetTopo
()
net
=
Mininet
(
topo
=
topo
)
net
=
Mininet
(
topo
=
topo
)
net
.
start
()
net
.
start
()
...
...
This diff is collapsed.
Click to expand it.
examples/test/test_natnet.py
0 → 100644
+
57
−
0
View file @
cee62eb2
#!/usr/bin/env python
"""
Test for natnet.py
"""
import
unittest
import
pexpect
from
mininet.util
import
quietRun
class
testNATNet
(
unittest
.
TestCase
):
prompt
=
'
mininet>
'
def
setUp
(
self
):
self
.
net
=
pexpect
.
spawn
(
'
python -m mininet.examples.natnet
'
)
self
.
net
.
expect
(
self
.
prompt
)
def
testPublicPing
(
self
):
"
Attempt to ping the public server (h0) from h1 and h2
"
self
.
net
.
sendline
(
'
h1 ping -c 1 h0
'
)
self
.
net
.
expect
(
'
(\d+)% packet loss
'
)
percent
=
int
(
self
.
net
.
match
.
group
(
1
)
)
if
self
.
net
.
match
else
-
1
self
.
assertEqual
(
percent
,
0
)
self
.
net
.
expect
(
self
.
prompt
)
self
.
net
.
sendline
(
'
h2 ping -c 1 h0
'
)
self
.
net
.
expect
(
'
(\d+)% packet loss
'
)
percent
=
int
(
self
.
net
.
match
.
group
(
1
)
)
if
self
.
net
.
match
else
-
1
self
.
assertEqual
(
percent
,
0
)
self
.
net
.
expect
(
self
.
prompt
)
def
testPrivatePing
(
self
):
"
Attempt to ping h1 and h2 from public server
"
self
.
net
.
sendline
(
'
h0 ping -c 1 -t 1 h1
'
)
result
=
self
.
net
.
expect
(
[
'
unreachable
'
,
'
loss
'
]
)
self
.
assertEqual
(
result
,
0
)
self
.
net
.
expect
(
self
.
prompt
)
self
.
net
.
sendline
(
'
h0 ping -c 1 -t 1 h2
'
)
result
=
self
.
net
.
expect
(
[
'
unreachable
'
,
'
loss
'
]
)
self
.
assertEqual
(
result
,
0
)
self
.
net
.
expect
(
self
.
prompt
)
def
testPrivateToPrivatePing
(
self
):
"
Attempt to ping from NAT
'
ed host h1 to NAT
'
ed host h2
"
self
.
net
.
sendline
(
'
h1 ping -c 1 -t 1 h2
'
)
result
=
self
.
net
.
expect
(
[
'
[Uu]nreachable
'
,
'
loss
'
]
)
self
.
assertEqual
(
result
,
0
)
self
.
net
.
expect
(
self
.
prompt
)
def
tearDown
(
self
):
self
.
net
.
sendline
(
'
exit
'
)
self
.
net
.
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