Search in sources :

Example 31 with RrcStateRange

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

the class RrcStateRangeFactoryImpl method createLTE.

/**
 * This method contains the main algorithm for creating the List of
 * RrcStateRange for a LTE profile
 *
 * @param analysisData
 *            Analysis data
 * @param profile
 *            LTE profile
 * @return list of RRC State range values.
 */
private List<RrcStateRange> createLTE(List<PacketInfo> packetlist, ProfileLTE profile, double traceDuration) {
    // Create results list
    ArrayList<RrcStateRange> result = new ArrayList<RrcStateRange>();
    // Iterate through packets in trace
    if (packetlist == null) {
        result.add(new RrcStateRange(0.0, traceDuration, RRCState.LTE_IDLE));
        return result;
    }
    Iterator<PacketInfo> iter = packetlist.iterator();
    PacketInfo packet;
    if (iter.hasNext()) {
        // Track time of state changes
        double timer = 0.0;
        // Keep timestamp of previous packet in iteration
        packet = iter.next();
        packet.setStateMachine(RRCState.LTE_CONTINUOUS);
        double last = packet.getTimeStamp();
        // First packet starts continuous reception
        timer = promoteLTE(result, timer, last, profile);
        while (iter.hasNext()) {
            packet = iter.next();
            packet.setStateMachine(RRCState.LTE_CONTINUOUS);
            double curr = packet.getTimeStamp();
            // Check to see if we dropped to CR tail
            if (curr - last > profile.getInactivityTimer()) {
                timer = tailLTE(result, timer, last, curr, profile);
                // packet
                if (timer < curr) {
                    timer = promoteLTE(result, timer, curr, profile);
                }
            }
            // Save current packet time as last packet for next iteration
            last = curr;
        }
        // Do final LTE tail
        timer = tailLTE(result, timer, last, traceDuration, profile);
        // Check for final idle time
        if (timer < traceDuration) {
            result.add(new RrcStateRange(timer, traceDuration, RRCState.LTE_IDLE));
        }
    } else {
        // State is idle for the entire trace
        result.add(new RrcStateRange(0.0, traceDuration, RRCState.LTE_IDLE));
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) RrcStateRange(com.att.aro.core.packetanalysis.pojo.RrcStateRange) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo)

Example 32 with RrcStateRange

use of com.att.aro.core.packetanalysis.pojo.RrcStateRange 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 33 with RrcStateRange

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

the class RrcStateRangeFactoryImplTest method create_WIFIIsIdleTrace.

@Test
public void create_WIFIIsIdleTrace() {
    ProfileWiFi profile04 = mock(ProfileWiFi.class);
    when(profile04.getProfileType()).thenReturn(ProfileType.WIFI);
    List<PacketInfo> packetlist1 = new ArrayList<PacketInfo>();
    double traceDuration = 2000.0;
    List<RrcStateRange> testList = rrcStateRangeFactory.create(packetlist1, profile04, traceDuration);
    assertEquals(1, testList.size());
}
Also used : ArrayList(java.util.ArrayList) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) RrcStateRange(com.att.aro.core.packetanalysis.pojo.RrcStateRange) ProfileWiFi(com.att.aro.core.configuration.pojo.ProfileWiFi) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 34 with RrcStateRange

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

the class RrcStateRangeFactoryImplTest method create_ProfileIsWifi.

@Test
public void create_ProfileIsWifi() {
    ProfileWiFi profile03 = mock(ProfileWiFi.class);
    when(profile03.getProfileType()).thenReturn(ProfileType.WIFI);
    List<PacketInfo> packetlist = new ArrayList<PacketInfo>();
    double traceDuration = 1000.0;
    when(profile03.getWifiTailTime()).thenReturn(1500.0);
    when(pktInfoArray[0].getTimeStamp()).thenReturn(date.getTime() - 1500.0);
    when(pktInfoArray[1].getTimeStamp()).thenReturn(date.getTime() - 500.0);
    when(pktInfoArray[2].getTimeStamp()).thenReturn(date.getTime() + 500.0);
    when(pktInfoArray[3].getTimeStamp()).thenReturn(date.getTime() + 1500.0);
    when(pktInfoArray[4].getTimeStamp()).thenReturn(date.getTime() + 2505.0);
    when(pktInfoArray[5].getTimeStamp()).thenReturn(date.getTime() + 3500.0);
    when(pktInfoArray[6].getTimeStamp()).thenReturn(date.getTime() + 4501.0);
    when(pktInfoArray[7].getTimeStamp()).thenReturn(date.getTime() + 5001.0);
    when(pktInfoArray[8].getTimeStamp()).thenReturn(date.getTime() + 6001.0);
    when(pktInfoArray[9].getTimeStamp()).thenReturn(date.getTime() + 6501.0);
    when(pktInfoArray[10].getTimeStamp()).thenReturn(date.getTime() + 7001.0);
    when(pktInfoArray[11].getTimeStamp()).thenReturn(date.getTime() + 9000.0);
    when(pktInfoArray[12].getTimeStamp()).thenReturn(date.getTime() + 9900.0);
    when(pktInfoArray[13].getTimeStamp()).thenReturn(date.getTime() + 15500.0);
    when(pktInfoArray[14].getTimeStamp()).thenReturn(date.getTime() + 25005.0);
    when(pktInfoArray[15].getTimeStamp()).thenReturn(date.getTime() + 36500.0);
    when(pktInfoArray[16].getTimeStamp()).thenReturn(date.getTime() + 47501.0);
    when(pktInfoArray[17].getTimeStamp()).thenReturn(date.getTime() + 57601.0);
    when(pktInfoArray[18].getTimeStamp()).thenReturn(date.getTime() + 107001.0);
    when(pktInfoArray[19].getTimeStamp()).thenReturn(date.getTime() + 216001.0);
    for (int i = 0; i < 20; i++) {
        packetlist.add(pktInfoArray[i]);
    }
    List<RrcStateRange> testList = rrcStateRangeFactory.create(packetlist, profile03, traceDuration);
    assertEquals(26, testList.size());
}
Also used : ArrayList(java.util.ArrayList) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) RrcStateRange(com.att.aro.core.packetanalysis.pojo.RrcStateRange) ProfileWiFi(com.att.aro.core.configuration.pojo.ProfileWiFi) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 35 with RrcStateRange

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

