From: Alina Quereilhac Date: Sat, 20 Sep 2014 10:11:56 +0000 (+0200) Subject: Improving ns-3 examples X-Git-Tag: nepi-3.2.0~77 X-Git-Url: http://git.onelab.eu/?p=nepi.git;a=commitdiff_plain;h=99f7205f29b7dca7baa2fb4d86b1e9869e392ca5 Improving ns-3 examples --- diff --git a/examples/ns3/csma_p2p_star.py b/examples/ns3/local_csma_p2p_star_ping.py similarity index 100% rename from examples/ns3/csma_p2p_star.py rename to examples/ns3/local_csma_p2p_star_ping.py diff --git a/examples/ns3/local_csma_ping.py b/examples/ns3/local_csma_ping.py new file mode 100644 index 00000000..b2cca6bf --- /dev/null +++ b/examples/ns3/local_csma_ping.py @@ -0,0 +1,95 @@ +#!/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 . +# +# Author: Alina Quereilhac + +from nepi.execution.ec import ExperimentController + +ec = ExperimentController(exp_id = "ns3-local-csma-ping") + +# Simulation will executed in the local machine +node = ec.register_resource("LinuxNode") +ec.set(node, "hostname", "localhost") + +# Add a simulation resource +simu = ec.register_resource("LinuxNS3Simulation") +ec.set(simu, "verbose", True) +ec.register_connection(simu, node) + +## Add a ns-3 node with its protocol stack +nsnode1 = ec.register_resource("ns3::Node") +ec.register_connection(nsnode1, simu) + +ipv4 = ec.register_resource("ns3::Ipv4L3Protocol") +ec.register_connection(nsnode1, ipv4) +arp = ec.register_resource("ns3::ArpL3Protocol") +ec.register_connection(nsnode1, arp) +icmp = ec.register_resource("ns3::Icmpv4L4Protocol") +ec.register_connection(nsnode1, icmp) + +# Add a csma net device to the node +dev1 = ec.register_resource("ns3::CsmaNetDevice") +ec.set(dev1, "ip", "10.0.0.1") +ec.set(dev1, "prefix", "30") +ec.register_connection(nsnode1, dev1) +queue1 = ec.register_resource("ns3::DropTailQueue") +ec.register_connection(dev1, queue1) + +## Add another ns-3 node with its protocol stack +nsnode2 = ec.register_resource("ns3::Node") +ec.register_connection(nsnode2, simu) + +ipv4 = ec.register_resource("ns3::Ipv4L3Protocol") +ec.register_connection(nsnode2, ipv4) +arp = ec.register_resource("ns3::ArpL3Protocol") +ec.register_connection(nsnode2, arp) +icmp = ec.register_resource("ns3::Icmpv4L4Protocol") +ec.register_connection(nsnode2, icmp) + +# Add a csma net device to the node +dev2 = ec.register_resource("ns3::CsmaNetDevice") +ec.set(dev2, "ip", "10.0.0.2") +ec.set(dev2, "prefix", "30") +ec.register_connection(nsnode2, dev2) +queue2 = ec.register_resource("ns3::DropTailQueue") +ec.register_connection(dev2, queue2) + +# Add a csma channel +chan = ec.register_resource("ns3::CsmaChannel") +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) + +ec.deploy() + +ec.wait_finished([ping]) + +stdout = ec.trace(simu, "stdout") + +ec.shutdown() + +print "PING OUTPUT", stdout diff --git a/examples/ns3/wifi_ping.py b/examples/ns3/local_mobile_wifi_ping.py similarity index 100% rename from examples/ns3/wifi_ping.py rename to examples/ns3/local_mobile_wifi_ping.py diff --git a/examples/ns3/local_ping.py b/examples/ns3/local_p2p_ping.py similarity index 98% rename from examples/ns3/local_ping.py rename to examples/ns3/local_p2p_ping.py index 1a319584..8b9f3791 100644 --- a/examples/ns3/local_ping.py +++ b/examples/ns3/local_p2p_ping.py @@ -20,7 +20,7 @@ from nepi.execution.ec import ExperimentController -ec = ExperimentController(exp_id = "ns3-local-ping") +ec = ExperimentController(exp_id = "ns3-local-p2p-ping") # Simulation will executed in the local machine node = ec.register_resource("LinuxNode") diff --git a/examples/ns3/local_wifi_ping.py b/examples/ns3/local_wifi_ping.py new file mode 100644 index 00000000..9d854d77 --- /dev/null +++ b/examples/ns3/local_wifi_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 . +# +# Author: Alina Quereilhac + +from nepi.execution.ec import ExperimentController + +ec = ExperimentController(exp_id = "ns3-local-wifi-ping") + +# Simulation will executed in the local machine +node = ec.register_resource("LinuxNode") +ec.set(node, "hostname", "localhost") + +# Add a simulation resource +simu = ec.register_resource("LinuxNS3Simulation") +ec.set(simu, "verbose", True) +ec.register_connection(simu, node) + +## Add a ns-3 node with its protocol stack +nsnode1 = ec.register_resource("ns3::Node") +ec.register_connection(nsnode1, simu) + +ipv4 = ec.register_resource("ns3::Ipv4L3Protocol") +ec.register_connection(nsnode1, ipv4) +arp = ec.register_resource("ns3::ArpL3Protocol") +ec.register_connection(nsnode1, arp) +icmp = ec.register_resource("ns3::Icmpv4L4Protocol") +ec.register_connection(nsnode1, icmp) + +# Adding constant mobility to the ns-3 node +mobility1 = ec.register_resource("ns3::ConstantPositionMobilityModel") +position1 = "%d:%d:%d" % (0, 0, 0) +ec.set(mobility1, "Position", position1) +ec.register_connection(nsnode1, mobility1) + +# Add a wifi access point net device to the node +dev1 = ec.register_resource("ns3::WifiNetDevice") +ec.set(dev1, "ip", "10.0.0.1") +ec.set(dev1, "prefix", "30") +ec.register_connection(nsnode1, dev1) + +phy1 = ec.register_resource("ns3::YansWifiPhy") +ec.set(phy1, "Standard", "WIFI_PHY_STANDARD_80211a") +ec.register_connection(dev1, phy1) + +error1 = ec.register_resource("ns3::NistErrorRateModel") +ec.register_connection(phy1, error1) + +manager1 = ec.register_resource("ns3::ArfWifiManager") +ec.register_connection(dev1, manager1) + +mac1 = ec.register_resource("ns3::ApWifiMac") +ec.set(mac1, "Standard", "WIFI_PHY_STANDARD_80211a") +ec.register_connection(dev1, mac1) + +## Add another ns-3 node with its protocol stack +nsnode2 = ec.register_resource("ns3::Node") +ec.register_connection(nsnode2, simu) + +ipv4 = ec.register_resource("ns3::Ipv4L3Protocol") +ec.register_connection(nsnode2, ipv4) +arp = ec.register_resource("ns3::ArpL3Protocol") +ec.register_connection(nsnode2, arp) +icmp = ec.register_resource("ns3::Icmpv4L4Protocol") +ec.register_connection(nsnode2, icmp) + +# Adding constant mobility to the ns-3 node +mobility2 = ec.register_resource("ns3::ConstantPositionMobilityModel") +position2 = "%d:%d:%d" % (50, 50, 0) +ec.set(mobility2, "Position", position1) +ec.register_connection(nsnode2, mobility2) + +# Add a wifi station net device to the node +dev2 = ec.register_resource("ns3::WifiNetDevice") +ec.set(dev2, "ip", "10.0.0.2") +ec.set(dev2, "prefix", "30") +ec.register_connection(nsnode2, dev2) + +phy2 = ec.register_resource("ns3::YansWifiPhy") +ec.set(phy2, "Standard", "WIFI_PHY_STANDARD_80211a") +ec.register_connection(dev2, phy2) + +error2 = ec.register_resource("ns3::NistErrorRateModel") +ec.register_connection(phy2, error2) + +manager2 = ec.register_resource("ns3::ArfWifiManager") +ec.register_connection(dev2, manager2) + +mac2 = ec.register_resource("ns3::StaWifiMac") +ec.set(mac2, "Standard", "WIFI_PHY_STANDARD_80211a") +ec.register_connection(dev2, mac2) + +# Add a wifi channel +chan = ec.register_resource("ns3::YansWifiChannel") +delay = ec.register_resource("ns3::ConstantSpeedPropagationDelayModel") +ec.register_connection(chan, delay) +loss = ec.register_resource("ns3::LogDistancePropagationLossModel") +ec.register_connection(chan, loss) +ec.register_connection(chan, phy1) +ec.register_connection(chan, phy2) + +### 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) + +ec.deploy() + +ec.wait_finished([ping]) + +stdout = ec.trace(simu, "stdout") + +ec.shutdown() + +print "PING OUTPUT", stdout diff --git a/examples/ns3/remote_ping.py b/examples/ns3/remote_p2p_ping.py similarity index 97% rename from examples/ns3/remote_ping.py rename to examples/ns3/remote_p2p_ping.py index e5a870f7..6f04d78c 100644 --- a/examples/ns3/remote_ping.py +++ b/examples/ns3/remote_p2p_ping.py @@ -20,7 +20,7 @@ from nepi.execution.ec import ExperimentController -from optparse import OptionParser, SUPPRESS_HELP +from optparse import OptionParser usage = ("usage: %prog -H -u -i ") @@ -38,7 +38,7 @@ hostname = options.hostname username = options.username identity = options.ssh_key -ec = ExperimentController(exp_id = "ns3-remote-ping") +ec = ExperimentController(exp_id = "ns3-remote-p2p-ping") # Simulation will run in a remote machine node = ec.register_resource("LinuxNode") diff --git a/examples/omf/nepi_omf5_nitos_xeyes.py b/examples/omf/nepi_omf5_nitos_xeyes.py index 8fd81feb..b39c335a 100644 --- a/examples/omf/nepi_omf5_nitos_xeyes.py +++ b/examples/omf/nepi_omf5_nitos_xeyes.py @@ -1,45 +1,45 @@ -""" - 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 . - - Author: Alina Quereilhac - Julien Tribino - - Example : - - Testbed : Nitos - - Explanation : - - VLC Streaming on VLC - - Node - omf.nitos.node0xx - 0 - | - | - 0 - xEyes - - - Experiment: - - t0 : Deployment - - t1 : xEeyes Start - - t2 (t1 + 10s) : xEyes stop - - t3 (t2 + 2s) : Kill the application -""" - #!/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.node0xx +# 0 +# | +# | +# 0 +# xEyes +# +# - Experiment: +# - t0 : Deployment +# - t1 : xEeyes Start +# - t2 (t1 + 10s) : xEyes stop +# - t3 (t2 + 2s) : Kill the application +# +# + from nepi.execution.resource import ResourceFactory, ResourceAction, ResourceState from nepi.execution.ec import ExperimentController @@ -49,8 +49,8 @@ ec = ExperimentController() # Create and Configure the Nodes node1 = ec.register_resource("OMFNode") ec.set(node1, 'hostname', 'omf.nitos.node0XX') -ec.set(node1, 'xmppServer', "ZZZ") -ec.set(node1, 'xmppUser', "nitlab.inf.uth.gr") +ec.set(node1, 'xmppServer', "nitlab.inf.uth.gr") +ec.set(node1, 'xmppUser', "") ec.set(node1, 'xmppPort', "5222") ec.set(node1, 'xmppPassword', "1234") ec.set(node1, 'version', "5")