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