use of com.att.aro.core.packetanalysis.pojo.PacketInfo in project VideoOptimzer by attdevsupport.
the class ProfileFactoryImplTest method energyLTE_RRCStateIsLTE_IDLE_a.
@Test
public void energyLTE_RRCStateIsLTE_IDLE_a() {
ProfileLTE profileLte03 = Mockito.mock(ProfileLTE.class);
List<PacketInfo> packets = new ArrayList<PacketInfo>();
when(profileLte03.getIdlePingTime()).thenReturn(1.0);
when(profileLte03.getLteIdlePingPower()).thenReturn(1.0);
when(profileLte03.getIdlePingPeriod()).thenReturn(9.0);
when(profileLte03.getLteIdlePower()).thenReturn(1.0);
double testResult = profilefactory.energyLTE(date.getTime() + 0.0, date.getTime() + 14750.0, RRCState.LTE_IDLE, profileLte03, packets);
assertEquals(14750.0, testResult, 0.0);
}
use of com.att.aro.core.packetanalysis.pojo.PacketInfo in project VideoOptimzer by attdevsupport.
the class ProfileFactoryImplTest method energyLTE_RRCStateIsLTE_CR_TAIL.
@Test
public void energyLTE_RRCStateIsLTE_CR_TAIL() {
ProfileLTE profileLte04 = Mockito.mock(ProfileLTE.class);
List<PacketInfo> packets = new ArrayList<PacketInfo>();
when(profileLte04.getIdlePingTime()).thenReturn(1.0);
when(profileLte04.getLteIdlePingPower()).thenReturn(1.0);
when(profileLte04.getIdlePingPeriod()).thenReturn(2.0);
when(profileLte04.getLteIdlePower()).thenReturn(1.0);
double testResult = profilefactory.energyLTE(date.getTime() + 0.0, date.getTime() + 1000.0, RRCState.LTE_CR_TAIL, profileLte04, packets);
assertEquals(0.0, testResult, 0.0);
}
use of com.att.aro.core.packetanalysis.pojo.PacketInfo in project VideoOptimzer by attdevsupport.
the class ProfileFactoryImplTest method energyLTE_RRCStateIsLTE_DRX_LONG.
@Test
public void energyLTE_RRCStateIsLTE_DRX_LONG() {
ProfileLTE profileLte05 = Mockito.mock(ProfileLTE.class);
List<PacketInfo> packets = new ArrayList<PacketInfo>();
when(profileLte05.getDrxLongPingPeriod()).thenReturn(5.0);
when(profileLte05.getDrxLongPingPower()).thenReturn(1.0);
when(profileLte05.getLteTailPower()).thenReturn(2.0);
when(profileLte05.getDrxPingTime()).thenReturn(1.0);
double testResult = profilefactory.energyLTE(date.getTime() + 0.0, date.getTime() + 1000.0, RRCState.LTE_DRX_LONG, profileLte05, packets);
assertEquals(1800.0, testResult, 0.0);
}
use of com.att.aro.core.packetanalysis.pojo.PacketInfo in project VideoOptimzer by attdevsupport.
the class UnsecureSSLVersionImplTest method getPacketAnalyzerResult.
private PacketAnalyzerResult getPacketAnalyzerResult(Set<String> unsecureSSLVersions) {
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.getUnsecureSSLVersions()).thenReturn(unsecureSSLVersions);
when(address.getHostAddress()).thenReturn(ipAddress);
when(session.getRemoteIP()).thenReturn(address);
when(session.getRemotePort()).thenReturn(port);
return packetAnalyzerResult;
}
use of com.att.aro.core.packetanalysis.pojo.PacketInfo in project VideoOptimzer by attdevsupport.
the class TimeRangeAnalysis method performTimeRangeAnalysis.
/**
* Performs a TimeRangeAnalysis on the trace data.
* TODO: The calculation should not be in the UI - move elsewhere (Core)
*
* @return TimeRangeAnalysis The object containing TimeRangeAnalysis
* data.
*/
public static TimeRangeAnalysis performTimeRangeAnalysis(PacketAnalyzerResult analysisData, double analyzeBeginTime, double analyzeEndTime) {
List<RrcStateRange> rrcCollection = analysisData.getStatemachine().getStaterangelist();
List<PacketInfo> packets = analysisData.getTraceresult().getAllpackets();
Profile profile = analysisData.getProfile();
long payloadLength = 0;
long totalBytes = 0;
long uplinkBytes = 0;
long downlinkBytes = 0;
int packetNum = packets.size();
for (int i = 0; i < packetNum; i++) {
PacketInfo packetInfo = packets.get(i);
if (packetInfo.getTimeStamp() >= analyzeBeginTime && packetInfo.getTimeStamp() <= analyzeEndTime) {
payloadLength += packetInfo.getPayloadLen();
totalBytes += packetInfo.getLen();
if (packetInfo.getDir().equals(PacketDirection.UPLINK)) {
uplinkBytes += packetInfo.getLen();
} else if (packetInfo.getDir().equals(PacketDirection.DOWNLINK)) {
downlinkBytes += packetInfo.getLen();
}
}
}
double energy = 0.0f;
double activeTime = 0.0f;
int collectionSize = rrcCollection.size();
for (int i = 0; i < collectionSize; i++) {
double beginTime;
double endTime;
RrcStateRange rrc = rrcCollection.get(i);
if (rrc.getEndTime() < analyzeBeginTime) {
continue;
}
if (rrc.getBeginTime() > analyzeEndTime) {
continue;
}
if (rrc.getBeginTime() >= analyzeBeginTime) {
beginTime = rrc.getBeginTime();
} else {
beginTime = analyzeBeginTime;
}
if (rrc.getEndTime() <= analyzeEndTime) {
endTime = rrc.getEndTime();
} else {
endTime = analyzeEndTime;
}
RRCState rrcState = rrc.getState();
IProfileFactory profileFactory = ContextAware.getAROConfigContext().getBean(IProfileFactory.class);
energy += updateEnergy(analysisData, profile, beginTime, endTime, rrcState, profileFactory);
activeTime += updateActiveTime(profile, beginTime, endTime, rrcState);
}
return new TimeRangeAnalysis(analyzeBeginTime, analyzeEndTime, totalBytes, uplinkBytes, downlinkBytes, payloadLength, activeTime, energy);
}
Aggregations