#!/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 # # CCN topology: # # h2 # 0 # content l1 / \ l2 ccncat # b1 /l5 \ b2 # 0 ----- h1 0 --- 0 h3 ------ 0 # \ / # l4 \ / l3 # 0 # h4 # Experiment: # - t0 : b2 retrives video published in b1 # - t1 : l1 goes down # - t2 : l2 goes down # - t3 : l5 goes up # from nepi.execution.ec import ExperimentController, ECState from nepi.execution.resource import ResourceState, ResourceAction, \ populate_factory from nepi.execution.trace import TraceAttr import subprocess from optparse import OptionParser, SUPPRESS_HELP import os import time def add_node(ec, host, user, ssh_key = None): node = ec.register_resource("LinuxNode") ec.set(node, "hostname", host) ec.set(node, "username", user) ec.set(node, "identity", ssh_key) #ec.set(node, "cleanHome", True) ec.set(node, "cleanProcesses", True) return node def add_ccnd(ec, node): ccnd = ec.register_resource("LinuxCCND") ec.set(ccnd, "debug", 7) ec.register_connection(ccnd, node) return ccnd def add_ccnr(ec, ccnd): ccnr = ec.register_resource("LinuxCCNR") ec.register_connection(ccnr, ccnd) return ccnr def add_fib_entry(ec, ccnd, peer_host): entry = ec.register_resource("LinuxFIBEntry") ec.set(entry, "host", peer_host) ec.register_connection(entry, ccnd) return entry def add_content(ec, ccnr, content_name, content): co = ec.register_resource("LinuxCCNContent") ec.set(co, "contentName", content_name) ec.set(co, "content", content) ec.register_connection(co, ccnr) return co def add_stream(ec, ccnd, content_name): # ccnx v7.2 issue 101007 command = "ccnpeek %(content_name)s; ccncat %(content_name)s" % { "content_name" : content_name} app = ec.register_resource("LinuxCCNApplication") ec.set(app, "command", command) ec.register_connection(app, ccnd) return app def add_collector(ec, trace_name, store_dir): collector = ec.register_resource("Collector") ec.set(collector, "traceName", trace_name) ec.set(collector, "storeDir", store_dir) return collector def get_options(): pl_slice = os.environ.get("PL_SLICE") # We use a specific SSH private key for PL if the PL_SSHKEY is specified or the # id_rsa_planetlab exists default_key = "%s/.ssh/id_rsa_planetlab" % (os.environ['HOME']) default_key = default_key if os.path.exists(default_key) else None pl_ssh_key = os.environ.get("PL_SSHKEY", default_key) usage = "usage: %prog -s -m -e -i -r