Search in sources :

Example 11 with Device

use of org.onosproject.net.Device in project ddosdn by ssulca.

the class Monitoring method getStatisticsEdgePorts.

/**
 * Retorna Conjunto de los PortStatistics de los puertos conectados a los edges
 * @param devId DeviceId del disposivo del cual se quiere obtener las estadisticas
 *             delta cada 10s
 * @return a Set con todos los PortStatics
 */
default Set<PortStatistics> getStatisticsEdgePorts(DeviceService deviceService, LinkService linkService, DeviceId devId, Logger log) {
    Device dev;
    Set<PortStatistics> portSet;
    portSet = new HashSet<>();
    // se obtienen todos los links conectado al dispostivo
    Set<Link> ingressLinks = linkService.getDeviceIngressLinks(devId);
    // busqueda en los enlaces, buscado conexiones con los edges
    for (Link link : ingressLinks) {
        dev = deviceService.getDevice(link.src().deviceId());
        try {
            if (dev.annotations().value(ANNT).equals(EDGE)) {
                // True: se agrega la estadistica del puerto.
                // log.info("dev/port: {}/{}",devId,link.dst().port()); //cometar
                portSet.add(deviceService.getDeltaStatisticsForPort(devId, link.dst().port()));
            }
        } catch (NullPointerException e) {
            log.error("No se encuentran las anotaciones EDGE :dev{}", dev.id().toString());
        }
    }
    return portSet;
}
Also used : Device(org.onosproject.net.Device) PortStatistics(org.onosproject.net.device.PortStatistics) Link(org.onosproject.net.Link)

Example 12 with Device

use of org.onosproject.net.Device in project ddosdn by ssulca.

the class Monitoring method getEdgeConnected.

/**
 * Get first EDGE device conetect to DISTRIBUTION device with next parameters
 * @param deviceService DeviceService
 * @param linkService LinkService
 * @param devId DISTRIBUTION DeviceId
 * @param portNumber DISTRIBUTION deviceId port conect
 * @param log Logger
 * @return EDGE device ID.
 */
default DeviceId getEdgeConnected(DeviceService deviceService, LinkService linkService, DeviceId devId, PortNumber portNumber, Logger log) {
    Device dev;
    Set<Link> ingressLinks;
    // se obtienen todos los links conectado al dispostivo
    ingressLinks = linkService.getDeviceIngressLinks(devId);
    // busqueda en los enlaces, buscado conexiones con los edges
    for (Link link : ingressLinks) {
        if (link.dst().port().equals(portNumber)) {
            dev = deviceService.getDevice(link.src().deviceId());
            try {
                if (dev.annotations().value(ANNT).equals(EDGE)) {
                    // log.info("dev/port: {}/{}",devId,link.dst().port()); //cometar
                    return dev.id();
                }
            } catch (NullPointerException e) {
                log.error("No se encuentran las anotaciones EDGE :dev{}", dev.id().toString());
            }
        }
    }
    return null;
}
Also used : Device(org.onosproject.net.Device) Link(org.onosproject.net.Link)

Example 13 with Device

use of org.onosproject.net.Device in project ddosdn by ssulca.

the class Monitoring method getStatisticsEdgePortsTotal.

/**
 * Retorna Conjunto de los PortStatistics de los puertos conectados a los edges
 * @param devId DeviceId del disposivo del cual se quiere obtener las estadisticas Totales
 * @return a Set con todos los PortStatics
 */
