Search in sources :

Example 21 with AnalysisFilter

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

the class GraphPanel method filterFlowTable.

// In 4.1.1, the method called refreshGraph()
public void filterFlowTable() {
    AROTraceData filteredSessionTraceData = getTraceData();
    double filteredStartTime = 0.0;
    double filteredEndTime = 0.0;
    double filteredDuration = filteredSessionTraceData.getAnalyzerResult().getTraceresult().getTraceDuration();
    List<Session> tcpsessionsList = new ArrayList<Session>();
    if (getTraceData() == null) {
        return;
    } else {
        TCPUDPFlowsTableModel model = (TCPUDPFlowsTableModel) parent.getJTCPFlowsTable().getModel();
        Map<String, Session> subSessionMap = model.getSessionMap();
        Map<String, Boolean> subcheckboxMap = model.getCheckboxMap();
        for (Map.Entry<String, Boolean> entry : subcheckboxMap.entrySet()) {
            if (entry.getValue()) {
                tcpsessionsList.add(subSessionMap.get(entry.getKey()));
            }
        }
        filteredSessionTraceData.getAnalyzerResult().setSessionlist(tcpsessionsList);
    }
    List<PacketInfo> packetsForSelectedSession = new ArrayList<PacketInfo>();
    for (Session tcpSession : tcpsessionsList) {
        if (tcpSession.getTcpPackets() != null) {
            packetsForSelectedSession.addAll(tcpSession.getTcpPackets());
        }
    }
    // when generating graph, make sure session is ordered by time stamp
    Collections.sort(packetsForSelectedSession, new Comparator<PacketInfo>() {

        @Override
        public int compare(PacketInfo p1, PacketInfo p2) {
            return (int) (p1.getTimeStamp() * 1000 - p2.getTimeStamp() * 1000);
        }
    });
    boolean selectedAllPackets = false;
    // Adding the TCP packets to the trace for getting redoing the analysis
    if (packetsForSelectedSession.size() > 0) {
        if (tcpsessionsList.size() == getAllTcpSessions()) {
            // For select all use all exiting packets
            filteredSessionTraceData.getAnalyzerResult().getTraceresult().setAllpackets(getAllPackets());
            selectedAllPackets = true;
        } else {
            // Collections.sort(packetsForSelectedSession);//?
            filteredSessionTraceData.getAnalyzerResult().getTraceresult().setAllpackets(packetsForSelectedSession);
        }
    }
    if (selectedAllPackets) {
        filteredStartTime = -0.01;
        filteredEndTime = filteredDuration;
    } else {
        int index = 0;
        for (Session tcpSession : tcpsessionsList) {
            if (tcpSession.getTcpPackets().size() != 0) {
                if (index == 0) {
                    filteredStartTime = tcpSession.getTcpPackets().get(0).getTimeStamp();
                    filteredEndTime = tcpSession.getTcpPackets().get(0).getTimeStamp();
                }
                if (filteredStartTime > tcpSession.getTcpPackets().get(0).getTimeStamp()) {
                    filteredStartTime = tcpSession.getTcpPackets().get(0).getTimeStamp();
                }
                if (filteredEndTime < tcpSession.getTcpPackets().get(0).getTimeStamp()) {
                    filteredEndTime = tcpSession.getTcpPackets().get(0).getTimeStamp();
                }
                index++;
            }
        }
        if (index == 0) {
            filteredStartTime = 0.0;
            filteredEndTime = 0.0;
        }
    }
    // for Analysis data particular time of the graph, some number is not clear..
    if (filteredStartTime > 0) {
        // adjust the time line axis number
        filteredStartTime = filteredStartTime - 2;
        if (filteredStartTime < 0) {
            filteredStartTime = -0.01;
        }
    }
    if (filteredStartTime < 0) {
        filteredStartTime = -0.01;
    }
    if (!selectedAllPackets) {
        if (filteredEndTime > 0) {
            // adjust the time line axis number
            filteredEndTime = filteredEndTime + 15;
        }
        if (filteredEndTime > filteredDuration) {
            filteredEndTime = filteredDuration;
        }
    }
    this.startTime = filteredStartTime;
    this.endTime = filteredEndTime;
    if (getTraceData() != null) {
        TimeRange timeRange = new TimeRange(filteredStartTime, filteredEndTime);
        AnalysisFilter filter = filteredSessionTraceData.getAnalyzerResult().getFilter();
        filter.setTimeRange(timeRange);
        filteredSessionTraceData.getAnalyzerResult().setFilter(filter);
        Statistic stat = ContextAware.getAROConfigContext().getBean(IPacketAnalyzer.class).getStatistic(packetsForSelectedSession);
        long totaltemp = 0;
        for (Session byteCountSession : tcpsessionsList) {
            totaltemp += byteCountSession.getBytesTransferred();
        }
        stat.setTotalByte(totaltemp);
        AbstractRrcStateMachine statemachine = ContextAware.getAROConfigContext().getBean(IRrcStateMachineFactory.class).create(packetsForSelectedSession, filteredSessionTraceData.getAnalyzerResult().getProfile(), stat.getPacketDuration(), filteredDuration, stat.getTotalByte(), timeRange);
        BurstCollectionAnalysisData burstcollectiondata = new BurstCollectionAnalysisData();
        if (stat.getTotalByte() > 0) {
            burstcollectiondata = ContextAware.getAROConfigContext().getBean(IBurstCollectionAnalysis.class).analyze(packetsForSelectedSession, filteredSessionTraceData.getAnalyzerResult().getProfile(), stat.getPacketSizeToCountMap(), statemachine.getStaterangelist(), filteredSessionTraceData.getAnalyzerResult().getTraceresult().getUserEvents(), filteredSessionTraceData.getAnalyzerResult().getTraceresult().getCpuActivityList().getCpuActivities(), tcpsessionsList);
        }
        filteredSessionTraceData.getAnalyzerResult().getStatistic().setTotalByte(stat.getTotalByte());
        filteredSessionTraceData.getAnalyzerResult().setStatemachine(statemachine);
        filteredSessionTraceData.getAnalyzerResult().setBurstCollectionAnalysisData(burstcollectiondata);
        refresh(filteredSessionTraceData);
    }
}
Also used : TCPUDPFlowsTableModel(com.att.aro.ui.model.diagnostic.TCPUDPFlowsTableModel) AnalysisFilter(com.att.aro.core.packetanalysis.pojo.AnalysisFilter) ArrayList(java.util.ArrayList) Statistic(com.att.aro.core.packetanalysis.pojo.Statistic) AbstractRrcStateMachine(com.att.aro.core.packetanalysis.pojo.AbstractRrcStateMachine) IPacketAnalyzer(com.att.aro.core.packetanalysis.IPacketAnalyzer) AROTraceData(com.att.aro.core.pojo.AROTraceData) Point(java.awt.Point) TimeRange(com.att.aro.core.packetanalysis.pojo.TimeRange) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) BurstCollectionAnalysisData(com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData) Map(java.util.Map) EnumMap(java.util.EnumMap) TreeMap(java.util.TreeMap) IRrcStateMachineFactory(com.att.aro.core.packetanalysis.IRrcStateMachineFactory) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 22 with AnalysisFilter

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

