Ejemplo n.º 1
0
    def make_experiment_desc(self, use_sfa=False):
        testbed_id = self.testbed_id
        slicename = self.slicename
        plchost = self.plchost
        pl_ssh_key = os.environ.get(
            "PL_SSH_KEY", "%s/.ssh/id_rsa_planetlab" % (os.environ['HOME'], ))
        pl_user, pl_pwd = test_util.pl_auth()

        exp_desc = ExperimentDescription()
        pl_provider = FactoriesProvider(testbed_id)
        pl_desc = exp_desc.add_testbed_description(pl_provider)
        pl_desc.set_attribute_value("homeDirectory", self.root_dir)
        pl_desc.set_attribute_value("slice", slicename)
        pl_desc.set_attribute_value("sliceSSHKey", pl_ssh_key)
        pl_desc.set_attribute_value("authUser", pl_user)
        pl_desc.set_attribute_value("authPass", pl_pwd)
        pl_desc.set_attribute_value("plcHost", plchost)
        pl_desc.set_attribute_value("tapPortBase", self.port_base)
        pl_desc.set_attribute_value(
            "p2pDeployment",
            False)  # it's interactive, we don't want it in tests
        pl_desc.set_attribute_value("cleanProc", True)
        pl_desc.set_attribute_value("plLogLevel", "DEBUG")
        if use_sfa:
            pl_desc.set_attribute_value("sfa", True)
            pl_desc.set_attribute_value("sliceHrn", self.slicehrn)

        return pl_desc, exp_desc
Ejemplo n.º 2
0
 def test_design_if(self):
     testbed_id = "netns"
     exp_desc = ExperimentDescription()
     provider = FactoriesProvider(testbed_id)
     
     tstbd_desc = exp_desc.add_testbed_description(provider)
     tstbd_desc.set_attribute_value("enableDebug", True)
     node1 = tstbd_desc.create("Node")
     node2 = tstbd_desc.create("Node")
     iface1 = tstbd_desc.create("NodeInterface")
     iface1.set_attribute_value("up", True)
     node1.connector("devs").connect(iface1.connector("node"))
     ip1 = iface1.add_address()
     ip1.set_attribute_value("Address", "10.0.0.1")
     iface2 = tstbd_desc.create("NodeInterface")
     iface2.set_attribute_value("up", True)
     node2.connector("devs").connect(iface2.connector("node"))
     ip2 = iface2.add_address()
     ip2.set_attribute_value("Address", "10.0.0.2")
     switch = tstbd_desc.create("Switch")
     switch.set_attribute_value("up", True)
     iface1.connector("switch").connect(switch.connector("devs"))
     iface2.connector("switch").connect(switch.connector("devs"))
     app = tstbd_desc.create("Application")
     app.set_attribute_value("command", "ping -qc10 10.0.0.2")
     app.connector("node").connect(node1.connector("apps"))
     
     xml = exp_desc.to_xml()
     exp_desc2 = ExperimentDescription()
     exp_desc2.from_xml(xml)
     xml2 = exp_desc2.to_xml()
     self.assertTrue(xml == xml2)
Ejemplo n.º 3
0
    def test_design_if(self):
        testbed_id = "netns"
        exp_desc = ExperimentDescription()
        provider = FactoriesProvider(testbed_id)

        tstbd_desc = exp_desc.add_testbed_description(provider)
        tstbd_desc.set_attribute_value("enableDebug", True)
        node1 = tstbd_desc.create("Node")
        node2 = tstbd_desc.create("Node")
        iface1 = tstbd_desc.create("NodeInterface")
        iface1.set_attribute_value("up", True)
        node1.connector("devs").connect(iface1.connector("node"))
        ip1 = iface1.add_address()
        ip1.set_attribute_value("Address", "10.0.0.1")
        iface2 = tstbd_desc.create("NodeInterface")
        iface2.set_attribute_value("up", True)
        node2.connector("devs").connect(iface2.connector("node"))
        ip2 = iface2.add_address()
        ip2.set_attribute_value("Address", "10.0.0.2")
        switch = tstbd_desc.create("Switch")
        switch.set_attribute_value("up", True)
        iface1.connector("switch").connect(switch.connector("devs"))
        iface2.connector("switch").connect(switch.connector("devs"))
        app = tstbd_desc.create("Application")
        app.set_attribute_value("command", "ping -qc10 10.0.0.2")
        app.connector("node").connect(node1.connector("apps"))

        xml = exp_desc.to_xml()
        exp_desc2 = ExperimentDescription()
        exp_desc2.from_xml(xml)
        xml2 = exp_desc2.to_xml()
        self.assertTrue(xml == xml2)
