From 19a601bf2df7a723df749f478e052978a8552154 Mon Sep 17 00:00:00 2001 From: Alina Quereilhac Date: Tue, 23 Sep 2014 10:38:16 +0200 Subject: [PATCH] Nitos OMF ping examples --- examples/linux/ccn_simple_transfer.py | 4 +- examples/omf/nitos_omf5_ping.py | 134 ++++++++++++++++++ examples/omf/nitos_omf6_ping.py | 148 ++++++++++++++++++++ src/nepi/resources/ns3/ns3dceapplication.py | 19 ++- 4 files changed, 302 insertions(+), 3 deletions(-) create mode 100644 examples/omf/nitos_omf5_ping.py create mode 100644 examples/omf/nitos_omf6_ping.py diff --git a/examples/linux/ccn_simple_transfer.py b/examples/linux/ccn_simple_transfer.py index 7e06207f..cf2f8be0 100644 --- a/examples/linux/ccn_simple_transfer.py +++ b/examples/linux/ccn_simple_transfer.py @@ -34,10 +34,10 @@ from nepi.execution.ec import ExperimentController -from optparse import OptionParser, SUPPRESS_HELP +from optparse import OptionParser import os -usage = ("usage: %prog -a -b -u -i ") +usage = ("usage: %prog -a -b -u -i ") parser = OptionParser(usage = usage) parser.add_option("-a", "--hostname1", dest="hostname1", diff --git a/examples/omf/nitos_omf5_ping.py b/examples/omf/nitos_omf5_ping.py new file mode 100644 index 00000000..ee0c316f --- /dev/null +++ b/examples/omf/nitos_omf5_ping.py @@ -0,0 +1,134 @@ +#!/usr/bin/env python +# +# NEPI, a framework to manage network experiments +# Copyright (C) 2013 INRIA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Authors: Alina Quereilhac +# Julien Tribino + +# Topology +# +# +# Testbed : Nitos +# +# Node +# omf.nitos.node0ZZ +# 0 +# | +# | +# 0 +# Node +# omf.nitos.node0ZZ +# PING +# +# +# - Experiment: +# - t0 : Deployment +# - t1 : Ping Start +# - t2 (t1 + 10s) : Ping stop +# - t3 (t2 + 2s) : Kill the application +# +# + +from nepi.execution.ec import ExperimentController +from nepi.execution.resource import ResourceAction, ResourceState + +from optparse import OptionParser +import os + +usage = ("usage: %prog -x -z -s -c ") + +parser = OptionParser(usage = usage) +parser.add_option("-x", "--nodex", dest="nodex", + help="Nitos first reserved node " + "(e.g. hostname must be of form: omf.nitos.node0XX)", + type="str") +parser.add_option("-z", "--nodez", dest="nodez", + help="Nitos second reserved node " + "(e.g. hostname must be of form: omf.nitos.node0ZZ)", + type="str") +parser.add_option("-c", "--channel", dest="channel", + help="Nitos reserved channel", + type="str") +parser.add_option("-s", "--slice-name", dest="slicename", + help="Nitos slice name", type="str") +(options, args) = parser.parse_args() + +nodex = options.nodex +nodez = options.nodez +slicename = options.slicename +chan = options.channel + +# Create the EC +ec = ExperimentController(exp_id="nitos_omf5_ping") + +# Create and Configure the Nodes +node1 = ec.register_resource("OMFNode") +ec.set(node1, "hostname", nodex) +ec.set(node1, "xmppUser", slicename) +ec.set(node1, "xmppServer", "nitlab.inf.uth.gr") +ec.set(node1, "xmppPort", "5222") +ec.set(node1, "xmppPassword", "1234") +ec.set(node1, "version", "5") + +# Create and Configure the Interfaces +iface1 = ec.register_resource("OMFWifiInterface") +ec.set(iface1, "name", "wlan0") +ec.set(iface1, "mode", "adhoc") +ec.set(iface1, "hw_mode", "g") +ec.set(iface1, "essid", "ping") +ec.set(iface1, "ip", "192.168.0.%s/24" % nodex[-2:]) +ec.set(iface1, "version", "5") +ec.register_connection(node1, iface1) + +# Create and Configure the Channel +channel = ec.register_resource("OMFChannel") +ec.set(channel, "channel", chan) +ec.set(channel, "xmppUser", slicename) +ec.set(channel, "xmppServer", "nitlab.inf.uth.gr") +ec.set(channel, "xmppPort", "5222") +ec.set(channel, "xmppPassword", "1234") +ec.set(channel, "version", "5") +ec.register_connection(iface1, channel) + +# Create and Configure the PING Application +app1 = ec.register_resource("OMFApplication") +ec.set(app1, "appid", "Ping#1") +ec.set(app1, "command", "/bin/ping -c3 192.168.0.%s" % nodex[-2:]) +ec.set(app1, "version", "5") +ec.register_connection(app1, node1) + +app2 = ec.register_resource("OMFApplication") +ec.set(app2, "appid", "Kill#1") +ec.set(app2, "command", "/usr/bin/killall ping") +ec.set(app2, "version", "5") +ec.register_connection(app2, node1) + +# User Behaviour +ec.register_condition(app1, ResourceAction.STOP, app1, ResourceState.STARTED , "10s") +ec.register_condition(app2, ResourceAction.START, app1, ResourceState.STARTED , "12s") +ec.register_condition(app2, ResourceAction.STOP, app2, ResourceState.STARTED , "1s") + +# Deploy +ec.deploy() + +ec.wait_finished([app1, app2]) + +print ec.trace(app1, "stdout") + +# Stop Experiment +ec.shutdown() + diff --git a/examples/omf/nitos_omf6_ping.py b/examples/omf/nitos_omf6_ping.py new file mode 100644 index 00000000..8626af6a --- /dev/null +++ b/examples/omf/nitos_omf6_ping.py @@ -0,0 +1,148 @@ +#!/usr/bin/env python +# +# NEPI, a framework to manage network experiments +# Copyright (C) 2013 INRIA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Authors: Alina Quereilhac +# Julien Tribino + +# Topology +# +# +# Testbed : Nitos +# +# Node +# node0ZZ +# 0 +# | +# | +# 0 +# Node +# node0ZZ +# PING +# +# +# - Experiment: +# - t0 : Deployment +# - t1 : Ping Start +# - t2 (t1 + 10s) : Ping stop +# - t3 (t2 + 2s) : Kill the application +# +# + +from nepi.execution.ec import ExperimentController +from nepi.execution.resource import ResourceAction, ResourceState + +from optparse import OptionParser +import os + +usage = ("usage: %prog -x -z -s -c ") + +parser = OptionParser(usage = usage) +parser.add_option("-x", "--nodex", dest="nodex", + help="Nitos first reserved node " + "(e.g. hostname must be of form: node0XX)", + type="str") +parser.add_option("-z", "--nodez", dest="nodez", + help="Nitos second reserved node " + "(e.g. hostname must be of form: node0ZZ)", + type="str") +parser.add_option("-c", "--channel", dest="channel", + help="Nitos reserved channel", + type="str") +parser.add_option("-s", "--slice-name", dest="slicename", + help="Nitos slice name", type="str") +(options, args) = parser.parse_args() + +nodex = options.nodex +nodez = options.nodez +slicename = options.slicename +chan = options.channel + +# Create the EC +ec = ExperimentController(exp_id="nitos_omf6_ping") + +# Create and Configure the Nodes +node1 = ec.register_resource("OMFNode") +ec.set(node1, "hostname", nodex) +ec.set(node1, "xmppUser", slicename) +ec.set(node1, "xmppServer", "nitlab.inf.uth.gr") +ec.set(node1, "xmppPort", "5222") +ec.set(node1, "xmppPassword", "1234") + +# Create and Configure the Interfaces +iface1 = ec.register_resource("OMFWifiInterface") +ec.set(iface1, "name", "wlan0") +ec.set(iface1, "mode", "adhoc") +ec.set(iface1, "hw_mode", "g") +ec.set(iface1, "essid", "ping") +ec.set(iface1, "ip", "192.168.0.%s/24" % nodex[-2:]) +ec.register_connection(node1, iface1) + +# Create and Configure the Nodes +node2 = ec.register_resource("OMFNode") +ec.set(node2, "hostname", nodez) +ec.set(node2, "xmppUser", slicename) +ec.set(node2, "xmppServer", "nitlab.inf.uth.gr") +ec.set(node2, "xmppPort", "5222") +ec.set(node2, "xmppPassword", "1234") + +# Create and Configure the Interfaces +iface2 = ec.register_resource("OMFWifiInterface") +ec.set(iface2, "name", "wlan0") +ec.set(iface2, "mode", "adhoc") +ec.set(iface2, "hw_mode", "g") +ec.set(iface2, "essid", "ping") +ec.set(iface2, "ip", "192.168.0.%s/24" % nodez[-2:]) +ec.register_connection(node2, iface2) + + +# Create and Configure the Channel +channel = ec.register_resource("OMFChannel") +ec.set(channel, "channel", chan) +ec.set(channel, "xmppUser", slicename) +ec.set(channel, "xmppServer", "nitlab.inf.uth.gr") +ec.set(channel, "xmppPort", "5222") +ec.set(channel, "xmppPassword", "1234") +ec.register_connection(iface1, channel) +ec.register_connection(iface2, channel) + +# Create and Configure the PING Application +app1 = ec.register_resource("OMFApplication") +ec.set(app1, "appid", "Ping#1") +ec.set(app1, "command", "/bin/ping -c3 192.168.0.%s" % nodez[-2:]) +ec.register_connection(app1, node1) + +app2 = ec.register_resource("OMFApplication") +ec.set(app2, "appid", "Kill#1") +ec.set(app2, "command", "/usr/bin/killall ping") +ec.register_connection(app2, node1) + +# User Behaviour +ec.register_condition(app1, ResourceAction.STOP, app1, ResourceState.STARTED , "10s") +ec.register_condition(app2, ResourceAction.START, app1, ResourceState.STARTED , "12s") +ec.register_condition(app2, ResourceAction.STOP, app2, ResourceState.STARTED , "1s") + +# Deploy +ec.deploy() + +ec.wait_finished([app1, app2]) + +print ec.trace(app1, "stdout") + +# Stop Experiment +ec.shutdown() + diff --git a/src/nepi/resources/ns3/ns3dceapplication.py b/src/nepi/resources/ns3/ns3dceapplication.py index 2b0f9749..10b2433c 100644 --- a/src/nepi/resources/ns3/ns3dceapplication.py +++ b/src/nepi/resources/ns3/ns3dceapplication.py @@ -60,6 +60,13 @@ class NS3BaseDceApplication(NS3BaseApplication): "DCE environment variables.", flags = Flags.Design) + """ + use_dlm = Attribute("useDlmLoader", + "Use ns3::DlmLoaderFactory as library loader", + type = Types.Bool, + flags = Flags.Design) + """ + starttime = Attribute("StartTime", "Time at which the application will start", default = "+0.0ns", @@ -74,6 +81,9 @@ class NS3BaseDceApplication(NS3BaseApplication): cls._register_attribute(stack_size) cls._register_attribute(arguments) cls._register_attribute(environment) + """ + cls._register_attribute(use_dlm) + """ cls._register_attribute(stoptime) cls._register_attribute(starttime) @@ -92,7 +102,14 @@ class NS3BaseDceApplication(NS3BaseApplication): @property def dce_manager_helper_uuid(self): if not self._dce_manager_helper_uuid: - self._dce_manager_helper_uuid = self.simulation.create("DceManagerHelper") + self._dce_manager_helper_uuid = self.simulation.create( + "DceManagerHelper") + """ + if self.get("useDlmLoader"): + self.simulation.invoke( + self._dce_manager_helper_uuid, "SetLoader", + "ns3::DlmLoaderFactory") + """ return self._dce_manager_helper_uuid @property -- 2.43.0