the class PacketAnalyzerImplTest method Test_analyzeTraceFile_returnIsPacketAnalyzerResult.

@Test
@Ignore
public void Test_analyzeTraceFile_returnIsPacketAnalyzerResult() throws Exception {
    iPacketAnalyzer.setProfileFactory(profilefactory);
    InetAddress iAdr = Mockito.mock(InetAddress.class);
    InetAddress iAdr1 = Mockito.mock(InetAddress.class);
    Mockito.when(iAdr.getAddress()).thenReturn(new byte[] { 89, 10, 1, 1 });
    Mockito.when(iAdr1.getAddress()).thenReturn(new byte[] { 72, 12, 13, 1 });
    Set<InetAddress> inetSet = new HashSet<InetAddress>();
    inetSet.add(iAdr);
    inetSet.add(iAdr1);
    DomainNameSystem dns = Mockito.mock(DomainNameSystem.class);
    Mockito.when(dns.getIpAddresses()).thenReturn(inetSet);
    Mockito.when(dns.getDomainName()).thenReturn("www.att.com");
    UDPPacket udpPacket = Mockito.mock(UDPPacket.class);
    Mockito.when(udpPacket.isDNSPacket()).thenReturn(true);
    Mockito.when(udpPacket.getDns()).thenReturn(dns);
    Mockito.when(udpPacket.getSourcePort()).thenReturn(83);
    Mockito.when(udpPacket.getDestinationPort()).thenReturn(84);
    Mockito.when(udpPacket.getDestinationIPAddress()).thenReturn(iAdr);
    PacketInfo packetInfo1 = Mockito.mock(PacketInfo.class);
    Mockito.when(packetInfo1.getPacket()).thenReturn(udpPacket);
    Mockito.when(packetInfo1.getDir()).thenReturn(PacketDirection.UPLINK);
    Mockito.when(packetInfo1.getPayloadLen()).thenReturn(0);
    Mockito.when(packetInfo1.getLen()).thenReturn(10);
    Mockito.when(packetInfo1.getAppName()).thenReturn("Test1");
    Mockito.when(packetInfo1.getTcpFlagString()).thenReturn("TestString");
    Mockito.when(packetInfo1.getTimeStamp()).thenReturn(500d);
    InetAddress iAdr2 = Mockito.mock(InetAddress.class);
    Mockito.when(iAdr2.getAddress()).thenReturn(new byte[] { 95, 10, 1, 1 });
    TCPPacket tcpPacket = Mockito.mock(TCPPacket.class);
    Mockito.when(tcpPacket.getSourcePort()).thenReturn(81);
    Mockito.when(tcpPacket.getDestinationPort()).thenReturn(82);
    Mockito.when(tcpPacket.getDestinationIPAddress()).thenReturn(iAdr2);
    Mockito.when(tcpPacket.isSYN()).thenReturn(true);
    Mockito.when(tcpPacket.isFIN()).thenReturn(true);
    Mockito.when(tcpPacket.isRST()).thenReturn(true);
    Mockito.when(tcpPacket.getTimeStamp()).thenReturn(1000d);
    PacketInfo packetInfo2 = Mockito.mock(PacketInfo.class);
    Mockito.when(packetInfo2.getPacket()).thenReturn(tcpPacket);
    Mockito.when(packetInfo2.getDir()).thenReturn(PacketDirection.UPLINK);
    Mockito.when(packetInfo2.getTcpInfo()).thenReturn(TcpInfo.TCP_ESTABLISH);
    Mockito.when(packetInfo2.getPayloadLen()).thenReturn(0);
    Mockito.when(packetInfo2.getLen()).thenReturn(15);
    Mockito.when(packetInfo2.getAppName()).thenReturn("Test2");
    Mockito.when(packetInfo2.getTcpFlagString()).thenReturn("Test2String");
    Mockito.when(packetInfo2.getTimeStamp()).thenReturn(10d);
    TCPPacket tcpPacket2 = Mockito.mock(TCPPacket.class);
    Mockito.when(tcpPacket2.getSourcePort()).thenReturn(95);
    Mockito.when(tcpPacket2.getDestinationPort()).thenReturn(99);
    Mockito.when(tcpPacket2.getDestinationIPAddress()).thenReturn(iAdr2);
    Mockito.when(tcpPacket2.isSYN()).thenReturn(true);
    Mockito.when(tcpPacket2.isFIN()).thenReturn(true);
    Mockito.when(tcpPacket2.isRST()).thenReturn(false);
    Mockito.when(tcpPacket2.getTimeStamp()).thenReturn(50d);
    Inet4Address address = (Inet4Address) InetAddress.getByName("192.168.1.4");
    PacketInfo packetInfo3 = Mockito.mock(PacketInfo.class);
    Mockito.when(packetInfo3.getPacket()).thenReturn(tcpPacket2);
    Mockito.when(packetInfo3.getDir()).thenReturn(PacketDirection.UPLINK);
    Mockito.when(packetInfo3.getTcpInfo()).thenReturn(TcpInfo.TCP_ESTABLISH);
    Mockito.when(packetInfo3.getPayloadLen()).thenReturn(0);
    Mockito.when(packetInfo3.getLen()).thenReturn(15);
    Mockito.when(packetInfo3.getAppName()).thenReturn("Test2");
    Mockito.when(packetInfo3.getTcpFlagString()).thenReturn("Test2String");
    Mockito.when(packetInfo3.getTimeStamp()).thenReturn(10d);
    Mockito.when(packetInfo3.getRemoteIPAddress()).thenReturn(address);
    List<PacketInfo> packetsList = new ArrayList<PacketInfo>();
    // Adding UDP Packet to the list
    packetsList.add(packetInfo1);
    packetsList.add(packetInfo2);
    packetsList.add(packetInfo3);
    TraceFileResult mockTraceResult = mock(TraceFileResult.class);
    List<PacketInfo> filteredPackets = new ArrayList<PacketInfo>();
    filteredPackets.add(mock(PacketInfo.class));
    when(mockTraceResult.getAllpackets()).thenReturn(packetsList);
    CpuActivityList cpuList = new CpuActivityList();
    cpuList.add(new CpuActivity());
    when(mockTraceResult.getCpuActivityList()).thenReturn(cpuList);
    when(tracereader.readTraceFile(any(String.class))).thenReturn(mockTraceResult);
    when(mockTraceResult.getTraceResultType()).thenReturn(TraceResultType.TRACE_FILE);
    ProfileLTE profileLTE = new ProfileLTE();
    when(profilefactory.createLTEdefault()).thenReturn(profileLTE);
    AnalysisFilter filter = mock(AnalysisFilter.class);
    filter.setIpv4Sel(false);
    filter.setIpv6Sel(false);
    filter.setUdpSel(false);
    iPacketAnalyzer.setEnergyModelFactory(energymodelfactory);
    iPacketAnalyzer.setBurstCollectionAnalayzer(burstcollectionanalyzer);
    iPacketAnalyzer.setRrcStateMachineFactory(statemachinefactory);
    RrcStateMachineLTE rrcstate = mock(RrcStateMachineLTE.class);
    EnergyModel energymodel = mock(EnergyModel.class);
    List<RrcStateRange> rrcstatelist = new ArrayList<RrcStateRange>();
    when(statemachinefactory.create(any(List.class), any(Profile.class), any(double.class), any(double.class), any(double.class), any(TimeRange.class))).thenReturn(rrcstate);
    when(rrcstate.getStaterangelist()).thenReturn(rrcstatelist);
    when(rrcstate.getTotalRRCEnergy()).thenReturn(1.0);
    when(energymodelfactory.create(any(Profile.class), any(double.class), any(List.class), any(List.class), any(List.class), any(List.class))).thenReturn(energymodel);
    BurstCollectionAnalysisData burstvalue = mock(BurstCollectionAnalysisData.class);
    when(burstcollectionanalyzer.analyze(any(List.class), any(Profile.class), any(Map.class), any(List.class), any(List.class), any(List.class), any(List.class))).thenReturn(burstvalue);
    // when(pktTimeUtil.getTimeRangeResult(any(AbstractTraceResult.class), any(AnalysisFilter.class)))
    // .thenReturn(value);
    PacketAnalyzerResult testResult = iPacketAnalyzer.analyzeTraceFile("", null, filter);
    assertSame(false, testResult.getFilter().isIpv4Sel());
}
Also used : CpuActivityList(com.att.aro.core.peripheral.pojo.CpuActivityList) DomainNameSystem(com.att.aro.core.packetreader.pojo.DomainNameSystem) AnalysisFilter(com.att.aro.core.packetanalysis.pojo.AnalysisFilter) ArrayList(java.util.ArrayList) RrcStateRange(com.att.aro.core.packetanalysis.pojo.RrcStateRange) ProfileLTE(com.att.aro.core.configuration.pojo.ProfileLTE) UDPPacket(com.att.aro.core.packetreader.pojo.UDPPacket) Profile(com.att.aro.core.configuration.pojo.Profile) RrcStateMachineLTE(com.att.aro.core.packetanalysis.pojo.RrcStateMachineLTE) List(java.util.List) CpuActivityList(com.att.aro.core.peripheral.pojo.CpuActivityList) ArrayList(java.util.ArrayList) CpuActivity(com.att.aro.core.peripheral.pojo.CpuActivity) HashSet(java.util.HashSet) Inet4Address(java.net.Inet4Address) EnergyModel(com.att.aro.core.packetanalysis.pojo.EnergyModel) TimeRange(com.att.aro.core.packetanalysis.pojo.TimeRange) TCPPacket(com.att.aro.core.packetreader.pojo.TCPPacket) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) BurstCollectionAnalysisData(com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) InetAddress(java.net.InetAddress) TraceFileResult(com.att.aro.core.packetanalysis.pojo.TraceFileResult) Map(java.util.Map) Ignore(org.junit.Ignore) BaseTest(com.att.aro.core.BaseTest) Test(org.junit.Test)

