use of com.att.aro.core.packetreader.pojo.TCPPacket in project VideoOptimzer by attdevsupport.
the class HttpRequestResponseInfo method writePayload.
public void writePayload(PacketInfo packetInfo, int limit) throws IOException {
try {
if (packetInfo.getPacket() instanceof TCPPacket) {
TCPPacket tcpPacket = (TCPPacket) packetInfo.getPacket();
dataStream = new BufferedOutputStream(payloadData);
dataStream.write(tcpPacket.getData(), tcpPacket.getDataOffset(), limit);
dataStream.flush();
}
} catch (Exception exception) {
LOGGER.error("Error Writing Payload to Request Response Info Object", exception);
}
}
use of com.att.aro.core.packetreader.pojo.TCPPacket in project VideoOptimzer by attdevsupport.
the class HttpsUsageImplTest method testUDPSessionNotConsidered.
@Test
public void testUDPSessionNotConsidered() {
Session session1 = mock(Session.class);
Session session2 = mock(Session.class);
InetAddress ipAddr = mock(InetAddress.class);
when(ipAddr.getHostAddress()).thenReturn("157.56.19.80");
when(session1.isUdpOnly()).thenReturn(true);
when(session2.getRemoteIP()).thenReturn(ipAddr);
when(session2.getDomainName()).thenReturn("www.hotmail.com");
TCPPacket tcpPacket1 = mock(TCPPacket.class);
TCPPacket tcpPacket2 = mock(TCPPacket.class);
when(tcpPacket1.containsSSLRecord()).thenReturn(false);
when(tcpPacket2.containsSSLRecord()).thenReturn(false);
PacketInfo packetInfo_tcp1 = mock(PacketInfo.class);
PacketInfo packetInfo_tcp2 = mock(PacketInfo.class);
when(packetInfo_tcp1.getPayloadLen()).thenReturn(1);
when(packetInfo_tcp1.getPacket()).thenReturn(tcpPacket1);
when(packetInfo_tcp2.getPayloadLen()).thenReturn(1);
when(packetInfo_tcp2.getPacket()).thenReturn(tcpPacket2);
List<PacketInfo> packetsInfo = new ArrayList<PacketInfo>();
packetsInfo.add(packetInfo_tcp1);
packetsInfo.add(packetInfo_tcp2);
when(session2.getTcpPackets()).thenReturn(packetsInfo);
List<Session> sessions = new ArrayList<Session>();
sessions.add(session1);
sessions.add(session2);
pktAnalyzerResult.setSessionlist(sessions);
Statistic statistic = new Statistic();
statistic.setTotalByte(123);
statistic.setTotalHTTPSByte(123);
statistic.setTotalHTTPSBytesNotAnalyzed(123);
pktAnalyzerResult.setStatistic(statistic);
httpsUsageResult = (HttpsUsageResult) httpsUsageImpl.runTest(pktAnalyzerResult);
httpsUsageEntries = httpsUsageResult.getResults();
assertEquals(1, httpsUsageEntries.size());
}
use of com.att.aro.core.packetreader.pojo.TCPPacket in project VideoOptimzer by attdevsupport.
the class HttpsUsageImplTest method testIsSSLSessionsAlteration.
@Test
public void testIsSSLSessionsAlteration() {
Session session1 = mock(Session.class);
Session session2 = mock(Session.class);
Session session3 = mock(Session.class);
InetAddress ipAddrA = mock(InetAddress.class);
InetAddress ipAddrB = mock(InetAddress.class);
when(ipAddrA.getHostAddress()).thenReturn("157.56.19.80");
when(ipAddrB.getHostAddress()).thenReturn("216.58.194.196");
when(session1.getRemoteIP()).thenReturn(ipAddrA);
when(session1.getDomainName()).thenReturn("www.gstatic.com");
when(session2.getRemoteIP()).thenReturn(ipAddrA);
when(session2.getDomainName()).thenReturn("ssl.gstatic.com");
when(session3.getRemoteIP()).thenReturn(ipAddrB);
when(session3.getDomainName()).thenReturn("www.arotest.com");
TCPPacket tcpPacket1_1 = mock(TCPPacket.class);
TCPPacket tcpPacket1_2 = mock(TCPPacket.class);
TCPPacket tcpPacket2 = mock(TCPPacket.class);
TCPPacket tcpPacket3 = mock(TCPPacket.class);
when(tcpPacket1_1.containsSSLRecord()).thenReturn(false);
when(tcpPacket1_2.containsSSLRecord()).thenReturn(true);
when(tcpPacket2.containsSSLRecord()).thenReturn(false);
when(tcpPacket3.containsSSLRecord()).thenReturn(true);
PacketInfo packetInfo1_1 = mock(PacketInfo.class);
PacketInfo packetInfo1_2 = mock(PacketInfo.class);
PacketInfo packetInfo2 = mock(PacketInfo.class);
PacketInfo packetInfo3 = mock(PacketInfo.class);
when(packetInfo1_1.getPayloadLen()).thenReturn(1);
when(packetInfo1_1.getPacket()).thenReturn(tcpPacket1_1);
when(packetInfo1_2.getPayloadLen()).thenReturn(1);
when(packetInfo1_2.getPacket()).thenReturn(tcpPacket1_2);
when(packetInfo2.getPayloadLen()).thenReturn(1);
when(packetInfo2.getPacket()).thenReturn(tcpPacket2);
when(packetInfo3.getPayloadLen()).thenReturn(1);
when(packetInfo3.getPacket()).thenReturn(tcpPacket3);
List<PacketInfo> packetsInfo1 = new ArrayList<PacketInfo>();
List<PacketInfo> packetsInfo2 = new ArrayList<PacketInfo>();
List<PacketInfo> packetsInfo3 = new ArrayList<PacketInfo>();
packetsInfo1.add(packetInfo1_1);
packetsInfo1.add(packetInfo1_2);
packetsInfo2.add(packetInfo2);
packetsInfo3.add(packetInfo3);
when(session1.getTcpPackets()).thenReturn(packetsInfo1);
when(session2.getTcpPackets()).thenReturn(packetsInfo2);
when(session3.getTcpPackets()).thenReturn(packetsInfo3);
List<Session> sessions = new ArrayList<Session>();
sessions.add(session1);
sessions.add(session2);
sessions.add(session3);
pktAnalyzerResult.setSessionlist(sessions);
Statistic statistic = new Statistic();
statistic.setTotalByte(123);
statistic.setTotalHTTPSByte(123);
statistic.setTotalHTTPSBytesNotAnalyzed(123);
pktAnalyzerResult.setStatistic(statistic);
httpsUsageResult = (HttpsUsageResult) httpsUsageImpl.runTest(pktAnalyzerResult);
httpsUsageEntries = httpsUsageResult.getResults();
assertEquals(1, httpsUsageEntries.size());
assertEquals("gstatic.com", httpsUsageEntries.get(0).getParentDomainName());
}
use of com.att.aro.core.packetreader.pojo.TCPPacket in project VideoOptimzer by attdevsupport.
the class ForwardSecrecyImplTest method getPacketAnalyzerResult.
private PacketAnalyzerResult getPacketAnalyzerResult(String cipherSuite) {
Session session = mock(Session.class);
PacketInfo info = mock(PacketInfo.class);
TCPPacket tcpPacket = mock(TCPPacket.class);
InetAddress address = mock(InetAddress.class);
String ipAddress = "127.0.0.1";
int port = 8080;
List<Session> sessions = new ArrayList<>();
sessions.add(session);
List<PacketInfo> packetInfos = new LinkedList<>();
packetInfos.add(info);
packetAnalyzerResult.setSessionlist(sessions);
when(session.getTcpPackets()).thenReturn(packetInfos);
when(info.getPacket()).thenReturn(tcpPacket);
when(tcpPacket.getSelectedCipherSuite()).thenReturn(cipherSuite);
when(address.getHostAddress()).thenReturn(ipAddress);
when(session.getRemoteIP()).thenReturn(address);
when(session.getRemotePort()).thenReturn(port);
return packetAnalyzerResult;
}
use of com.att.aro.core.packetreader.pojo.TCPPacket in project VideoOptimzer by attdevsupport.
the class HttpsUsageImplTest method sessionPacketsPayloadTestSetup.
private PacketAnalyzerResult sessionPacketsPayloadTestSetup(int payloadSize1, int payloadSize2, int payloadSize3, int payloadSize4) {
Session session1 = mock(Session.class);
Session session2 = mock(Session.class);
Session session3 = mock(Session.class);
InetAddress ipAddrA = mock(InetAddress.class);
InetAddress ipAddrB = mock(InetAddress.class);
InetAddress ipAddrC = mock(InetAddress.class);
when(ipAddrA.getHostAddress()).thenReturn("157.56.19.80");
when(ipAddrB.getHostAddress()).thenReturn("216.58.194.196");
when(ipAddrC.getHostAddress()).thenReturn("216.58.194.198");
when(session1.getRemoteIP()).thenReturn(ipAddrA);
when(session1.getDomainName()).thenReturn("www.gstatic.com");
when(session2.getRemoteIP()).thenReturn(ipAddrB);
when(session2.getDomainName()).thenReturn("ssl.gstatic.com");
when(session3.getRemoteIP()).thenReturn(ipAddrC);
when(session3.getDomainName()).thenReturn("www.arotest.com");
TCPPacket tcpPacket1_1 = mock(TCPPacket.class);
TCPPacket tcpPacket1_2 = mock(TCPPacket.class);
TCPPacket tcpPacket2 = mock(TCPPacket.class);
TCPPacket tcpPacket3 = mock(TCPPacket.class);
when(tcpPacket1_1.containsSSLRecord()).thenReturn(false);
when(tcpPacket1_2.containsSSLRecord()).thenReturn(false);
when(tcpPacket2.containsSSLRecord()).thenReturn(false);
when(tcpPacket3.containsSSLRecord()).thenReturn(true);
PacketInfo packetInfo1_1 = mock(PacketInfo.class);
PacketInfo packetInfo1_2 = mock(PacketInfo.class);
PacketInfo packetInfo2 = mock(PacketInfo.class);
PacketInfo packetInfo3 = mock(PacketInfo.class);
when(packetInfo1_1.getPayloadLen()).thenReturn(payloadSize1);
when(packetInfo1_1.getPacket()).thenReturn(tcpPacket1_1);
when(packetInfo1_2.getPayloadLen()).thenReturn(payloadSize2);
when(packetInfo1_2.getPacket()).thenReturn(tcpPacket1_2);
when(packetInfo2.getPayloadLen()).thenReturn(payloadSize3);
when(packetInfo2.getPacket()).thenReturn(tcpPacket2);
when(packetInfo3.getPayloadLen()).thenReturn(payloadSize4);
when(packetInfo3.getPacket()).thenReturn(tcpPacket3);
List<PacketInfo> packetsInfo1 = new ArrayList<PacketInfo>();
List<PacketInfo> packetsInfo2 = new ArrayList<PacketInfo>();
List<PacketInfo> packetsInfo3 = new ArrayList<PacketInfo>();
packetsInfo1.add(packetInfo1_1);
packetsInfo1.add(packetInfo1_2);
packetsInfo2.add(packetInfo2);
packetsInfo3.add(packetInfo3);
when(session1.getTcpPackets()).thenReturn(packetsInfo1);
when(session2.getTcpPackets()).thenReturn(packetsInfo2);
when(session3.getTcpPackets()).thenReturn(packetsInfo3);
List<Session> sessions = new ArrayList<Session>();
sessions.add(session1);
sessions.add(session2);
sessions.add(session3);
Statistic statistic = new Statistic();
statistic.setTotalByte(123);
statistic.setTotalHTTPSByte(123);
statistic.setTotalHTTPSBytesNotAnalyzed(123);
pktAnalyzerResult.setStatistic(statistic);
pktAnalyzerResult.setSessionlist(sessions);
return pktAnalyzerResult;
}
Aggregations