Search in sources :

Example 1 with NetworkBearerTypeInfo

use of com.att.aro.core.packetanalysis.pojo.NetworkBearerTypeInfo in project VideoOptimzer by attdevsupport.

the class NetworkTypeReaderImpl method readData.

@Override
public NetworkTypeObject readData(String directory, double startTime, double traceDuration) {
    NetworkTypeObject obj = null;
    List<NetworkBearerTypeInfo> networkTypeInfos = new ArrayList<NetworkBearerTypeInfo>();
    List<NetworkType> networkTypesList = new ArrayList<NetworkType>();
    String filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.NETWORKINFO_FILE;
    if (!filereader.fileExist(filepath)) {
        return obj;
    }
    String[] lines = null;
    try {
        lines = filereader.readAllLine(filepath);
    } catch (IOException e1) {
        LOGGER.error("failed to read network info file: " + filepath);
    }
    String line;
    if (lines != null && lines.length > 0) {
        line = lines[0];
        // Clear any data that may have been added by device_details
        networkTypeInfos.clear();
        NetworkType networkType;
        NetworkType overrideNetworkType = NetworkType.OVERRIDE_NETWORK_TYPE_NONE;
        double beginTime;
        double endTime;
        String[] fields = line.split(" ");
        if (fields.length >= 2) {
            beginTime = Util.normalizeTime(Double.parseDouble(fields[0]), startTime);
            try {
                networkType = getNetworkTypeFromCode(Integer.parseInt(fields[1]));
                if (fields.length > 2) {
                    overrideNetworkType = getOverriderNetworkTypeFromCode(Integer.parseInt(fields[2]));
                }
            } catch (NumberFormatException e) {
                networkType = NetworkType.UNKNOWN;
                LOGGER.warn("Invalid network type [" + fields[1] + "]");
            }
            networkTypesList.add(networkType);
            for (int i = 1; i < lines.length; i++) {
                line = lines[i];
                fields = line.split(" ");
                if (fields.length >= 2) {
                    endTime = Util.normalizeTime(Double.parseDouble(fields[0]), startTime);
                    networkTypeInfos.add(new NetworkBearerTypeInfo(beginTime, endTime, networkType, overrideNetworkType));
                    try {
                        networkType = getNetworkTypeFromCode(Integer.parseInt(fields[1]));
                        if (fields.length > 2) {
                            overrideNetworkType = getOverriderNetworkTypeFromCode(Integer.parseInt(fields[2]));
                        }
                    } catch (NumberFormatException e) {
                        networkType = NetworkType.UNKNOWN;
                        LOGGER.warn("Invalid network type [" + fields[1] + "]");
                    }
                    beginTime = endTime;
                    if (!networkTypesList.contains(networkType)) {
                        networkTypesList.add(networkType);
                    }
                }
            }
            networkTypeInfos.add(new NetworkBearerTypeInfo(beginTime, traceDuration, networkType, overrideNetworkType));
        }
    }
    obj = new NetworkTypeObject();
    obj.setNetworkTypeInfos(networkTypeInfos);
    obj.setNetworkTypesList(networkTypesList);
    return obj;
}
Also used : NetworkTypeObject(com.att.aro.core.peripheral.pojo.NetworkTypeObject) NetworkType(com.att.aro.core.peripheral.pojo.NetworkType) ArrayList(java.util.ArrayList) IOException(java.io.IOException) NetworkBearerTypeInfo(com.att.aro.core.packetanalysis.pojo.NetworkBearerTypeInfo)

Example 2 with NetworkBearerTypeInfo

use of com.att.aro.core.packetanalysis.pojo.NetworkBearerTypeInfo in project VideoOptimzer by attdevsupport.

the class NetworkTypePlot method populate.

