Search in sources :

Example 1 with UplinkUpfFlow

use of org.omecproject.up4.impl.UplinkUpfFlow 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)

Aggregations

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 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 AbstractShellCommand (org.onosproject.cli.AbstractShellCommand)1 UpfApplication (org.onosproject.net.behaviour.upf.UpfApplication)1 UpfEntity (org.onosproject.net.behaviour.upf.UpfEntity)1 UpfEntityType (org.onosproject.net.behaviour.upf.UpfEntityType)1 UpfMeter (org.onosproject.net.behaviour.upf.UpfMeter)1 UpfSessionUplink (org.onosproject.net.behaviour.upf.UpfSessionUplink)1