default Set<PortStatistics> getStatisticsEdgePortsTotal(DeviceService deviceService, LinkService linkService, DeviceId devId, Logger log) {
    Device dev;
    Set<PortStatistics> portSet;
    portSet = new HashSet<>();
    // se obtienen todos los links conectado al dispostivo
    Set<Link> ingressLinks = linkService.getDeviceIngressLinks(devId);
    // busqueda en los enlaces, buscado conexiones con los edges
    for (Link link : ingressLinks) {
        dev = deviceService.getDevice(link.src().deviceId());
        try {
            if (dev.annotations().value(ANNT).equals(EDGE)) {
                /* True: se agrega la estadistica del puerto. */
                // log.info("dev/port: {}/{}",devId,link.dst().port()); //cometar
                portSet.add(deviceService.getStatisticsForPort(devId, link.dst().port()));
            }
        } catch (NullPointerException e) {
            log.error("No se encuentran las anotaciones :dev{}", dev.id().toString());
        }
    }
    return portSet;
}
Also used : Device(org.onosproject.net.Device) PortStatistics(org.onosproject.net.device.PortStatistics) Link(org.onosproject.net.Link)

Example 14 with Device

use of org.onosproject.net.Device in project ddosdn by ssulca.

the class Monitoring method getDevIdsByAnnot.

/**
 * Metodo retorna un conjunto con los devices identifiacados por annotatios
 * @param annot String anontation que identifca la caracteristica
 * @return a Set con los devicesId
 */
default Set<DeviceId> getDevIdsByAnnot(DeviceService deviceService, String annot, Logger log) {
    Set<DeviceId> deviceIds;
    Iterable<Device> availableDevices;
    deviceIds = new HashSet<>();
    // get sw disponibles
    availableDevices = deviceService.getAvailableDevices(Device.Type.SWITCH);
    for (Device dev : availableDevices) {
        /* busqueda de las anotaciones si no existe no se agrega al conjunto */
        try {
            if (dev.annotations().value(ANNT).equals(annot)) {
                deviceIds.add(dev.id());
            // log.info("dev {}:{}",annot,dev.id().toString());
            }
        } catch (NullPointerException e) {
            log.error("No se encuentran las anotaciones :dev{}", dev.id().toString());
        }
    }
    return deviceIds;
}
Also used : DeviceId(org.onosproject.net.DeviceId) Device(org.onosproject.net.Device)

Example 15 with Device

use of org.onosproject.net.Device in project TFG by mattinelorza.

the class Ipv6RoutingComponent method setUpHostRules.

/**
 * Sets up the given device with the necessary rules to route packets to the
 * given host.
 *
 * @param deviceId deviceId the device ID
 * @param host     the host
 */
