本文整理汇总了Python中nepi.execution.ec.ExperimentController.enable_trace方法的典型用法代码示例。如果您正苦于以下问题:Python ExperimentController.enable_trace方法的具体用法?Python ExperimentController.enable_trace怎么用?Python ExperimentController.enable_trace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nepi.execution.ec.ExperimentController
的用法示例。
在下文中一共展示了ExperimentController.enable_trace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: t_traces
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import enable_trace [as 别名]
def t_traces(self, host, user):
ec = ExperimentController(exp_id = "test-fib-traces")
node1 = ec.register_resource("linux::Node")
ec.set(node1, "hostname", host)
ec.set(node1, "username", user)
ec.set(node1, "cleanExperiment", True)
ec.set(node1, "cleanProcesses", True)
ccnd1 = ec.register_resource("linux::CCND")
ec.register_connection(ccnd1, node1)
entry1 = ec.register_resource("linux::FIBEntry")
ec.set(entry1, "host", self.target)
ec.enable_trace(entry1, "ping")
ec.enable_trace(entry1, "mtr")
ec.register_connection(entry1, ccnd1)
node2 = ec.register_resource("linux::Node")
ec.set(node2, "hostname", self.target)
ec.set(node2, "username", self.fedora_user)
ec.set(node2, "cleanExperiment", True)
ec.set(node2, "cleanProcesses", True)
ccnd2 = ec.register_resource("linux::CCND")
ec.register_connection(ccnd2, node2)
entry2 = ec.register_resource("linux::FIBEntry")
ec.set(entry2, "host", host)
ec.register_connection(entry2, ccnd2)
ec.deploy()
ec.wait_started([ccnd1, ccnd2])
stdout = ec.trace(entry1, "ping")
expected = "icmp_seq=1"
self.assertTrue(stdout.find(expected) > -1)
stdout = ec.trace(entry1, "mtr")
expected = "1."
self.assertTrue(stdout.find(expected) > -1)
ec.shutdown()
示例2: t_cross_ping
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import enable_trace [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()
示例3: t_traces
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import enable_trace [as 别名]
def t_traces(self, host, user = None, identity = None):
ec = ExperimentController(exp_id = "test-ns3-traces")
node = ec.register_resource("linux::Node")
if host == "localhost":
ec.set(node, "hostname", "localhost")
else:
ec.set(node, "hostname", self.fedora_host)
ec.set(node, "username", self.fedora_user)
ec.set(node, "identity", self.fedora_identity)
ec.set(node, "cleanProcesses", True)
#ec.set(node, "cleanHome", True)
simu = ec.register_resource("linux::ns3::Simulation")
ec.set(simu, "verbose", True)
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")
# Create channel
chan = ec.register_resource("ns3::PointToPointChannel")
ec.set(chan, "Delay", "0s")
ec.register_connection(chan, dev1)
ec.register_connection(chan, dev2)
### create pinger
ping = ec.register_resource("ns3::V4Ping")
ec.set (ping, "Remote", "10.0.0.2")
ec.set (ping, "Interval", "1s")
ec.set (ping, "Verbose", True)
ec.set (ping, "StartTime", "0s")
ec.set (ping, "StopTime", "20s")
ec.register_connection(ping, nsnode1)
# enable traces
ec.enable_trace(dev1, "pcap")
ec.enable_trace(dev1, "promiscPcap")
ec.enable_trace(dev1, "ascii")
ec.enable_trace(dev2, "pcap")
ec.enable_trace(dev2, "promiscPcap")
ec.enable_trace(dev2, "ascii")
ec.deploy()
ec.wait_finished([ping])
# Trace verification
rm_simu = ec.get_resource(simu)
# TODO: Fix this in ns-3: pcap traces do not flush until the Simulator
# process is ended, so we can't get the traces of the 'pcap' and
# 'promiscPcap' traces.
#
#for trace in ["pcap", "promiscPcap", "ascii"]:
for trace in ["ascii"]:
for guid in [dev1, dev2]:
output = ec.trace(guid, trace)
size = ec.trace(guid, trace, attr = TraceAttr.SIZE)
self.assertEquals(size, len(output))
self.assertTrue(size > 100)
block = ec.trace(guid, trace, attr = TraceAttr.STREAM, block = 5, offset = 1)
self.assertEquals(block, output[5:10])
trace_path = ec.trace(guid, trace, attr = TraceAttr.PATH)
rm = ec.get_resource(guid)
path = os.path.join(rm_simu.run_home, rm._trace_filename.get(trace))
self.assertEquals(trace_path, path)
ec.shutdown()