Search in sources :

Example 1 with UpfMeter

use of org.onosproject.net.behaviour.upf.UpfMeter in project up4 by omec-project.

the class Up4DeviceManager method getUplinkFlows.

@Override
public Collection<UplinkUpfFlow> getUplinkFlows() throws UpfProgrammableException {
    Collection<UplinkUpfFlow> uplinkFlows = Lists.newArrayList();
    Collection<? extends UpfEntity> uplinkTerm = this.adminReadAll(TERMINATION_UPLINK);
    Map<Integer, UpfMeter> appMeters = Maps.newHashMap();
    this.adminReadAll(APPLICATION_METER).forEach(am -> appMeters.put(((UpfMeter) am).cellId(), (UpfMeter) am));
    for (UpfEntity t : uplinkTerm) {
        UpfTerminationUplink term = (UpfTerminationUplink) t;
        uplinkFlows.add(UplinkUpfFlow.builder().withTerminationUplink(term).withCounter(this.readCounter(term.counterId())).withAppMeter(appMeters.getOrDefault(term.appMeterIdx(), null)).build());
    }
    return uplinkFlows;
}
Also used : UpfEntity(org.onosproject.net.behaviour.upf.UpfEntity) UpfMeter(org.onosproject.net.behaviour.upf.UpfMeter) UpfTerminationUplink(org.onosproject.net.behaviour.upf.UpfTerminationUplink)

Example 2 with UpfMeter

use of org.onosproject.net.behaviour.upf.UpfMeter in project up4 by omec-project.

the class Up4TranslatorImpl method upfEntityToUp4MeterEntry.

@Override
public PiMeterCellConfig upfEntityToUp4MeterEntry(UpfEntity entity) throws Up4TranslationException {
    PiMeterId meterId;
    switch(entity.type()) {
        case SESSION_METER:
            meterId = PRE_QOS_PIPE_SESSION_METER;
            break;
        case APPLICATION_METER:
            meterId = PRE_QOS_PIPE_APP_METER;
            break;
        default:
            throw new Up4TranslationException("Attempting to translate an unsupported UPF entity to a meter entry! " + entity);
    }
    UpfMeter upfMeter = (UpfMeter) entity;
    PiMeterCellId piMeterCellId = PiMeterCellId.ofIndirect(meterId, upfMeter.cellId());
    if (upfMeter.isReset()) {
        return PiMeterCellConfig.reset(piMeterCellId);
    }
    Band peakBand = upfMeter.peakBand().orElse(DefaultBand.builder().withRate(ZERO_BAND_RATE).burstSize(ZERO_BAND_BURST).ofType(Band.Type.MARK_RED).build());
    Band commitedBand = upfMeter.committedBand().orElse(DefaultBand.builder().withRate(ZERO_BAND_RATE).burstSize(ZERO_BAND_BURST).ofType(Band.Type.MARK_YELLOW).build());
    return PiMeterCellConfig.builder().withMeterBand(new PiMeterBand(PiMeterBandType.PEAK, peakBand.rate(), peakBand.burst())).withMeterBand(new PiMeterBand(PiMeterBandType.COMMITTED, commitedBand.rate(), commitedBand.burst())).withMeterCellId(piMeterCellId).build();
}
Also used : PiMeterBand(org.onosproject.net.pi.runtime.PiMeterBand) PiMeterId(org.onosproject.net.pi.model.PiMeterId) PiMeterCellId(org.onosproject.net.pi.runtime.PiMeterCellId) UpfMeter(org.onosproject.net.behaviour.upf.UpfMeter) Band(org.onosproject.net.meter.Band) DefaultBand(org.onosproject.net.meter.DefaultBand) PiMeterBand(org.onosproject.net.pi.runtime.PiMeterBand)

Example 3 with UpfMeter

use of org.onosproject.net.behaviour.upf.UpfMeter in project up4 by omec-project.

the class UpfSessionMeterCommand method doExecute.

@Override
protected void doExecute() throws Exception {
    Up4Service app = get(Up4Service.class);
    if (delete) {
        app.apply(UpfMeter.resetSession(cellId));
    } else {
        if (pir == null || pburst == null) {
            print("PIR and PBURST must be provided when creating a meter");
            return;
        }
        UpfMeter sessionMeter = UpfMeter.builder().setCellId(cellId).setPeakBand(pir, pburst).setSession().build();
        app.apply(sessionMeter);
    }
}
Also used : Up4Service(org.omecproject.up4.Up4Service) UpfMeter(org.onosproject.net.behaviour.upf.UpfMeter)

Example 4 with UpfMeter

use of org.onosproject.net.behaviour.upf.UpfMeter in project up4 by omec-project.

the class ReadFlowsCommand method doExecute.

