import getpass
import os
+import os.path
import re
import sys
import shutil
import math
import subprocess
-sys.path.append("../../src")
+sys.path.append(os.path.abspath("../../src"))
from nepi.core.design import ExperimentDescription, FactoriesProvider
from nepi.core.execute import ExperimentController
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("dedicatedSlice", True)
+ pl_desc.set_attribute_value("cleanProc", True)
pl_desc.set_attribute_value("plLogLevel", "INFO")
return pl_desc, exp_desc
r1.set_attribute_value("NextHop", nexthop)
if mcast:
- fwd = pl.create("MulticastForwarder")
- fwd.enable_trace("stderr")
- fwd.connector("node").connect(node1.connector("apps"))
if mcastrouter:
+ fwd = pl.create("MulticastForwarder")
+ fwd.enable_trace("stderr")
+ fwd.connector("node").connect(node1.connector("apps"))
mrt = pl.create("MulticastRouter")
mrt.connector("fwd").connect(fwd.connector("router"))
mrt.enable_trace("stderr")
+ else:
+ ann = pl.create("MulticastAnnouncer")
+ ann.enable_trace("stderr")
+ ann.connector("node").connect(node1.connector("apps"))
return node1, iface1, tap1, tap1ip, inet
app.set_attribute_value("label","vlc_restreamer_%d" % (node.guid,))
app.set_attribute_value("command",
"sudo -S dbus-uuidgen --ensure ; "
+ "while true ; do "
"vlc -vvv -I dummy"
" udp/ts://@239.255.12.42"
- " --sout '#std{access=http,mux=ts,dst="+hostname+":8080}'")
+ " --sout '#std{access=http,mux=ts,dst=:8080}'"
+ " ; sleep 5 ; done ")
return app
def add_vlc_dumper(self, pl, node, hostname=None, labelprefix = "vlc_dumper", precmd = "sleep 5 ; "):
app.set_attribute_value("command",
precmd+
"sudo -S dbus-uuidgen --ensure ; "
+ "cat /dev/null > {#["+mylabel+"].trace[output].[name]#} ; "
+ "while [[ $(stat -c '%s' {#["+mylabel+"].trace[output].[name]#}) == '0' ]] ; do "
"vlc -vvv -I dummy"
- " http://"+hostname+":8080"
- " --sout '#std{access=file,mux=ts,dst={#["+mylabel+"].trace[output].[name]#}}'")
+ " http://"+hostname+":8080 vlc://quit"
+ " --sout '#std{access=file,mux=ts,dst={#["+mylabel+"].trace[output].[name]#}}'"
+ " ; sleep 5 ; done ")
app.enable_trace("output")
return app
def add_pl_ns_connection(self, pl_desc, pl_node, pl_addr,
ns, ns_node, ns_addr, prefix = 30,
- fd = False):
+ fd = False, ptp = False):
pl_tap = pl_desc.create("TapInterface")
if fd:
pl_tap.set_attribute_value("tun_cipher", "PLAIN")
tunchannel = ns.create("ns3::Nepi::TunChannel")
tunchannel.connector("fd->").connect(ns_fdnd.connector("->fd"))
pl_tap.connector("udp").connect(tunchannel.connector("udp"))
+
+ if ptp:
+ pl_tap.set_attribute_value("pointopoint", ns_addr)
def make_pl_overlay(self, numnodes):
ns3_testbed_id = "ns3"
ap_wifi, ap_phy = self.add_ns_wifi_dev(ns, ap_node, access_point = True)
ap_phy.connector("chan").connect(wifi_chan.connector("phys"))
- # connect AP to PL
- pl_addr = str(ipaddr.IPAddress(vnet_i | 254))
- ns_addr = str(ipaddr.IPAddress(vnet_i | 253))
- self.add_pl_ns_connection(pl, pl_ns_root, pl_addr, ns, ap_node, ns_addr, fd = True)
-
+ # Net range free for WiFi
wifi_net_prefix = 32-int(math.floor(math.log(256-nextip[0]&0xff) / math.log(2)))
wifi_net = vnet_i | (256 - (1<<(32-wifi_net_prefix)))
+
+ # connect AP to PL
+ pl_addr = str(ipaddr.IPAddress(wifi_net | 1))
+ ns_addr = str(ipaddr.IPAddress(wifi_net | 2))
+ self.add_pl_ns_connection(
+ pl, pl_ns_root, pl_addr,
+ ns, ap_node, ns_addr,
+ fd = True, ptp = True, prefix=30)
+
# AP ip
- ap_addr = str(ipaddr.IPAddress(vnet_i | 253))
+ ap_addr = str(ipaddr.IPAddress(vnet_i | 254))
ap_addr_prefix = 32-int(math.ceil(math.log(self.nsta+3) / math.log(2)))
self.add_ip_address(ap_wifi, ap_addr, ap_addr_prefix)
# route for PL->wifi
self.add_route(pl_ns_root,
str(ipaddr.IPAddress(wifi_net)), wifi_net_prefix,
- ap_addr)
+ ns_addr)
- print "NS-3 AP\t%s/%s <--> PL AP %s" % (ap_addr, ap_addr_prefix, pl_addr)
+ print "NS-3 AP\t%s/%s <--> PL AP %s" % (ns_addr, 30, pl_addr)
+ print " | (|) %s/%s" % (ap_addr, ap_addr_prefix)
print " |"
+ print " | R %s/%d --> %s" % (str(ipaddr.IPAddress(wifi_net)), wifi_net_prefix, ns_addr)
nextpip = (vnet_i | 255) >> (32-ap_addr_prefix) << (32-ap_addr_prefix)
- nextdip = vnet_i | 252
+ nextdip = vnet_i | 253
ap_net = nextpip - (1<<(32-ap_addr_prefix))
r = 50
# STA nodes
prefix = 30)
self.add_vlc_dumper(pl, pl_nodei,
- hostname = pl_addr2,
+ hostname = pl_addr,
labelprefix = "vlc_dumper_ns",
precmd = "sleep 15 ; ")
exp.plpass = getpass.getpass("Password for %s: " % (exp.pluser,))
# Fix some distro's environment to work well with netns
- if re.match(r"[^:]*:\d+", os.environ['DISPLAY']):
+ if re.match(r"[^:]*:\d+$", os.environ['DISPLAY']):
os.environ['DISPLAY'] += '.0'
if not os.environ.get('XAUTHORITY'):
os.environ['XAUTHORITY'] = os.path.join(os.environ['HOME'], '.Xauthority')