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