private void setUpHostRules(DeviceId deviceId, Host host) {
    // Get all IPv6 addresses associated to this host. In this tutorial we
    // use hosts with only 1 IPv6 address.
    final Collection<Ip6Address> hostIpv6Addrs = host.ipAddresses().stream().filter(IpAddress::isIp6).map(IpAddress::getIp6Address).collect(Collectors.toSet());
    if (hostIpv6Addrs.isEmpty()) {
        // Ignore.
        log.debug("No IPv6 addresses for host {}, ignore", host.id());
        return;
    } else {
        log.info("Adding routes on {} for host {} [{}]", deviceId, host.id(), hostIpv6Addrs);
    }
    // Create an ECMP group with only one member, where the group ID is
    // derived from the host MAC.
    final MacAddress hostMac = host.mac();
    int groupId = macToGroupId(hostMac);
    final GroupDescription group = createNextHopGroup(groupId, Collections.singleton(hostMac), deviceId);
    // Map each host IPV6 address to corresponding /128 prefix and obtain a
    // flow rule that points to the group ID. In this tutorial we expect
    // only one flow rule per host.
    final List<FlowRule> flowRules = hostIpv6Addrs.stream().map(IpAddress::toIpPrefix).filter(IpPrefix::isIp6).map(IpPrefix::getIp6Prefix).map(prefix -> createRoutingRule(deviceId, prefix, groupId)).collect(Collectors.toList());
    // Helper function to install flows after groups, since here flows
    // points to the group and P4Runtime enforces this dependency during
    // write operations.
    insertInOrder(group, flowRules);
}
Also used : GroupDescription(org.onosproject.net.group.GroupDescription) IpPrefix(org.onlab.packet.IpPrefix) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) Interface(org.onosproject.net.intf.Interface) PiActionParamId(org.onosproject.net.pi.model.PiActionParamId) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) LoggerFactory(org.slf4j.LoggerFactory) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) Link(org.onosproject.net.Link) FlowRuleService(org.onosproject.net.flow.FlowRuleService) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) ApplicationId(org.onosproject.core.ApplicationId) MastershipService(org.onosproject.mastership.MastershipService) PiTableAction(org.onosproject.net.pi.runtime.PiTableAction) Ip6Address(org.onlab.packet.Ip6Address) Device(org.onosproject.net.Device) Deactivate(org.osgi.service.component.annotations.Deactivate) FabricDeviceConfig(org.onosproject.ngsdn.tutorial.common.FabricDeviceConfig) Collection(java.util.Collection) Set(java.util.Set) ItemNotFoundException(org.onlab.util.ItemNotFoundException) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) Collectors(java.util.stream.Collectors) LinkListener(org.onosproject.net.link.LinkListener) List(java.util.List) INITIAL_SETUP_DELAY(org.onosproject.ngsdn.tutorial.AppConstants.INITIAL_SETUP_DELAY) FlowRule(org.onosproject.net.flow.FlowRule) DeviceEvent(org.onosproject.net.device.DeviceEvent) LinkService(org.onosproject.net.link.LinkService) Optional(java.util.Optional) DeviceId(org.onosproject.net.DeviceId) GroupDescription(org.onosproject.net.group.GroupDescription) PiActionProfileGroupId(org.onosproject.net.pi.runtime.PiActionProfileGroupId) IpPrefix(org.onlab.packet.IpPrefix) Host(org.onosproject.net.Host) LinkEvent(org.onosproject.net.link.LinkEvent) HostListener(org.onosproject.net.host.HostListener) InterfaceService(org.onosproject.net.intf.InterfaceService) HostService(org.onosproject.net.host.HostService) Component(org.osgi.service.component.annotations.Component) Lists(com.google.common.collect.Lists) HostEvent(org.onosproject.net.host.HostEvent) Activate(org.osgi.service.component.annotations.Activate) Utils(org.onosproject.ngsdn.tutorial.common.Utils) IpAddress(org.onlab.packet.IpAddress) DeviceListener(org.onosproject.net.device.DeviceListener) Logger(org.slf4j.Logger) GroupService(org.onosproject.net.group.GroupService) PiMatchFieldId(org.onosproject.net.pi.model.PiMatchFieldId) Ip6Prefix(org.onlab.packet.Ip6Prefix) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) Streams.stream(com.google.common.collect.Streams.stream) PiAction(org.onosproject.net.pi.runtime.PiAction) MacAddress(org.onlab.packet.MacAddress) Reference(org.osgi.service.component.annotations.Reference) Collections(java.util.Collections) PiActionId(org.onosproject.net.pi.model.PiActionId) Ip6Address(org.onlab.packet.Ip6Address) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) IpAddress(org.onlab.packet.IpAddress) FlowRule(org.onosproject.net.flow.FlowRule) MacAddress(org.onlab.packet.MacAddress)

Aggregations

Device (org.onosproject.net.Device)350 DeviceService (org.onosproject.net.device.DeviceService)112 DeviceId (org.onosproject.net.DeviceId)108 Port (org.onosproject.net.Port)64 ConnectPoint (org.onosproject.net.ConnectPoint)63 List (java.util.List)54 PortNumber (org.onosproject.net.PortNumber)52 DefaultDevice (org.onosproject.net.DefaultDevice)50 Test (org.junit.Test)43 Set (java.util.Set)41 Link (org.onosproject.net.Link)41 Logger (org.slf4j.Logger)41 DeviceEvent (org.onosproject.net.device.DeviceEvent)40 TrafficSelector (org.onosproject.net.flow.TrafficSelector)35 ArrayList (java.util.ArrayList)34 Optional (java.util.Optional)33 Collectors (java.util.stream.Collectors)33 Map (java.util.Map)32 IpAddress (org.onlab.packet.IpAddress)32 ApplicationId (org.onosproject.core.ApplicationId)31