use of com.att.aro.core.peripheral.pojo.CpuActivity in project VideoOptimzer by attdevsupport.
the class CpuPlot method populate.
@Override
public void populate(XYPlot plot, AROTraceData analysis) {
XYSeries series = new XYSeries(0);
if (analysis == null) {
LOGGER.info("didn't get analysis trace data!");
} else {
TraceResultType resultType = analysis.getAnalyzerResult().getTraceresult().getTraceResultType();
if (resultType.equals(TraceResultType.TRACE_FILE)) {
LOGGER.info("didn't get analysis trace folder!");
} else {
TraceDirectoryResult traceresult = (TraceDirectoryResult) analysis.getAnalyzerResult().getTraceresult();
cpuAList = traceresult.getCpuActivityList();
boolean filterByTime = cpuAList.isFilterByTime();
double beginTime = 0;
double endTime = 0;
if (filterByTime) {
beginTime = cpuAList.getBeginTraceTime();
endTime = cpuAList.getEndTraceTime();
}
cpuData = cpuAList.getCpuActivities();
LOGGER.debug("Size of CPU data: " + cpuData.size());
if (cpuData.size() > 0) {
for (CpuActivity cpu : cpuData) {
if (filterByTime) {
// logger.debug("timestamp: {0}" + cpu.getTimeStamp());
if (cpu.getTimeStamp() >= beginTime && cpu.getTimeStamp() <= endTime) {
// logger.debug("CPU usage: {0}"+ cpu.getCpuUsageTotalFiltered());
series.add(cpu.getTimeStamp(), cpu.getCpuUsageTotalFiltered());
}
} else {
// logger.debug("CPU usage: {0}"+ cpu.getCpuUsageTotalFiltered());
series.add(cpu.getTimeStamp(), cpu.getCpuUsageTotalFiltered());
}
}
}
// Assign ToolTip to renderer
XYItemRenderer renderer = plot.getRenderer();
renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {
@Override
public String generateToolTip(XYDataset dataset, int series, int item) {
return constructCpuToolTipText(cpuAList, cpuData, item);
}
});
}
}
plot.setDataset(new XYSeriesCollection(series));
// return plot;
}
use of com.att.aro.core.peripheral.pojo.CpuActivity in project VideoOptimzer by attdevsupport.
the class BurstCollectionAnalysisImpl method analyzeBursts.
/**
* Assigns burst category to each burst in a collection of bursts.
* The collection of bursts have been populated prior to this API call.
*/
private int analyzeBursts(List<Burst> burstCollection, List<UserEvent> userEvents, List<CpuActivity> cpuEvents, Profile profile) {
int userEventsSize = userEvents.size();
int cpuEventsSize = cpuEvents.size();
int userEventPointer = 0;
int cpuPointer = 0;
int longBurstCount = 0;
// Analyze each burst
Burst burst = null;
Burst lastBurst;
for (Iterator<Burst> iterator = burstCollection.iterator(); iterator.hasNext(); ) {
lastBurst = burst;
burst = iterator.next();
List<PacketInfo> burstPacketCollection = new ArrayList<PacketInfo>(burst.getPackets().size());
int burstPayloadLen = 0;
Set<TcpInfo> burstPacketTcpInfo = new HashSet<TcpInfo>();
for (PacketInfo pInfo : burst.getPackets()) {
burstPayloadLen += pInfo.getPayloadLen();
burstPacketCollection.add(pInfo);
TcpInfo tcp = pInfo.getTcpInfo();
if (tcp != null) {
burstPacketTcpInfo.add(tcp);
}
}
PacketInfo pkt0 = null;
TcpInfo info0 = null;
double time0 = 0;
if (!burstPacketCollection.isEmpty()) {
pkt0 = burstPacketCollection.get(0);
info0 = pkt0.getTcpInfo();
time0 = pkt0.getTimeStamp();
}
/*
* Mark the burst as Long Burst based on the
* burst duration and size of the payload.
*/
if (burst.getEndTime() - burst.getBeginTime() > profile.getLargeBurstDuration() && burstPayloadLen > profile.getLargeBurstSize()) {
burst.setBurstInfo(BurstCategory.LONG);
++longBurstCount;
continue;
}
/*
* For bursts with no payload assign burst type based on
* the the type of TCP packets.
*/
if (burstPayloadLen == 0) {
if (burstPacketTcpInfo.contains(TcpInfo.TCP_CLOSE) || burstPacketTcpInfo.contains(TcpInfo.TCP_ESTABLISH) || burstPacketTcpInfo.contains(TcpInfo.TCP_RESET) || burstPacketTcpInfo.contains(TcpInfo.TCP_KEEP_ALIVE) || burstPacketTcpInfo.contains(TcpInfo.TCP_KEEP_ALIVE_ACK) || burstPacketTcpInfo.contains(TcpInfo.TCP_ZERO_WINDOW) || burstPacketTcpInfo.contains(TcpInfo.TCP_WINDOW_UPDATE)) {
burst.setBurstInfo(BurstCategory.TCP_PROTOCOL);
continue;
}
if (info0 == TcpInfo.TCP_ACK_RECOVER || info0 == TcpInfo.TCP_ACK_DUP) {
burst.setBurstInfo(BurstCategory.TCP_LOSS_OR_DUP);
continue;
}
}
if (pkt0 == null) {
continue;
}
// Step 4: Server delay
if (pkt0.getDir() == PacketDirection.DOWNLINK && (info0 == TcpInfo.TCP_DATA || info0 == TcpInfo.TCP_ACK)) {
burst.setBurstInfo(BurstCategory.SERVER_NET_DELAY);
continue;
}
// Step 5: Loss recover
if (info0 == TcpInfo.TCP_ACK_DUP || info0 == TcpInfo.TCP_DATA_DUP) {
burst.setBurstInfo(BurstCategory.TCP_LOSS_OR_DUP);
continue;
}
if (info0 == TcpInfo.TCP_DATA_RECOVER || info0 == TcpInfo.TCP_ACK_RECOVER) {
burst.setBurstInfo(BurstCategory.TCP_LOSS_OR_DUP);
continue;
}
// Step 6: User triggered
final double USER_EVENT_SMALL_TOLERATE = profile.getUserInputTh();
if (burstPayloadLen > 0) {
UserEvent uevent = null;
while ((userEventPointer < userEventsSize) && ((uevent = userEvents.get(userEventPointer)).getReleaseTime() < (time0 - USER_EVENT_TOLERATE))) {
++userEventPointer;
}
BurstCategory userInputBurst = null;
if (uevent != null) {
if (uevent.getEventType() == UserEventType.SCREEN_LANDSCAPE || uevent.getEventType() == UserEventType.SCREEN_PORTRAIT) {
userInputBurst = BurstCategory.SCREEN_ROTATION;
} else {
userInputBurst = BurstCategory.USER_INPUT;
}
}
int userEventCount = userEventPointer;
double minGap = Double.MAX_VALUE;
while (userEventCount < userEventsSize) {
UserEvent uEvent = userEvents.get(userEventCount);
if (withinTolerate(uEvent.getPressTime(), time0)) {
double gap = time0 - uEvent.getPressTime();
if (gap < minGap) {
minGap = gap;
}
}
if (withinTolerate(uEvent.getReleaseTime(), time0)) {
double gap = time0 - uEvent.getReleaseTime();
if (gap < minGap) {
minGap = gap;
}
}
if (uEvent.getPressTime() > time0) {
break;
}
userEventCount++;
}
if (minGap < USER_EVENT_SMALL_TOLERATE) {
burst.setBurstInfo(userInputBurst);
continue;
} else if (minGap < USER_EVENT_TOLERATE && (lastBurst == null || lastBurst.getEndTime() < burst.getBeginTime() - minGap)) {
double cpuBegin = time0 - minGap;
double cpuEnd = time0;
// Check CPU usage
while (cpuPointer < cpuEventsSize) {
double eventTimeStamp = cpuEvents.get(cpuPointer).getTimeStamp();
if (eventTimeStamp < burst.getBeginTime() - USER_EVENT_TOLERATE) {
++cpuPointer;
} else {
break;
}
}
int cpuActivityKey = cpuPointer;
double totalCpuUsage = 0.0f;
int cEventsCount = 0;
while (cpuActivityKey < cpuEventsSize) {
CpuActivity cpuAct = cpuEvents.get(cpuActivityKey);
double caTimeStamp = cpuAct.getTimeStamp();
if (caTimeStamp > cpuBegin && caTimeStamp < cpuEnd) {
totalCpuUsage += cpuAct.getTotalCpuUsage();
cEventsCount++;
}
if (caTimeStamp >= cpuEnd) {
break;
}
cpuActivityKey++;
}
if (cEventsCount > 0 && (totalCpuUsage / cEventsCount) > AVG_CPU_USAGE_THRESHOLD) {
burst.setBurstInfo(BurstCategory.CPU);
continue;
} else {
burst.setBurstInfo(userInputBurst);
continue;
}
}
}
// Step 7: Client delay
if (burstPayloadLen == 0) {
burst.setBurstInfo(BurstCategory.UNKNOWN);
continue;
} else {
burst.setBurstInfo(BurstCategory.CLIENT_APP);
continue;
}
}
return longBurstCount;
}
use of com.att.aro.core.peripheral.pojo.CpuActivity 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());
}
use of com.att.aro.core.peripheral.pojo.CpuActivity 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());
}
use of com.att.aro.core.peripheral.pojo.CpuActivity in project VideoOptimzer by attdevsupport.
the class BurstCollectionAnalysisImplTest method analyze3Test.
@Test
public void analyze3Test() {
// Date date = new Date();
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");
// UDP Packet Mock
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);
// Mockito.when(tcpPacket.getTimeStamp()).thenReturn((double)date.getTime()-10000);
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);
PacketInfo packetInfo3 = Mockito.mock(PacketInfo.class);
Mockito.when(packetInfo3.getPacket()).thenReturn(tcpPacket2);
Mockito.when(packetInfo3.getDir()).thenReturn(PacketDirection.DOWNLINK);
Mockito.when(packetInfo3.getTcpInfo()).thenReturn(TcpInfo.TCP_ACK_RECOVER);
Mockito.when(packetInfo3.getPayloadLen()).thenReturn(0);
Mockito.when(packetInfo3.getLen()).thenReturn(20);
Mockito.when(packetInfo3.getAppName()).thenReturn("Test3");
Mockito.when(packetInfo3.getTcpFlagString()).thenReturn("Test3String");
Mockito.when(packetInfo3.getTimeStamp()).thenReturn(0d);
PacketInfo packetInfo4 = Mockito.mock(PacketInfo.class);
Mockito.when(packetInfo4.getPacket()).thenReturn(tcpPacket2);
Mockito.when(packetInfo4.getDir()).thenReturn(PacketDirection.DOWNLINK);
Mockito.when(packetInfo4.getTcpInfo()).thenReturn(TcpInfo.TCP_ACK);
Mockito.when(packetInfo4.getTimeStamp()).thenReturn(90d);
Mockito.when(packetInfo4.getPayloadLen()).thenReturn(0);
PacketInfo packetInfo5 = Mockito.mock(PacketInfo.class);
Mockito.when(packetInfo5.getPacket()).thenReturn(tcpPacket2);
Mockito.when(packetInfo5.getDir()).thenReturn(PacketDirection.DOWNLINK);
Mockito.when(packetInfo5.getTcpInfo()).thenReturn(TcpInfo.TCP_DATA_RECOVER);
Mockito.when(packetInfo5.getTimeStamp()).thenReturn(750d);
Mockito.when(packetInfo5.getPayloadLen()).thenReturn(0);
List<PacketInfo> packetsList = new ArrayList<PacketInfo>();
// Adding UDP Packet to the list
packetsList.add(packetInfo1);
// Adding TCP Packet to the list
packetsList.add(packetInfo2);
packetsList.add(packetInfo3);
packetsList.add(packetInfo4);
packetsList.add(packetInfo5);
ProfileLTE profile = Mockito.mock(ProfileLTE.class);
Mockito.when(profile.getBurstTh()).thenReturn(50d);
Mockito.when(profile.getLongBurstTh()).thenReturn(40.0d);
Mockito.when(profile.getLargeBurstDuration()).thenReturn(150d);
Mockito.when(profile.getLargeBurstSize()).thenReturn(50);
Mockito.when(profile.getProfileType()).thenReturn(ProfileType.LTE);
Mockito.when(profile.getBurstTh()).thenReturn(25.0d);
Mockito.when(profile.getCarrier()).thenReturn("ATT");
Mockito.when(profile.getCloseSpacedBurstThreshold()).thenReturn(45d);
Mockito.when(profile.getDrxLongPingPeriod()).thenReturn(50.0d);
Mockito.when(profile.getDrxLongPingPower()).thenReturn(75d);
Mockito.when(profile.getDrxLongTime()).thenReturn(75d);
Mockito.when(profile.getDevice()).thenReturn("lg");
Mockito.when(profile.getDrxShortPingPeriod()).thenReturn(100d);
Mockito.when(profile.getDrxShortPingPower()).thenReturn(200d);
Mockito.when(profile.getDrxShortTime()).thenReturn(50d);
Mockito.when(profile.getLargeBurstDuration()).thenReturn(500d);
Mockito.when(profile.getLargeBurstSize()).thenReturn(1000);
Mockito.when(profile.getLongBurstTh()).thenReturn(250d);
Map<Integer, Integer> packetSizeToCountMap = new HashMap<Integer, Integer>();
packetSizeToCountMap.put(1001, 10);
packetSizeToCountMap.put(2002, 20);
packetSizeToCountMap.put(3003, 30);
RrcStateRange rrcStateRange1 = Mockito.mock(RrcStateRange.class);
Mockito.when(rrcStateRange1.getBeginTime()).thenReturn(500d);
Mockito.when(rrcStateRange1.getEndTime()).thenReturn(590d);
Mockito.when(rrcStateRange1.getState()).thenReturn(RRCState.TAIL_DCH);
RrcStateRange rrcStateRange2 = Mockito.mock(RrcStateRange.class);
Mockito.when(rrcStateRange2.getBeginTime()).thenReturn(8.30d);
Mockito.when(rrcStateRange2.getEndTime()).thenReturn(12.30d);
Mockito.when(rrcStateRange2.getState()).thenReturn(RRCState.PROMO_FACH_DCH);
RrcStateRange rrcStateRange3 = Mockito.mock(RrcStateRange.class);
Mockito.when(rrcStateRange3.getBeginTime()).thenReturn(0.0d);
Mockito.when(rrcStateRange3.getEndTime()).thenReturn(-2.0d);
Mockito.when(rrcStateRange3.getState()).thenReturn(RRCState.TAIL_DCH);
RrcStateRange rrcStateRange4 = Mockito.mock(RrcStateRange.class);
Mockito.when(rrcStateRange4.getBeginTime()).thenReturn(25d);
Mockito.when(rrcStateRange4.getEndTime()).thenReturn(75d);
Mockito.when(rrcStateRange4.getState()).thenReturn(RRCState.WIFI_TAIL);
RrcStateRange rrcStateRange5 = Mockito.mock(RrcStateRange.class);
Mockito.when(rrcStateRange5.getBeginTime()).thenReturn(105d);
Mockito.when(rrcStateRange5.getEndTime()).thenReturn(95d);
Mockito.when(rrcStateRange5.getState()).thenReturn(RRCState.PROMO_IDLE_DCH);
List<RrcStateRange> rrcstaterangelist = new ArrayList<RrcStateRange>();
rrcstaterangelist.add(rrcStateRange1);
rrcstaterangelist.add(rrcStateRange2);
rrcstaterangelist.add(rrcStateRange3);
rrcstaterangelist.add(rrcStateRange4);
rrcstaterangelist.add(rrcStateRange5);
UserEvent uEvent1 = Mockito.mock(UserEvent.class);
Mockito.when(uEvent1.getEventType()).thenReturn(UserEventType.SCREEN_LANDSCAPE);
Mockito.when(uEvent1.getPressTime()).thenReturn(503d);
Mockito.when(uEvent1.getReleaseTime()).thenReturn(6d);
UserEvent uEvent2 = Mockito.mock(UserEvent.class);
Mockito.when(uEvent2.getEventType()).thenReturn(UserEventType.SCREEN_PORTRAIT);
Mockito.when(uEvent2.getPressTime()).thenReturn(14d);
Mockito.when(uEvent2.getReleaseTime()).thenReturn(2000d);
UserEvent uEvent3 = Mockito.mock(UserEvent.class);
Mockito.when(uEvent3.getEventType()).thenReturn(UserEventType.KEY_RED);
Mockito.when(uEvent3.getPressTime()).thenReturn(497d);
Mockito.when(uEvent3.getReleaseTime()).thenReturn(499d);
UserEvent uEvent4 = Mockito.mock(UserEvent.class);
Mockito.when(uEvent4.getEventType()).thenReturn(UserEventType.EVENT_UNKNOWN);
Mockito.when(uEvent4.getPressTime()).thenReturn(25d);
Mockito.when(uEvent4.getReleaseTime()).thenReturn(4d);
UserEvent uEvent5 = Mockito.mock(UserEvent.class);
Mockito.when(uEvent5.getEventType()).thenReturn(UserEventType.KEY_SEARCH);
Mockito.when(uEvent5.getPressTime()).thenReturn(752d);
Mockito.when(uEvent5.getReleaseTime()).thenReturn(30000d);
List<UserEvent> uEventList = new ArrayList<UserEvent>();
uEventList.add(uEvent1);
uEventList.add(uEvent2);
uEventList.add(uEvent3);
uEventList.add(uEvent4);
uEventList.add(uEvent5);
CpuActivity cActivity1 = Mockito.mock(CpuActivity.class);
Mockito.when(cActivity1.getTimeStamp()).thenReturn(23000d);
Mockito.when(cActivity1.getTotalCpuUsage()).thenReturn(5000d);
CpuActivity cActivity2 = Mockito.mock(CpuActivity.class);
Mockito.when(cActivity2.getTimeStamp()).thenReturn(24000d);
Mockito.when(cActivity2.getTotalCpuUsage()).thenReturn(6000d);
CpuActivity cActivity3 = Mockito.mock(CpuActivity.class);
Mockito.when(cActivity3.getTimeStamp()).thenReturn(25000d);
Mockito.when(cActivity3.getTotalCpuUsage()).thenReturn(6000d);
List<CpuActivity> cpuActivityList = new ArrayList<CpuActivity>();
cpuActivityList.add(cActivity1);
cpuActivityList.add(cActivity2);
cpuActivityList.add(cActivity3);
Session aSession = Mockito.mock(Session.class);
List<Session> sessionList = new ArrayList<Session>();
sessionList.add(aSession);
BurstCollectionAnalysisData bcaData = aBurstCollectionAnalysis.analyze(packetsList, profile, packetSizeToCountMap, rrcstaterangelist, uEventList, cpuActivityList, sessionList);
if (bcaData != null) {
assertEquals(3, bcaData.getBurstAnalysisInfo().size());
assertEquals(3, bcaData.getBurstCollection().size());
assertEquals(0, bcaData.getLongBurstCount());
assertEquals(0, (int) bcaData.getTotalEnergy());
}
}
Aggregations