Search in sources :

Example 66 with Ip4Address

use of org.onlab.packet.Ip4Address in project up4 by omec-project.

the class Up4DeviceManager method configInterfaces.

@Override
public Collection<UpfInterface> configInterfaces() {
    Collection<UpfInterface> interfaces = new ArrayList<>();
    if (config.n3Address().isPresent()) {
        if (config.sliceId().isPresent()) {
            interfaces.add(UpfInterface.createN3From(config.n3Address().get(), config.sliceId().get()));
        } else {
            log.error("Missing slice ID in the netcfg to configure N3 interface for {}", config.n3Address().get());
        }
    }
    for (Ip4Prefix uePool : config.uePools()) {
        if (config.sliceId().isPresent()) {
            interfaces.add(UpfInterface.createUePoolFrom(uePool, config.sliceId().get()));
        } else {
            log.error("Missing slice ID in the netcfg to configure N6 interface for UE subnet {}", uePool);
        }
    }
    Ip4Address dbufDrainAddr = config.dbufDrainAddr();
    if (dbufDrainAddr != null) {
        // TODO: change slice ID when adding multi-slice support,
        // see: https://jira.opennetworking.org/browse/SDFAB-986
        interfaces.add(UpfInterface.createDbufReceiverFrom(dbufDrainAddr, DEFAULT_SLICE_ID));
    }
    return interfaces;
}
Also used : ArrayList(java.util.ArrayList) Ip4Address(org.onlab.packet.Ip4Address) UpfInterface(org.onosproject.net.behaviour.upf.UpfInterface) Ip4Prefix(org.onlab.packet.Ip4Prefix)

Example 67 with Ip4Address

use of org.onlab.packet.Ip4Address in project up4 by omec-project.

the class Up4DeviceManager method getDownlinkFlows.

@Override
public Collection<DownlinkUpfFlow> getDownlinkFlows() throws UpfProgrammableException {
    Collection<DownlinkUpfFlow> downlinkFlows = Lists.newArrayList();
    Map<Ip4Address, UpfSessionDownlink> ueToSess = Maps.newHashMap();
    Map<Byte, UpfGtpTunnelPeer> idToTunn = Maps.newHashMap();
    Map<Integer, UpfMeter> sessMeters = Maps.newHashMap();
    Map<Integer, UpfMeter> appMeters = Maps.newHashMap();
    Collection<? extends UpfEntity> downlinkTerm = this.adminReadAll(TERMINATION_DOWNLINK);
    this.adminReadAll(SESSION_DOWNLINK).forEach(s -> ueToSess.put(((UpfSessionDownlink) s).ueAddress(), (UpfSessionDownlink) s));
    this.adminReadAll(TUNNEL_PEER).forEach(t -> idToTunn.put(((UpfGtpTunnelPeer) t).tunPeerId(), (UpfGtpTunnelPeer) t));
    this.adminReadAll(SESSION_METER).forEach(sm -> sessMeters.put(((UpfMeter) sm).cellId(), (UpfMeter) sm));
    this.adminReadAll(APPLICATION_METER).forEach(am -> appMeters.put(((UpfMeter) am).cellId(), (UpfMeter) am));
    for (UpfEntity t : downlinkTerm) {
        UpfTerminationDownlink term = (UpfTerminationDownlink) t;
        UpfSessionDownlink sess = ueToSess.getOrDefault(term.ueSessionId(), null);
        UpfGtpTunnelPeer tunn = null;
        UpfMeter sMeter = null;
        UpfMeter aMeter = null;
        if (sess != null) {
            tunn = idToTunn.getOrDefault(sess.tunPeerId(), null);
            sMeter = sessMeters.getOrDefault(sess.sessionMeterIdx(), null);
        }
        aMeter = appMeters.getOrDefault(term.appMeterIdx(), null);
        downlinkFlows.add(DownlinkUpfFlow.builder().withTerminationDownlink(term).withSessionDownlink(sess).withTunnelPeer(tunn).withCounter(this.readCounter(term.counterId(), COUNTER)).withAppMeter(aMeter).withSessionMeter(sMeter).build());
    }
    return downlinkFlows;
}
Also used : UpfTerminationDownlink(org.onosproject.net.behaviour.upf.UpfTerminationDownlink) UpfMeter(org.onosproject.net.behaviour.upf.UpfMeter) Ip4Address(org.onlab.packet.Ip4Address) UpfSessionDownlink(org.onosproject.net.behaviour.upf.UpfSessionDownlink) UpfGtpTunnelPeer(org.onosproject.net.behaviour.upf.UpfGtpTunnelPeer) UpfEntity(org.onosproject.net.behaviour.upf.UpfEntity)

Example 68 with Ip4Address

use of org.onlab.packet.Ip4Address in project up4 by omec-project.

the class Up4TranslatorUtil method getFieldPrefix.