Ejemplo n.º 4
0
    def make_experiment_desc(self, use_sfa=False):
        testbed_id = self.testbed_id
        slicename = self.slicename
        plchost = self.plchost
        pl_ssh_key = os.environ.get("PL_SSH_KEY", "%s/.ssh/id_rsa_planetlab" % (os.environ["HOME"],))
        pl_user, pl_pwd = test_util.pl_auth()

        exp_desc = ExperimentDescription()
        pl_provider = FactoriesProvider(testbed_id)
        pl_desc = exp_desc.add_testbed_description(pl_provider)
        pl_desc.set_attribute_value("homeDirectory", self.root_dir)
        pl_desc.set_attribute_value("slice", slicename)
        pl_desc.set_attribute_value("sliceSSHKey", pl_ssh_key)
        pl_desc.set_attribute_value("authUser", pl_user)
        pl_desc.set_attribute_value("authPass", pl_pwd)
        pl_desc.set_attribute_value("plcHost", plchost)
        pl_desc.set_attribute_value("tapPortBase", self.port_base)
        pl_desc.set_attribute_value("p2pDeployment", False)  # it's interactive, we don't want it in tests
        pl_desc.set_attribute_value("cleanProc", True)
        pl_desc.set_attribute_value("plLogLevel", "DEBUG")
        if use_sfa:
            pl_desc.set_attribute_value("sfa", True)
            pl_desc.set_attribute_value("sliceHrn", self.slicehrn)

        return pl_desc, exp_desc
Ejemplo n.º 5
0
    def make_experiment_desc(self):
        testbed_id = self.testbed_id
        slicename = self.slicename
        plchost = self.plchost
        pl_ssh_key = self.plkey
        pl_user = self.pluser
        pl_pwd = self.plpass
        
        plroot_dir = os.path.join(self.root_dir,"pl")
        if not os.path.exists(plroot_dir):
            os.makedirs(plroot_dir)

        exp_desc = ExperimentDescription()
        pl_provider = FactoriesProvider(testbed_id)
        pl_desc = exp_desc.add_testbed_description(pl_provider)
        pl_desc.set_attribute_value(DC.ROOT_DIRECTORY, plroot_dir )
        pl_desc.set_attribute_value("homeDirectory", self.root_dir)
        pl_desc.set_attribute_value("slice", slicename)
        pl_desc.set_attribute_value("sliceSSHKey", pl_ssh_key)
        pl_desc.set_attribute_value("authUser", pl_user)
        pl_desc.set_attribute_value("authPass", pl_pwd)
        pl_desc.set_attribute_value("plcHost", plchost)
        pl_desc.set_attribute_value("tapPortBase", self.port_base)
        pl_desc.set_attribute_value("p2pDeployment", not self.no_p2p_deploy)
        pl_desc.set_attribute_value("cleanProc", True)
        pl_desc.set_attribute_value("plLogLevel", "INFO")
        
        return pl_desc, exp_desc
Ejemplo n.º 6
0
    def test_design(self):
        exp_desc = ExperimentDescription()
        testbed_id = "mock"
        provider = FactoriesProvider(testbed_id)
        desc = exp_desc.add_testbed_description(provider)
        desc.set_attribute_value("fake", True)
        node1 = desc.create("Node")
        node2 = desc.create("Node")
        iface1 = desc.create("Interface")
        iface1.set_attribute_value("fake", True)
        addr1 = iface1.add_address()
        addr2 = iface1.add_address()
        addr3 = iface1.add_address()
        self.assertRaises(RuntimeError, iface1.add_address)
        node1.connector("devs").connect(iface1.connector("node"))
        iface2 = desc.create("Interface")
        iface2.set_attribute_value("fake", True)
        node2.connector("devs").connect(iface2.connector("node"))
        iface1.connector("iface").connect(iface2.connector("iface"))
        app = desc.create("Application")
        app.connector("node").connect(node1.connector("apps"))
        app.enable_trace("fake")

        self.assertEquals(node1.tags, [tags.MOBILE, tags.NODE, tags.ALLOW_ROUTES])

        xml = exp_desc.to_xml()
        exp_desc2 = ExperimentDescription()
        exp_desc2.from_xml(xml)
        xml2 = exp_desc2.to_xml()
        self.assertTrue(xml == xml2)
Ejemplo n.º 7
0
    def _test_switched(self, controller_access_config = None,
            testbed_access_config = None):
        testbed_id = "netns"
        exp_desc = ExperimentDescription()
        user = getpass.getuser()
        netns_provider = FactoriesProvider(testbed_id)
        
        netns_desc = exp_desc.add_testbed_description(netns_provider)
        netns_desc.set_attribute_value("homeDirectory", self.root_dir)
        #netns_desc.set_attribute_value("enableDebug", True)
        node1 = netns_desc.create("Node")
        node2 = netns_desc.create("Node")
        iface1 = netns_desc.create("NodeInterface")
        iface1.set_attribute_value("up", True)
        node1.connector("devs").connect(iface1.connector("node"))
        ip1 = iface1.add_address()
        ip1.set_attribute_value("Address", "10.0.0.1")
        iface2 = netns_desc.create("NodeInterface")
        iface2.set_attribute_value("up", True)
        node2.connector("devs").connect(iface2.connector("node"))
        ip2 = iface2.add_address()
        ip2.set_attribute_value("Address", "10.0.0.2")
        switch = netns_desc.create("Switch")
        switch.set_attribute_value("up", True)
        iface1.connector("switch").connect(switch.connector("devs"))
        iface2.connector("switch").connect(switch.connector("devs"))
        app = netns_desc.create("Application")
        app.set_attribute_value("command", "ping -qc1 10.0.0.2")
        app.set_attribute_value("user", user)
        app.connector("node").connect(node1.connector("apps"))
        app.enable_trace("stdout")

        if testbed_access_config:
            for attr in testbed_access_config.attributes:
                if attr.value:
                    netns_desc.set_attribute_value(attr.name, attr.value)

        xml = exp_desc.to_xml()

        controller = proxy.create_experiment_controller(xml, 
                controller_access_config)
        
        try:
            controller.start()
            while not controller.is_finished(app.guid):
                time.sleep(0.5)
            ping_result = controller.trace(app.guid, "stdout")
            comp_result = """PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.

--- 10.0.0.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
"""
            self.assertTrue(ping_result.startswith(comp_result))
        finally:
            controller.stop()
            controller.shutdown()
