use of android.net.metrics.RaEvent in project android_frameworks_base by DirtyUnicorns.
the class IpConnectivityMetricsTest method testEndToEndLogging.
@SmallTest
public void testEndToEndLogging() {
IpConnectivityLog logger = new IpConnectivityLog(mService.impl);
Parcelable[] events = { new IpReachabilityEvent("wlan0", IpReachabilityEvent.NUD_FAILED), new DhcpClientEvent("wlan0", "SomeState", 192), new DefaultNetworkEvent(102, new int[] { 1, 2, 3 }, 101, true, false), new IpManagerEvent("wlan0", IpManagerEvent.PROVISIONING_OK, 5678), new ValidationProbeEvent(120, 40730, ValidationProbeEvent.PROBE_HTTP, 204), new ApfStats(45000, 10, 2, 2, 1, 2, 4, 2048), new RaEvent(2000, 400, 300, -1, 1000, -1) };
for (int i = 0; i < events.length; i++) {
logger.log(100 * (i + 1), events[i]);
}
String want = joinLines("dropped_events: 0", "events <", " time_ms: 100", " transport: 0", " ip_reachability_event <", " event_type: 512", " if_name: \"wlan0\"", " >", ">", "events <", " time_ms: 200", " transport: 0", " dhcp_event <", " duration_ms: 192", " if_name: \"wlan0\"", " state_transition: \"SomeState\"", " >", ">", "events <", " time_ms: 300", " transport: 0", " default_network_event <", " network_id <", " network_id: 102", " >", " previous_network_id <", " network_id: 101", " >", " previous_network_ip_support: 1", " transport_types: 1", " transport_types: 2", " transport_types: 3", " >", ">", "events <", " time_ms: 400", " transport: 0", " ip_provisioning_event <", " event_type: 1", " if_name: \"wlan0\"", " latency_ms: 5678", " >", ">", "events <", " time_ms: 500", " transport: 0", " validation_probe_event <", " latency_ms: 40730", " network_id <", " network_id: 120", " >", " probe_result: 204", " probe_type: 1", " >", ">", "events <", " time_ms: 600", " transport: 0", " apf_statistics <", " dropped_ras: 2", " duration_ms: 45000", " matching_ras: 2", " max_program_size: 2048", " parse_errors: 2", " program_updates: 4", " received_ras: 10", " zero_lifetime_ras: 1", " >", ">", "events <", " time_ms: 700", " transport: 0", " ra_event <", " dnssl_lifetime: -1", " prefix_preferred_lifetime: 300", " prefix_valid_lifetime: 400", " rdnss_lifetime: 1000", " route_info_lifetime: -1", " router_lifetime: 2000", " >", ">", "version: 2");
verifySerialization(want, getdump("flush"));
}
use of android.net.metrics.RaEvent in project platform_frameworks_base by android.
the class IpConnectivityMetricsTest method testEndToEndLogging.
public void testEndToEndLogging() {
IpConnectivityLog logger = new IpConnectivityLog(mService.impl);
Parcelable[] events = { new IpReachabilityEvent("wlan0", IpReachabilityEvent.NUD_FAILED), new DhcpClientEvent("wlan0", "SomeState", 192), new DefaultNetworkEvent(102, new int[] { 1, 2, 3 }, 101, true, false), new IpManagerEvent("wlan0", IpManagerEvent.PROVISIONING_OK, 5678), new ValidationProbeEvent(120, 40730, ValidationProbeEvent.PROBE_HTTP, 204), new ApfStats(45000, 10, 2, 2, 1, 2, 4, 2048), new RaEvent(2000, 400, 300, -1, 1000, -1) };
for (int i = 0; i < events.length; i++) {
logger.log(100 * (i + 1), events[i]);
}
String want = joinLines("dropped_events: 0", "events <", " ip_reachability_event <", " event_type: 512", " if_name: \"wlan0\"", " >", " time_ms: 100", ">", "events <", " dhcp_event <", " duration_ms: 192", " error_code: 0", " if_name: \"wlan0\"", " state_transition: \"SomeState\"", " >", " time_ms: 200", ">", "events <", " default_network_event <", " network_id <", " network_id: 102", " >", " previous_network_id <", " network_id: 101", " >", " previous_network_ip_support: 1", " transport_types: 1", " transport_types: 2", " transport_types: 3", " >", " time_ms: 300", ">", "events <", " ip_provisioning_event <", " event_type: 1", " if_name: \"wlan0\"", " latency_ms: 5678", " >", " time_ms: 400", ">", "events <", " time_ms: 500", " validation_probe_event <", " latency_ms: 40730", " network_id <", " network_id: 120", " >", " probe_result: 204", " probe_type: 1", " >", ">", "events <", " apf_statistics <", " dropped_ras: 2", " duration_ms: 45000", " matching_ras: 2", " max_program_size: 2048", " parse_errors: 2", " program_updates: 4", " received_ras: 10", " zero_lifetime_ras: 1", " >", " time_ms: 600", ">", "events <", " ra_event <", " dnssl_lifetime: -1", " prefix_preferred_lifetime: 300", " prefix_valid_lifetime: 400", " rdnss_lifetime: 1000", " route_info_lifetime: -1", " router_lifetime: 2000", " >", " time_ms: 700", ">", "version: 2");
verifySerialization(want, getdump("flush"));
}
use of android.net.metrics.RaEvent in project android_frameworks_base by crdroidandroid.
the class IpConnectivityMetricsTest method testEndToEndLogging.
@SmallTest
public void testEndToEndLogging() {
IpConnectivityLog logger = new IpConnectivityLog(mService.impl);
Parcelable[] events = { new IpReachabilityEvent("wlan0", IpReachabilityEvent.NUD_FAILED), new DhcpClientEvent("wlan0", "SomeState", 192), new DefaultNetworkEvent(102, new int[] { 1, 2, 3 }, 101, true, false), new IpManagerEvent("wlan0", IpManagerEvent.PROVISIONING_OK, 5678), new ValidationProbeEvent(120, 40730, ValidationProbeEvent.PROBE_HTTP, 204), new ApfStats(45000, 10, 2, 2, 1, 2, 4, 2048), new RaEvent(2000, 400, 300, -1, 1000, -1) };
for (int i = 0; i < events.length; i++) {
logger.log(100 * (i + 1), events[i]);
}
String want = joinLines("dropped_events: 0", "events <", " time_ms: 100", " transport: 0", " ip_reachability_event <", " event_type: 512", " if_name: \"wlan0\"", " >", ">", "events <", " time_ms: 200", " transport: 0", " dhcp_event <", " duration_ms: 192", " if_name: \"wlan0\"", " state_transition: \"SomeState\"", " >", ">", "events <", " time_ms: 300", " transport: 0", " default_network_event <", " network_id <", " network_id: 102", " >", " previous_network_id <", " network_id: 101", " >", " previous_network_ip_support: 1", " transport_types: 1", " transport_types: 2", " transport_types: 3", " >", ">", "events <", " time_ms: 400", " transport: 0", " ip_provisioning_event <", " event_type: 1", " if_name: \"wlan0\"", " latency_ms: 5678", " >", ">", "events <", " time_ms: 500", " transport: 0", " validation_probe_event <", " latency_ms: 40730", " network_id <", " network_id: 120", " >", " probe_result: 204", " probe_type: 1", " >", ">", "events <", " time_ms: 600", " transport: 0", " apf_statistics <", " dropped_ras: 2", " duration_ms: 45000", " matching_ras: 2", " max_program_size: 2048", " parse_errors: 2", " program_updates: 4", " received_ras: 10", " zero_lifetime_ras: 1", " >", ">", "events <", " time_ms: 700", " transport: 0", " ra_event <", " dnssl_lifetime: -1", " prefix_preferred_lifetime: 300", " prefix_valid_lifetime: 400", " rdnss_lifetime: 1000", " route_info_lifetime: -1", " router_lifetime: 2000", " >", ">", "version: 2");
verifySerialization(want, getdump("flush"));
}
use of android.net.metrics.RaEvent in project android_frameworks_base by crdroidandroid.
the class ApfTest method verifyRaEvent.
private void verifyRaEvent(RaEvent expected) {
ArgumentCaptor<Parcelable> captor = ArgumentCaptor.forClass(Parcelable.class);
verify(mLog, atLeastOnce()).log(captor.capture());
RaEvent got = lastRaEvent(captor.getAllValues());
if (!raEventEquals(expected, got)) {
// fail for printing an assertion error message.
assertEquals(expected, got);
}
}
use of android.net.metrics.RaEvent in project android_frameworks_base by crdroidandroid.
the class ApfTest method testApfFilterRa.
@LargeTest
public void testApfFilterRa() throws Exception {
MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback();
TestApfFilter apfFilter = new TestApfFilter(ipManagerCallback, DROP_MULTICAST, mLog);
byte[] program = ipManagerCallback.getApfProgram();
// Verify RA is passed the first time
ByteBuffer basePacket = ByteBuffer.wrap(new byte[ICMP6_RA_OPTION_OFFSET]);
basePacket.putShort(ETH_ETHERTYPE_OFFSET, (short) ETH_P_IPV6);
basePacket.put(IPV6_NEXT_HEADER_OFFSET, (byte) IPPROTO_ICMPV6);
basePacket.put(ICMP6_TYPE_OFFSET, (byte) ICMP6_ROUTER_ADVERTISEMENT);
basePacket.putShort(ICMP6_RA_ROUTER_LIFETIME_OFFSET, (short) 1000);
basePacket.position(IPV6_DEST_ADDR_OFFSET);
basePacket.put(IPV6_ALL_NODES_ADDRESS);
assertPass(program, basePacket.array());
testRaLifetime(apfFilter, ipManagerCallback, basePacket, 1000);
verifyRaEvent(new RaEvent(1000, -1, -1, -1, -1, -1));
// Ensure zero-length options cause the packet to be silently skipped.
// Do this before we test other packets. http://b/29586253
ByteBuffer zeroLengthOptionPacket = ByteBuffer.wrap(new byte[ICMP6_RA_OPTION_OFFSET + ICMP6_4_BYTE_OPTION_LEN]);
basePacket.clear();
zeroLengthOptionPacket.put(basePacket);
zeroLengthOptionPacket.put((byte) ICMP6_PREFIX_OPTION_TYPE);
zeroLengthOptionPacket.put((byte) 0);
assertInvalidRa(apfFilter, ipManagerCallback, zeroLengthOptionPacket);
// Generate several RAs with different options and lifetimes, and verify when
// ApfFilter is shown these packets, it generates programs to filter them for the
// appropriate lifetime.
ByteBuffer prefixOptionPacket = ByteBuffer.wrap(new byte[ICMP6_RA_OPTION_OFFSET + ICMP6_PREFIX_OPTION_LEN]);
basePacket.clear();
prefixOptionPacket.put(basePacket);
prefixOptionPacket.put((byte) ICMP6_PREFIX_OPTION_TYPE);
prefixOptionPacket.put((byte) (ICMP6_PREFIX_OPTION_LEN / 8));
prefixOptionPacket.putInt(ICMP6_RA_OPTION_OFFSET + ICMP6_PREFIX_OPTION_PREFERRED_LIFETIME_OFFSET, 100);
prefixOptionPacket.putInt(ICMP6_RA_OPTION_OFFSET + ICMP6_PREFIX_OPTION_VALID_LIFETIME_OFFSET, 200);
testRaLifetime(apfFilter, ipManagerCallback, prefixOptionPacket, 100);
verifyRaEvent(new RaEvent(1000, 200, 100, -1, -1, -1));
ByteBuffer rdnssOptionPacket = ByteBuffer.wrap(new byte[ICMP6_RA_OPTION_OFFSET + ICMP6_4_BYTE_OPTION_LEN]);
basePacket.clear();
rdnssOptionPacket.put(basePacket);
rdnssOptionPacket.put((byte) ICMP6_RDNSS_OPTION_TYPE);
rdnssOptionPacket.put((byte) (ICMP6_4_BYTE_OPTION_LEN / 8));
rdnssOptionPacket.putInt(ICMP6_RA_OPTION_OFFSET + ICMP6_4_BYTE_LIFETIME_OFFSET, 300);
testRaLifetime(apfFilter, ipManagerCallback, rdnssOptionPacket, 300);
verifyRaEvent(new RaEvent(1000, -1, -1, -1, 300, -1));
ByteBuffer routeInfoOptionPacket = ByteBuffer.wrap(new byte[ICMP6_RA_OPTION_OFFSET + ICMP6_4_BYTE_OPTION_LEN]);
basePacket.clear();
routeInfoOptionPacket.put(basePacket);
routeInfoOptionPacket.put((byte) ICMP6_ROUTE_INFO_OPTION_TYPE);
routeInfoOptionPacket.put((byte) (ICMP6_4_BYTE_OPTION_LEN / 8));
routeInfoOptionPacket.putInt(ICMP6_RA_OPTION_OFFSET + ICMP6_4_BYTE_LIFETIME_OFFSET, 400);
testRaLifetime(apfFilter, ipManagerCallback, routeInfoOptionPacket, 400);
verifyRaEvent(new RaEvent(1000, -1, -1, 400, -1, -1));
ByteBuffer dnsslOptionPacket = ByteBuffer.wrap(new byte[ICMP6_RA_OPTION_OFFSET + ICMP6_4_BYTE_OPTION_LEN]);
basePacket.clear();
dnsslOptionPacket.put(basePacket);
dnsslOptionPacket.put((byte) ICMP6_DNSSL_OPTION_TYPE);
dnsslOptionPacket.put((byte) (ICMP6_4_BYTE_OPTION_LEN / 8));
dnsslOptionPacket.putInt(ICMP6_RA_OPTION_OFFSET + ICMP6_4_BYTE_LIFETIME_OFFSET, 2000);
// Note that lifetime of 2000 will be ignored in favor of shorter
// route lifetime of 1000.
testRaLifetime(apfFilter, ipManagerCallback, dnsslOptionPacket, 1000);
verifyRaEvent(new RaEvent(1000, -1, -1, -1, -1, 2000));
// Verify that current program filters all five RAs:
verifyRaLifetime(ipManagerCallback, basePacket, 1000);
verifyRaLifetime(ipManagerCallback, prefixOptionPacket, 100);
verifyRaLifetime(ipManagerCallback, rdnssOptionPacket, 300);
verifyRaLifetime(ipManagerCallback, routeInfoOptionPacket, 400);
verifyRaLifetime(ipManagerCallback, dnsslOptionPacket, 1000);
apfFilter.shutdown();
}
Aggregations