@Override
public void populate(XYPlot plot, AROTraceData analysis) {
    plot.setDataset(new XYIntervalSeriesCollection());
    if (analysis == null) {
        LOGGER.info("no trace data here");
    } else {
        if (analysis.getAnalyzerResult().getTraceresult().getTraceResultType() == TraceResultType.TRACE_FILE) {
            LOGGER.info("no trace folder data here");
        } else {
            TraceDirectoryResult traceresult = (TraceDirectoryResult) analysis.getAnalyzerResult().getTraceresult();
            final XYIntervalSeriesCollection networkDataSeries = new XYIntervalSeriesCollection();
            final Map<NetworkType, XYIntervalSeries> seriesMap = new EnumMap<NetworkType, XYIntervalSeries>(NetworkType.class);
            createDataSeriesForAllNetworkTypes(seriesMap, networkDataSeries);
            Iterator<NetworkBearerTypeInfo> iter = traceresult.getNetworkTypeInfos().iterator();
            if (iter.hasNext()) {
                while (iter.hasNext()) {
                    NetworkBearerTypeInfo networkInfo = iter.next();
                    if (networkInfo.getNetworkType() != NetworkType.UNKNOWN) {
                        if (NetworkType.LTE == networkInfo.getNetworkType() && (NetworkType.OVERRIDE_NETWORK_TYPE_NR_NSA == networkInfo.getOverrideNetworkType() || NetworkType.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE == networkInfo.getOverrideNetworkType() || NetworkType.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO == networkInfo.getOverrideNetworkType())) {
                            seriesMap.get(networkInfo.getOverrideNetworkType()).add(networkInfo.getBeginTimestamp(), networkInfo.getBeginTimestamp(), networkInfo.getEndTimestamp(), 0.5, 0, 1);
                        } else {
                            seriesMap.get(networkInfo.getNetworkType()).add(networkInfo.getBeginTimestamp(), networkInfo.getBeginTimestamp(), networkInfo.getEndTimestamp(), 0.5, 0, 1);
                        }
                    }
                }
            } else {
                NetworkType nt = traceresult.getNetworkType();
                if (nt != null && nt != NetworkType.UNKNOWN) {
                    seriesMap.get(nt).add(0, 0, traceresult.getTraceDuration(), 0.5, 0, 1);
                }
            }
            XYItemRenderer renderer = plot.getRenderer();
            setRenderingColorForDataSeries(renderer, networkDataSeries);
            // Assign ToolTip to renderer
            renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {

                @Override
                public String generateToolTip(XYDataset dataset, int series, int item) {
                    NetworkType networkType = (NetworkType) networkDataSeries.getSeries(series).getKey();
                    return MessageFormat.format(ResourceBundleHelper.getMessageString("network.tooltip"), dataset.getX(series, item), ResourceBundleHelper.getEnumString(networkType));
                }
            });
            plot.setDataset(networkDataSeries);
        }
    }
}
Also used : XYIntervalSeriesCollection(org.jfree.data.xy.XYIntervalSeriesCollection) NetworkType(com.att.aro.core.peripheral.pojo.NetworkType) XYIntervalSeries(org.jfree.data.xy.XYIntervalSeries) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) XYDataset(org.jfree.data.xy.XYDataset) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) XYToolTipGenerator(org.jfree.chart.labels.XYToolTipGenerator) EnumMap(java.util.EnumMap) NetworkBearerTypeInfo(com.att.aro.core.packetanalysis.pojo.NetworkBearerTypeInfo)

Example 3 with NetworkBearerTypeInfo

use of com.att.aro.core.packetanalysis.pojo.NetworkBearerTypeInfo in project VideoOptimzer by attdevsupport.

the class PktAnazlyzerTimeRangeImpl method getNetworkInfosForTheTimeRange.

private void getNetworkInfosForTheTimeRange(TraceDirectoryResult result, double beginTime, double endTime) {
    List<NetworkBearerTypeInfo> orifilteredBearerInfos = result.getNetworkTypeInfos();
    List<NetworkBearerTypeInfo> filteredBearerInfos = new ArrayList<NetworkBearerTypeInfo>();
    for (NetworkBearerTypeInfo bearerInfo : orifilteredBearerInfos) {
        if (bearerInfo.getBeginTimestamp() >= beginTime && bearerInfo.getEndTimestamp() <= endTime) {
            filteredBearerInfos.add(bearerInfo);
        } else if (bearerInfo.getBeginTimestamp() <= beginTime && bearerInfo.getEndTimestamp() <= endTime && bearerInfo.getEndTimestamp() > beginTime) {
            filteredBearerInfos.add(new NetworkBearerTypeInfo(beginTime, bearerInfo.getEndTimestamp(), bearerInfo.getNetworkType(), bearerInfo.getOverrideNetworkType()));
        } else if (bearerInfo.getBeginTimestamp() <= beginTime && bearerInfo.getEndTimestamp() >= endTime) {
            filteredBearerInfos.add(new NetworkBearerTypeInfo(beginTime, endTime, bearerInfo.getNetworkType(), bearerInfo.getOverrideNetworkType()));
        } else if (bearerInfo.getBeginTimestamp() >= beginTime && bearerInfo.getBeginTimestamp() < endTime && bearerInfo.getEndTimestamp() >= endTime) {
            filteredBearerInfos.add(new NetworkBearerTypeInfo(bearerInfo.getBeginTimestamp(), endTime, bearerInfo.getNetworkType(), bearerInfo.getOverrideNetworkType()));
        }
    }
    result.setNetworkTypeInfos(filteredBearerInfos);
// return filteredBearerInfos;
}
Also used : ArrayList(java.util.ArrayList) NetworkBearerTypeInfo(com.att.aro.core.packetanalysis.pojo.NetworkBearerTypeInfo)