Ejemplo n.º 8
0
    def test_design_if(self):
        testbed_id = "ns3"
        exp_desc = ExperimentDescription()
        provider = FactoriesProvider(testbed_id)
        tstbd_desc = exp_desc.add_testbed_description(provider)

        node1 = tstbd_desc.create("ns3::Node")
        ipv41 = tstbd_desc.create("ns3::Ipv4L3Protocol")
        arp1  = tstbd_desc.create("ns3::ArpL3Protocol")
        icmp1 = tstbd_desc.create("ns3::Icmpv4L4Protocol")
        udp1 = tstbd_desc.create("ns3::UdpL4Protocol")
        node1.connector("protos").connect(ipv41.connector("node"))
        node1.connector("protos").connect(arp1.connector("node"))
        node1.connector("protos").connect(icmp1.connector("node"))
        node1.connector("protos").connect(udp1.connector("node"))
        iface1 = tstbd_desc.create("ns3::PointToPointNetDevice")
        queue1 = tstbd_desc.create("ns3::DropTailQueue")
        node1.connector("devs").connect(iface1.connector("node"))
        iface1.connector("queue").connect(queue1.connector("dev"))
        trace1 = iface1.enable_trace("P2PPcapTrace")
        ip1 = iface1.add_address()
        ip1.set_attribute_value("Address", "10.0.0.1")

        node2 = tstbd_desc.create("ns3::Node")
        ipv42 = tstbd_desc.create("ns3::Ipv4L3Protocol")
        arp2  = tstbd_desc.create("ns3::ArpL3Protocol")
        icmp2 = tstbd_desc.create("ns3::Icmpv4L4Protocol")
        udp2 = tstbd_desc.create("ns3::UdpL4Protocol")
        node2.connector("protos").connect(ipv42.connector("node"))
        node2.connector("protos").connect(arp2.connector("node"))
        node2.connector("protos").connect(icmp2.connector("node"))
        node2.connector("protos").connect(udp2.connector("node"))
        iface2 = tstbd_desc.create("ns3::PointToPointNetDevice")
        queue2 = tstbd_desc.create("ns3::DropTailQueue")
        node2.connector("devs").connect(iface2.connector("node"))
        iface2.connector("queue").connect(queue2.connector("dev"))
        trace2 = iface2.enable_trace("P2PPcapTrace")
        ip2 = iface2.add_address()
        ip2.set_attribute_value("Address", "10.0.0.2")

        chan = tstbd_desc.create("ns3::PointToPointChannel")
        iface1.connector("chan").connect(chan.connector("dev2"))
        iface2.connector("chan").connect(chan.connector("dev2"))

        app = tstbd_desc.create("ns3::V4Ping")
        app.set_attribute_value("Remote", "10.0.0.2")
        app.set_attribute_value("StartTime", "0s")
        app.set_attribute_value("StopTime", "20s")
        app.set_attribute_value("Verbose", False)
        app.connector("node").connect(node1.connector("apps"))

        xml = exp_desc.to_xml()
        exp_desc2 = ExperimentDescription()
        exp_desc2.from_xml(xml)
        xml2 = exp_desc2.to_xml()
        self.assertTrue(xml == xml2)