Example 23 with AnalysisFilter

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

the class PacketAnalyzerImplTest method Test_analyzeTraceDirectory_returnIsPacketAnalyzerResult.

@Test
public void Test_analyzeTraceDirectory_returnIsPacketAnalyzerResult() throws Exception {
    iPacketAnalyzer.setEnergyModelFactory(energymodelfactory);
    iPacketAnalyzer.setBurstCollectionAnalayzer(burstcollectionanalyzer);
    iPacketAnalyzer.setRrcStateMachineFactory(statemachinefactory);
    iPacketAnalyzer.setProfileFactory(profilefactory);
    TraceDirectoryResult mockTraceDirResult = mock(TraceDirectoryResult.class);
    MetaDataHelper metaDataHelper = mock(MetaDataHelper.class);
    MetaDataModel metaDataModel = new MetaDataModel();
    AnalysisFilter filter = mock(AnalysisFilter.class);
    filter.setIpv4Sel(true);
    filter.setIpv6Sel(true);
    filter.setUdpSel(true);
    CpuActivityList cpuList = new CpuActivityList();
    cpuList.add(new CpuActivity());
    when(mockTraceDirResult.getCpuActivityList()).thenReturn(cpuList);
    when(tracereader.readTraceDirectory(any(String.class))).thenReturn(mockTraceDirResult);
    when(metaDataHelper.initMetaData(any(PacketAnalyzerResult.class))).thenReturn(metaDataModel);
    ProfileLTE profileLTE = new ProfileLTE();
    when(profilefactory.createLTEdefault()).thenReturn(profileLTE);
    PacketAnalyzerResult testResult = iPacketAnalyzer.analyzeTraceDirectory("", profileLTE, filter);
    assertEquals(null, testResult.getSessionlist());
}
Also used : CpuActivityList(com.att.aro.core.peripheral.pojo.CpuActivityList) AnalysisFilter(com.att.aro.core.packetanalysis.pojo.AnalysisFilter) MetaDataModel(com.att.aro.core.tracemetadata.pojo.MetaDataModel) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) MetaDataHelper(com.att.aro.core.tracemetadata.impl.MetaDataHelper) ProfileLTE(com.att.aro.core.configuration.pojo.ProfileLTE) CpuActivity(com.att.aro.core.peripheral.pojo.CpuActivity) BaseTest(com.att.aro.core.BaseTest) Test(org.junit.Test)

Aggregations

AnalysisFilter (com.att.aro.core.packetanalysis.pojo.AnalysisFilter)23 TimeRange (com.att.aro.core.packetanalysis.pojo.TimeRange)8 ApplicationSelection (com.att.aro.core.packetanalysis.pojo.ApplicationSelection)6 HashMap (java.util.HashMap)5 MainFrame (com.att.aro.ui.view.MainFrame)4 ArrayList (java.util.ArrayList)4 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)3 Session (com.att.aro.core.packetanalysis.pojo.Session)3 Statistic (com.att.aro.core.packetanalysis.pojo.Statistic)3 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)3 ActionEvent (java.awt.event.ActionEvent)3 ActionListener (java.awt.event.ActionListener)3 InetAddress (java.net.InetAddress)3 Map (java.util.Map)3 JButton (javax.swing.JButton)3 BaseTest (com.att.aro.core.BaseTest)2 Profile (com.att.aro.core.configuration.pojo.Profile)2 ProfileLTE (com.att.aro.core.configuration.pojo.ProfileLTE)2 TimeRangeAnalysis (com.att.aro.core.packetanalysis.impl.TimeRangeAnalysis)2 BurstCollectionAnalysisData (com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData)2