MCPcopy Create free account
hub / github.com/mininet/mininet / Mininet

Class Mininet

mininet/net.py:114–950  ·  view source on GitHub ↗

Network emulation with hosts spawned in network namespaces.

Source from the content-addressed store, hash-verified

112VERSION = "2.3.1b4"
113
114class Mininet( object ):
115 "Network emulation with hosts spawned in network namespaces."
116
117 # pylint: disable=too-many-arguments
118 def __init__( self, topo=None, switch=OVSKernelSwitch, host=Host,
119 controller=DefaultController, link=Link, intf=Intf,
120 build=True, xterms=False, cleanup=False, ipBase='10.0.0.0/8',
121 inNamespace=False,
122 autoSetMacs=False, autoStaticArp=False, autoPinCpus=False,
123 listenPort=None, waitConnected=False ):
124 """Create Mininet object.
125 topo: Topo (topology) object or None
126 switch: default Switch class
127 host: default Host class/constructor
128 controller: default Controller class/constructor
129 link: default Link class/constructor
130 intf: default Intf class/constructor
131 ipBase: base IP address for hosts,
132 build: build now from topo?
133 xterms: if build now, spawn xterms?
134 cleanup: if build now, cleanup before creating?
135 inNamespace: spawn switches and controller in net namespaces?
136 autoSetMacs: set MAC addrs automatically like IP addresses?
137 autoStaticArp: set all-pairs static MAC addrs?
138 autoPinCpus: pin hosts to (real) cores (requires CPULimitedHost)?
139 listenPort: base listening port to open; will be incremented for
140 each additional switch in the net if inNamespace=False
141 waitConnected: wait for switches to Connect?
142 (False; True/None=wait indefinitely; time(s)=timed wait)"""
143 self.topo = topo
144 self.switch = switch
145 self.host = host
146 self.controller = controller
147 self.link = link
148 self.intf = intf
149 self.ipBase = ipBase
150 self.ipBaseNum, self.prefixLen = netParse( self.ipBase )
151 hostIP = ( 0xffffffff >> self.prefixLen ) & self.ipBaseNum
152 # Start for address allocation
153 self.nextIP = hostIP if hostIP > 0 else 1
154 self.inNamespace = inNamespace
155 self.xterms = xterms
156 self.cleanup = cleanup
157 self.autoSetMacs = autoSetMacs
158 self.autoStaticArp = autoStaticArp
159 self.autoPinCpus = autoPinCpus
160 self.numCores = numCores()
161 self.nextCore = 0 # next core for pinning hosts to CPUs
162 self.listenPort = listenPort
163 self.waitConn = waitConnected
164
165 self.hosts = []
166 self.switches = []
167 self.controllers = []
168 self.links = []
169
170 self.nameToNode = {} # name to Node (Host/Switch) objects
171

Callers 15

TreeNetFunction · 0.90
testDefaultDpidMethod · 0.90
testDefaultDpidLenMethod · 0.90
testMinimalMethod · 0.90
testSingle5Method · 0.90
testLinear5Method · 0.90
testPtyLeakMethod · 0.90
runOptionsTopoTestMethod · 0.90
testCPULimitsMethod · 0.90
testLinkBandwidthMethod · 0.90

Calls

no outgoing calls

Tested by 13

testDefaultDpidMethod · 0.72
testDefaultDpidLenMethod · 0.72
testMinimalMethod · 0.72
testSingle5Method · 0.72
testLinear5Method · 0.72
testPtyLeakMethod · 0.72
runOptionsTopoTestMethod · 0.72
testCPULimitsMethod · 0.72
testLinkBandwidthMethod · 0.72
testLinkDelayMethod · 0.72