主机类
包括 Host 和 CPULimitedHost 两个类。

mininet.node.Host

表示一个主机节点,目前跟 Node 类定义相同。 在主机类上执行命令可以通过 Cmd() 或者 sendCmd() 方法,前者会等待命令的输出结果,后者会直接返回,并允许使用后续的 monitor() 来进行监视跟踪。

mininet.node.CPULimitedHost

继承自 Host 类,通过 cgroup 工具来对 CPU 进行限制。

init

1
def __init__( self, name, sched='cfs', **kwargs ):
2
Host.__init__( self, name, **kwargs )
3
# Initialize class if necessary
4
if not CPULimitedHost.inited:
5
CPULimitedHost.init()
6
# Create a cgroup and move shell into it
7
self.cgroup = 'cpu,cpuacct,cpuset:/' + self.name
8
errFail( 'cgcreate -g ' + self.cgroup )
9
# We don't add ourselves to a cpuset because you must
10
# specify the cpu and memory placement first
11
errFail( 'cgclassify -g cpu,cpuacct:/%s %s' % ( self.name, self.pid ) )
12
# BL: Setting the correct period/quota is tricky, particularly
13
# for RT. RT allows very small quotas, but the overhead
14
# seems to be high. CFS has a mininimum quota of 1 ms, but
15
# still does better with larger period values.
16
self.period_us = kwargs.get( 'period_us', 100000 )
17
self.sched = sched
18
self.rtprio = 20
Copied!
Last modified 2yr ago