A Discrete-Event Network Simulator
QKDNetSim v2.0 (NS-3 v3.41) @ (+)
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Enumerations
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
v
w
Enumerator
a
b
c
d
e
f
h
i
l
m
n
o
p
q
r
s
t
u
v
w
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
Enumerations
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
Enumerator
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Properties
Related Functions
:
a
b
c
d
e
g
h
i
j
l
m
n
o
p
q
r
s
t
u
w
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
Enumerations
Enumerator
c
e
i
l
o
r
s
t
v
Macros
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
tap-csma-virtual-machine.py
Go to the documentation of this file.
1
# -*- Mode: Python; -*-
2
#
3
# Copyright 2010 University of Washington
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License version 2 as
7
# published by the Free Software Foundation;
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
#
18
19
import
sys
20
21
try
:
22
from
ns
import
ns
23
except
ModuleNotFoundError:
24
raise
SystemExit(
25
"Error: ns3 Python module not found;"
26
" Python bindings may not be enabled"
27
" or your PYTHONPATH might not be properly configured"
28
)
29
30
31
def
main(argv):
32
ns.core.CommandLine().Parse(argv)
33
34
#
35
# We are interacting with the outside, real, world. This means we have to
36
# interact in real-time and therefore we have to use the real-time simulator
37
# and take the time to calculate checksums.
38
#
39
ns.core.GlobalValue.Bind(
40
"SimulatorImplementationType"
, ns.core.StringValue(
"ns3::RealtimeSimulatorImpl"
)
41
)
42
ns.core.GlobalValue.Bind(
"ChecksumEnabled"
, ns.core.BooleanValue(
True
))
43
44
#
45
# Create two ghost nodes. The first will represent the virtual machine host
46
# on the left side of the network; and the second will represent the VM on
47
# the right side.
48
#
49
nodes = ns.network.NodeContainer()
50
nodes.Create(2)
51
52
#
53
# Use a CsmaHelper to get a CSMA channel created, and the needed net
54
# devices installed on both of the nodes. The data rate and delay for the
55
# channel can be set through the command-line parser.
56
#
57
csma = ns.csma.CsmaHelper()
58
devices = csma.Install(nodes)
59
60
#
61
# Use the TapBridgeHelper to connect to the pre-configured tap devices for
62
# the left side. We go with "UseLocal" mode since the wifi devices do not
63
# support promiscuous mode (because of their natures0. This is a special
64
# case mode that allows us to extend a linux bridge into ns-3 IFF we will
65
# only see traffic from one other device on that bridge. That is the case
66
# for this configuration.
67
#
68
tapBridge = ns.tap_bridge.TapBridgeHelper()
69
tapBridge.SetAttribute(
"Mode"
, ns.core.StringValue(
"UseLocal"
))
70
tapBridge.SetAttribute(
"DeviceName"
, ns.core.StringValue(
"tap-left"
))
71
tapBridge.Install(nodes.Get(0), devices.Get(0))
72
73
#
74
# Connect the right side tap to the right side wifi device on the right-side
75
# ghost node.
76
#
77
tapBridge.SetAttribute(
"DeviceName"
, ns.core.StringValue(
"tap-right"
))
78
tapBridge.Install(nodes.Get(1), devices.Get(1))
79
80
#
81
# Run the simulation for ten minutes to give the user time to play around
82
#
83
ns.core.Simulator.Stop(ns.core.Seconds(600))
84
ns.core.Simulator.Run()
# signal_check_frequency = -1
85
ns.core.Simulator.Destroy()
86
return
0
87
88
89
if
__name__ ==
"__main__"
:
90
sys.exit(main(sys.argv))
src
tap-bridge
examples
tap-csma-virtual-machine.py
Generated on Sun Mar 3 2024 17:11:08 for ns-3 by
1.9.1