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