def __init__(self, config): super(GlobalNodeManager, self).__init__("global") self.control_engine = wishful_controller.Controller() self.control_engine.load_config(config) self.control_engine.nodeManager.add_new_node_callback(self.add_node) self.control_engine.nodeManager.add_node_exit_callback(self.remove_node) self.control_engine.start() self.connected_nodes = {} self.mac_address_to_node_id = {} self.mac_address_to_event_cb = {} self.mac_address_to_report_cb = {} self.mac_address_to_local_monitoring_cp = {} self.mac_address_to_custom_local_cp = {} self.mac_address_to_custom_local_cp_callback = {}
def __init__(self, config=None, ip_address="172.0.0.1", interface="lo", group_name="wishful_1234"): super(GlobalNodeManager, self).__init__("global") self.control_engine = wishful_controller.Controller( dl="tcp://" + ip_address + ":8990", ul="tcp://" + ip_address + ":8989") if config is not None: self.control_engine.load_config(config) else: # downlink = "tcp://" + ip_address + ":8990" # uplink = "tcp://" + ip_address + ":8989" # print("downlink {} uplink {}".format(downlink,uplink)) self.control_engine.set_controller_info( name="ContikiGlobalController", info="ContikiGlobalController") self.control_engine.add_module( moduleName="discovery", pyModuleName="wishful_module_discovery_pyre", className="PyreDiscoveryControllerModule", kwargs={ "iface": interface, "groupName": group_name, "downlink": "tcp://" + ip_address + ":8990", "uplink": "tcp://" + ip_address + ":8989" }) self.control_engine.nodeManager.add_new_node_callback(self.add_node) self.control_engine.nodeManager.add_node_exit_callback( self.remove_node) self.control_engine.start() self.connected_nodes = {} self.mac_address_to_node_id = {} self.mac_address_to_event_cb = {} self.mac_address_to_report_cb = {} self.mac_address_to_local_monitoring_cp = {} self.mac_address_to_custom_local_cp = {} self.mac_address_to_custom_local_cp_callback = {}
logfile = None if args['--logfile']: logfile = args['--logfile'] logging.basicConfig( filename=logfile, level=log_level, format= '%(asctime)s - %(name)s.%(funcName)s() - %(levelname)s - %(message)s') try: config_file_path = args['--config'] config = None with open(config_file_path, 'r') as f: config = yaml.load(f) controller = wishful_controller.Controller() controller.load_config(config) controller.start() @controller.new_node_callback() def new_node(node): nodes.append(node) print("New node appeared :") print(node) first_time = True coap_server_initialized = False radio_param_list = [
#calculated values t_EIFS = T_Turnaround + T_MacAck + ( T_LIFS if n_MacPayloadBytes > N_aMaxSIFSFrameSize else T_SIFS) t_AppData = n_MacPayloadBytes * T_Byte t_Packet = T_PhyPre + T_PhySFD + T_MacHdr + t_AppData t_Collision = t_Packet + t_EIFS CW_f = n_Tx_ED * math.sqrt(2 * t_Collision / T_Slot) CW = round(CW_f) CW = int(CW) CW = max(CW, CW_MIN) CW = min(CW, CW_MAX) return CW log = logging.getLogger('global_cp.main') global_control_engine = wishful_controller.Controller() global_taisc_manager = GlobalTAISCMACManager(global_control_engine, "CSMA") global_app_manager = GlobalAppManager(global_control_engine, global_taisc_manager) nodes = [] @global_control_engine.new_node_callback() def new_node(node): nodes.append(node) print("New node appeared:") print(node) @global_control_engine.node_exit_callback() def node_exit(node, reason):
""" END setting of experiment nodes """ """ START the WiSHFUL controller setting """ """ The WiSHFUL controller module is the core module of the WiSHFUL framework and allow all the basics functions such as the node discovery, the UPI functions execution on local and remote node, perform the messages exchange between global control program and local control program, and all the other management functions of the framework. The different works of the controller are performed by different module can be added on demand in the controller """ #Create controller, we specify in the parameters the ip addresses and the ports used for downlink and uplink connection #with the nodes tesbed, in this case we spcify the interface loopback and the port 8990 for the downlink and the # interface loopback and the port 8989 for the uplink. controller = wishful_controller.Controller( dl="tcp://" + controller_PC_ip_address + ":8990", ul="tcp://" + controller_PC_ip_address + ":8989") #Configure controller, we specify in the parameters the controller name and a string information related to the #controller controller.set_controller_info(name="WishfulController", info="WishfulControllerInfo") #the following rows add all the needed modules to the controller #add the discovery module, responsable for the nodes discovery procedure and nodes adding to the controllers #we specify interface, the name of the nodes group, and the ip address and port for the downlink and uplink connection controller.add_module(moduleName="discovery", pyModuleName="wishful_module_discovery_pyre", className="PyreDiscoveryControllerModule", kwargs={
controller_PC_IP_address = "192.168.5.64" controller_PC_interface = "ens3" """ END setting of controller nodes """ DL_address = "tcp://" + controller_PC_IP_address + ":8990" UL_address = "tcp://" + controller_PC_IP_address + ":8989" """ START Define logging controller """ """ we use the python logging system module (https://docs.python.org/2/library/logging.html) """ log = logging.getLogger('wishful_controller') #Create controller, we specify in the parameters the ip addresses and the ports used for downlink and uplink connection #with the nodes tesbed, in this case we spcify the interface loopback and the port 8990 for the downlink and the # interface loopback and the port 8989 for the uplink. controller = wishful_controller.Controller(dl=DL_address, ul=UL_address) #Configure controller, we specify in the parameters the controller name and a string information related to the #controller controller.set_controller_info(name="WishfulController", info="WishfulControllerInfo") #add the discovery module, responsable for the nodes discovery procedure and nodes adding to the controllers #we specify interface, the name of the nodes group, and the ip address and port for the downlink and uplink connection controller.add_module(moduleName="discovery", pyModuleName="wishful_module_discovery_pyre", className="PyreDiscoveryControllerModule", kwargs={ "iface": controller_PC_interface, "groupName": "wishful_4321", "downlink": DL_address,
__author__ = "Maicon Kist" __copyright__ = "Copyright (c) 2017 Connect Centre - Trinity College Dublin" __version__ = "0.1.0" __email__ = "*****@*****.**" log = logging.getLogger('wishful_controller') log_level = logging.CRITICAL logging.basicConfig( level=log_level, format='%(asctime)s - %(name)s.%(funcName)s() - %(levelname)s - %(message)s' ) #Create controller # ::TRICKY:: update IP addresses to external interface controller = wishful_controller.Controller(dl="tcp://172.16.16.5:8990", ul="tcp://172.16.16.5:8989") #Configure controller controller.set_controller_info(name="TCD_RadioVirtualization", info="WishfulControllerInfo") # ::TRICKY:: update IP addresses to external interface controller.add_module(moduleName="discovery", pyModuleName="wishful_module_discovery_pyre", className="PyreDiscoveryControllerModule", kwargs={ "iface": "eth0", "groupName": "tcd_hydra", "downlink": "tcp://172.16.16.5:8990", "uplink": "tcp://172.16.16.5:8989" })
], "vr1tx-split3": [ 'rate', ], "vr2tx": ['tx_iq_rate', 'iq_rxrate'], "usrp": ['vr1_iq_txrate', 'vr2_iq_txrate', 'vr1_iq_rxrate', 'vr2_iq_rxrate'], "vr1rx": ['rx_goodput', ''], "vr2rx": [ 'rx_goodput', ], } #Create controller # ::TRICKY:: update IP addresses to external interface controller = wishful_controller.Controller(dl="tcp://192.168.10.10:8990", ul="tcp://192.168.10.10:8989") controller.set_controller_info(name="TCD_RadioVirtualization", info="WishfulControllerInfo") controller.add_module(moduleName="discovery", pyModuleName="wishful_module_discovery_pyre", className="PyreDiscoveryControllerModule", kwargs={ "iface": "br0", "groupName": "tcd", "downlink": "tcp://192.168.10.10:8990", "uplink": "tcp://192.168.10.10:8989" }) @controller.new_node_callback() def new_node(node):