use of com.att.aro.core.bestpractice.pojo.HttpsUsageEntry in project VideoOptimzer by attdevsupport.
the class HttpsUsageImpl method buildHttpsUsageEntry.
/*
* If an IP contains a session that does not contain any SSL packet, we
* create a HttpsUsageEntry for it.
*
* This method loops through the IP-sessions map, and returns the list of
* HttpsUsageEntry created. If no IP from the IP-sessions map contains a
* connection that we consider as HTTP, the method returns an empty list.
*/
private List<HttpsUsageEntry> buildHttpsUsageEntry(Map<InetAddress, List<Session>> ipSessionsMap) {
List<HttpsUsageEntry> results = new ArrayList<HttpsUsageEntry>();
for (Map.Entry<InetAddress, List<Session>> ipSessions : ipSessionsMap.entrySet()) {
int totalNumConnectionsCurrentIp = 0;
int totalNumHttpConnectionsCurrentIp = 0;
int totalHttpTrafficInByteCurrentIp = 0;
int totalTrafficInByteCurrentIp = 0;
int httpTrafficPercentage = 0;
for (Session session : ipSessions.getValue()) {
boolean isSslSession = false;
// Excluding UDP Sessions
if (session.isUdpOnly()) {
continue;
}
List<PacketInfo> packetsInfo = session.getTcpPackets();
if (packetsInfo.isEmpty()) {
LOGGER.error("Session without packets! Session's remote IP and port: " + session.getRemoteIP().getHostAddress() + ":" + session.getRemotePort());
continue;
}
/*
* Determine if the TCP session is using SSL/TLS. If we find at
* least one TCP packet that contains one or more SSL record(s),
* we consider that session a SSL session.
*/
for (PacketInfo packetInfo : packetsInfo) {
Packet packet = packetInfo.getPacket();
if ((packet instanceof TCPPacket) && ((TCPPacket) packet).containsSSLRecord()) {
isSslSession = true;
break;
}
}
/*
* Calculate traffic size for the TCP session
*/
// total packet size (ip header + tcp header + payload) of all
// the packets in the session
// total payload size of all the packets in the session
int totalPacketsPayloadSize = 0;
for (PacketInfo packetInfo : packetsInfo) {
totalPacketsPayloadSize += packetInfo.getPayloadLen();
}
totalNumConnectionsCurrentIp++;
totalTrafficInByteCurrentIp += totalPacketsPayloadSize;
if (!(totalPacketsPayloadSize == 0 || isSslSession)) {
totalHttpTrafficInByteCurrentIp += totalPacketsPayloadSize;
totalNumHttpConnectionsCurrentIp++;
}
}
// End all sessions associated to an IP
if (totalNumHttpConnectionsCurrentIp > 0) {
BigDecimal totalTrafficInKBCurrentIp = new BigDecimal(totalTrafficInByteCurrentIp).divide(new BigDecimal(1000), 3, RoundingMode.HALF_UP);
BigDecimal totalHttpTrafficInKBCurrentIp = new BigDecimal(totalHttpTrafficInByteCurrentIp).divide(new BigDecimal(1000), 3, RoundingMode.HALF_UP);
int httpConnectionsPercentage = getHttpConnectionsPercentage(totalNumHttpConnectionsCurrentIp, totalNumConnectionsCurrentIp);
/*
* Initialize percentage to be 0 to avoid getting the
* divide-by-zero exception for any unexpected reason.
*/
if (totalTrafficInByteCurrentIp <= 0) {
LOGGER.error("Total traffic size of all TCP sessions is zero or less (" + totalTrafficInByteCurrentIp + " byte)! IP: " + ipSessions.getKey().getHostAddress());
} else {
httpTrafficPercentage = getHttpTrafficPercentage(totalHttpTrafficInByteCurrentIp, totalTrafficInByteCurrentIp);
}
String parentDomainName = getParentDomainName(ipSessions.getKey(), ipSessions.getValue());
results.add(new HttpsUsageEntry(ipSessions.getKey().getHostAddress(), parentDomainName, totalNumConnectionsCurrentIp, totalNumHttpConnectionsCurrentIp, httpConnectionsPercentage, totalTrafficInKBCurrentIp, totalHttpTrafficInKBCurrentIp, httpTrafficPercentage));
}
totalNumHttpConnectionsCurrentTrace += totalNumHttpConnectionsCurrentIp;
totalNumConnectionsCurrentTrace += totalNumConnectionsCurrentIp;
}
// End all IPs
return results;
}
use of com.att.aro.core.bestpractice.pojo.HttpsUsageEntry in project VideoOptimzer by attdevsupport.
the class BpSecurityHttpsUsageTablePanel method getContentTable.
@SuppressWarnings("unchecked")
@Override
public DataTable<HttpsUsageEntry> getContentTable() {
if (contentTable == null) {
contentTable = new DataTable<HttpsUsageEntry>(tableModel);
contentTable.setName(ResourceBundleHelper.getMessageString("security.https.usage.tableName"));
contentTable.setAutoCreateRowSorter(true);
contentTable.setGridColor(Color.LIGHT_GRAY);
contentTable.setRowHeight(ROW_HEIGHT);
contentTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
TableRowSorter<TableModel> sorter = new TableRowSorter<>(tableModel);
contentTable.setRowSorter(sorter);
sorter.setComparator(0, Util.getDomainSorter());
sorter.setComparator(7, Util.getIntSorter());
sorter.setComparator(4, Util.getIntSorter());
sorter.setComparator(5, Util.getFloatSorter());
sorter.setComparator(6, Util.getFloatSorter());
sorter.setComparator(1, Util.getDomainSorter());
DataTablePopupMenu popupMenu = (DataTablePopupMenu) contentTable.getPopup();
popupMenu.initialize();
}
return contentTable;
}
use of com.att.aro.core.bestpractice.pojo.HttpsUsageEntry in project VideoOptimzer by attdevsupport.
the class HttpsUsageImplTest method testHttpTrafficPercentage.
@Test
public void testHttpTrafficPercentage() {
PacketAnalyzerResult pktAnalyzerResult = resultTestSetup(5);
HttpsUsageResult httpsUsageResult = (HttpsUsageResult) httpsUsageImpl.runTest(pktAnalyzerResult);
List<HttpsUsageEntry> httpsUsageEntries = httpsUsageResult.getResults();
assertEquals(2, httpsUsageEntries.size());
if (httpsUsageEntries.get(0).getIPAddress().equals("157.56.19.80")) {
assertEquals("100", String.valueOf(httpsUsageEntries.get(0).getTotalHttpTrafficPercentage()));
assertEquals("25", String.valueOf(httpsUsageEntries.get(1).getTotalHttpTrafficPercentage()));
} else {
assertEquals("25", String.valueOf(httpsUsageEntries.get(0).getTotalHttpTrafficPercentage()));
assertEquals("100", String.valueOf(httpsUsageEntries.get(1).getTotalHttpTrafficPercentage()));
}
}
use of com.att.aro.core.bestpractice.pojo.HttpsUsageEntry in project VideoOptimzer by attdevsupport.
the class HttpsUsageImpl method runTest.
@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
/*
* Reset these total numbers before each test-run due to bean being
* singleton.
*/
totalNumConnectionsCurrentTrace = 0;
totalNumHttpConnectionsCurrentTrace = 0;
List<Session> sessions = tracedata.getSessionlist();
Map<InetAddress, List<Session>> ipSessionsMap = buildIpSessionsMap(sessions);
List<HttpsUsageEntry> httpsUsageEntries = buildHttpsUsageEntry(ipSessionsMap);
int httpConnectionsPercentageCurrentTrace = getHttpConnectionsPercentage(totalNumHttpConnectionsCurrentTrace, totalNumConnectionsCurrentTrace);
HttpsUsageResult result = new HttpsUsageResult();
String testResultText = "";
Statistic stat = tracedata.getStatistic();
if (passTest()) {
result.setResultType(BPResultType.PASS);
testResultText = MessageFormat.format(testResultPassText, ApplicationConfig.getInstance().getAppShortName(), totalNumHttpConnectionsCurrentTrace, formatDoubleToString(stat.getTotalHTTPSByte() / 1000.0, 2), formatDoubleToString(stat.getTotalHTTPSByte() * 100.0 / stat.getTotalByte(), 2), formatDoubleToString(stat.getTotalHTTPSBytesNotAnalyzed() / 1000.0, 2));
result.setResultExcelText(BPResultType.PASS.getDescription());
} else if (failTest(httpsUsageEntries, httpConnectionsPercentageCurrentTrace)) {
result.setResultType(BPResultType.FAIL);
testResultText = MessageFormat.format(testResultAnyText, ApplicationConfig.getInstance().getAppShortName(), totalNumHttpConnectionsCurrentTrace, httpConnectionsPercentageCurrentTrace, formatDoubleToString(stat.getTotalHTTPSByte() / 1000.0, 2), formatDoubleToString(stat.getTotalHTTPSByte() * 100.0 / stat.getTotalByte(), 2), formatDoubleToString(stat.getTotalHTTPSBytesNotAnalyzed() / 1000.0, 2));
result.setResultExcelText(MessageFormat.format(textExcelResults, BPResultType.FAIL.getDescription(), totalNumHttpConnectionsCurrentTrace, httpConnectionsPercentageCurrentTrace));
} else {
result.setResultType(BPResultType.WARNING);
testResultText = MessageFormat.format(testResultAnyText, ApplicationConfig.getInstance().getAppShortName(), totalNumHttpConnectionsCurrentTrace, httpConnectionsPercentageCurrentTrace, formatDoubleToString(stat.getTotalHTTPSByte() / 1000.0, 2), formatDoubleToString(stat.getTotalHTTPSByte() * 100.0 / stat.getTotalByte(), 2), formatDoubleToString(stat.getTotalHTTPSBytesNotAnalyzed() / 1000.0, 2));
result.setResultExcelText(MessageFormat.format(textExcelResults, BPResultType.WARNING.getDescription(), totalNumHttpConnectionsCurrentTrace, httpConnectionsPercentageCurrentTrace));
}
result.setOverviewTitle(overviewTitle);
result.setDetailTitle(detailedTitle);
result.setLearnMoreUrl(learnMoreUrl);
result.setAboutText(aboutText);
result.setResults(httpsUsageEntries);
result.setResultText(testResultText);
result.setExportAll(exportAll);
return result;
}
Aggregations