Example 4 with NetworkBearerTypeInfo

use of com.att.aro.core.packetanalysis.pojo.NetworkBearerTypeInfo in project VideoOptimzer by attdevsupport.

the class PktAnazlyzerTimeRangeImplTest method getTimeRangeResultTest.

@Test
public void getTimeRangeResultTest() {
    TraceDirectoryResult result = new TraceDirectoryResult();
    List<UserEvent> userEvents = new ArrayList<UserEvent>();
    userEvents.add(new UserEvent(UserEventType.KEY_HOME, 4.0, 3.0));
    result.setUserEvents(userEvents);
    List<GpsInfo> gpsInfos = new ArrayList<GpsInfo>();
    gpsInfos.add(new GpsInfo(0.0, 0.9, GpsState.GPS_ACTIVE));
    gpsInfos.add(new GpsInfo(1.0, 4.0, GpsState.GPS_ACTIVE));
    gpsInfos.add(new GpsInfo(1.4, 12.0, GpsState.GPS_ACTIVE));
    gpsInfos.add(new GpsInfo(12.4, 14.0, GpsState.GPS_ACTIVE));
    result.setGpsInfos(gpsInfos);
    List<BluetoothInfo> bluetoothInfos = new ArrayList<BluetoothInfo>();
    bluetoothInfos.add(new BluetoothInfo(0.0, 3.0, BluetoothState.BLUETOOTH_CONNECTED));
    bluetoothInfos.add(new BluetoothInfo(4.0, 10.0, BluetoothState.BLUETOOTH_CONNECTED));
    bluetoothInfos.add(new BluetoothInfo(1.0, 13.0, BluetoothState.BLUETOOTH_DISCONNECTED));
    bluetoothInfos.add(new BluetoothInfo(11.0, 16.0, BluetoothState.BLUETOOTH_CONNECTED));
    result.setBluetoothInfos(bluetoothInfos);
    List<CameraInfo> cameraInfos = new ArrayList<CameraInfo>();
    cameraInfos.add(new CameraInfo(0.0, 1.0, CameraState.CAMERA_ON));
    cameraInfos.add(new CameraInfo(3.0, 7.0, CameraState.CAMERA_ON));
    cameraInfos.add(new CameraInfo(8.0, 14.0, CameraState.CAMERA_ON));
    cameraInfos.add(new CameraInfo(1.0, 14.0, CameraState.CAMERA_ON));
    cameraInfos.add(new CameraInfo(12.0, 15.0, CameraState.CAMERA_ON));
    result.setCameraInfos(cameraInfos);
    List<ScreenStateInfo> screenStateInfos = new ArrayList<ScreenStateInfo>();
    ScreenStateInfo screenInfo01 = new ScreenStateInfo(0.0, 1.0, ScreenState.SCREEN_ON, " ", 5);
    ScreenStateInfo screenInfo02 = new ScreenStateInfo(1.0, 12.0, ScreenState.SCREEN_ON, "", 3);
    ScreenStateInfo screenInfo03 = new ScreenStateInfo(5.0, 9.0, ScreenState.SCREEN_ON, "", 2);
    ScreenStateInfo screenInfo04 = new ScreenStateInfo(12.0, 15.0, ScreenState.SCREEN_ON, "", 4);
    screenStateInfos.add(screenInfo01);
    screenStateInfos.add(screenInfo02);
    screenStateInfos.add(screenInfo03);
    screenStateInfos.add(screenInfo04);
    result.setScreenStateInfos(screenStateInfos);
    List<RadioInfo> radioInfos = new ArrayList<RadioInfo>();
    radioInfos.add(new RadioInfo(0.0, 3.0));
    radioInfos.add(new RadioInfo(4.0, 8.0));
    result.setRadioInfos(radioInfos);
    List<BatteryInfo> batteryInfos = new ArrayList<BatteryInfo>();
    batteryInfos.add(new BatteryInfo(3.0, true, 2, 3));
    result.setBatteryInfos(batteryInfos);
    List<WifiInfo> wifiInfos = new ArrayList<WifiInfo>();
    wifiInfos.add(new WifiInfo(1.0, 2.0, WifiState.WIFI_CONNECTED, "", "", ""));
    wifiInfos.add(new WifiInfo(1.0, 5.0, WifiState.WIFI_CONNECTING, "", "", ""));
    wifiInfos.add(new WifiInfo(1.4, 13.0, WifiState.WIFI_CONNECTING, "", "", ""));
    wifiInfos.add(new WifiInfo(9.0, 13.0, WifiState.WIFI_CONNECTING, "", "", ""));
    result.setWifiInfos(wifiInfos);
    List<NetworkType> networkTypesList = new ArrayList<NetworkType>();
    networkTypesList.add(NetworkType.LTE);
    result.setNetworkTypesList(networkTypesList);
    List<NetworkBearerTypeInfo> networkTypeInfos = new ArrayList<NetworkBearerTypeInfo>();
    networkTypeInfos.add(new NetworkBearerTypeInfo(1.0, 3.0, NetworkType.HSPA, NetworkType.OVERRIDE_NETWORK_TYPE_NONE));
    networkTypeInfos.add(new NetworkBearerTypeInfo(8.0, 12.0, NetworkType.HSPA, NetworkType.OVERRIDE_NETWORK_TYPE_NONE));
    result.setNetworkTypeInfos(networkTypeInfos);
    TimeRange timeRange = new TimeRange(2.00, 11.00);
    TraceDirectoryResult testResult = (TraceDirectoryResult) pktTimeUtil.getTimeRangeResult(result, timeRange);
    assertEquals(1, testResult.getBatteryInfos().size());
    assertEquals(2, testResult.getGpsInfos().size());
    assertEquals(1, testResult.getBatteryInfos().size());
    assertEquals(5, testResult.getCameraInfos().size());
    assertEquals(2, testResult.getScreenStateInfos().size());
    assertEquals(1, testResult.getRadioInfos().size());
    assertEquals(3, testResult.getWifiInfos().size());
    assertEquals(2, testResult.getNetworkTypeInfos().size());
}
Also used : BluetoothInfo(com.att.aro.core.peripheral.pojo.BluetoothInfo) BatteryInfo(com.att.aro.core.peripheral.pojo.BatteryInfo) ArrayList(java.util.ArrayList) GpsInfo(com.att.aro.core.peripheral.pojo.GpsInfo) ScreenStateInfo(com.att.aro.core.peripheral.pojo.ScreenStateInfo) CameraInfo(com.att.aro.core.peripheral.pojo.CameraInfo) UserEvent(com.att.aro.core.peripheral.pojo.UserEvent) WifiInfo(com.att.aro.core.peripheral.pojo.WifiInfo) RadioInfo(com.att.aro.core.peripheral.pojo.RadioInfo) TimeRange(com.att.aro.core.packetanalysis.pojo.TimeRange) NetworkType(com.att.aro.core.peripheral.pojo.NetworkType) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) NetworkBearerTypeInfo(com.att.aro.core.packetanalysis.pojo.NetworkBearerTypeInfo) BaseTest(com.att.aro.core.BaseTest) Test(org.junit.Test)

