Commit Graph

9 Commits

Author SHA1 Message Date
Ryan Zuklie
80d705566b Try to fix and diagnose Perfetto flush errors.
Around 10% of the traces with Nettrace have "traced_final_flush_failed"
errors. It is believed that Network Tracing isn't writing enough data to
fill one "Chunk" in Perfetto's buffer. Although this should still be
saved by Perfetto, it doesn't seem to be.

This change records the number of packets read from the ring buffer to
understand whether the error coincided with low-data cases. It also
tries to flush the data OnStop to potentially fix the issue.

Test: flash and run trace
Change-Id: I92c8d2d8d47d1ed123585e1cfdde802d286f120f
2023-05-12 18:12:00 -07:00
Ryan Zuklie
5a6b1eefd5 Add test for the NetworkTraceHandler
This tests the logic of converting bpf PacketTraces into Perfetto
TracePackets. The test stands up an in-process trace and parses the
resulting trace output (filtering to only the events we care about).

On the implementation side, `Write` is added as a non-static method
to do the conversion from a batch of PacketTraces. Because this becomes
part of the instance, per-instance configuration (e.g. interning) can be
applied without causing conflicts between concurrent sessions.

Bug: 246985031
Test: atest libnetworkstats_test
Change-Id: I15a26ba720eff308d01e6827a176a6b2f7c60e80
2023-03-13 17:13:33 -07:00
Ryan Zuklie
75de743f67 Move NetworkTracePoller to a new file
This finishes the split of NetworkTraceHandler into separate DataSource
and Polling parts by moving the Polling part to its own file.

Despite being a large diff, all this change did was copy the
NetworkTraceHandler files to their NetworkTracePoller counterparts and
delete the irrelevant sections in each file. The actual content of the
classes and functions should be identical.

Bug: 246985031
Test: atest libnetworkstats_test
Change-Id: Ibc9d945658e89f969fa3d1551863ccd26fd51a78
2023-03-07 10:15:32 -08:00
Ryan Zuklie
a603ce5b8e Add Perfetto part of NetworkTraceHandler
This adds the DataSource base class, data source registration and
overrides the lifecycle methods.

Adding the Perfetto SDK increases the size of the tethering apex by
450kb (~150 KB for the compressed apex).

Bug: 246985031
Test: atest libnetworkstats_test
Change-Id: Ie2e8f3e43c8080434408f752346e575a19e9042e
2023-01-24 06:49:11 -08:00
Ryan Zuklie
0b9478b53b Add NetworkTraceHandler with Start/Stop/ConsumeAll
This adds the base (non-perfetto) NetworkTraceHandler with support for
starting and stopping tracing, and pulling messages from BPF. The
included test covers the end-to-end scenario from socket creation,
socket tagging and data traffic.

Bug: 246985031
Test: atest --iterations 500 libnetworkstats_test
Change-Id: I035d2e03fa7c461ecb93d207b7fd2f53e6a2f52e
2023-01-23 13:35:24 -08:00
Ken Chen
b9266bf507 Add traffic_controller, networkstats, netd_updatable tests to MTS.
In order to get counted by mts code coverage, these native tests need to
be run as part of mts.

Bug: 233904825
Test: m mts && mts-tradefed run mts-tethering-coverage
Change-Id: I79313197b146c7043ffb5e164faa46c2e16dd1d2
2022-05-27 15:00:18 +00:00
Remi NGUYEN VAN
d95048929c Add JNI stats libraries to connectivity
Add new symbols to libservice-connectivity loaded on T only, and the
framework libraries to apex and tests.

Bug: 197717846
Test: atest FrameworksNetTests
  (cherry-picked and splitting apex Android.bp to aosp/1994130)
Change-Id: Iae44344701a3267110e5cbf271120201134d59e5
Merged-In: Iae44344701a3267110e5cbf271120201134d59e5
2022-02-28 04:16:17 +00:00
Lorenzo Colitti
0db496ef39 Fix libnetworkstats_test.
If libraries are moved from the platform to a module, the test
will fail with:

CANNOT LINK EXECUTABLE "/data/local/tmp/libnetworkstats_test/arm64/libnetworkstats_test": library "libnetworkstats.so" not found: needed by main executable

This may be because it can't find libnetworkstats.so because that
is in platform.

In any case, since this is the test for libnetworkstats,
dynamically linking libnetworkstats is incorrect, because it
means if the same CL modifies both libnetworkstats and its test,
that CL will run the modified test against the unmodified
libnetworkstats.so on the device, when running updating tests
without reflashing the device.

Also remove libutils because it does not seem to be needed.

Test: atest libnetworkstats_test passes with libraries moved
Change-Id: Id49641c0a919129e2c54531c3995ec7421161002
2022-02-07 02:16:34 +00:00
Ken Chen
f426b2b287 Rename libnetdbpf to libnetworkstats
Two reason for renaming:
1. Avoid module name collision in sc-mainline-prod branch.
2. The libnetdbpf was misnamed before.

Bug: 202086915
Test: atest libnetworkstats_test FrameworksNetTests
      ConnectivityCoverageTests FrameworksNetSmokeTests
      CtsAppOpsTestCases
Change-Id: I87fcf4b1a9d58780a45743a9aa91b9b936e54266
2022-01-24 11:53:59 +08:00