use of com.att.aro.core.packetanalysis.pojo.TimeRange in project VideoOptimzer by attdevsupport.
the class TimeRangeEditorDialog method buildConfigGroup.
private JPanel buildConfigGroup() {
JPanel framePanel = new JPanel(new FlowLayout());
configNameField.setSize(new Dimension(200, 20));
framePanel.add(wrapAndLabelComponent((sliderAlert = new JTextField("")), "", 200));
sliderAlert.setVisible(false);
sliderAlert.setDisabledTextColor(Color.RED);
sliderAlert.setFont(new Font("Dialog", Font.BOLD, 14));
sliderAlert.setEditable(false);
sliderAlert.setBackground(Color.LIGHT_GRAY);
framePanel.add(wrapAndLabelComponent(configNameField, "Configuration name:", 200));
framePanel.add(wrapAndLabelComponent(autoLaunchComboBox, "Auto Launch:", 110));
configNameField.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
if (collisionTest(configNameField.getText())) {
int actionCode = ask();
if (actionCode != 0) {
configNameField.grabFocus();
} else {
if (startAnalysisTextField.getText().isEmpty() && endAnalysisTextField.getText().isEmpty()) {
TimeRange timeRange = locateTimeRange(configNameField.getText());
if (timeRange != null) {
startAnalysisTextField.setText(timeRange.getBeginTime().toString());
endAnalysisTextField.setText(timeRange.getEndTime().toString());
autoLaunchComboBox.getModel().setSelectedItem(timeRange.getTimeRangeType());
}
}
}
}
}
@Override
public void focusGained(FocusEvent e) {
}
});
return framePanel;
}
use of com.att.aro.core.packetanalysis.pojo.TimeRange in project VideoOptimzer by attdevsupport.
the class PacketAnalyzerImpl method filterPackets.
/**
* Runs the filtering process on the specified packets/PacketInfos.
*
* @return packets/PacketInfos filtered
*/
public List<PacketInfo> filterPackets(AnalysisFilter filter, List<PacketInfo> packetsInfo) {
// create new packets according to the filter setting
List<PacketInfo> filteredPackets = new ArrayList<PacketInfo>();
TimeRange timeRange = filter.getTimeRange();
int packetIdx = 0;
// Ff you select the check box, you want to include it.
// All of of the skip-flags are false at first.
boolean ipv4Skip = !filter.isIpv4Sel();
boolean ipv6Skip = !filter.isIpv6Sel();
boolean tcpSkip = !filter.isTcpSel();
boolean udpSkip = !filter.isUdpSel();
boolean dnsSkip = !filter.isDnsSelection();
for (PacketInfo packetInfo : packetsInfo) {
if (packetInfo.getRemoteIPAddress() != null) {
if (ipv4Skip && packetInfo.getRemoteIPAddress() instanceof Inet4Address) {
continue;
}
if (ipv6Skip && packetInfo.getRemoteIPAddress() instanceof Inet6Address) {
continue;
}
} else {
IPPacket ipPacket = (IPPacket) packetInfo.getPacket();
if (ipPacket != null) {
if (ipv4Skip && ipPacket.getIPVersion() == 4) {
continue;
}
if (ipv6Skip && ipPacket.getIPVersion() == 6) {
continue;
}
}
}
if (tcpSkip && packetInfo.getPacket() instanceof TCPPacket) {
continue;
}
if (udpSkip && packetInfo.getPacket() instanceof UDPPacket) {
UDPPacket udpPacket = (UDPPacket) packetInfo.getPacket();
if (!(DNS_PORT == udpPacket.getDestinationPort() || DNS_PORT == udpPacket.getSourcePort())) {
continue;
}
}
if (dnsSkip && packetInfo.getPacket() instanceof UDPPacket) {
UDPPacket udpPacket = (UDPPacket) packetInfo.getPacket();
if (DNS_PORT == udpPacket.getDestinationPort() || DNS_PORT == udpPacket.getSourcePort()) {
continue;
}
}
// Check time range
double timestamp = packetInfo.getTimeStamp();
if (timeRange != null && (timeRange.getBeginTime() > timestamp || timeRange.getEndTime() < timestamp)) {
// Not in time range
continue;
}
// Check to see if application is selected
if (filter.getPacketColor(packetInfo) == null) {
// App unknown by filter
continue;
}
packetInfo.setPacketId(++packetIdx);
filteredPackets.add(packetInfo);
}
return filteredPackets;
}
use of com.att.aro.core.packetanalysis.pojo.TimeRange in project VideoOptimzer by attdevsupport.
the class PacketAnalyzerImpl method analyzeTraceDirectory.
@Override
public PacketAnalyzerResult analyzeTraceDirectory(String traceDirectory, Profile profile, AnalysisFilter filter) throws FileNotFoundException {
long bpStartTime = System.currentTimeMillis();
TraceDirectoryResult result = tracereader.readTraceDirectory(traceDirectory);
if (filter != null) {
TimeRange tempTimeRange = filter.getTimeRange();
if (tempTimeRange != null) {
TraceDirectoryResult tempResult = (TraceDirectoryResult) pktTimeUtil.getTimeRangeResult(result, tempTimeRange);
result.setAlarmInfos(tempResult.getAlarmInfos());
result.setBatteryInfos(tempResult.getBatteryInfos());
result.setBluetoothInfos(tempResult.getBluetoothInfos());
result.setCameraInfos(tempResult.getCameraInfos());
result.setGpsInfos(tempResult.getGpsInfos());
result.setNetworkTypeInfos(tempResult.getNetworkTypeInfos());
result.setRadioInfos(tempResult.getRadioInfos());
result.setScreenStateInfos(tempResult.getScreenStateInfos());
result.setUserEvents(tempResult.getUserEvents());
result.setTemperatureInfos(tempResult.getTemperatureInfos());
result.setLocationEventInfos(tempResult.getLocationEventInfos());
result.setWifiInfos(tempResult.getWifiInfos());
result.getCpuActivityList().updateTimeRange(tempTimeRange.getBeginTime(), tempTimeRange.getEndTime());
result.setDeviceKeywordInfos(tempResult.getDeviceKeywordInfos());
result.setAttenautionEvent(tempResult.getAttenautionEvent());
}
}
PacketAnalyzerResult res = finalResult(result, profile, filter);
result.setMetaData(metaDataHelper.initMetaData(res));
GoogleAnalyticsUtil.getGoogleAnalyticsInstance().sendAnalyticsTimings(pktAnalysisTitle, System.currentTimeMillis() - bpStartTime, analysisCategory);
LOGGER.debug(String.format("Time to process PacketAnalyzerImpl %s :%12.4f", pktAnalysisTitle, ((float) (System.currentTimeMillis() - bpStartTime)) / 3600.0));
return res;
}
use of com.att.aro.core.packetanalysis.pojo.TimeRange in project VideoOptimzer by attdevsupport.
the class PacketAnalyzerImpl method finalResult.
protected PacketAnalyzerResult finalResult(AbstractTraceResult result, Profile profile, AnalysisFilter filter) {
PacketAnalyzerResult data = new PacketAnalyzerResult();
if (filter == null) {
double endTime = result.getAllpackets().size() > 0 ? Math.max(result.getAllpackets().get(result.getAllpackets().size() - 1).getTimeStamp(), result.getTraceDuration()) : 0.0;
result.setTimeRange(new TimeRange("Full", TimeRange.TimeRangeType.FULL, 0.0, endTime));
} else {
result.setTimeRange(filter.getTimeRange());
}
// List of packets included in analysis (application filtered)
List<PacketInfo> filteredPackets;
Profile aProfile = profile;
if (aProfile == null) {
// if the user doesn't load any profile.....
aProfile = profilefactory.createLTEdefault();
aProfile.setName("AT&T LTE");
}
// for the situation, filter out all no-ip packets and caused the allpackets is empty, need to refactor
if (result != null && result.getAllpackets() != null && result.getAllpackets().size() == 0) {
data.setTraceresult(result);
return data;
}
/* Purpose of this code block is to finish building out the filter, if needed, for TimeRange analysis
*
* This code block is excuted when:
* 1: time-range.json exists in trace folder
* a: and the json contains an entry with RangeType.AUTO
* 2: A TimeRange object was created and launched in TimeRangeEditorDialog
*
* AroController will have created an AnalysisFilter and so filter will not be null
*
*/
try {
if ((filter != null && filter.getTimeRange() != null && filter.getTimeRange().getPath() != null) || result.getAllAppNames().size() == 1) {
String app = TraceDataReaderImpl.UNKNOWN_APPNAME;
if (filter != null && filter.getAppSelections() != null && filter.getAppSelections().containsKey(app) && filter.getAppSelections().get(app).getIPAddressSelections().isEmpty()) {
LOGGER.debug("AUTO Time Range analysis: add all found appIps to " + app + ", then store in the filter");
ApplicationSelection appSelection = new ApplicationSelection(app, result.getAppIps().get(app));
filter.getAppSelections().put(app, appSelection);
}
}
} catch (Exception e) {
LOGGER.error("Error handling TimeRange JSON data", e);
}
TimeRange timeRange = null;
boolean isCSI = false;
filteredPackets = new ArrayList<PacketInfo>();
if (filter == null) {
if (result != null) {
filteredPackets = result.getAllpackets();
}
} else {
// do the filter
if (filter.isCSI() && filter.getManifestFilePath() != null) {
isCSI = true;
}
timeRange = filter.getTimeRange();
if (result != null) {
filteredPackets = filterPackets(filter, result.getAllpackets());
}
}
// Fix for Sev 2 Time Range Analysis Issue - DE187848
if (result != null) {
result.setAllpackets(filteredPackets);
SessionManagerImpl sessionMangerImpl = (SessionManagerImpl) sessionmanager;
sessionMangerImpl.setPcapTimeOffset(result.getPcapTimeOffset());
// for iOS trace
sessionmanager.setiOSSecureTracePath(result.getTraceDirectory());
// Check if secure trace path exists
if (result instanceof TraceDirectoryResult) {
File file = new File(((SessionManagerImpl) sessionmanager).getTracePath());
if (file.exists()) {
((TraceDirectoryResult) result).setSecureTrace(true);
}
}
}
Statistic stat = this.getStatistic(filteredPackets);
List<Session> sessionList = sessionmanager.processPacketsAndAssembleSessions(filteredPackets);
generateGetRequestMapAndPopulateLatencyStat(sessionList, stat);
if (result != null && stat.getAppName() != null && stat.getAppName().size() == 1 && stat.getAppName().contains(TraceDataReaderImpl.UNKNOWN_APPNAME)) {
stat.setAppName(new HashSet<String>(result.getAppInfos()));
}
// get Unanalyzed HTTPS bytes
boolean isSecureTrace = result instanceof TraceDirectoryResult ? ((TraceDirectoryResult) result).isSecureTrace() : false;
if (isSecureTrace) {
stat.setTotalHTTPSBytesNotAnalyzed(getHttpsBytesNotAnalyzed(sessionList));
} else {
stat.setTotalHTTPSBytesNotAnalyzed(stat.getTotalHTTPSByte());
}
// stat is used to get some info for RrcStateMachine etc
if (result != null) {
LOGGER.debug("Starting pre processing in PAI");
AbstractRrcStateMachine statemachine = statemachinefactory.create(filteredPackets, aProfile, stat.getPacketDuration(), result.getTraceDuration(), stat.getTotalByte(), timeRange);
EnergyModel energymodel = energymodelfactory.create(aProfile, statemachine.getTotalRRCEnergy(), result.getGpsInfos(), result.getCameraInfos(), result.getBluetoothInfos(), result.getScreenStateInfos());
BurstCollectionAnalysisData burstcollectiondata = burstcollectionanalyzer.analyze(filteredPackets, aProfile, stat.getPacketSizeToCountMap(), statemachine.getStaterangelist(), result.getUserEvents(), result.getCpuActivityList().getCpuActivities(), sessionList);
data.clearBPResults();
try {
List<BestPracticeType> videoBPList = BestPracticeType.getByCategory(BestPracticeType.Category.VIDEO);
data.setStreamingVideoData(videoTrafficCollector.clearData());
if (CollectionUtils.containsAny(SettingsUtil.retrieveBestPractices(), videoBPList)) {
if (isCSI || csiDataHelper.doesCSIFileExist(result.getTraceDirectory())) {
data.setStreamingVideoData(videoTrafficInferencer.inferVideoData(result, sessionList, (filter != null && filter.getManifestFilePath() != null) ? filter.getManifestFilePath() : result.getTraceDirectory()));
} else {
data.setStreamingVideoData(videoTrafficCollector.collect(result, sessionList, requestMap));
}
}
} catch (Exception ex) {
LOGGER.error("Error in Video usage analysis :", ex);
// Guarantee that StreamingVideoData is empty
data.setStreamingVideoData(videoTrafficCollector.clearData());
data.getStreamingVideoData().setFinished(true);
}
try {
List<BestPracticeType> imageBPList = new ArrayList<>();
imageBPList.add(BestPracticeType.IMAGE_MDATA);
imageBPList.add(BestPracticeType.IMAGE_CMPRS);
imageBPList.add(BestPracticeType.IMAGE_FORMAT);
imageBPList.add(BestPracticeType.IMAGE_COMPARE);
if (CollectionUtils.containsAny(SettingsUtil.retrieveBestPractices(), imageBPList)) {
imageExtractor.execute(result, sessionList, requestMap);
}
} catch (Exception ex) {
LOGGER.error("Error in Image extraction:" + ex.getMessage(), ex);
}
htmlExtractor.execute(result, sessionList, requestMap);
// Calculate time range analysis
double beginTime = 0.0d;
double endTime = 0.0d;
if (filter != null && filter.getTimeRange() != null) {
beginTime = filter.getTimeRange().getBeginTime();
endTime = filter.getTimeRange().getEndTime();
} else {
endTime = result.getTraceDuration();
}
data.setBurstCollectionAnalysisData(burstcollectiondata);
data.setEnergyModel(energymodel);
data.setSessionlist(sessionList);
data.setStatemachine(statemachine);
data.setStatistic(stat);
data.setTraceresult(result);
data.setProfile(aProfile);
data.setFilter(filter);
data.setDeviceKeywords(result.getDeviceKeywordInfos());
data.setTimeRangeAnalysis(new TimeRangeAnalysis(beginTime, endTime, data));
}
return data;
}
use of com.att.aro.core.packetanalysis.pojo.TimeRange in project VideoOptimzer by attdevsupport.
the class ExcludeTimeRangeAnalysisDialog method closeWindow.
private void closeWindow() {
AnalysisFilter filter = ((MainFrame) parent).getController().getTheModel().getAnalyzerResult().getFilter();
filter.setTimeRange(new TimeRange(initTimeRangeStartTime, initTimeRangeEndTime));
dispose();
}
Aggregations