Example 5 with NetworkBearerTypeInfo

use of com.att.aro.core.packetanalysis.pojo.NetworkBearerTypeInfo in project VideoOptimzer by attdevsupport.

the class NetworkTypeReaderImplTest method readData.

@Test
public void readData() throws IOException {
    Mockito.when(filereader.fileExist(Mockito.anyString())).thenReturn(true);
    String[] arr = new String[] { // 0
    "1.358205538539E9 10", // 1
    "1.358205540396E9 15", // 2
    "1.35820554882E9 3", // 3
    "1.358205549444E9 1", // 4
    "1.358205552859E9 9", // 5
    "1.358205564577E9 3", // 6
    "1.358205565208E9 10", // 7
    "1.358205565834E9 15", // 8
    "1.358205572238E9 3", // 9
    "1.358205572969E9 8", // 10
    "1.358205584581E9 3", // 11
    "1.358205586095E9 13", // 12
    "1.358205590906E9 3", // 13
    "1.358205591561E9 2", // 14
    "1.358205594481E9 5", // 15
    "1.358205605874E9 3", // 16
    "1.358205606144E9 0", // 17
    "1.358205607302E9 15", // 18
    "1.358205614199E9 -1", // 19
    "1.358205623225E9 -1", // 20
    "1.358205763101E9 15", // 21
    "1.358205779064E9 3", // 22
    "1.358205779663E9 33", // 23
    "1.358205782276E9 fe", // 24
    "1.358205790737E9 3", // 25
    "1.358205791067E9 10", // 26
    "1.358205801382E9 15" };
    Mockito.when(filereader.readAllLine(Mockito.anyString())).thenReturn(arr);
    networkTypeReader.setFileReader(filereader);
    NetworkTypeObject info = networkTypeReader.readData("/", 0, 0);
    List<NetworkType> listNetworkType = info.getNetworkTypesList();
    assertEquals(11, listNetworkType.size(), 0);
    List<NetworkBearerTypeInfo> listNetworkBearerTypeInfo = info.getNetworkTypeInfos();
    assertEquals(27, listNetworkBearerTypeInfo.size(), 0);
    assertEquals(1.358205538539E9, listNetworkBearerTypeInfo.get(0).getBeginTimestamp(), 0);
    assertEquals(1.358205801382E9, listNetworkBearerTypeInfo.get(26).getBeginTimestamp(), 0);
    assertEquals("HSPAP", listNetworkBearerTypeInfo.get(26).getNetworkType().toString());
    Mockito.when(filereader.fileExist(Mockito.anyString())).thenReturn(false);
    Mockito.when(filereader.readAllLine(Mockito.anyString())).thenReturn(arr);
    info = networkTypeReader.readData("/", 0, 0);
    assertTrue(listNetworkType != null);
    Mockito.when(filereader.fileExist(Mockito.anyString())).thenReturn(true);
    arr = new String[] { "1.358205538539E9 bd", "1.358205540396E9 15" };
    Mockito.when(filereader.readAllLine(Mockito.anyString())).thenReturn(arr);
    info = networkTypeReader.readData("/", 0, 0);
    listNetworkType = info.getNetworkTypesList();
    assertEquals(2, listNetworkType.size(), 0);
}
Also used : NetworkTypeObject(com.att.aro.core.peripheral.pojo.NetworkTypeObject) NetworkType(com.att.aro.core.peripheral.pojo.NetworkType) NetworkBearerTypeInfo(com.att.aro.core.packetanalysis.pojo.NetworkBearerTypeInfo) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Aggregations

