本文整理汇总了Python中nepi.execution.ec.ExperimentController.release方法的典型用法代码示例。如果您正苦于以下问题:Python ExperimentController.release方法的具体用法?Python ExperimentController.release怎么用?Python ExperimentController.release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nepi.execution.ec.ExperimentController
的用法示例。
在下文中一共展示了ExperimentController.release方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: t_cross_ping
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import release [as 别名]
def t_cross_ping(self, host, user = None, identity = None):
ec = ExperimentController(exp_id = "test-linux-ns3-tap-fd")
node = ec.register_resource("linux::Node")
if host == "localhost":
ec.set(node, "hostname", "localhost")
else:
ec.set(node, "hostname", host)
ec.set(node, "username", user)
ec.set(node, "identity", identity)
ec.set(node, "cleanProcesses", True)
ec.set(node, "cleanExperiment", True)
simu = ec.register_resource("linux::ns3::Simulation")
ec.set(simu, "simulatorImplementationType", "ns3::RealtimeSimulatorImpl")
ec.set(simu, "checksumEnabled", True)
ec.set(simu, "verbose", True)
#ec.set(simu, "buildMode", "debug")
#ec.set(simu, "nsLog", "FdNetDevice")
ec.register_connection(simu, node)
nsnode1 = add_ns3_node(ec, simu)
dev1 = add_point2point_device(ec, nsnode1, "10.0.0.1", "30")
nsnode2 = add_ns3_node(ec, simu)
dev2 = add_point2point_device(ec, nsnode2, "10.0.0.2", "30")
# Add routes on the NS3 side
r1 = ec.register_resource("ns3::Route")
ec.set(r1, "network", "10.0.1.0")
ec.set(r1, "prefix", "30")
ec.set(r1, "nexthop", "10.0.0.1")
ec.register_connection(r1, nsnode2)
# Create channel
chan = ec.register_resource("ns3::PointToPointChannel")
ec.set(chan, "Delay", "0s")
ec.register_connection(chan, dev1)
ec.register_connection(chan, dev2)
fddev = add_fd_device(ec, nsnode1, "10.0.1.2", "30")
ec.enable_trace(fddev, "pcap")
ec.enable_trace(fddev, "promiscPcap")
ec.enable_trace(fddev, "ascii")
tap = add_tap_device(ec, node, "10.0.1.1", "30")
crosslink = ec.register_resource("linux::ns3::TapFdLink")
ec.register_connection(crosslink, tap)
ec.register_connection(crosslink, fddev)
# Add routes on the localhost side
r2 = ec.register_resource("linux::Route")
ec.set(r2, "network", "10.0.0.0")
ec.set(r2, "prefix", "30")
ec.set(r2, "nexthop", "10.0.1.2")
ec.register_connection(r2, tap)
app = ec.register_resource("linux::Application")
ec.set(app, "command", "ping -c3 10.0.0.1")
ec.register_connection(app, node)
ec.register_condition(app, ResourceAction.START, simu,
ResourceState.STARTED, time="5s")
ec.deploy()
ec.wait_finished([app])
stdout = ec.trace(app, "stdout")
expected = "3 packets transmitted, 3 received, 0% packet loss"
self.assertTrue(stdout.find(expected) > -1)
## Releasing to force ns3 to flush the traces
ec.release()
pcap = ec.trace(fddev, "pcap")
self.assertTrue(len(pcap) > 4000)
ec.shutdown()