Ejemplo n.º 9
0
    def make_experiment_desc(self):
        testbed_id = self.testbed_id

        slicename1 = self.slicename1
        plchost1 = self.plchost1

        slicename2 = self.slicename2
        plchost2 = self.plchost2

        pl_ssh_key = os.environ.get(
            "PL_SSH_KEY", "%s/.ssh/id_rsa_planetlab" % (os.environ['HOME'], ))
        pl_user, pl_pwd = test_util.pl_auth()

        exp_desc = ExperimentDescription()
        pl_provider = FactoriesProvider(testbed_id)
        pl_desc = exp_desc.add_testbed_description(pl_provider)
        pl_desc.set_attribute_value("homeDirectory", self.root_dir)
        pl_desc.set_attribute_value("slice", slicename1)
        pl_desc.set_attribute_value("sliceSSHKey", pl_ssh_key)
        pl_desc.set_attribute_value("authUser", pl_user)
        pl_desc.set_attribute_value("authPass", pl_pwd)
        pl_desc.set_attribute_value("plcHost", plchost1)
        pl_desc.set_attribute_value("tapPortBase", self.port_base)
        pl_desc.set_attribute_value(
            "p2pDeployment",
            False)  # it's interactive, we don't want it in tests
        pl_desc.set_attribute_value("cleanProc", True)

        pl_desc2 = exp_desc.add_testbed_description(pl_provider)
        pl_desc2.set_attribute_value("homeDirectory", self.root_dir + "v2")
        pl_desc2.set_attribute_value("slice", slicename2)
        pl_desc2.set_attribute_value("sliceSSHKey", pl_ssh_key)
        pl_desc2.set_attribute_value("authUser", pl_user)
        pl_desc2.set_attribute_value("authPass", pl_pwd)
        pl_desc2.set_attribute_value("plcHost", plchost2)
        pl_desc2.set_attribute_value("tapPortBase", self.port_base + 500)
        pl_desc2.set_attribute_value(
            "p2pDeployment",
            False)  # it's interactive, we don't want it in tests
        pl_desc2.set_attribute_value("cleanProc", True)

        return pl_desc, pl_desc2, exp_desc
Ejemplo n.º 10
0
    def make_experiment_desc(self):
        testbed_id = self.testbed_id
        
        slicename1 = self.slicename1
        plchost1 = self.plchost1
        
        slicename2 = self.slicename2
        plchost2 = self.plchost2
        
        pl_ssh_key = os.environ.get(
            "PL_SSH_KEY",
            "%s/.ssh/id_rsa_planetlab" % (os.environ['HOME'],) )
        pl_user, pl_pwd = test_util.pl_auth()

        exp_desc = ExperimentDescription()
        pl_provider = FactoriesProvider(testbed_id)
        pl_desc = exp_desc.add_testbed_description(pl_provider)
        pl_desc.set_attribute_value("homeDirectory", self.root_dir)
        pl_desc.set_attribute_value("slice", slicename1)
        pl_desc.set_attribute_value("sliceSSHKey", pl_ssh_key)
        pl_desc.set_attribute_value("authUser", pl_user)
        pl_desc.set_attribute_value("authPass", pl_pwd)
        pl_desc.set_attribute_value("plcHost", plchost1)
        pl_desc.set_attribute_value("tapPortBase", self.port_base)
        pl_desc.set_attribute_value("p2pDeployment", False) # it's interactive, we don't want it in tests
        pl_desc.set_attribute_value("cleanProc", True)

        pl_desc2 = exp_desc.add_testbed_description(pl_provider)
        pl_desc2.set_attribute_value("homeDirectory", self.root_dir+"v2")
        pl_desc2.set_attribute_value("slice", slicename2)
        pl_desc2.set_attribute_value("sliceSSHKey", pl_ssh_key)
        pl_desc2.set_attribute_value("authUser", pl_user)
        pl_desc2.set_attribute_value("authPass", pl_pwd)
        pl_desc2.set_attribute_value("plcHost", plchost2)
        pl_desc2.set_attribute_value("tapPortBase", self.port_base+500)
        pl_desc2.set_attribute_value("p2pDeployment", False) # it's interactive, we don't want it in tests
        pl_desc2.set_attribute_value("cleanProc", True)
        
        return pl_desc, pl_desc2, exp_desc
Ejemplo n.º 11
0
 def make_test_design(self):
     testbed_id = "planetlab"
     exp_desc = ExperimentDescription()
     provider = FactoriesProvider(testbed_id)
     tstbd_desc = exp_desc.add_testbed_description(provider)
     tstbd_desc.set_attribute_value("slice", "inria_nepi")
     node1 = tstbd_desc.create("Node")
     node2 = tstbd_desc.create("Node")
     iface1 = tstbd_desc.create("NodeInterface")
     node1.connector("devs").connect(iface1.connector("node"))
     iface2 = tstbd_desc.create("NodeInterface")
     node2.connector("devs").connect(iface2.connector("node"))
     switch = tstbd_desc.create("Internet")
     iface1.connector("inet").connect(switch.connector("devs"))
     iface2.connector("inet").connect(switch.connector("devs"))
     app = tstbd_desc.create("Application")
     app.set_attribute_value("command", "ping -qc10 10.0.0.2")
     app.connector("node").connect(node1.connector("apps"))
     
     return exp_desc, tstbd_desc, node1, node2, iface1, iface2, app
Ejemplo n.º 12
0
    def make_test_design(self):
        testbed_id = "planetlab"
        exp_desc = ExperimentDescription()
        provider = FactoriesProvider(testbed_id)
        tstbd_desc = exp_desc.add_testbed_description(provider)
        tstbd_desc.set_attribute_value("slice", "inria_nepi")
        node1 = tstbd_desc.create("Node")
        node2 = tstbd_desc.create("Node")
        iface1 = tstbd_desc.create("NodeInterface")
        node1.connector("devs").connect(iface1.connector("node"))
        iface2 = tstbd_desc.create("NodeInterface")
        node2.connector("devs").connect(iface2.connector("node"))
        switch = tstbd_desc.create("Internet")
        iface1.connector("inet").connect(switch.connector("devs"))
        iface2.connector("inet").connect(switch.connector("devs"))
        app = tstbd_desc.create("Application")
        app.set_attribute_value("command", "ping -qc10 10.0.0.2")
        app.connector("node").connect(node1.connector("apps"))

        return exp_desc, tstbd_desc, node1, node2, iface1, iface2, app
