--- /dev/null
+diff -r f860e2eac903 src/nepi/testbeds/ns3/connection_metadata.py
+--- a/src/nepi/testbeds/ns3/connection_metadata.py Wed Aug 15 18:22:33 2012 +0200
++++ b/src/nepi/testbeds/ns3/connection_metadata.py Thu Aug 16 19:02:36 2012 +0200
+@@ -121,7 +121,34 @@
+ (fd, msg) = passfd.recvfd(sock)
+ # Store a reference to the endpoint to keep the socket alive
+ fdnd.SetFileDescriptor(fd)
+-
++
++ try:
++ import fcntl
++ import struct
++ TUNGETIFF = 0x800454d2
++ IFF_NO_PI = 0x00001000
++ IFF_TUN = 0x00000001
++ IFF_TAP = 0x00000002
++ struct_ifreq = "x"*16+"H"+"x"*22
++
++ (flags, ) = struct.unpack(struct_ifreq,
++ fcntl.ioctl(fd, TUNGETIFF, struct.pack(struct_ifreq, 0)))
++
++ with_pi = (0 == (flags & IFF_NO_PI))
++ is_tap = (0 == (flags & IFF_TUN))
++
++ if is_tap and with_pi:
++ fdnd.SetEncapsulationMode(fdnd.DIXPI)
++ elif not is_tap and with_pi:
++ fdnd.SetEncapsulationMode(fdnd.PI)
++ except:
++ # maybe the kernel doesn't support the IOCTL,
++ # in which case, we assume it uses PI headers (as is usual)
++ pass
++
++ #import traceback
++ #err = traceback.format_exc()
++
+ import threading
+ import passfd
+ import socket
+diff -r f860e2eac903 src/nepi/testbeds/ns3/ns3_bindings_import.py
+--- a/src/nepi/testbeds/ns3/ns3_bindings_import.py Wed Aug 15 18:22:33 2012 +0200
++++ b/src/nepi/testbeds/ns3/ns3_bindings_import.py Thu Aug 16 19:02:36 2012 +0200
+@@ -16,7 +16,7 @@
+ #from ns.click import *
+ from ns.mobility import *
+ from ns.wifi import *
+-from ns.netanim import *
++#from ns.netanim import *
+ from ns.stats import *
+ from ns.uan import *
+ from ns.spectrum import *
+diff -r f860e2eac903 src/nepi/testbeds/planetlab/application.py
+--- a/src/nepi/testbeds/planetlab/application.py Wed Aug 15 18:22:33 2012 +0200
++++ b/src/nepi/testbeds/planetlab/application.py Thu Aug 16 19:02:36 2012 +0200
+@@ -907,10 +907,12 @@
+ # We have to download the sources, untar, build...
+ #pygccxml_source_url = "http://leaseweb.dl.sourceforge.net/project/pygccxml/pygccxml/pygccxml-1.0/pygccxml-1.0.0.zip"
+ pygccxml_source_url = "http://yans.pl.sophia.inria.fr/libs/pygccxml-1.0.0.zip"
+- ns3_source_url = "http://nepi.inria.fr/code/nepi-ns3.13/archive/tip.tar.gz"
++ #ns3_source_url = "http://nepi.inria.fr/code/nepi-ns3.13/archive/tip.tar.gz"
++ ns3_source_url = "http://nepi.inria.fr/code/nepi-ns3.fdnetdev/archive/tip.tar.gz"
+ passfd_source_url = "http://nepi.inria.fr/code/python-passfd/archive/tip.tar.gz"
+
+- pybindgen_version = "797"
++ #pybindgen_version = "797"
++ pybindgen_version = "809"
+
+ self.build =(
+ " ( "
+@@ -927,21 +929,21 @@
+ "echo '7158877faff2254e6c094bf18e6b4283cac19137 pygccxml-1.0.0.zip' > archive_sums.txt && "
+ " ( " # check existing files
+ " sha1sum -c archive_sums.txt && "
+- " test -f passfd-src.tar.gz && "
++ " test -f passfd.tar.gz && "
+ " test -f ns3-src.tar.gz "
+ " ) || ( " # nope? re-download
+- " rm -rf pybindgen pygccxml-1.0.0.zip passfd-src.tar.gz ns3-src.tar.gz && "
++ " rm -rf pybindgen pygccxml-1.0.0.zip passfd.tar.gz ns3-src.tar.gz && "
+ " bzr checkout lp:pybindgen -r %(pybindgen_version)s && " # continue, to exploit the case when it has already been dl'ed
+ " wget -q -c -O pygccxml-1.0.0.zip %(pygccxml_source_url)s && "
+- " wget -q -c -O passfd-src.tar.gz %(passfd_source_url)s && "
++ " wget -q -c -O passfd.tar.gz %(passfd_source_url)s && "
+ " wget -q -c -O ns3-src.tar.gz %(ns3_source_url)s && "
+ " sha1sum -c archive_sums.txt " # Check SHA1 sums when applicable
+ " ) && "
+ "unzip -n pygccxml-1.0.0.zip && "
+ "mkdir -p ns3-src && "
+- "mkdir -p passfd-src && "
++ "mkdir -p passfd && "
+ "tar xzf ns3-src.tar.gz --strip-components=1 -C ns3-src && "
+- "tar xzf passfd-src.tar.gz --strip-components=1 -C passfd-src && "
++ "tar xzf passfd.tar.gz --strip-components=1 -C passfd && "
+ "rm -rf target && " # mv doesn't like unclean targets
+ "mkdir -p target && "
+ "cd pygccxml-1.0.0 && "
+@@ -957,12 +959,12 @@
+ "./waf clean && "
+ "mv -f ${BUILD}/target/lib/python*/site-packages/pybindgen ${BUILD}/target/. && "
+ "rm -rf ${BUILD}/target/lib && "
+- "cd ../passfd-src && "
++ "cd ../passfd && "
+ "python setup.py build && "
+ "python setup.py install --install-lib ${BUILD}/target && "
+ "python setup.py clean && "
+ "cd ../ns3-src && "
+- "./waf configure --prefix=${BUILD}/target --with-pybindgen=../pybindgen-src -d release --disable-examples --disable-tests && "
++ "./waf configure --prefix=${BUILD}/target --with-pybindgen=../pybindgen -d release --disable-examples --disable-tests && "
+ "./waf &&"
+ "./waf install && "
+ "rm -f ${BUILD}/target/lib/*.so && "
--- /dev/null
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import getpass
+from nepi.core.design import ExperimentDescription, FactoriesProvider
+from nepi.core.execute import ExperimentController
+from nepi.util import proxy
+from nepi.util.constants import DeploymentConfiguration as DC
+import os
+import shutil
+import tempfile
+import time
+
+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"]
+slicehrn = os.environ["PL_SLICE_HRN"]
+plchost = os.environ["PL_HOST"]
+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("sliceHrn", slicehrn)
+pl_desc.set_attribute_value("sfa", True)
+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")
+pl_iface.connector("inet").connect(pl_inet.connector("devs"))
+pl_node.connector("devs").connect(pl_iface.connector("node"))
+
+app = pl_desc.create("Application")
+app.set_attribute_value("command", "ping -qc1 173.194.34.51")
+app.enable_trace("stdout")
+app.connector("node").connect(pl_node.connector("apps"))
+
+xml = exp_desc.to_xml()
+
+controller = ExperimentController(xml, root_dir)
+controller.start()
+while not controller.is_finished(app.guid):
+ time.sleep(0.5)
+
+ping_result = controller.trace(app.guid, "stdout")
+print ping_result
+
+controller.stop()
+controller.shutdown()
+