NetworkBearerTypeInfo (com.att.aro.core.packetanalysis.pojo.NetworkBearerTypeInfo)5 NetworkType (com.att.aro.core.peripheral.pojo.NetworkType)4 ArrayList (java.util.ArrayList)3 BaseTest (com.att.aro.core.BaseTest)2 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)2 NetworkTypeObject (com.att.aro.core.peripheral.pojo.NetworkTypeObject)2 Test (org.junit.Test)2 TimeRange (com.att.aro.core.packetanalysis.pojo.TimeRange)1 BatteryInfo (com.att.aro.core.peripheral.pojo.BatteryInfo)1 BluetoothInfo (com.att.aro.core.peripheral.pojo.BluetoothInfo)1 CameraInfo (com.att.aro.core.peripheral.pojo.CameraInfo)1 GpsInfo (com.att.aro.core.peripheral.pojo.GpsInfo)1 RadioInfo (com.att.aro.core.peripheral.pojo.RadioInfo)1 ScreenStateInfo (com.att.aro.core.peripheral.pojo.ScreenStateInfo)1 UserEvent (com.att.aro.core.peripheral.pojo.UserEvent)1 WifiInfo (com.att.aro.core.peripheral.pojo.WifiInfo)1 IOException (java.io.IOException)1 EnumMap (java.util.EnumMap)1 XYToolTipGenerator (org.jfree.chart.labels.XYToolTipGenerator)1 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)1