root_dir = tempfile.mkdtemp()
netns_root_dir = os.path.join(root_dir, "netns")
os.makedirs(netns_root_dir)
user = getpass.getuser()
slicename = os.environ["PL_SLICE"]
plchost = "www.planet-lab.eu"
port_base = 2000 + (os.getpid() % 1000) * 13
pl_ssh_key = os.environ.get(
    "PL_SSH_KEY", "%s/.ssh/id_rsa_planetlab" % (os.environ['HOME'], ))
pl_user = os.environ.get('PL_USER')
pl_pwd = os.environ.get('PL_PASS')

exp_desc = ExperimentDescription()

pl_provider = FactoriesProvider("planetlab")
pl_desc = exp_desc.add_testbed_description(pl_provider)
pl_desc.set_attribute_value("homeDirectory", root_dir)
pl_desc.set_attribute_value("slice", slicename)
pl_desc.set_attribute_value("sliceSSHKey", pl_ssh_key)
pl_desc.set_attribute_value("authUser", pl_user)
pl_desc.set_attribute_value("authPass", pl_pwd)
pl_desc.set_attribute_value("plcHost", plchost)
pl_desc.set_attribute_value("tapPortBase", port_base)
pl_desc.set_attribute_value(
    "p2pDeployment", False)  # it's interactive, we don't want it in tests
pl_desc.set_attribute_value("cleanProc", True)
pl_desc.set_attribute_value("plLogLevel", "DEBUG")

pl_inet = pl_desc.create("Internet")

pl_node = pl_desc.create("Node")
Ejemplo n.º 14
0
    phy = ns3_desc.create("ns3::YansWifiPhy")
    phy.set_attribute_value("Standard",  "WIFI_PHY_STANDARD_80211b")
    dev.connector("phy").connect(phy.connector("dev"))
    channel.connector("phys").connect(phy.connector("chan"))
    error = ns3_desc.create("ns3::NistErrorRateModel")
    phy.connector("err").connect(error.connector("phy"))
 
    return dev

root_dir = tempfile.mkdtemp()

exp_desc = ExperimentDescription()

testbed_id = "ns3"
ns3_provider = FactoriesProvider(testbed_id)
ns3_desc = exp_desc.add_testbed_description(ns3_provider)
ns3_desc.set_attribute_value("homeDirectory", root_dir)
#ns3_desc.set_attribute_value("SimulatorImplementationType", "ns3::RealtimeSimulatorImpl")
#ns3_desc.set_attribute_value("ChecksumEnabled", True)

# 0. Enable or disable CTS/RTS
# ??

# 1 & 2 & 6. Create 3 nodes with their mobility models, and Install TCP/IP stack & assign IP addresses
(node1, mob1) = create_node(ns3_desc)
(node2, mob2) = create_node(ns3_desc)
(node3, mob3) = create_node(ns3_desc)

#  3. Create propagation loss matrix
matrix = ns3_desc.create("ns3::MatrixPropagationLossModel")
matrix.set_attribute_value("DefaultLoss", 200.0)
Ejemplo n.º 15
0
from nepi.core.design import ExperimentDescription, FactoriesProvider
from nepi.core.execute import ExperimentController
import getpass
import logging
import tempfile
import time

logging.basicConfig(level=logging.DEBUG)

root_dir = tempfile.mkdtemp()

exp_desc = ExperimentDescription()

testbed_id = "omf"
omf_provider = FactoriesProvider(testbed_id)
omf_desc = exp_desc.add_testbed_description(omf_provider)
omf_desc.set_attribute_value("homeDirectory", root_dir)
omf_desc.set_attribute_value("enableDebug", True)
omf_desc.set_attribute_value("xmppSlice", "default_slice")
omf_desc.set_attribute_value("xmppHost", "xmpp-plexus.onelab.eu")
omf_desc.set_attribute_value("xmppPort", 5222)
omf_desc.set_attribute_value("xmppPassword", "1234")

node1 = omf_desc.create("Node")
node1.set_attribute_value("hostname", "omf.plexus.wlab17")