the class RrcStateRangeFactoryImplTest method create3G_test3.

@Test
public void create3G_test3() {
    Profile3G profile3g = mock(Profile3G.class);
    when(profile3g.getProfileType()).thenReturn(ProfileType.T3G);
    when(profile3g.getIdleDchPromoAvg()).thenReturn(1000.0);
    when(profile3g.getIdleDchPromoMin()).thenReturn((double) date.getTime());
    when(profile3g.getIdleDchPromoMax()).thenReturn(1500.0);
    when(profile3g.getFachDchPromoAvg()).thenReturn(1000.0);
    when(profile3g.getFachDchPromoMin()).thenReturn(1000.0);
    when(profile3g.getFachDchPromoMax()).thenReturn(1000.0);
    when(profile3g.getDchFachTimer()).thenReturn(1000.0);
    when(profile3g.getFachIdleTimer()).thenReturn(1000.0);
    double traceDuration = 2000.0;
    List<PacketInfo> packetlist = new ArrayList<PacketInfo>();
    when(pktInfoArray[0].getTimeStamp()).thenReturn(date.getTime() - 1500.0);
    when(pktInfoArray[0].getDir()).thenReturn(PacketDirection.DOWNLINK);
    when(pktInfoArray[0].getLen()).thenReturn(1000);
    when(pktInfoArray[0].getStateMachine()).thenReturn(RRCState.PROMO_IDLE_DCH);
    packetlist.add(pktInfoArray[0]);
    when(pktInfoArray[1].getTimeStamp()).thenReturn(date.getTime() + 100.0);
    when(pktInfoArray[1].getDir()).thenReturn(PacketDirection.UPLINK);
    when(pktInfoArray[1].getLen()).thenReturn(1000);
    when(pktInfoArray[1].getStateMachine()).thenReturn(RRCState.PROMO_IDLE_DCH);
    packetlist.add(pktInfoArray[1]);
    List<RrcStateRange> testList = rrcStateRangeFactory.create(packetlist, profile3g, traceDuration);
    assertEquals(1, testList.size());
}
Also used : ArrayList(java.util.ArrayList) Profile3G(com.att.aro.core.configuration.pojo.Profile3G) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) RrcStateRange(com.att.aro.core.packetanalysis.pojo.RrcStateRange) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Aggregations

RrcStateRange (com.att.aro.core.packetanalysis.pojo.RrcStateRange)59 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)48 ArrayList (java.util.ArrayList)47 BaseTest (com.att.aro.core.BaseTest)42 Test (org.junit.Test)42 Profile3G (com.att.aro.core.configuration.pojo.Profile3G)27 Profile (com.att.aro.core.configuration.pojo.Profile)23 RRCState (com.att.aro.core.packetanalysis.pojo.RRCState)22 ProfileLTE (com.att.aro.core.configuration.pojo.ProfileLTE)12 ProfileWiFi (com.att.aro.core.configuration.pojo.ProfileWiFi)9 RrcStateMachine3G (com.att.aro.core.packetanalysis.pojo.RrcStateMachine3G)9 RrcStateMachineLTE (com.att.aro.core.packetanalysis.pojo.RrcStateMachineLTE)9 TCPPacket (com.att.aro.core.packetreader.pojo.TCPPacket)5 UDPPacket (com.att.aro.core.packetreader.pojo.UDPPacket)5 BurstCollectionAnalysisData (com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData)4 RrcStateMachineWiFi (com.att.aro.core.packetanalysis.pojo.RrcStateMachineWiFi)4 DomainNameSystem (com.att.aro.core.packetreader.pojo.DomainNameSystem)4 CpuActivity (com.att.aro.core.peripheral.pojo.CpuActivity)4 InetAddress (java.net.InetAddress)4 HashSet (java.util.HashSet)4