Fix Flaky testTrafficStatsForLocalhost

This commit fixes several identified sources of flakiness in
this test:

1.  Upper bound of verifying getIfaceStats did not include the
    lingering traffic, which is the major cause of the flakiness.
    Relaxes the upper bound to align with the expectations of
    other APIs.
2.  TCP syn/syn-ack packets have a header size of 40 bytes due
    to TCP options, not 32 bytes. The test had an incorrect
    assumption about the upper bound, causing flakiness when
    encountering 16 bytes more than expected.
3.  The `getTotalStats` API sometimes reports 2 packets short
    because fin/fin-ack packets cannot be counted if the socket
    has already closed. Relaxes the lower bound to
    align with the expectations of other APIs.

This change also enables tcpdump collection on failures for future
debugging.

Test: atest CtsNetTestCases:android.net.cts.TrafficStatsTest#testTrafficStatsForLocalhost \
      --rerun-until-failure 100
Bug: 385238831
Change-Id: Ibb38cfe0bde5afdf9741583cdff153153a9f855e
1 file changed