app1 = omf_desc.create("OmfApplication")
app1.set_attribute_value("appId", "xeyes#1")
app1.set_attribute_value("path", "/usr/bin/xeyes")
app1.set_attribute_value("env", "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
app1.connector("node").connect(node1.connector("apps"))
netns_root_dir = os.path.join(root_dir, "netns")
os.makedirs(netns_root_dir)
user = getpass.getuser()
slicename = os.environ["PL_SLICE"]
plchost = "www.planet-lab.eu"
port_base = 2000 + (os.getpid() % 1000) * 13
pl_ssh_key = os.environ.get(
    "PL_SSH_KEY",
    "%s/.ssh/id_rsa_planetlab" % (os.environ['HOME'],) )
pl_user = os.environ.get('PL_USER')
pl_pwd = os.environ.get('PL_PASS')

exp_desc = ExperimentDescription()

pl_provider = FactoriesProvider("planetlab")
pl_desc = exp_desc.add_testbed_description(pl_provider)
pl_desc.set_attribute_value("homeDirectory", root_dir)
pl_desc.set_attribute_value("slice", slicename)
pl_desc.set_attribute_value("sliceSSHKey", pl_ssh_key)
pl_desc.set_attribute_value("authUser", pl_user)
pl_desc.set_attribute_value("authPass", pl_pwd)
pl_desc.set_attribute_value("plcHost", plchost)
pl_desc.set_attribute_value("tapPortBase", port_base)
pl_desc.set_attribute_value("p2pDeployment", False) # it's interactive, we don't want it in tests
pl_desc.set_attribute_value("cleanProc", True)
pl_desc.set_attribute_value("plLogLevel", "DEBUG")
       
pl_inet = pl_desc.create("Internet")

pl_node = pl_desc.create("Node")
pl_iface = pl_desc.create("NodeInterface")
Ejemplo n.º 17
0
from nepi.core.design import ExperimentDescription, FactoriesProvider
from nepi.core.execute import ExperimentController
import getpass
import logging
import tempfile
import time

logging.basicConfig(level=logging.DEBUG)

root_dir = tempfile.mkdtemp()

exp_desc = ExperimentDescription()

testbed_id = "omf"
omf_provider = FactoriesProvider(testbed_id)
omf_desc = exp_desc.add_testbed_description(omf_provider)
omf_desc.set_attribute_value("homeDirectory", root_dir)
omf_desc.set_attribute_value("enableDebug", True)
omf_desc.set_attribute_value("xmppSlice", "tribino")
omf_desc.set_attribute_value("xmppHost", "nitlab.inf.uth.gr")
omf_desc.set_attribute_value("xmppPort", 5222)
omf_desc.set_attribute_value("xmppPassword", "1234")

# Add node1
node1 = omf_desc.create("Node")
node1.set_attribute_value("hostname", "omf.nitos.node019")

# Add configuration for interface 1
iface1 = omf_desc.create("WifiInterface")
iface1.set_attribute_value("alias", "w0")
iface1.set_attribute_value("mode", "adhoc")
Ejemplo n.º 18
0
    node.connector("protos").connect(icmp.connector("node"))
    node.connector("protos").connect(udp.connector("node"))
    return node


user = getpass.getuser()
root_dir = tempfile.mkdtemp()
movie = "/home/alina/repos/nepi/big_buck_bunny_240p_mpeg4_lq.ts"
bounds_width = bounds_height = 200
x = y = 100
speed = 1

exp_desc = ExperimentDescription()

ns3_provider = FactoriesProvider("ns3")
ns3_desc = exp_desc.add_testbed_description(ns3_provider)
ns3_dir = tempfile.mkdtemp()
ns3_desc.set_attribute_value("rootDirectory", ns3_dir)
ns3_desc.set_attribute_value("SimulatorImplementationType",
                             "ns3::RealtimeSimulatorImpl")
ns3_desc.set_attribute_value("ChecksumEnabled", True)

netns_provider = FactoriesProvider("netns")
netns_desc1 = exp_desc.add_testbed_description(netns_provider)
netns_dir1 = tempfile.mkdtemp()
netns_desc1.set_attribute_value("rootDirectory", netns_dir1)
netns_desc1.set_attribute_value("enableDebug", True)
netns_desc1.set_attribute_value("useSudo", True)
netns_desc1.set_attribute_value("deployment_communication", "LOCAL")
netns_desc1.set_attribute_value("deployment_mode", "DAEMON")
Ejemplo n.º 19
0
    def _test_fd_net_device(self, daemonize_testbed,
            controller_access_configuration):
        testbed_id = "ns3"
        exp_desc = ExperimentDescription()
        ns3_provider = FactoriesProvider(testbed_id)
        ns3_desc1 = exp_desc.add_testbed_description(ns3_provider)
        root_dir1 = os.path.join(self.root_dir, "1")
        ns3_desc1.set_attribute_value("homeDirectory", root_dir1)
        ns3_desc1.set_attribute_value("SimulatorImplementationType",
                "ns3::RealtimeSimulatorImpl")
        ns3_desc1.set_attribute_value("ChecksumEnabled", True)
        ns3_desc2 = exp_desc.add_testbed_description(ns3_provider)
        root_dir2 = os.path.join(self.root_dir, "2")
        ns3_desc2.set_attribute_value("homeDirectory", root_dir2)
        ns3_desc2.set_attribute_value("SimulatorImplementationType",
                "ns3::RealtimeSimulatorImpl")
        ns3_desc2.set_attribute_value("ChecksumEnabled", True)

        node1 = ns3_desc1.create("ns3::Node")
        ipv41 = ns3_desc1.create("ns3::Ipv4L3Protocol")
        arp1  = ns3_desc1.create("ns3::ArpL3Protocol")
        icmp1 = ns3_desc1.create("ns3::Icmpv4L4Protocol")
        node1.connector("protos").connect(ipv41.connector("node"))
        node1.connector("protos").connect(arp1.connector("node"))
        node1.connector("protos").connect(icmp1.connector("node"))
        iface1 = ns3_desc1.create("ns3::FdNetDevice")
        node1.connector("devs").connect(iface1.connector("node"))
        ip1 = iface1.add_address()
        ip1.set_attribute_value("Address", "10.0.0.1")
        tc1 = ns3_desc1.create("ns3::Nepi::TunChannel")
        tc1.connector("fd->").connect(iface1.connector("->fd"))

        node2 = ns3_desc2.create("ns3::Node")
        ipv42 = ns3_desc2.create("ns3::Ipv4L3Protocol")
        arp2  = ns3_desc2.create("ns3::ArpL3Protocol")
        icmp2 = ns3_desc2.create("ns3::Icmpv4L4Protocol")
        node2.connector("protos").connect(ipv42.connector("node"))
        node2.connector("protos").connect(arp2.connector("node"))
        node2.connector("protos").connect(icmp2.connector("node"))
        iface2 = ns3_desc2.create("ns3::FdNetDevice")
        iface2.enable_trace("FdAsciiTrace")
        node2.connector("devs").connect(iface2.connector("node"))
        ip2 = iface2.add_address()
        ip2.set_attribute_value("Address", "10.0.0.2")
        tc2 = ns3_desc2.create("ns3::Nepi::TunChannel")
        tc2.connector("fd->").connect(iface2.connector("->fd"))

        tc2.connector("udp").connect(tc1.connector("udp"))

        app = ns3_desc1.create("ns3::V4Ping")
        app.set_attribute_value("Remote", "10.0.0.2")
        app.set_attribute_value("StartTime", "0s")
        app.set_attribute_value("StopTime", "2s")
        app.connector("node").connect(node1.connector("apps"))

        if daemonize_testbed:
            ns3_desc1.set_attribute_value(DC.DEPLOYMENT_MODE, DC.MODE_DAEMON)
            inst_root_dir = os.path.join(root_dir1, "instance")
            os.makedirs(inst_root_dir)
            ns3_desc1.set_attribute_value(DC.ROOT_DIRECTORY, inst_root_dir)
            #ns3_desc1.set_attribute_value(DC.LOG_LEVEL, DC.DEBUG_LEVEL)

            ns3_desc2.set_attribute_value(DC.DEPLOYMENT_MODE, DC.MODE_DAEMON)
            inst_root_dir = os.path.join(root_dir2, "instance")
            os.makedirs(inst_root_dir)
            ns3_desc2.set_attribute_value(DC.ROOT_DIRECTORY, inst_root_dir)
            #ns3_desc2.set_attribute_value(DC.LOG_LEVEL, DC.DEBUG_LEVEL)

        xml = exp_desc.to_xml()
        
        if controller_access_configuration:
            controller = ExperimentController(xml, self.root_dir)
        else:
            controller = proxy.create_experiment_controller(xml, 
                controller_access_configuration)
        
        try:
            controller.start()
            while not controller.is_finished(app.guid):
                time.sleep(0.5)
            ping_result = controller.trace(iface2.guid, "FdAsciiTrace")
            ping_exp_result = r"""r [-+0-9.e]+ /NodeList/0/DeviceList/0/\$ns3::FdNetDevice/Rx Payload \(size=42\)
r [-+0-9.e]+ /NodeList/0/DeviceList/0/\$ns3::FdNetDevice/Rx Payload \(size=98\)
r [-+0-9.e]+ /NodeList/0/DeviceList/0/\$ns3::FdNetDevice/Rx Payload \(size=42\)
r [-+0-9.e]+ /NodeList/0/DeviceList/0/\$ns3::FdNetDevice/Rx Payload \(size=98\)
"""
            if not re.match(ping_exp_result, ping_result):
                self.fail("Unexpected trace: %s" % (ping_result,))

        finally:
            controller.stop()
            controller.shutdown()
Ejemplo n.º 20
0
    def _test_if(self, daemonize_testbed, controller_access_configuration):
        exp_desc = ExperimentDescription()
        testbed_id = "ns3"
        ns3_provider = FactoriesProvider(testbed_id)
        ns3_desc = exp_desc.add_testbed_description(ns3_provider)
        ns3_desc.set_attribute_value("homeDirectory", self.root_dir)

        node1 = ns3_desc.create("ns3::Node")
        ipv41 = ns3_desc.create("ns3::Ipv4L3Protocol")
        arp1  = ns3_desc.create("ns3::ArpL3Protocol")
        icmp1 = ns3_desc.create("ns3::Icmpv4L4Protocol")
        node1.connector("protos").connect(ipv41.connector("node"))
        node1.connector("protos").connect(arp1.connector("node"))
        node1.connector("protos").connect(icmp1.connector("node"))
        iface1 = ns3_desc.create("ns3::PointToPointNetDevice")
        queue1 = ns3_desc.create("ns3::DropTailQueue")
        node1.connector("devs").connect(iface1.connector("node"))
        iface1.connector("queue").connect(queue1.connector("dev"))
        trace1 = iface1.enable_trace("P2PAsciiTrace")
        ip1 = iface1.add_address()
        ip1.set_attribute_value("Address", "10.0.0.1")

        node2 = ns3_desc.create("ns3::Node")
        ipv42 = ns3_desc.create("ns3::Ipv4L3Protocol")
        arp2  = ns3_desc.create("ns3::ArpL3Protocol")
        icmp2 = ns3_desc.create("ns3::Icmpv4L4Protocol")
        node2.connector("protos").connect(ipv42.connector("node"))
        node2.connector("protos").connect(arp2.connector("node"))
        node2.connector("protos").connect(icmp2.connector("node"))
        iface2 = ns3_desc.create("ns3::PointToPointNetDevice")
        queue2 = ns3_desc.create("ns3::DropTailQueue")
        node2.connector("devs").connect(iface2.connector("node"))
        iface2.connector("queue").connect(queue2.connector("dev"))
        trace2 = iface2.enable_trace("P2PAsciiTrace")
        ip2 = iface2.add_address()
        ip2.set_attribute_value("Address", "10.0.0.2")

        chan = ns3_desc.create("ns3::PointToPointChannel")
        iface1.connector("chan").connect(chan.connector("dev2"))
        iface2.connector("chan").connect(chan.connector("dev2"))

        app = ns3_desc.create("ns3::V4Ping")
        app.set_attribute_value("Remote", "10.0.0.2")
        app.set_attribute_value("StartTime", "0s")
        app.set_attribute_value("StopTime", "20s")
        app.connector("node").connect(node1.connector("apps"))

        if daemonize_testbed:
            ns3_desc.set_attribute_value(DC.DEPLOYMENT_MODE, DC.MODE_DAEMON)
            inst_root_dir = os.path.join(self.root_dir, "instance")
            os.mkdir(inst_root_dir)
            ns3_desc.set_attribute_value(DC.ROOT_DIRECTORY, inst_root_dir)
            #ns3_desc.set_attribute_value(DC.LOG_LEVEL, DC.DEBUG_LEVEL)

        xml = exp_desc.to_xml()
        
        if controller_access_configuration:
            controller = ExperimentController(xml, self.root_dir)
        else:
            controller = proxy.create_experiment_controller(xml, 
                controller_access_configuration)
        
        try:
            controller.start()
            while not controller.is_finished(app.guid):
                time.sleep(0.5)
            ping_result = controller.trace(iface2.guid, "P2PAsciiTrace")

            comp_result = "- 19.021 /NodeList/1/DeviceList/0/$ns3::PointToPointNetDevice/TxQueue/Dequeue ns3::PppHeader (Point-to-Point Protocol: IP (0x0021)) ns3::Ipv4Header (tos 0x0 DSCP Default ECN Not-ECT ttl 64 id 19 protocol 1 offset (bytes) 0 flags [none] length: 84 10.0.0.2 > 10.0.0.1) ns3::Icmpv4Header (type=0, code=0) ns3::Icmpv4Echo (identifier=0, sequence=19)"
            
            if ping_result.find(comp_result) == -1:
                self.fail("Unexpected trace: %s" % (ping_result,))
        finally:
            controller.stop()
            controller.shutdown()
Ejemplo n.º 21
0
    node.connector("protos").connect(arp.connector("node"))
    node.connector("protos").connect(icmp.connector("node"))
    node.connector("protos").connect(udp.connector("node"))
    return node

user = getpass.getuser()
root_dir = tempfile.mkdtemp()
movie = "/home/alina/repos/nepi/big_buck_bunny_240p_mpeg4_lq.ts" 
bounds_width = bounds_height = 200
x = y = 100
speed = 1

exp_desc = ExperimentDescription()

ns3_provider = FactoriesProvider("ns3")
ns3_desc = exp_desc.add_testbed_description(ns3_provider)
ns3_dir = tempfile.mkdtemp()
ns3_desc.set_attribute_value("rootDirectory", ns3_dir)
ns3_desc.set_attribute_value("SimulatorImplementationType", "ns3::RealtimeSimulatorImpl")
ns3_desc.set_attribute_value("ChecksumEnabled", True)

netns_provider = FactoriesProvider("netns")
netns_desc1 = exp_desc.add_testbed_description(netns_provider)
netns_dir1 = tempfile.mkdtemp()
netns_desc1.set_attribute_value("rootDirectory", netns_dir1)
netns_desc1.set_attribute_value("enableDebug", True)
netns_desc1.set_attribute_value("useSudo", True)
netns_desc1.set_attribute_value("deployment_communication", "LOCAL")
netns_desc1.set_attribute_value("deployment_mode", "DAEMON")

netns_provider = FactoriesProvider("netns")