def find_interface_network_object(self, interface): network_id = xmlutils.get_first_child_text_trim_with_attribute(interface, 'member', 'type', 'network') if not network_id: # support legacy notation: <interface net="netid" ... network_id = interface.getAttribute('net') obj = self.get_core_object(network_id) if obj: # the network_id should exist for ptp or wlan/emane networks return obj # the network should correspond to a layer-2 device if the # network_id does not exist channel_id = xmlutils.get_first_child_text_trim_with_attribute(interface, 'member', 'type', 'channel') if not network_id or not channel_id: return None network = xmlutils.get_first_child_with_attribute(self.scenario, 'network', 'id', network_id) if not network: return None channel = xmlutils.get_first_child_with_attribute(network, 'channel', 'id', channel_id) if not channel: return None device = None for dev, if_name in self.iter_network_member_devices(channel): if self.device_type(dev) in self.layer2_device_types: assert not device # XXX device = dev if device: obj = self.get_core_object(device.getAttribute('id')) if obj: return obj return None
def find_interface_network_object(self, interface): network_id = xmlutils.get_first_child_text_trim_with_attribute( interface, 'member', 'type', 'network') if not network_id: # support legacy notation: <interface net="netid" ... network_id = interface.getAttribute('net') obj = self.get_core_object(network_id) if obj: # the network_id should exist for ptp or wlan/emane networks return obj # the network should correspond to a layer-2 device if the # network_id does not exist channel_id = xmlutils.get_first_child_text_trim_with_attribute( interface, 'member', 'type', 'channel') if not network_id or not channel_id: return None network = xmlutils.get_first_child_with_attribute( self.scenario, 'network', 'id', network_id) if not network: return None channel = xmlutils.get_first_child_with_attribute( network, 'channel', 'id', channel_id) if not channel: return None device = None for dev, if_name in self.iter_network_member_devices(channel): if self.device_type(dev) in self.layer2_device_types: assert not device # XXX device = dev if device: obj = self.get_core_object(device.getAttribute('id')) if obj: return obj return None
def core_node_type(self, device): # use an explicit CORE type if it exists coretype = xmlutils.get_first_child_text_trim_with_attribute( device, 'type', 'domain', 'CORE') if coretype: return coretype return self.device_type(device)
def set_wireless_link_parameters(self, channel, link_params, mobility_model_name, mobility_params): network = self.find_channel_network(channel) network_id = network.getAttribute('id') if network_id in self.objidmap: nodenum = self.objidmap[network_id] else: logger.warn('unknown network: %s', network.toxml('utf-8')) assert False # XXX for testing model_name = xmlutils.get_first_child_text_trim_with_attribute( channel, 'type', 'domain', 'CORE') if not model_name: model_name = 'basic_range' if model_name == 'basic_range': mgr = self.session.mobility elif model_name.startswith('emane'): mgr = self.session.emane elif model_name.startswith('xen'): mgr = self.session.xen else: # TODO: any other config managers? raise NotImplementedError logger.info( "setting wireless link params: node(%s) model(%s) mobility_model(%s)", nodenum, model_name, mobility_model_name) mgr.setconfig_keyvalues(nodenum, model_name, link_params.items()) if mobility_model_name and mobility_params: mgr.setconfig_keyvalues(nodenum, mobility_model_name, mobility_params.items())
def set_wireless_link_parameters(self, channel, link_params, mobility_model_name, mobility_params): network = self.find_channel_network(channel) network_id = network.getAttribute('id') if network_id in self.objidmap: nodenum = self.objidmap[network_id] else: logger.warn('unknown network: %s', network.toxml('utf-8')) assert False # XXX for testing model_name = xmlutils.get_first_child_text_trim_with_attribute(channel, 'type', 'domain', 'CORE') if not model_name: model_name = 'basic_range' if model_name == 'basic_range': mgr = self.session.mobility elif model_name.startswith('emane'): mgr = self.session.emane else: # TODO: any other config managers? raise NotImplementedError logger.info("setting wireless link params: node(%s) model(%s) mobility_model(%s)", nodenum, model_name, mobility_model_name) mgr.set_model_config(node_id=nodenum, model_name=model_name, config=link_params) if mobility_model_name and mobility_params: self.session.mobility.set_model_config(node_id=nodenum, model_name=mobility_model_name, config=mobility_params)
def network_class(self, network, network_type): """ Return the corresponding CORE network class for the given network/network_type. """ if network_type in ['ethernet', 'satcom']: return nodeutils.get_node_class(NodeTypes.PEER_TO_PEER) elif network_type == 'wireless': channel = xmlutils.get_first_child_by_tag_name(network, 'channel') if channel: # use an explicit CORE type if it exists coretype = xmlutils.get_first_child_text_trim_with_attribute(channel, 'type', 'domain', 'CORE') if coretype: if coretype == 'basic_range': return nodeutils.get_node_class(NodeTypes.WIRELESS_LAN) elif coretype.startswith('emane'): return nodeutils.get_node_class(NodeTypes.EMANE) else: logger.warn('unknown network type: \'%s\'', coretype) return xmlutils.xml_type_to_node_class(coretype) return nodeutils.get_node_class(NodeTypes.WIRELESS_LAN) logger.warn('unknown network type: \'%s\'', network_type) return None
def network_class(self, network, network_type): """ Return the corresponding CORE network class for the given network/network_type. """ if network_type in ['ethernet', 'satcom']: return nodeutils.get_node_class(NodeTypes.PEER_TO_PEER) elif network_type == 'wireless': channel = xmlutils.get_first_child_by_tag_name(network, 'channel') if channel: # use an explicit CORE type if it exists coretype = xmlutils.get_first_child_text_trim_with_attribute(channel, 'type', 'domain', 'CORE') if coretype: if coretype == 'basic_range': return nodeutils.get_node_class(NodeTypes.WIRELESS_LAN) elif coretype.startswith('emane'): return nodeutils.get_node_class(NodeTypes.EMANE) else: logger.warn('unknown network type: \'%s\'', coretype) return xmlutils.xml_type_to_node_class(coretype) return nodeutils.get_node_class(NodeTypes.WIRELESS_LAN) logger.warn('unknown network type: \'%s\'', network_type) return None
def core_node_type(self, device): # use an explicit CORE type if it exists coretype = xmlutils.get_first_child_text_trim_with_attribute(device, 'type', 'domain', 'CORE') if coretype: return coretype return self.device_type(device)