@Override
protected void doExecute() throws Exception {
    Up4AdminService adminService = get(Up4AdminService.class);
    Collection<DownlinkUpfFlow> dlUpfFlow = adminService.getDownlinkFlows();
    Collection<UplinkUpfFlow> ulUpfFlow = adminService.getUplinkFlows();
    Collection<? extends UpfEntity> ulSess = adminService.adminReadAll(UpfEntityType.SESSION_UPLINK);
    Collection<? extends UpfEntity> appFilters = adminService.adminReadAll(UpfEntityType.APPLICATION);
    // Get session and app meter only to show the number of meters
    Collection<? extends UpfEntity> sessMeters = adminService.adminReadAll(UpfEntityType.SESSION_METER);
    Map<Integer, UpfMeter> sessMeterMap = sessMeters.stream().map(m -> (UpfMeter) m).collect(Collectors.toMap(UpfMeter::cellId, m -> m));
    Collection<? extends UpfEntity> appMeters = adminService.adminReadAll(UpfEntityType.APPLICATION_METER);
    print(SEPARATOR);
    print(appFilters.size() + " Applications");
    for (UpfEntity a : appFilters) {
        if (!a.type().equals(UpfEntityType.APPLICATION)) {
            print("ERROR: Wrong application filter: " + a);
            continue;
        }
        UpfApplication app = (UpfApplication) a;
        print("app_id=" + app.appId() + ", ipv4_prefix=" + app.ip4Prefix() + ", l4_range=" + app.l4PortRange() + ", ip_proto=" + app.ipProto());
    }
    print(SEPARATOR);
    print(ulSess.size() + " Uplink Sessions");
    for (UpfEntity s : ulSess) {
        if (!s.type().equals(UpfEntityType.SESSION_UPLINK)) {
            print("ERROR: Wrong uplink session: " + s);
            continue;
        }
        UpfSessionUplink sess = (UpfSessionUplink) s;
        print("n3_addr=" + sess.tunDstAddr() + ", teid=" + sess.teid() + (sess.needsDropping() ? ", drop()" : ", fwd(" + "sess_meter_idx=" + sess.sessionMeterIdx() + ")"));
        UpfMeter sessMeter = sessMeterMap.getOrDefault(sess.sessionMeterIdx(), null);
        if (sessMeter == null) {
            print("    NO SESSION METER (sess_meter_idx=" + sess.sessionMeterIdx() + ")");
        } else {
            print("    Session meter: " + ppUpfMeter(sessMeter));
        }
    }
    print(SEPARATOR);
    print(ulUpfFlow.size() + " Uplink Flows");
    for (UplinkUpfFlow f : ulUpfFlow) {
        print(f.toString());
    }
    print(SEPARATOR);
    print(dlUpfFlow.size() + " Downlink Flows");
    for (DownlinkUpfFlow f : dlUpfFlow) {
        print(f.toString());
    }
    print(SEPARATOR);
    print("Apps=%d, UL sess=%d, UL flows=%d, DL flows=%s", appFilters.size(), ulSess.size(), ulUpfFlow.size(), dlUpfFlow.size());
    print("App meters=%d, Sess meters=%d", appMeters.size(), sessMeters.size());
}
Also used : UpfMeter(org.onosproject.net.behaviour.upf.UpfMeter) Collection(java.util.Collection) DownlinkUpfFlow(org.omecproject.up4.impl.DownlinkUpfFlow) UpfSessionUplink(org.onosproject.net.behaviour.upf.UpfSessionUplink) Collectors(java.util.stream.Collectors) Command(org.apache.karaf.shell.api.action.Command) Up4Utils.ppUpfMeter(org.omecproject.up4.impl.Up4Utils.ppUpfMeter) AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) UplinkUpfFlow(org.omecproject.up4.impl.UplinkUpfFlow) UpfEntity(org.onosproject.net.behaviour.upf.UpfEntity) Map(java.util.Map) Service(org.apache.karaf.shell.api.action.lifecycle.Service) UpfEntityType(org.onosproject.net.behaviour.upf.UpfEntityType) UpfApplication(org.onosproject.net.behaviour.upf.UpfApplication) Up4AdminService(org.omecproject.up4.impl.Up4AdminService) UpfSessionUplink(org.onosproject.net.behaviour.upf.UpfSessionUplink) DownlinkUpfFlow(org.omecproject.up4.impl.DownlinkUpfFlow) UpfMeter(org.onosproject.net.behaviour.upf.UpfMeter) Up4Utils.ppUpfMeter(org.omecproject.up4.impl.Up4Utils.ppUpfMeter) UpfApplication(org.onosproject.net.behaviour.upf.UpfApplication) UplinkUpfFlow(org.omecproject.up4.impl.UplinkUpfFlow) UpfEntity(org.onosproject.net.behaviour.upf.UpfEntity) Up4AdminService(org.omecproject.up4.impl.Up4AdminService)

Example 5 with UpfMeter

use of org.onosproject.net.behaviour.upf.UpfMeter 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())).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)

Aggregations

UpfMeter (org.onosproject.net.behaviour.upf.UpfMeter)5 UpfEntity (org.onosproject.net.behaviour.upf.UpfEntity)3 Collection (java.util.Collection)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Command (org.apache.karaf.shell.api.action.Command)1 Service (org.apache.karaf.shell.api.action.lifecycle.Service)1 Up4Service (org.omecproject.up4.Up4Service)1 DownlinkUpfFlow (org.omecproject.up4.impl.DownlinkUpfFlow)1 Up4AdminService (org.omecproject.up4.impl.Up4AdminService)1 Up4Utils.ppUpfMeter (org.omecproject.up4.impl.Up4Utils.ppUpfMeter)1 UplinkUpfFlow (org.omecproject.up4.impl.UplinkUpfFlow)1 Ip4Address (org.onlab.packet.Ip4Address)1 AbstractShellCommand (org.onosproject.cli.AbstractShellCommand)1 UpfApplication (org.onosproject.net.behaviour.upf.UpfApplication)1 UpfEntityType (org.onosproject.net.behaviour.upf.UpfEntityType)1 UpfGtpTunnelPeer (org.onosproject.net.behaviour.upf.UpfGtpTunnelPeer)1 UpfSessionDownlink (org.onosproject.net.behaviour.upf.UpfSessionDownlink)1 UpfSessionUplink (org.onosproject.net.behaviour.upf.UpfSessionUplink)1 UpfTerminationDownlink (org.onosproject.net.behaviour.upf.UpfTerminationDownlink)1