static Ip4Prefix getFieldPrefix(PiTableEntry entry, PiMatchFieldId fieldId) {
    Optional<PiFieldMatch> optField = entry.matchKey().fieldMatch(fieldId);
    if (optField.isEmpty()) {
        return null;
    }
    PiLpmFieldMatch field = (PiLpmFieldMatch) optField.get();
    Ip4Address address = Ip4Address.valueOf(field.value().asArray());
    return Ip4Prefix.valueOf(address, field.prefixLength());
}
Also used : Ip4Address(org.onlab.packet.Ip4Address) PiFieldMatch(org.onosproject.net.pi.runtime.PiFieldMatch) PiLpmFieldMatch(org.onosproject.net.pi.runtime.PiLpmFieldMatch)

Example 69 with Ip4Address

use of org.onlab.packet.Ip4Address in project up4 by omec-project.

the class FlowsStatsCommand method doExecute.

@Override
protected void doExecute() throws Exception {
    Up4AdminService adminService = get(Up4AdminService.class);
    Ip4Address ueAddr = ueSessionId != null ? Ip4Address.valueOf(ueSessionId) : null;
    do {
        Map<Ip4Address, UpfCounter> beforeDownlink = sumDownlinkUpfCountersPerSession(adminService.getDownlinkFlows(), ueAddr);
        Map<Ip4Address, UpfCounter> beforeUplink = sumUplinkUpfCountersPerSession(adminService.getUplinkFlows(), ueAddr);
        if (beforeDownlink.isEmpty() || beforeUplink.isEmpty()) {
            print("No UE Sessions\n");
            if (cont) {
                Thread.sleep((int) (sleepTimeS * 1000));
            }
            continue;
        }
        Thread.sleep((int) (sleepTimeS * 1000));
        Map<Ip4Address, UpfCounter> afterDownlink = sumDownlinkUpfCountersPerSession(adminService.getDownlinkFlows(), ueAddr);
        Map<Ip4Address, UpfCounter> afterUplink = sumUplinkUpfCountersPerSession(adminService.getUplinkFlows(), ueAddr);
        if (beforeDownlink.keySet().containsAll(beforeUplink.keySet()) && beforeDownlink.keySet().equals(afterUplink.keySet()) && beforeDownlink.keySet().equals(afterDownlink.keySet())) {
            print(SEPARATOR);
            for (Ip4Address ueSessionId : beforeDownlink.keySet()) {
                if (ueAddr == null || ueAddr.equals(ueSessionId)) {
                    print("Session: " + ueSessionId.toString());
                    UpfCounter bfUl = beforeUplink.get(ueSessionId);
                    UpfCounter bfDl = beforeDownlink.get(ueSessionId);
                    UpfCounter afUl = afterUplink.get(ueSessionId);
                    UpfCounter afDl = afterDownlink.get(ueSessionId);
                    long afUlIngressPkts = afUl.getIngressPkts().orElse(0L);
                    long afUlEgressPkts = afUl.getEgressPkts().orElse(0L);
                    long afDlIngressPkts = afDl.getIngressPkts().orElse(0L);
                    long afDlEgressPkts = afDl.getEgressPkts().orElse(0L);
                    long afUlIngressBytes = afUl.getIngressBytes().orElse(0L);
                    long afUlEgressBytes = afUl.getEgressBytes().orElse(0L);
                    long afDlIngressBytes = afDl.getIngressBytes().orElse(0L);
                    long afDlEgressBytes = afDl.getEgressBytes().orElse(0L);
                    long bfUlIngressPkts = bfUl.getIngressPkts().orElse(0L);
                    long bfUlEgressPkts = bfUl.getEgressPkts().orElse(0L);
                    long bfDlIngressPkts = bfDl.getIngressPkts().orElse(0L);
                    long bfDlEgressPkts = bfDl.getEgressPkts().orElse(0L);
                    long bfUlIngressBytes = bfUl.getIngressBytes().orElse(0L);
                    long bfUlEgressBytes = bfUl.getEgressBytes().orElse(0L);
                    long bfDlIngressBytes = bfDl.getIngressBytes().orElse(0L);
                    long bfDlEgressBytes = bfDl.getEgressBytes().orElse(0L);
                    long rxPktsUl = afUlIngressPkts - bfUlIngressPkts;
                    long rxPktsDl = afDlIngressPkts - bfDlIngressPkts;
                    long txPktsUl = afUlEgressPkts - bfUlEgressPkts;
                    long txPktsDl = afDlEgressPkts - bfDlEgressPkts;
                    long rxBitsUl = (afUlIngressBytes - bfUlIngressBytes) * 8;
                    long rxBitsDl = (afDlIngressBytes - bfDlIngressBytes) * 8;
                    long txBitsUl = (afUlEgressBytes - bfUlEgressBytes) * 8;
                    long txBitsDl = (afDlEgressBytes - bfDlEgressBytes) * 8;
                    long droppedPktsUl = (afUlIngressPkts - afUlEgressPkts) - (bfUlIngressPkts - bfUlEgressPkts);
                    long droppedPktsDl = (afDlIngressPkts - afDlEgressPkts) - (bfDlIngressPkts - bfDlEgressPkts);
                    long droppedBitsUl = ((afUlIngressPkts - afUlEgressPkts) - (bfUlIngressPkts - bfUlEgressPkts)) * 8;
                    long droppedBitsDl = ((afDlIngressBytes - afDlEgressBytes) - (bfDlIngressBytes - bfDlEgressBytes)) * 8;
                    if (droppedPktsUl > rxPktsUl) {
                        print("  Uplink: more dropped packets than received! (%d > %d)", droppedPktsUl, rxPktsUl);
                    }
                    print("  Uplink: %s / %s (%.2f%% dropped)", toReadable((double) txBitsUl / sleepTimeS, "bps"), toReadable((double) txPktsUl / sleepTimeS, "pps"), rxPktsUl == 0 ? 0.0 : ((double) droppedPktsUl / (double) rxPktsUl) * 100.0);
                    if (debug) {
                        print("    RX: %s / %s", toReadable(rxPktsUl, "pkts"), toReadable(rxBitsUl, "bit"));
                        print("    TX: %s / %s", toReadable(txPktsUl, "pkts"), toReadable(txBitsUl, "bit"));
                        print("    Dropped: %s / %s", toReadable(droppedPktsUl, "pkts"), toReadable(droppedBitsUl, "bit"));
                    }
                    if (droppedPktsDl > rxPktsDl) {
                        print("  Downlink: more dropped packets than received! (%d > %d)", droppedPktsDl, rxPktsDl);
                    }
                    print("  Downlink: %s / %s (%.2f%% dropped)", toReadable((double) txBitsDl / sleepTimeS, "bps"), toReadable((double) txPktsDl / sleepTimeS, "pps"), rxPktsDl == 0 ? 0.0 : ((double) droppedPktsDl / (double) rxPktsDl) * 100.0);
                    if (debug) {
                        print("    RX: %s / %s", toReadable(rxPktsDl, "pkts"), toReadable(rxBitsDl, "bit"));
                        print("    TX: %s / %s", toReadable(txPktsDl, "pkts"), toReadable(txBitsDl, "bit"));
                        print("    Dropped: %s / %s", toReadable(droppedPktsDl, "pkts"), toReadable(droppedBitsDl, "bit"));
                    }
                    print(SEPARATOR);
                }
            }
            if (cont) {
                print("");
            }
        } else {
            print("Error while reading stats!\n");
        }
    } while (cont);
}
Also used : Ip4Address(org.onlab.packet.Ip4Address) Up4AdminService(org.omecproject.up4.impl.Up4AdminService) UpfCounter(org.onosproject.net.behaviour.upf.UpfCounter)

Example 70 with Ip4Address

use of org.onlab.packet.Ip4Address in project up4 by omec-project.

the class InterfaceDeleteCommand method doExecute.

@Override
protected void doExecute() throws Exception {
    Up4Service app = get(Up4Service.class);
    Ip4Address n3Addr = Ip4Address.valueOf(this.n3Addr);
    print("Removing N3 interface address %s", n3Addr.toString());
    app.delete(UpfInterface.createN3From(n3Addr, sliceId));
}
Also used : Up4Service(org.omecproject.up4.Up4Service) Ip4Address(org.onlab.packet.Ip4Address)

Aggregations

Ip4Address (org.onlab.packet.Ip4Address)98 Test (org.junit.Test)29 Ip4Prefix (org.onlab.packet.Ip4Prefix)20 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)15 MacAddress (org.onlab.packet.MacAddress)15 ArrayList (java.util.ArrayList)14 Ip6Address (org.onlab.packet.Ip6Address)14 IpAddress (org.onlab.packet.IpAddress)13 LinkedList (java.util.LinkedList)12 Ethernet (org.onlab.packet.Ethernet)12 ProtocolType (org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4.ProtocolType)12 BgpPathAttributes (org.onosproject.bgpio.protocol.ver4.BgpPathAttributes)12 AsPath (org.onosproject.bgpio.types.AsPath)12 BgpHeader (org.onosproject.bgpio.types.BgpHeader)12 BgpValueType (org.onosproject.bgpio.types.BgpValueType)12 LinkStateAttributes (org.onosproject.bgpio.types.LinkStateAttributes)12 Med (org.onosproject.bgpio.types.Med)12 MpReachNlri (org.onosproject.bgpio.types.MpReachNlri)12 Origin (org.onosproject.bgpio.types.Origin)12 OriginType (org.onosproject.bgpio.types.Origin.OriginType)12