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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations